mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 03:52:50 +00:00
49 lines
141 KiB
JavaScript
Vendored
49 lines
141 KiB
JavaScript
Vendored
var Is=Object.defineProperty;var Bs=(r,t,e)=>t in r?Is(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var m=(r,t,e)=>(Bs(r,typeof t!="symbol"?t+"":t,e),e);import{D as b,a as D}from"./quill-delta.72524c38.js";import{i as fe,c as ft,m as tt}from"./lodash-es.df04b444.js";var y=(r=>(r[r.TYPE=3]="TYPE",r[r.LEVEL=12]="LEVEL",r[r.ATTRIBUTE=13]="ATTRIBUTE",r[r.BLOT=14]="BLOT",r[r.INLINE=7]="INLINE",r[r.BLOCK=11]="BLOCK",r[r.BLOCK_BLOT=10]="BLOCK_BLOT",r[r.INLINE_BLOT=6]="INLINE_BLOT",r[r.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",r[r.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",r[r.ANY=15]="ANY",r))(y||{});class z{constructor(t,e,s={}){this.attrName=t,this.keyName=e;const i=y.TYPE&y.ATTRIBUTE;this.scope=s.scope!=null?s.scope&y.LEVEL|i:y.ATTRIBUTE,s.whitelist!=null&&(this.whitelist=s.whitelist)}static keys(t){return Array.from(t.attributes).map(e=>e.name)}add(t,e){return this.canAdd(t,e)?(t.setAttribute(this.keyName,e),!0):!1}canAdd(t,e){return this.whitelist==null?!0:typeof e=="string"?this.whitelist.indexOf(e.replace(/["']/g,""))>-1:this.whitelist.indexOf(e)>-1}remove(t){t.removeAttribute(this.keyName)}value(t){const e=t.getAttribute(this.keyName);return this.canAdd(t,e)&&e?e:""}}class mt extends Error{constructor(t){t="[Parchment] "+t,super(t),this.message=t,this.name=this.constructor.name}}const Qe=class Qt{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(t,e=!1){if(t==null)return null;if(this.blots.has(t))return this.blots.get(t)||null;if(e){let s=null;try{s=t.parentNode}catch{return null}return this.find(s,e)}return null}create(t,e,s){const i=this.query(e);if(i==null)throw new mt(`Unable to create ${e} blot`);const n=i,l=e instanceof Node||e.nodeType===Node.TEXT_NODE?e:n.create(s),o=new n(t,l,s);return Qt.blots.set(o.domNode,o),o}find(t,e=!1){return Qt.find(t,e)}query(t,e=y.ANY){let s;return typeof t=="string"?s=this.types[t]||this.attributes[t]:t instanceof Text||t.nodeType===Node.TEXT_NODE?s=this.types.text:typeof t=="number"?t&y.LEVEL&y.BLOCK?s=this.types.block:t&y.LEVEL&y.INLINE&&(s=this.types.inline):t instanceof Element&&((t.getAttribute("class")||"").split(/\s+/).some(i=>(s=this.classes[i],!!s)),s=s||this.tags[t.tagName]),s==null?null:"scope"in s&&e&y.LEVEL&s.scope&&e&y.TYPE&s.scope?s:null}register(...t){return t.map(e=>{const s="blotName"in e,i="attrName"in e;if(!s&&!i)throw new mt("Invalid definition");if(s&&e.blotName==="abstract")throw new mt("Cannot register abstract class");const n=s?e.blotName:i?e.attrName:void 0;return this.types[n]=e,i?typeof e.keyName=="string"&&(this.attributes[e.keyName]=e):s&&(e.className&&(this.classes[e.className]=e),e.tagName&&(Array.isArray(e.tagName)?e.tagName=e.tagName.map(l=>l.toUpperCase()):e.tagName=e.tagName.toUpperCase(),(Array.isArray(e.tagName)?e.tagName:[e.tagName]).forEach(l=>{(this.tags[l]==null||e.className==null)&&(this.tags[l]=e)}))),e})}};Qe.blots=new WeakMap;let pt=Qe;function Te(r,t){return(r.getAttribute("class")||"").split(/\s+/).filter(e=>e.indexOf(`${t}-`)===0)}class Ds extends z{static keys(t){return(t.getAttribute("class")||"").split(/\s+/).map(e=>e.split("-").slice(0,-1).join("-"))}add(t,e){return this.canAdd(t,e)?(this.remove(t),t.classList.add(`${this.keyName}-${e}`),!0):!1}remove(t){Te(t,this.keyName).forEach(e=>{t.classList.remove(e)}),t.classList.length===0&&t.removeAttribute("class")}value(t){const e=(Te(t,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(t,e)?e:""}}const _=Ds;function zt(r){const t=r.split("-"),e=t.slice(1).map(s=>s[0].toUpperCase()+s.slice(1)).join("");return t[0]+e}class Ms extends z{static keys(t){return(t.getAttribute("style")||"").split(";").map(e=>e.split(":")[0].trim())}add(t,e){return this.canAdd(t,e)?(t.style[zt(this.keyName)]=e,!0):!1}remove(t){t.style[zt(this.keyName)]="",t.getAttribute("style")||t.removeAttribute("style")}value(t){const e=t.style[zt(this.keyName)];return this.canAdd(t,e)?e:""}}const et=Ms;class Us{constructor(t){this.attributes={},this.domNode=t,this.build()}attribute(t,e){e?t.add(this.domNode,e)&&(t.value(this.domNode)!=null?this.attributes[t.attrName]=t:delete this.attributes[t.attrName]):(t.remove(this.domNode),delete this.attributes[t.attrName])}build(){this.attributes={};const t=pt.find(this.domNode);if(t==null)return;const e=z.keys(this.domNode),s=_.keys(this.domNode),i=et.keys(this.domNode);e.concat(s).concat(i).forEach(n=>{const l=t.scroll.query(n,y.ATTRIBUTE);l instanceof z&&(this.attributes[l.attrName]=l)})}copy(t){Object.keys(this.attributes).forEach(e=>{const s=this.attributes[e].value(this.domNode);t.format(e,s)})}move(t){this.copy(t),Object.keys(this.attributes).forEach(e=>{this.attributes[e].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((t,e)=>(t[e]=this.attributes[e].value(this.domNode),t),{})}}const _t=Us,Je=class{constructor(t,e){this.scroll=t,this.domNode=e,pt.blots.set(e,this),this.prev=null,this.next=null}static create(t){if(this.tagName==null)throw new mt("Blot definition missing tagName");let e,s;return Array.isArray(this.tagName)?(typeof t=="string"?(s=t.toUpperCase(),parseInt(s,10).toString()===s&&(s=parseInt(s,10))):typeof t=="number"&&(s=t),typeof s=="number"?e=document.createElement(this.tagName[s-1]):s&&this.tagName.indexOf(s)>-1?e=document.createElement(s):e=document.createElement(this.tagName[0])):e=document.createElement(this.tagName),this.className&&e.classList.add(this.className),e}get statics(){return this.constructor}attach(){}clone(){const t=this.domNode.cloneNode(!1);return this.scroll.create(t)}detach(){this.parent!=null&&this.parent.removeChild(this),pt.blots.delete(this.domNode)}deleteAt(t,e){this.isolate(t,e).remove()}formatAt(t,e,s,i){const n=this.isolate(t,e);if(this.scroll.query(s,y.BLOT)!=null&&i)n.wrap(s,i);else if(this.scroll.query(s,y.ATTRIBUTE)!=null){const l=this.scroll.create(this.statics.scope);n.wrap(l),l.format(s,i)}}insertAt(t,e,s){const i=s==null?this.scroll.create("text",e):this.scroll.create(e,s),n=this.split(t);this.parent.insertBefore(i,n||void 0)}isolate(t,e){const s=this.split(t);if(s==null)throw new Error("Attempt to isolate at end");return s.split(e),s}length(){return 1}offset(t=this.parent){return this.parent==null||this===t?0:this.parent.children.offset(this)+this.parent.offset(t)}optimize(t){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(t,e){const s=typeof t=="string"?this.scroll.create(t,e):t;return this.parent!=null&&(this.parent.insertBefore(s,this.next||void 0),this.remove()),s}split(t,e){return t===0?this:this.next}update(t,e){}wrap(t,e){const s=typeof t=="string"?this.scroll.create(t,e):t;if(this.parent!=null&&this.parent.insertBefore(s,this.next||void 0),typeof s.appendChild!="function")throw new mt(`Cannot wrap ${t}`);return s.appendChild(this),s}};Je.blotName="abstract";let ts=Je;const es=class extends ts{static value(t){return!0}index(t,e){return this.domNode===t||this.domNode.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(e,1):-1}position(t,e){let s=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return t>0&&(s+=1),[this.parent.domNode,s]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};es.scope=y.INLINE_BLOT;let _s=es;const w=_s;class Ps{constructor(){this.head=null,this.tail=null,this.length=0}append(...t){if(this.insertBefore(t[0],null),t.length>1){const e=t.slice(1);this.append(...e)}}at(t){const e=this.iterator();let s=e();for(;s&&t>0;)t-=1,s=e();return s}contains(t){const e=this.iterator();let s=e();for(;s;){if(s===t)return!0;s=e()}return!1}indexOf(t){const e=this.iterator();let s=e(),i=0;for(;s;){if(s===t)return i;i+=1,s=e()}return-1}insertBefore(t,e){t!=null&&(this.remove(t),t.next=e,e!=null?(t.prev=e.prev,e.prev!=null&&(e.prev.next=t),e.prev=t,e===this.head&&(this.head=t)):this.tail!=null?(this.tail.next=t,t.prev=this.tail,this.tail=t):(t.prev=null,this.head=this.tail=t),this.length+=1)}offset(t){let e=0,s=this.head;for(;s!=null;){if(s===t)return e;e+=s.length(),s=s.next}return-1}remove(t){this.contains(t)&&(t.prev!=null&&(t.prev.next=t.next),t.next!=null&&(t.next.prev=t.prev),t===this.head&&(this.head=t.next),t===this.tail&&(this.tail=t.prev),this.length-=1)}iterator(t=this.head){return()=>{const e=t;return t!=null&&(t=t.next),e}}find(t,e=!1){const s=this.iterator();let i=s();for(;i;){const n=i.length();if(t<n||e&&t===n&&(i.next==null||i.next.length()!==0))return[i,t];t-=n,i=s()}return[null,0]}forEach(t){const e=this.iterator();let s=e();for(;s;)t(s),s=e()}forEachAt(t,e,s){if(e<=0)return;const[i,n]=this.find(t);let l=t-n;const o=this.iterator(i);let a=o();for(;a&&l<t+e;){const c=a.length();t>l?s(a,t-l,Math.min(e,l+c-t)):s(a,0,Math.min(c,t+e-l)),l+=c,a=o()}}map(t){return this.reduce((e,s)=>(e.push(t(s)),e),[])}reduce(t,e){const s=this.iterator();let i=s();for(;i;)e=t(e,i),i=s();return e}}function Se(r,t){const e=t.find(r);if(e)return e;try{return t.create(r)}catch{const s=t.create(y.INLINE);return Array.from(r.childNodes).forEach(i=>{s.domNode.appendChild(i)}),r.parentNode&&r.parentNode.replaceChild(s.domNode,r),s.attach(),s}}const ss=class G extends ts{constructor(t,e){super(t,e),this.uiNode=null,this.build()}appendChild(t){this.insertBefore(t)}attach(){super.attach(),this.children.forEach(t=>{t.attach()})}attachUI(t){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=t,G.uiClass&&this.uiNode.classList.add(G.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new Ps,Array.from(this.domNode.childNodes).filter(t=>t!==this.uiNode).reverse().forEach(t=>{try{const e=Se(t,this.scroll);this.insertBefore(e,this.children.head||void 0)}catch(e){if(e instanceof mt)return;throw e}})}deleteAt(t,e){if(t===0&&e===this.length())return this.remove();this.children.forEachAt(t,e,(s,i,n)=>{s.deleteAt(i,n)})}descendant(t,e=0){const[s,i]=this.children.find(e);return t.blotName==null&&t(s)||t.blotName!=null&&s instanceof t?[s,i]:s instanceof G?s.descendant(t,i):[null,-1]}descendants(t,e=0,s=Number.MAX_VALUE){let i=[],n=s;return this.children.forEachAt(e,s,(l,o,a)=>{(t.blotName==null&&t(l)||t.blotName!=null&&l instanceof t)&&i.push(l),l instanceof G&&(i=i.concat(l.descendants(t,o,n))),n-=a}),i}detach(){this.children.forEach(t=>{t.detach()}),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach(e=>{t||this.statics.allowedChildren.some(s=>e instanceof s)||(e.statics.scope===y.BLOCK_BLOT?(e.next!=null&&this.splitAfter(e),e.prev!=null&&this.splitAfter(e.prev),e.parent.unwrap(),t=!0):e instanceof G?e.unwrap():e.remove())})}formatAt(t,e,s,i){this.children.forEachAt(t,e,(n,l,o)=>{n.formatAt(l,o,s,i)})}insertAt(t,e,s){const[i,n]=this.children.find(t);if(i)i.insertAt(n,e,s);else{const l=s==null?this.scroll.create("text",e):this.scroll.create(e,s);this.appendChild(l)}}insertBefore(t,e){t.parent!=null&&t.parent.children.remove(t);let s=null;this.children.insertBefore(t,e||null),t.parent=this,e!=null&&(s=e.domNode),(this.domNode.parentNode!==t.domNode||this.domNode.nextSibling!==s)&&this.domNode.insertBefore(t.domNode,s),t.attach()}length(){return this.children.reduce((t,e)=>t+e.length(),0)}moveChildren(t,e){this.children.forEach(s=>{t.insertBefore(s,e)})}optimize(t){if(super.optimize(t),this.enforceAllowedChildren(),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0)if(this.statics.defaultChild!=null){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove()}path(t,e=!1){const[s,i]=this.children.find(t,e),n=[[this,t]];return s instanceof G?n.concat(s.path(i,e)):(s!=null&&n.push([s,i]),n)}removeChild(t){this.children.remove(t)}replaceWith(t,e){const s=typeof t=="string"?this.scroll.create(t,e):t;return s instanceof G&&this.moveChildren(s),super.replaceWith(s)}split(t,e=!1){if(!e){if(t===0)return this;if(t===this.length())return this.next}const s=this.clone();return this.parent&&this.parent.insertBefore(s,this.next||void 0),this.children.forEachAt(t,this.length(),(i,n,l)=>{const o=i.split(n,e);o!=null&&s.appendChild(o)}),s}splitAfter(t){const e=this.clone();for(;t.next!=null;)e.appendChild(t.next);return this.parent&&this.parent.insertBefore(e,this.next||void 0),e}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(t,e){const s=[],i=[];t.forEach(n=>{n.target===this.domNode&&n.type==="childList"&&(s.push(...n.addedNodes),i.push(...n.removedNodes))}),i.forEach(n=>{if(n.parentNode!=null&&n.tagName!=="IFRAME"&&document.body.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;const l=this.scroll.find(n);l!=null&&(l.domNode.parentNode==null||l.domNode.parentNode===this.domNode)&&l.detach()}),s.filter(n=>n.parentNode===this.domNode&&n!==this.uiNode).sort((n,l)=>n===l?0:n.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(n=>{let l=null;n.nextSibling!=null&&(l=this.scroll.find(n.nextSibling));const o=Se(n,this.scroll);(o.next!==l||o.next==null)&&(o.parent!=null&&o.parent.removeChild(this),this.insertBefore(o,l||void 0))}),this.enforceAllowedChildren()}};ss.uiClass="";let Fs=ss;const M=Fs;function $s(r,t){if(Object.keys(r).length!==Object.keys(t).length)return!1;for(const e in r)if(r[e]!==t[e])return!1;return!0}const lt=class ot extends M{static create(t){return super.create(t)}static formats(t,e){const s=e.query(ot.blotName);if(!(s!=null&&t.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(t,e){super(t,e),this.attributes=new _t(this.domNode)}format(t,e){if(t===this.statics.blotName&&!e)this.children.forEach(s=>{s instanceof ot||(s=s.wrap(ot.blotName,!0)),this.attributes.copy(s)}),this.unwrap();else{const s=this.scroll.query(t,y.INLINE);if(s==null)return;s instanceof z?this.attributes.attribute(s,e):e&&(t!==this.statics.blotName||this.formats()[t]!==e)&&this.replaceWith(t,e)}}formats(){const t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return e!=null&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,i){this.formats()[s]!=null||this.scroll.query(s,y.ATTRIBUTE)?this.isolate(t,e).format(s,i):super.formatAt(t,e,s,i)}optimize(t){super.optimize(t);const e=this.formats();if(Object.keys(e).length===0)return this.unwrap();const s=this.next;s instanceof ot&&s.prev===this&&$s(e,s.formats())&&(s.moveChildren(this),s.remove())}replaceWith(t,e){const s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}wrap(t,e){const s=super.wrap(t,e);return s instanceof ot&&this.attributes.move(s),s}};lt.allowedChildren=[lt,w],lt.blotName="inline",lt.scope=y.INLINE_BLOT,lt.tagName="SPAN";let Hs=lt;const me=Hs,at=class Jt extends M{static create(t){return super.create(t)}static formats(t,e){const s=e.query(Jt.blotName);if(!(s!=null&&t.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(t,e){super(t,e),this.attributes=new _t(this.domNode)}format(t,e){const s=this.scroll.query(t,y.BLOCK);s!=null&&(s instanceof z?this.attributes.attribute(s,e):t===this.statics.blotName&&!e?this.replaceWith(Jt.blotName):e&&(t!==this.statics.blotName||this.formats()[t]!==e)&&this.replaceWith(t,e))}formats(){const t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return e!=null&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,i){this.scroll.query(s,y.BLOCK)!=null?this.format(s,i):super.formatAt(t,e,s,i)}insertAt(t,e,s){if(s==null||this.scroll.query(e,y.INLINE)!=null)super.insertAt(t,e,s);else{const i=this.split(t);if(i!=null){const n=this.scroll.create(e,s);i.parent.insertBefore(n,i)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(t,e){const s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}};at.blotName="block",at.scope=y.BLOCK_BLOT,at.tagName="P",at.allowedChildren=[me,at,w];let zs=at;const qt=zs,te=class extends M{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(t,e){super.deleteAt(t,e),this.enforceAllowedChildren()}formatAt(t,e,s,i){super.formatAt(t,e,s,i),this.enforceAllowedChildren()}insertAt(t,e,s){super.insertAt(t,e,s),this.enforceAllowedChildren()}optimize(t){super.optimize(t),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};te.blotName="container",te.scope=y.BLOCK_BLOT;let js=te;const Pt=js;class Ks extends w{static formats(t,e){}format(t,e){super.formatAt(0,this.length(),t,e)}formatAt(t,e,s,i){t===0&&e===this.length()?this.format(s,i):super.formatAt(t,e,s,i)}formats(){return this.statics.formats(this.domNode,this.scroll)}}const S=Ks,Vs={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},Ws=100,ct=class extends M{constructor(t,e){super(null,e),this.registry=t,this.scroll=this,this.build(),this.observer=new MutationObserver(s=>{this.update(s)}),this.observer.observe(this.domNode,Vs),this.attach()}create(t,e){return this.registry.create(this,t,e)}find(t,e=!1){const s=this.registry.find(t,e);return s?s.scroll===this?s:e?this.find(s.scroll.domNode.parentNode,!0):null:null}query(t,e=y.ANY){return this.registry.query(t,e)}register(...t){return this.registry.register(...t)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(t,e){this.update(),t===0&&e===this.length()?this.children.forEach(s=>{s.remove()}):super.deleteAt(t,e)}formatAt(t,e,s,i){this.update(),super.formatAt(t,e,s,i)}insertAt(t,e,s){this.update(),super.insertAt(t,e,s)}optimize(t=[],e={}){super.optimize(e);const s=e.mutationsMap||new WeakMap;let i=Array.from(this.observer.takeRecords());for(;i.length>0;)t.push(i.pop());const n=(a,c=!0)=>{a==null||a===this||a.domNode.parentNode!=null&&(s.has(a.domNode)||s.set(a.domNode,[]),c&&n(a.parent))},l=a=>{s.has(a.domNode)&&(a instanceof M&&a.children.forEach(l),s.delete(a.domNode),a.optimize(e))};let o=t;for(let a=0;o.length>0;a+=1){if(a>=Ws)throw new Error("[Parchment] Maximum optimize iterations reached");for(o.forEach(c=>{const h=this.find(c.target,!0);h!=null&&(h.domNode===c.target&&(c.type==="childList"?(n(this.find(c.previousSibling,!1)),Array.from(c.addedNodes).forEach(d=>{const N=this.find(d,!1);n(N,!1),N instanceof M&&N.children.forEach(E=>{n(E,!1)})})):c.type==="attributes"&&n(h.prev)),n(h))}),this.children.forEach(l),o=Array.from(this.observer.takeRecords()),i=o.slice();i.length>0;)t.push(i.pop())}}update(t,e={}){t=t||this.observer.takeRecords();const s=new WeakMap;t.map(i=>{const n=this.find(i.target,!0);return n==null?null:s.has(n.domNode)?(s.get(n.domNode).push(i),null):(s.set(n.domNode,[i]),n)}).forEach(i=>{i!=null&&i!==this&&s.has(i.domNode)&&i.update(s.get(i.domNode)||[],e)}),e.mutationsMap=s,s.has(this.domNode)&&super.update(s.get(this.domNode),e),this.optimize(t,e)}};ct.blotName="scroll",ct.defaultChild=qt,ct.allowedChildren=[qt,Pt],ct.scope=y.BLOCK_BLOT,ct.tagName="DIV";let Gs=ct;const ge=Gs,ee=class is extends w{static create(t){return document.createTextNode(t)}static value(t){return t.data}constructor(t,e){super(t,e),this.text=this.statics.value(this.domNode)}deleteAt(t,e){this.domNode.data=this.text=this.text.slice(0,t)+this.text.slice(t+e)}index(t,e){return this.domNode===t?e:-1}insertAt(t,e,s){s==null?(this.text=this.text.slice(0,t)+e+this.text.slice(t),this.domNode.data=this.text):super.insertAt(t,e,s)}length(){return this.text.length}optimize(t){super.optimize(t),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof is&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(t,e=!1){return[this.domNode,t]}split(t,e=!1){if(!e){if(t===0)return this;if(t===this.length())return this.next}const s=this.scroll.create(this.domNode.splitText(t));return this.parent.insertBefore(s,this.next||void 0),this.text=this.statics.value(this.domNode),s}update(t,e){t.some(s=>s.type==="characterData"&&s.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};ee.blotName="text",ee.scope=y.INLINE_BLOT;let Zs=ee;const Ut=Zs;var Xs=Object.freeze(Object.defineProperty({__proto__:null,Attributor:z,AttributorStore:_t,BlockBlot:qt,ClassAttributor:_,ContainerBlot:Pt,EmbedBlot:S,InlineBlot:me,LeafBlot:w,ParentBlot:M,Registry:pt,Scope:y,ScrollBlot:ge,StyleAttributor:et,TextBlot:Ut},Symbol.toStringTag,{value:"Module"}));class P extends S{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}P.blotName="break";P.tagName="BR";class U extends Ut{}function Ft(r){return r.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}const Z=class extends me{static compare(t,e){const s=Z.order.indexOf(t),i=Z.order.indexOf(e);return s>=0||i>=0?s-i:t===e?0:t<e?-1:1}formatAt(t,e,s,i){if(Z.compare(this.statics.blotName,s)<0&&this.scroll.query(s,y.BLOT)){const n=this.isolate(t,e);i&&n.wrap(s,i)}else super.formatAt(t,e,s,i)}optimize(t){if(super.optimize(t),this.parent instanceof Z&&Z.compare(this.statics.blotName,this.parent.statics.blotName)>0){const e=this.parent.isolate(this.offset(),this.length());this.moveChildren(e),e.wrap(this)}}};let I=Z;m(I,"allowedChildren",[Z,P,S,U]),m(I,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]);const Ce=1;class v extends qt{constructor(){super(...arguments);m(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=ns(this)),this.cache.delta}deleteAt(e,s){super.deleteAt(e,s),this.cache={}}formatAt(e,s,i,n){s<=0||(this.scroll.query(i,y.BLOCK)?e+s===this.length()&&this.format(i,n):super.formatAt(e,Math.min(s,this.length()-e-1),i,n),this.cache={})}insertAt(e,s,i){if(i!=null){super.insertAt(e,s,i),this.cache={};return}if(s.length===0)return;const n=s.split(`
|
|
`),l=n.shift();l.length>0&&(e<this.length()-1||this.children.tail==null?super.insertAt(Math.min(e,this.length()-1),l):this.children.tail.insertAt(this.children.tail.length(),l),this.cache={});let o=this;n.reduce((a,c)=>(o=o.split(a,!0),o.insertAt(0,c),c.length),e+l.length)}insertBefore(e,s){const{head:i}=this.children;super.insertBefore(e,s),i instanceof P&&i.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+Ce),this.cache.length}moveChildren(e,s){super.moveChildren(e,s),this.cache={}}optimize(e){super.optimize(e),this.cache={}}path(e){return super.path(e,!0)}removeChild(e){super.removeChild(e),this.cache={}}split(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(s&&(e===0||e>=this.length()-Ce)){const n=this.clone();return e===0?(this.parent.insertBefore(n,this),this):(this.parent.insertBefore(n,this.next),n)}const i=super.split(e,s);return this.cache={},i}}v.blotName="block";v.tagName="P";v.defaultChild=P;v.allowedChildren=[P,I,S,U];class R extends S{attach(){super.attach(),this.attributes=new _t(this.domNode)}delta(){return new b().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const s=this.scroll.query(t,y.BLOCK_ATTRIBUTE);s!=null&&this.attributes.attribute(s,e)}formatAt(t,e,s,i){this.format(s,i)}insertAt(t,e,s){if(s!=null){super.insertAt(t,e,s);return}const i=e.split(`
|
|
`),n=i.pop(),l=i.map(a=>{const c=this.scroll.create(v.blotName);return c.insertAt(0,a),c}),o=this.split(t);l.forEach(a=>{this.parent.insertBefore(a,o)}),n&&this.parent.insertBefore(this.scroll.create("text",n),o)}}R.scope=y.BLOCK_BLOT;function ns(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return r.descendants(w).reduce((e,s)=>s.length()===0?e:e.insert(s.value(),C(s,{},t)),new b).insert(`
|
|
`,C(r))}function C(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return r==null||("formats"in r&&typeof r.formats=="function"&&(t={...t,...r.formats()},e&&delete t["code-token"]),r.parent==null||r.parent.statics.blotName==="scroll"||r.parent.statics.scope!==r.statics.scope)?t:C(r.parent,t,e)}const X=class extends S{static value(){}constructor(t,e,s){super(t,e),this.selection=s,this.textNode=document.createTextNode(X.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(t,e){if(this.savedLength!==0){super.format(t,e);return}let s=this,i=0;for(;s!=null&&s.statics.scope!==y.BLOCK_BLOT;)i+=s.offset(s.parent),s=s.parent;s!=null&&(this.savedLength=X.CONTENTS.length,s.optimize(),s.formatAt(i,X.CONTENTS.length,t,e),this.savedLength=0)}index(t,e){return t===this.textNode?0:super.index(t,e)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||this.parent==null)return null;const t=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);const e=this.prev instanceof U?this.prev:null,s=e?e.length():0,i=this.next instanceof U?this.next:null,n=i?i.text:"",{textNode:l}=this,o=l.data.split(X.CONTENTS).join("");l.data=X.CONTENTS;let a;if(e)a=e,(o||i)&&(e.insertAt(e.length(),o+n),i&&i.remove());else if(i)a=i,i.insertAt(0,o);else{const c=document.createTextNode(o);a=this.scroll.create(c),this.parent.insertBefore(a,this)}if(this.remove(),t){const c=(N,E)=>e&&N===e.domNode?E:N===l?s+E-1:i&&N===i.domNode?s+o.length+E:null,h=c(t.start.node,t.start.offset),d=c(t.end.node,t.end.offset);if(h!==null&&d!==null)return{startNode:a.domNode,startOffset:h,endNode:a.domNode,endOffset:d}}return null}update(t,e){if(t.some(s=>s.type==="characterData"&&s.target===this.textNode)){const s=this.restore();s&&(e.range=s)}}optimize(t){super.optimize(t);let{parent:e}=this;for(;e;){if(e.domNode.tagName==="A"){this.savedLength=X.CONTENTS.length,e.isolate(this.offset(e),this.length()).unwrap(),this.savedLength=0;break}e=e.parent}}value(){return""}};let $=X;m($,"blotName","cursor"),m($,"className","ql-cursor"),m($,"tagName","span"),m($,"CONTENTS","\uFEFF");var rs={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(a,c,h){this.fn=a,this.context=c,this.once=h||!1}function n(a,c,h,d,N){if(typeof h!="function")throw new TypeError("The listener must be a function");var E=new i(h,d||a,N),g=e?e+c:c;return a._events[g]?a._events[g].fn?a._events[g]=[a._events[g],E]:a._events[g].push(E):(a._events[g]=E,a._eventsCount++),a}function l(a,c){--a._eventsCount===0?a._events=new s:delete a._events[c]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],h,d;if(this._eventsCount===0)return c;for(d in h=this._events)t.call(h,d)&&c.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(h)):c},o.prototype.listeners=function(c){var h=e?e+c:c,d=this._events[h];if(!d)return[];if(d.fn)return[d.fn];for(var N=0,E=d.length,g=new Array(E);N<E;N++)g[N]=d[N].fn;return g},o.prototype.listenerCount=function(c){var h=e?e+c:c,d=this._events[h];return d?d.fn?1:d.length:0},o.prototype.emit=function(c,h,d,N,E,g){var q=e?e+c:c;if(!this._events[q])return!1;var f=this._events[q],x=arguments.length,k,A;if(f.fn){switch(f.once&&this.removeListener(c,f.fn,void 0,!0),x){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,h),!0;case 3:return f.fn.call(f.context,h,d),!0;case 4:return f.fn.call(f.context,h,d,N),!0;case 5:return f.fn.call(f.context,h,d,N,E),!0;case 6:return f.fn.call(f.context,h,d,N,E,g),!0}for(A=1,k=new Array(x-1);A<x;A++)k[A-1]=arguments[A];f.fn.apply(f.context,k)}else{var Rs=f.length,yt;for(A=0;A<Rs;A++)switch(f[A].once&&this.removeListener(c,f[A].fn,void 0,!0),x){case 1:f[A].fn.call(f[A].context);break;case 2:f[A].fn.call(f[A].context,h);break;case 3:f[A].fn.call(f[A].context,h,d);break;case 4:f[A].fn.call(f[A].context,h,d,N);break;default:if(!k)for(yt=1,k=new Array(x-1);yt<x;yt++)k[yt-1]=arguments[yt];f[A].fn.apply(f[A].context,k)}}return!0},o.prototype.on=function(c,h,d){return n(this,c,h,d,!1)},o.prototype.once=function(c,h,d){return n(this,c,h,d,!0)},o.prototype.removeListener=function(c,h,d,N){var E=e?e+c:c;if(!this._events[E])return this;if(!h)return l(this,E),this;var g=this._events[E];if(g.fn)g.fn===h&&(!N||g.once)&&(!d||g.context===d)&&l(this,E);else{for(var q=0,f=[],x=g.length;q<x;q++)(g[q].fn!==h||N&&!g[q].once||d&&g[q].context!==d)&&f.push(g[q]);f.length?this._events[E]=f.length===1?f[0]:f:l(this,E)}return this},o.prototype.removeAllListeners=function(c){var h;return c?(h=e?e+c:c,this._events[h]&&l(this,h)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,r.exports=o})(rs);var Ys=rs.exports,se=new WeakMap;const ie=["error","warn","log","info"];let ne="warn";function ls(r){if(ne&&ie.indexOf(r)<=ie.indexOf(ne)){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s<t;s++)e[s-1]=arguments[s];console[r](...e)}}function W(r){return ie.reduce((t,e)=>(t[e]=ls.bind(console,e,r),t),{})}W.level=r=>{ne=r};ls.level=W.level;const jt=W("quill:events"),Qs=["selectionchange","mousedown","mouseup","click"];Qs.forEach(r=>{document.addEventListener(r,function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];Array.from(document.querySelectorAll(".ql-container")).forEach(i=>{const n=se.get(i);n&&n.emitter&&n.emitter.handleDOM(...e)})})});class p extends Ys{constructor(){super(),this.domListeners={},this.on("error",jt.error)}emit(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return jt.log.call(jt,...e),super.emit(...e)}handleDOM(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];(this.domListeners[t.type]||[]).forEach(n=>{let{node:l,handler:o}=n;(t.target===l||l.contains(t.target))&&o(t,...s)})}listenDOM(t,e,s){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:e,handler:s})}}m(p,"events",{EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_BLOT_MOUNT:"scroll-blot-mount",SCROLL_BLOT_UNMOUNT:"scroll-blot-unmount",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SCROLL_EMBED_UPDATE:"scroll-embed-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change",COMPOSITION_BEFORE_START:"composition-before-start",COMPOSITION_START:"composition-start",COMPOSITION_BEFORE_END:"composition-before-end",COMPOSITION_END:"composition-end"}),m(p,"sources",{API:"api",SILENT:"silent",USER:"user"});const Kt=W("quill:selection");class st{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=t,this.length=e}}class Js{constructor(t,e){this.emitter=e,this.scroll=t,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create("cursor",this),this.savedRange=new st(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,()=>{!this.mouseDown&&!this.composing&&setTimeout(this.update.bind(this,p.sources.USER),1)}),this.emitter.on(p.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;const s=this.getNativeRange();s!=null&&s.start.node!==this.cursor.textNode&&this.emitter.once(p.events.SCROLL_UPDATE,(i,n)=>{try{this.root.contains(s.start.node)&&this.root.contains(s.end.node)&&this.setNativeRange(s.start.node,s.start.offset,s.end.node,s.end.offset);const l=n.some(o=>o.type==="characterData"||o.type==="childList"||o.type==="attributes"&&o.target===this.root);this.update(l?p.sources.SILENT:i)}catch{}})}),this.emitter.on(p.events.SCROLL_OPTIMIZE,(s,i)=>{if(i.range){const{startNode:n,startOffset:l,endNode:o,endOffset:a}=i.range;this.setNativeRange(n,l,o,a),this.update(p.sources.SILENT)}}),this.update(p.sources.SILENT)}handleComposition(){this.emitter.on(p.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(p.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){const t=this.cursor.restore();if(!t)return;setTimeout(()=>{this.setNativeRange(t.startNode,t.startOffset,t.endNode,t.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM("mousedown",document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,()=>{this.mouseDown=!1,this.update(p.sources.USER)})}focus(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}format(t,e){this.scroll.update();const s=this.getNativeRange();if(!(s==null||!s.native.collapsed||this.scroll.query(t,y.BLOCK))){if(s.start.node!==this.cursor.textNode){const i=this.scroll.find(s.start.node,!1);if(i==null)return;if(i instanceof w){const n=i.split(s.start.offset);i.parent.insertBefore(this.cursor,n)}else i.insertBefore(this.cursor,s.start.node);this.cursor.attach()}this.cursor.format(t,e),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const s=this.scroll.length();t=Math.min(t,s-1),e=Math.min(t+e,s-1)-t;let i,[n,l]=this.scroll.leaf(t);if(n==null)return null;if(e>0&&l===n.length()){const[h]=this.scroll.leaf(t+1);if(h){const[d]=this.scroll.line(t),[N]=this.scroll.line(t+1);d===N&&(n=h,l=0)}}[i,l]=n.position(l,!0);const o=document.createRange();if(e>0)return o.setStart(i,l),[n,l]=this.scroll.leaf(t+e),n==null?null:([i,l]=n.position(l,!0),o.setEnd(i,l),o.getBoundingClientRect());let a="left",c;if(i instanceof Text){if(!i.data.length)return null;l<i.data.length?(o.setStart(i,l),o.setEnd(i,l+1)):(o.setStart(i,l-1),o.setEnd(i,l),a="right"),c=o.getBoundingClientRect()}else{if(!(n.domNode instanceof Element))return null;c=n.domNode.getBoundingClientRect(),l>0&&(a="right")}return{bottom:c.top+c.height,height:c.height,left:c[a],right:c[a],top:c.top,width:0}}getNativeRange(){const t=document.getSelection();if(t==null||t.rangeCount<=0)return null;const e=t.getRangeAt(0);if(e==null)return null;const s=this.normalizeNative(e);return Kt.info("getNativeRange",s),s}getRange(){const t=this.scroll.domNode;if("isConnected"in t&&!t.isConnected)return[null,null];const e=this.getNativeRange();return e==null?[null,null]:[this.normalizedToRange(e),e]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&Vt(this.root,document.activeElement)}normalizedToRange(t){const e=[[t.start.node,t.start.offset]];t.native.collapsed||e.push([t.end.node,t.end.offset]);const s=e.map(l=>{const[o,a]=l,c=this.scroll.find(o,!0),h=c.offset(this.scroll);return a===0?h:c instanceof w?h+c.index(o,a):h+c.length()}),i=Math.min(Math.max(...s),this.scroll.length()-1),n=Math.min(i,...s);return new st(n,i-n)}normalizeNative(t){if(!Vt(this.root,t.startContainer)||!t.collapsed&&!Vt(this.root,t.endContainer))return null;const e={start:{node:t.startContainer,offset:t.startOffset},end:{node:t.endContainer,offset:t.endOffset},native:t};return[e.start,e.end].forEach(s=>{let{node:i,offset:n}=s;for(;!(i instanceof Text)&&i.childNodes.length>0;)if(i.childNodes.length>n)i=i.childNodes[n],n=0;else if(i.childNodes.length===n)i=i.lastChild,i instanceof Text?n=i.data.length:i.childNodes.length>0?n=i.childNodes.length:n=i.childNodes.length+1;else break;s.node=i,s.offset=n}),e}rangeToNative(t){const e=this.scroll.length(),s=(i,n)=>{i=Math.min(e-1,i);const[l,o]=this.scroll.leaf(i);return l?l.position(o,n):[null,-1]};return[...s(t.index,!1),...s(t.index+t.length,!0)]}setNativeRange(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(Kt.info("setNativeRange",t,e,s,i),t!=null&&(this.root.parentNode==null||t.parentNode==null||s.parentNode==null))return;const l=document.getSelection();if(l!=null)if(t!=null){this.hasFocus()||this.root.focus();const{native:o}=this.getNativeRange()||{};if(o==null||n||t!==o.startContainer||e!==o.startOffset||s!==o.endContainer||i!==o.endOffset){t instanceof Element&&t.tagName==="BR"&&(e=Array.from(t.parentNode.childNodes).indexOf(t),t=t.parentNode),s instanceof Element&&s.tagName==="BR"&&(i=Array.from(s.parentNode.childNodes).indexOf(s),s=s.parentNode);const a=document.createRange();a.setStart(t,e),a.setEnd(s,i),l.removeAllRanges(),l.addRange(a)}}else l.removeAllRanges(),this.root.blur()}setRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:p.sources.API;if(typeof e=="string"&&(s=e,e=!1),Kt.info("setRange",t),t!=null){const i=this.rangeToNative(t);this.setNativeRange(...i,e)}else this.setNativeRange(null);this.update(s)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p.sources.USER;const e=this.lastRange,[s,i]=this.getRange();if(this.lastRange=s,this.lastNative=i,this.lastRange!=null&&(this.savedRange=this.lastRange),!fe(e,this.lastRange)){if(!this.composing&&i!=null&&i.native.collapsed&&i.start.node!==this.cursor.textNode){const l=this.cursor.restore();l&&this.setNativeRange(l.startNode,l.startOffset,l.endNode,l.endOffset)}const n=[p.events.SELECTION_CHANGE,ft(this.lastRange),ft(e),t];this.emitter.emit(p.events.EDITOR_CHANGE,...n),t!==p.sources.SILENT&&this.emitter.emit(...n)}}}function Vt(r,t){try{t.parentNode}catch{return!1}return r.contains(t)}const ti=/^[ -~]*$/;class ei{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();const s=Oe(t),i=new b;return ii(s.ops.slice()).reduce((l,o)=>{const a=D.exports.Op.length(o);let c=o.attributes||{},h=!1,d=!1;if(o.insert!=null){if(i.retain(a),typeof o.insert=="string"){const g=o.insert;d=!g.endsWith(`
|
|
`)&&(e<=l||!!this.scroll.descendant(R,l)[0]),this.scroll.insertAt(l,g);const[q,f]=this.scroll.line(l);let x=tt({},C(q));if(q instanceof v){const[k]=q.descendant(w,f);k&&(x=tt(x,C(k)))}c=D.exports.AttributeMap.diff(x,c)||{}}else if(typeof o.insert=="object"){const g=Object.keys(o.insert)[0];if(g==null)return l;const q=this.scroll.query(g,y.INLINE)!=null;if(q)(e<=l||!!this.scroll.descendant(R,l)[0])&&(d=!0);else if(l>0){const[f,x]=this.scroll.descendant(w,l-1);f instanceof U?f.value()[x]!==`
|
|
`&&(h=!0):f instanceof S&&f.statics.scope===y.INLINE_BLOT&&(h=!0)}if(this.scroll.insertAt(l,g,o.insert[g]),q){const[f]=this.scroll.descendant(w,l);if(f){const x=tt({},C(f));c=D.exports.AttributeMap.diff(x,c)||{}}}}e+=a}else if(i.push(o),o.retain!==null&&typeof o.retain=="object"){const g=Object.keys(o.retain)[0];if(g==null)return l;this.scroll.updateEmbedAt(l,g,o.retain[g])}Object.keys(c).forEach(g=>{this.scroll.formatAt(l,a,g,c[g])});const N=h?1:0,E=d?1:0;return e+=N+E,i.retain(N),i.delete(E),l+a+N+E},0),i.reduce((l,o)=>typeof o.delete=="number"?(this.scroll.deleteAt(l,o.delete),l):l+D.exports.Op.length(o),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(s)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update(new b().retain(t).delete(e))}formatLine(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(s).forEach(n=>{this.scroll.lines(t,Math.max(e,1)).forEach(l=>{l.format(n,s[n])})}),this.scroll.optimize();const i=new b().retain(t).retain(e,ft(s));return this.update(i)}formatText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(s).forEach(n=>{this.scroll.formatAt(t,e,n,s[n])});const i=new b().retain(t).retain(e,ft(s));return this.update(i)}getContents(t,e){return this.delta.slice(t,t+e)}getDelta(){return this.scroll.lines().reduce((t,e)=>t.concat(e.delta()),new b)}getFormat(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=[],i=[];e===0?this.scroll.path(t).forEach(o=>{const[a]=o;a instanceof v?s.push(a):a instanceof w&&i.push(a)}):(s=this.scroll.lines(t,e),i=this.scroll.descendants(w,t,e));const[n,l]=[s,i].map(o=>{const a=o.shift();if(a==null)return{};let c=C(a);for(;Object.keys(c).length>0;){const h=o.shift();if(h==null)return c;c=si(C(h),c)}return c});return{...n,...l}}getHTML(t,e){const[s,i]=this.scroll.line(t);if(s){const n=s.length();return s.length()>=i+e&&!(i===0&&e===n)?At(s,i,e,!0):At(this.scroll,t,e,!0)}return""}getText(t,e){return this.getContents(t,e).filter(s=>typeof s.insert=="string").map(s=>s.insert).join("")}insertContents(t,e){const s=Oe(e),i=new b().retain(t).concat(s);return this.scroll.insertContents(t,s),this.update(i)}insertEmbed(t,e,s){return this.scroll.insertAt(t,e,s),this.update(new b().retain(t).insert({[e]:s}))}insertText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return e=e.replace(/\r\n/g,`
|
|
`).replace(/\r/g,`
|
|
`),this.scroll.insertAt(t,e),Object.keys(s).forEach(i=>{this.scroll.formatAt(t,e.length,i,s[i])}),this.update(new b().retain(t).insert(e,ft(s)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;const t=this.scroll.children.head;if((t==null?void 0:t.statics.blotName)!==v.blotName)return!1;const e=t;return e.children.length>1?!1:e.children.head instanceof P}removeFormat(t,e){const s=this.getText(t,e),[i,n]=this.scroll.line(t+e);let l=0,o=new b;i!=null&&(l=i.length()-n,o=i.delta().slice(n,n+l-1).insert(`
|
|
`));const c=this.getContents(t,e+l).diff(new b().insert(s).concat(o)),h=new b().retain(t).concat(c);return this.applyDelta(h)}update(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;const i=this.delta;if(e.length===1&&e[0].type==="characterData"&&e[0].target.data.match(ti)&&this.scroll.find(e[0].target)){const n=this.scroll.find(e[0].target),l=C(n),o=n.offset(this.scroll),a=e[0].oldValue.replace($.CONTENTS,""),c=new b().insert(a),h=new b().insert(n.value()),d=s&&{oldRange:Re(s.oldRange,-o),newRange:Re(s.newRange,-o)};t=new b().retain(o).concat(c.diff(h,d)).reduce((E,g)=>g.insert?E.insert(g.insert,l):E.push(g),new b),this.delta=i.compose(t)}else this.delta=this.getDelta(),(!t||!fe(i.compose(t),this.delta))&&(t=i.diff(this.delta,s));return t}}function ht(r,t,e){if(r.length===0){const[E]=Wt(e.pop());return t<=0?`</li></${E}>`:`</li></${E}>${ht([],t-1,e)}`}const[{child:s,offset:i,length:n,indent:l,type:o},...a]=r,[c,h]=Wt(o);if(l>t)return e.push(o),l===t+1?`<${c}><li${h}>${At(s,i,n)}${ht(a,l,e)}`:`<${c}><li>${ht(r,t+1,e)}`;const d=e[e.length-1];if(l===t&&o===d)return`</li><li${h}>${At(s,i,n)}${ht(a,l,e)}`;const[N]=Wt(e.pop());return`</li></${N}>${ht(r,t-1,e)}`}function At(r,t,e){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in r&&typeof r.html=="function")return r.html(t,e);if(r instanceof U)return Ft(r.value().slice(t,t+e));if(r instanceof M){if(r.statics.blotName==="list-container"){const c=[];return r.children.forEachAt(t,e,(h,d,N)=>{const E="formats"in h&&typeof h.formats=="function"?h.formats():{};c.push({child:h,offset:d,length:N,indent:E.indent||0,type:E.list})}),ht(c,-1,[])}const i=[];if(r.children.forEachAt(t,e,(c,h,d)=>{i.push(At(c,h,d))}),s||r.statics.blotName==="list")return i.join("");const{outerHTML:n,innerHTML:l}=r.domNode,[o,a]=n.split(`>${l}<`);return o==="<table"?`<table style="border: 1px solid #000;">${i.join("")}<${a}`:`${o}>${i.join("")}<${a}`}return r.domNode instanceof Element?r.domNode.outerHTML:""}function si(r,t){return Object.keys(t).reduce((e,s)=>{if(r[s]==null)return e;const i=t[s];return i===r[s]?e[s]=i:Array.isArray(i)?i.indexOf(r[s])<0?e[s]=i.concat([r[s]]):e[s]=i:e[s]=[i,r[s]],e},{})}function Wt(r){const t=r==="ordered"?"ol":"ul";switch(r){case"checked":return[t,' data-list="checked"'];case"unchecked":return[t,' data-list="unchecked"'];default:return[t,""]}}function Oe(r){return r.reduce((t,e)=>{if(typeof e.insert=="string"){const s=e.insert.replace(/\r\n/g,`
|
|
`).replace(/\r/g,`
|
|
`);return t.insert(s,e.attributes)}return t.push(e)},new b)}function Re(r,t){let{index:e,length:s}=r;return new st(e+t,s)}function ii(r){const t=[];return r.forEach(e=>{typeof e.insert=="string"?e.insert.split(`
|
|
`).forEach((i,n)=>{n&&t.push({insert:`
|
|
`,attributes:e.attributes}),i&&t.push({insert:i,attributes:e.attributes})}):t.push(e)}),t}class F{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=t,this.options=e}}m(F,"DEFAULTS",{});const Ct="\uFEFF";class pe extends S{constructor(t,e){super(t,e),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(s=>{this.contentNode.appendChild(s)}),this.leftGuard=document.createTextNode(Ct),this.rightGuard=document.createTextNode(Ct),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(t,e){return t===this.leftGuard?0:t===this.rightGuard?1:super.index(t,e)}restore(t){let e=null,s;const i=t.data.split(Ct).join("");if(t===this.leftGuard)if(this.prev instanceof U){const n=this.prev.length();this.prev.insertAt(n,i),e={startNode:this.prev.domNode,startOffset:n+i.length}}else s=document.createTextNode(i),this.parent.insertBefore(this.scroll.create(s),this),e={startNode:s,startOffset:i.length};else t===this.rightGuard&&(this.next instanceof U?(this.next.insertAt(0,i),e={startNode:this.next.domNode,startOffset:i.length}):(s=document.createTextNode(i),this.parent.insertBefore(this.scroll.create(s),this.next),e={startNode:s,startOffset:i.length}));return t.data=Ct,e}update(t,e){t.forEach(s=>{if(s.type==="characterData"&&(s.target===this.leftGuard||s.target===this.rightGuard)){const i=this.restore(s.target);i&&(e.range=i)}})}}class ni{constructor(t,e){m(this,"isComposing",!1);this.scroll=t,this.emitter=e,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",t=>{this.isComposing||this.handleCompositionStart(t)}),this.scroll.domNode.addEventListener("compositionend",t=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(t)})})}handleCompositionStart(t){const e=t.target instanceof Node?this.scroll.find(t.target,!0):null;e&&!(e instanceof pe)&&(this.emitter.emit(p.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(p.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(p.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(p.events.COMPOSITION_END,t),this.isComposing=!1}}const Le=class{constructor(t,e){m(this,"modules",{});this.quill=t,this.options=e}init(){Object.keys(this.options.modules).forEach(t=>{this.modules[t]==null&&this.addModule(t)})}addModule(t){const e=this.quill.constructor.import(`modules/${t}`);return this.modules[t]=new e(this.quill,this.options.modules[t]||{}),this.modules[t]}};let Y=Le;m(Y,"DEFAULTS",{modules:{}}),m(Y,"themes",{default:Le});const ri=r=>r.parentElement||r.getRootNode().host||null,li=r=>{const t=r.getBoundingClientRect(),e="offsetWidth"in r&&Math.abs(t.width)/r.offsetWidth||1,s="offsetHeight"in r&&Math.abs(t.height)/r.offsetHeight||1;return{top:t.top,right:t.left+r.clientWidth*e,bottom:t.top+r.clientHeight*s,left:t.left}},Ot=r=>{const t=parseInt(r,10);return Number.isNaN(t)?0:t},Ie=(r,t,e,s,i,n)=>r<e&&t>s?0:r<e?-(e-r+i):t>s?t-r>s-e?r+i-e:t-s+n:0,oi=(r,t)=>{var n,l,o,a,c;const e=r.ownerDocument;let s=t,i=r;for(;i;){const h=i===e.body,d=h?{top:0,right:(l=(n=window.visualViewport)==null?void 0:n.width)!=null?l:e.documentElement.clientWidth,bottom:(a=(o=window.visualViewport)==null?void 0:o.height)!=null?a:e.documentElement.clientHeight,left:0}:li(i),N=getComputedStyle(i),E=Ie(s.left,s.right,d.left,d.right,Ot(N.scrollPaddingLeft),Ot(N.scrollPaddingRight)),g=Ie(s.top,s.bottom,d.top,d.bottom,Ot(N.scrollPaddingTop),Ot(N.scrollPaddingBottom));if(E||g)if(h)(c=e.defaultView)==null||c.scrollBy(E,g);else{const{scrollLeft:q,scrollTop:f}=i;g&&(i.scrollTop+=g),E&&(i.scrollLeft+=E);const x=i.scrollLeft-q,k=i.scrollTop-f;s={left:s.left-x,top:s.top-k,right:s.right-x,bottom:s.bottom-k}}i=h||N.position==="fixed"?null:ri(i)}},ai=100,ci=["block","break","cursor","inline","scroll","text"],hi=(r,t,e)=>{const s=new pt;return ci.forEach(i=>{const n=t.query(i);n&&s.register(n)}),r.forEach(i=>{var o;let n=t.query(i);n||e.error(`Cannot register "${i}" specified in "formats" config. Are you sure it was registered?`);let l=0;for(;n;)if(s.register(n),n="blotName"in n&&(o=n.requiredContainer)!=null?o:null,l+=1,l>ai){e.error(`Cycle detected in registering blot requiredContainer: "${i}"`);break}}),s},gt=W("quill"),Rt=new pt;M.uiClass="ql-ui";const dt=class{static debug(t){t===!0&&(t="log"),W.level(t)}static find(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return se.get(t)||Rt.find(t,e)}static import(t){return this.imports[t]==null&>.error(`Cannot import ${t}. Are you sure it was registered?`),this.imports[t]}static register(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof t!="string"){const i="attrName"in t?t.attrName:t.blotName;typeof i=="string"?this.register(`formats/${i}`,t,e):Object.keys(t).forEach(n=>{this.register(n,t[n],e)})}else this.imports[t]!=null&&!s&>.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&typeof e!="boolean"&&e.blotName!=="abstract"&&Rt.register(e),typeof e.register=="function"&&e.register(Rt)}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=ui(t,e),this.container=this.options.container,this.container==null){gt.error("Invalid Quill container",t);return}this.options.debug&&dt.debug(this.options.debug);const s=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",se.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new p;const i=ge.blotName,n=this.options.registry.query(i);if(!n||!("blotName"in n))throw new Error(`Cannot initialize Quill without "${i}" blot`);if(this.scroll=new n(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new ei(this.scroll),this.selection=new Js(this.scroll,this.emitter),this.composition=new ni(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.uploader=this.theme.addModule("uploader"),this.theme.addModule("input"),this.theme.addModule("uiNode"),this.theme.init(),this.emitter.on(p.events.COMPOSITION_START,()=>{this.root.classList.toggle("ql-blank",!1)}),this.emitter.on(p.events.COMPOSITION_END,()=>{this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(p.events.EDITOR_CHANGE,l=>{l===p.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(p.events.SCROLL_UPDATE,(l,o)=>{const a=this.selection.lastRange,[c]=this.selection.getRange(),h=a&&c?{oldRange:a,newRange:c}:void 0;B.call(this,()=>this.editor.update(null,o,h),l)}),this.emitter.on(p.events.SCROLL_EMBED_UPDATE,(l,o)=>{const a=this.selection.lastRange,[c]=this.selection.getRange(),h=a&&c?{oldRange:a,newRange:c}:void 0;B.call(this,()=>{const d=new b().retain(l.offset(this)).retain({[l.statics.blotName]:o});return this.editor.update(d,[],h)},dt.sources.USER)}),s){const l=this.clipboard.convert({html:`${s}<p><br></p>`,text:`
|
|
`});this.setContents(l)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof t=="string"){const s=t;t=document.createElement("div"),t.classList.add(s)}return this.container.insertBefore(t,e),t}blur(){this.selection.setRange(null)}deleteText(t,e,s){return[t,e,,s]=j(t,e,s),B.call(this,()=>this.editor.deleteText(t,e),s,t,-1*e)}disable(){this.enable(!1)}editReadOnly(t){this.allowReadOnlyEdits=!0;const e=t();return this.allowReadOnlyEdits=!1,e}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(t),this.container.classList.toggle("ql-disabled",!t)}focus(){this.selection.focus(),this.scrollSelectionIntoView()}format(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:p.sources.API;return B.call(this,()=>{const i=this.getSelection(!0);let n=new b;if(i==null)return n;if(this.scroll.query(t,y.BLOCK))n=this.editor.formatLine(i.index,i.length,{[t]:e});else{if(i.length===0)return this.selection.format(t,e),n;n=this.editor.formatText(i.index,i.length,{[t]:e})}return this.setSelection(i,p.sources.SILENT),n},s)}formatLine(t,e,s,i,n){let l;return[t,e,l,n]=j(t,e,s,i,n),B.call(this,()=>this.editor.formatLine(t,e,l),n,t,0)}formatText(t,e,s,i,n){let l;return[t,e,l,n]=j(t,e,s,i,n),B.call(this,()=>this.editor.formatText(t,e,l),n,t,0)}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=null;if(typeof t=="number"?s=this.selection.getBounds(t,e):s=this.selection.getBounds(t.index,t.length),!s)return null;const i=this.container.getBoundingClientRect();return{bottom:s.bottom-i.top,height:s.height,left:s.left-i.left,right:s.right-i.left,top:s.top-i.top,width:s.width}}getContents(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-t;return[t,e]=j(t,e),this.editor.getContents(t,e)}getFormat(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof t=="number"?this.editor.getFormat(t,e):this.editor.getFormat(t.index,t.length)}getIndex(t){return t.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(t){return this.scroll.leaf(t)}getLine(t){return this.scroll.line(t)}getLines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof t!="number"?this.scroll.lines(t.index,t.length):this.scroll.lines(t,e)}getModule(t){return this.theme.modules[t]}getSelection(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1)&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return typeof t=="number"&&(e=e!=null?e:this.getLength()-t),[t,e]=j(t,e),this.editor.getHTML(t,e)}getText(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return typeof t=="number"&&(e=e!=null?e:this.getLength()-t),[t,e]=j(t,e),this.editor.getText(t,e)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:dt.sources.API;return B.call(this,()=>this.editor.insertEmbed(t,e,s),i,t)}insertText(t,e,s,i,n){let l;return[t,,l,n]=j(t,0,s,i,n),B.call(this,()=>this.editor.insertText(t,e,l),n,t,e.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(t,e,s){return[t,e,,s]=j(t,e,s),B.call(this,()=>this.editor.removeFormat(t,e),s,t)}scrollRectIntoView(t){oi(this.root,t)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){const t=this.selection.lastRange,e=t&&this.selection.getBounds(t.index,t.length);e&&this.scrollRectIntoView(e)}setContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p.sources.API;return B.call(this,()=>{t=new b(t);const s=this.getLength(),i=this.editor.deleteText(0,s),n=this.editor.insertContents(0,t),l=this.editor.deleteText(this.getLength()-1,1);return i.compose(n).compose(l)},e)}setSelection(t,e,s){t==null?this.selection.setRange(null,e||dt.sources.API):([t,e,,s]=j(t,e,s),this.selection.setRange(new st(Math.max(0,t),e),s),s!==p.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p.sources.API;const s=new b().insert(t);return this.setContents(s,e)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p.sources.USER;const e=this.scroll.update(t);return this.selection.update(t),e}updateContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p.sources.API;return B.call(this,()=>(t=new b(t),this.editor.applyDelta(t)),e,!0)}};let u=dt;m(u,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:Rt,theme:"default"}),m(u,"events",p.events),m(u,"sources",p.sources),m(u,"version","2.0.0"),m(u,"imports",{delta:b,parchment:Xs,"core/module":F,"core/theme":Y});function Be(r){return typeof r=="string"?document.querySelector(r):r}function Gt(r){return Object.entries(r!=null?r:{}).reduce((t,e)=>{let[s,i]=e;return{...t,[s]:i===!0?{}:i}},{})}function De(r){return Object.fromEntries(Object.entries(r).filter(t=>t[1]!==void 0))}function ui(r,t){const e=Be(r);if(!e)throw new Error("Invalid Quill container");const i=!t.theme||t.theme===u.DEFAULTS.theme?Y:u.import(`themes/${t.theme}`);if(!i)throw new Error(`Invalid theme ${t.theme}. Did you register it?`);const{modules:n,...l}=u.DEFAULTS,{modules:o,...a}=i.DEFAULTS,c=tt({},Gt(n),Gt(o),Gt(t.modules));c!=null&&c.toolbar&&c.toolbar.constructor!==Object&&(c.toolbar={container:c.toolbar});const h={...l,...De(a),...De(t)};let d=t.registry;return d?t.formats&>.warn('Ignoring "formats" option because "registry" is specified'):d=t.formats?hi(t.formats,h.registry,gt):h.registry,{...h,registry:d,container:e,theme:i,modules:Object.entries(c).reduce((N,E)=>{let[g,q]=E;if(!q)return N;const f=u.import(`modules/${g}`);return f==null?(gt.error(`Cannot load ${g} module. Are you sure you registered it?`),N):{...N,[g]:tt({},f.DEFAULTS||{},q)}},{}),bounds:Be(h.bounds)}}function B(r,t,e,s){if(!this.isEnabled()&&t===p.sources.USER&&!this.allowReadOnlyEdits)return new b;let i=e==null?null:this.getSelection();const n=this.editor.delta,l=r();if(i!=null&&(e===!0&&(e=i.index),s==null?i=Me(i,l,t):s!==0&&(i=Me(i,e,s,t)),this.setSelection(i,p.sources.SILENT)),l.length()>0){const o=[p.events.TEXT_CHANGE,l,n,t];this.emitter.emit(p.events.EDITOR_CHANGE,...o),t!==p.sources.SILENT&&this.emitter.emit(...o)}return l}function j(r,t,e,s,i){let n={};return typeof r.index=="number"&&typeof r.length=="number"?typeof t!="number"?(i=s,s=e,e=t,t=r.length,r=r.index):(t=r.length,r=r.index):typeof t!="number"&&(i=s,s=e,e=t,t=0),typeof e=="object"?(n=e,i=s):typeof e=="string"&&(s!=null?n[e]=s:i=e),i=i||p.sources.API,[r,t,n,i]}function Me(r,t,e,s){const i=typeof e=="number"?e:0;if(r==null)return null;let n,l;return t&&typeof t.transformPosition=="function"?[n,l]=[r.index,r.index+r.length].map(o=>t.transformPosition(o,s!==p.sources.USER)):[n,l]=[r.index,r.index+r.length].map(o=>o<t||o===t&&s===p.sources.USER?o:i>=0?o+i:Math.max(t,o+i)),new st(n,l-n)}class it extends Pt{}function Ue(r){return r instanceof v||r instanceof R}function _e(r){return typeof r.updateContent=="function"}class ut extends ge{constructor(t,e,s){let{emitter:i}=s;super(t,e),this.emitter=i,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",n=>this.handleDragStart(n))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;const t=this.batch;this.batch=!1,this.update(t)}emitMount(t){this.emitter.emit(p.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(p.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,e){this.emitter.emit(p.events.SCROLL_EMBED_UPDATE,t,e)}deleteAt(t,e){const[s,i]=this.line(t),[n]=this.line(t+e);if(super.deleteAt(t,e),n!=null&&s!==n&&i>0){if(s instanceof R||n instanceof R){this.optimize();return}const l=n.children.head instanceof P?null:n.children.head;s.moveChildren(n,l),s.remove()}this.optimize()}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",t?"true":"false")}formatAt(t,e,s,i){super.formatAt(t,e,s,i),this.optimize()}insertAt(t,e,s){if(t>=this.length())if(s==null||this.scroll.query(e,y.BLOCK)==null){const i=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(i),s==null&&e.endsWith(`
|
|
`)?i.insertAt(0,e.slice(0,-1),s):i.insertAt(0,e,s)}else{const i=this.scroll.create(e,s);this.appendChild(i)}else super.insertAt(t,e,s);this.optimize()}insertBefore(t,e){if(t.statics.scope===y.INLINE_BLOT){const s=this.scroll.create(this.statics.defaultChild.blotName);s.appendChild(t),super.insertBefore(s,e)}else super.insertBefore(t,e)}insertContents(t,e){const s=this.deltaToRenderBlocks(e.concat(new b().insert(`
|
|
`))),i=s.pop();if(i==null)return;this.batchStart();const n=s.shift();if(n){const a=n.type==="block"&&(n.delta.length()===0||!this.descendant(R,t)[0]&&t<this.length()),c=n.type==="block"?n.delta:new b().insert({[n.key]:n.value});Zt(this,t,c);const h=n.type==="block"?1:0,d=t+c.length()+h;a&&this.insertAt(d-1,`
|
|
`);const N=C(this.line(t)[0]),E=D.exports.AttributeMap.diff(N,n.attributes)||{};Object.keys(E).forEach(g=>{this.formatAt(d-1,1,g,E[g])}),t=d}let[l,o]=this.children.find(t);if(s.length&&(l&&(l=l.split(o),o=0),s.forEach(a=>{if(a.type==="block"){const c=this.createBlock(a.attributes,l||void 0);Zt(c,0,a.delta)}else{const c=this.create(a.key,a.value);this.insertBefore(c,l||void 0),Object.keys(a.attributes).forEach(h=>{c.format(h,a.attributes[h])})}})),i.type==="block"&&i.delta.length()){const a=l?l.offset(l.scroll)+o:this.length();Zt(this,a,i.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(t){const e=this.path(t).pop();if(!e)return[null,-1];const[s,i]=e;return s instanceof w?[s,i]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(Ue,t)}lines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;const s=(i,n,l)=>{let o=[],a=l;return i.children.forEachAt(n,l,(c,h,d)=>{Ue(c)?o.push(c):c instanceof Pt&&(o=o.concat(s(c,h,a))),a-=d}),o};return s(this,t,e)}optimize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(t,e),t.length>0&&this.emitter.emit(p.events.SCROLL_OPTIMIZE,t,e))}path(t){return super.path(t).slice(1)}remove(){}update(t){if(this.batch){Array.isArray(t)&&(this.batch=this.batch.concat(t));return}let e=p.sources.USER;typeof t=="string"&&(e=t),Array.isArray(t)||(t=this.observer.takeRecords()),t=t.filter(s=>{let{target:i}=s;const n=this.find(i,!0);return n&&!_e(n)}),t.length>0&&this.emitter.emit(p.events.SCROLL_BEFORE_UPDATE,e,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(p.events.SCROLL_UPDATE,e,t)}updateEmbedAt(t,e,s){const[i]=this.descendant(n=>n instanceof R,t);i&&i.statics.blotName===e&&_e(i)&&i.updateContent(s)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){const e=[];let s=new b;return t.forEach(i=>{var l;const n=i==null?void 0:i.insert;if(!!n)if(typeof n=="string"){const o=n.split(`
|
|
`);o.slice(0,-1).forEach(c=>{var h;s.insert(c,i.attributes),e.push({type:"block",delta:s,attributes:(h=i.attributes)!=null?h:{}}),s=new b});const a=o[o.length-1];a&&s.insert(a,i.attributes)}else{const o=Object.keys(n)[0];if(!o)return;this.query(o,y.INLINE)?s.push(i):(s.length()&&e.push({type:"block",delta:s,attributes:{}}),s=new b,e.push({type:"blockEmbed",key:o,value:n[o],attributes:(l=i.attributes)!=null?l:{}}))}}),s.length()&&e.push({type:"block",delta:s,attributes:{}}),e}createBlock(t,e){let s;const i={};Object.entries(t).forEach(o=>{let[a,c]=o;this.query(a,y.BLOCK&y.BLOT)!=null?s=a:i[a]=c});const n=this.create(s||this.statics.defaultChild.blotName,s?t[s]:void 0);this.insertBefore(n,e||void 0);const l=n.length();return Object.entries(i).forEach(o=>{let[a,c]=o;n.formatAt(0,l,a,c)}),n}}m(ut,"blotName","scroll"),m(ut,"className","ql-editor"),m(ut,"tagName","DIV"),m(ut,"defaultChild",v),m(ut,"allowedChildren",[v,R,it]);function Zt(r,t,e){e.reduce((s,i)=>{const n=D.exports.Op.length(i);let l=i.attributes||{};if(i.insert!=null){if(typeof i.insert=="string"){const o=i.insert;r.insertAt(s,o);const[a]=r.descendant(w,s),c=C(a);l=D.exports.AttributeMap.diff(c,l)||{}}else if(typeof i.insert=="object"){const o=Object.keys(i.insert)[0];if(o==null)return s;if(r.insertAt(s,o,i.insert[o]),r.scroll.query(o,y.INLINE)!=null){const[c]=r.descendant(w,s),h=C(c);l=D.exports.AttributeMap.diff(h,l)||{}}}}return Object.keys(l).forEach(o=>{r.formatAt(s,n,o,l[o])}),s+n},t)}const be={scope:y.BLOCK,whitelist:["right","center","justify"]},di=new z("align","align",be),os=new _("align","ql-align",be),as=new et("align","text-align",be);class cs extends et{value(t){let e=super.value(t);return e.startsWith("rgb(")?(e=e.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${e.split(",").map(i=>`00${parseInt(i,10).toString(16)}`.slice(-2)).join("")}`):e}}const fi=new _("color","ql-color",{scope:y.INLINE}),ye=new cs("color","color",{scope:y.INLINE}),mi=new _("background","ql-bg",{scope:y.INLINE}),Ne=new cs("background","background-color",{scope:y.INLINE});class nt extends it{static create(t){const e=super.create(t);return e.setAttribute("spellcheck","false"),e}code(t,e){return this.children.map(s=>s.length()<=1?"":s.domNode.innerText).join(`
|
|
`).slice(t,t+e)}html(t,e){return`<pre>
|
|
${Ft(this.code(t,e))}
|
|
</pre>`}}class L extends v{static register(){u.register(nt)}}m(L,"TAB"," ");class Ee extends I{}Ee.blotName="code";Ee.tagName="CODE";L.blotName="code-block";L.className="ql-code-block";L.tagName="DIV";nt.blotName="code-block-container";nt.className="ql-code-block-container";nt.tagName="DIV";nt.allowedChildren=[L];L.allowedChildren=[U,P,$];L.requiredContainer=nt;const xe={scope:y.BLOCK,whitelist:["rtl"]},hs=new z("direction","dir",xe),us=new _("direction","ql-direction",xe),ds=new et("direction","direction",xe),fs={scope:y.INLINE,whitelist:["serif","monospace"]},ms=new _("font","ql-font",fs);class gi extends et{value(t){return super.value(t).replace(/["']/g,"")}}const gs=new gi("font","font-family",fs),ps=new _("size","ql-size",{scope:y.INLINE,whitelist:["small","large","huge"]}),bs=new et("size","font-size",{scope:y.INLINE,whitelist:["10px","18px","32px"]}),pi=W("quill:keyboard"),bi=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey";class $t extends F{static match(t,e){return["altKey","ctrlKey","metaKey","shiftKey"].some(s=>!!e[s]!==t[s]&&e[s]!==null)?!1:e.key===t.key||e.key===t.which}constructor(t,e){super(t,e),this.bindings={},Object.keys(this.options.bindings).forEach(s=>{this.options.bindings[s]&&this.addBinding(this.options.bindings[s])}),this.addBinding({key:"Enter",shiftKey:null},this.handleEnter),this.addBinding({key:"Enter",metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:"Backspace"},{collapsed:!0},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0},this.handleDelete)):(this.addBinding({key:"Backspace"},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:"Backspace"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Delete"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Backspace",altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=Ni(t);if(i==null){pi.warn("Attempted to add invalid keyboard binding",i);return}typeof e=="function"&&(e={handler:e}),typeof s=="function"&&(s={handler:s}),(Array.isArray(i.key)?i.key:[i.key]).forEach(l=>{const o={...i,key:l,...e,...s};this.bindings[o.key]=this.bindings[o.key]||[],this.bindings[o.key].push(o)})}listen(){this.quill.root.addEventListener("keydown",t=>{if(t.defaultPrevented||t.isComposing)return;const s=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(f=>$t.match(t,f));if(s.length===0)return;const i=u.find(t.target,!0);if(i&&i.scroll!==this.quill.scroll)return;const n=this.quill.getSelection();if(n==null||!this.quill.hasFocus())return;const[l,o]=this.quill.getLine(n.index),[a,c]=this.quill.getLeaf(n.index),[h,d]=n.length===0?[a,c]:this.quill.getLeaf(n.index+n.length),N=a instanceof Ut?a.value().slice(0,c):"",E=h instanceof Ut?h.value().slice(d):"",g={collapsed:n.length===0,empty:n.length===0&&l.length()<=1,format:this.quill.getFormat(n),line:l,offset:o,prefix:N,suffix:E,event:t};s.some(f=>{if(f.collapsed!=null&&f.collapsed!==g.collapsed||f.empty!=null&&f.empty!==g.empty||f.offset!=null&&f.offset!==g.offset)return!1;if(Array.isArray(f.format)){if(f.format.every(x=>g.format[x]==null))return!1}else if(typeof f.format=="object"&&!Object.keys(f.format).every(x=>f.format[x]===!0?g.format[x]!=null:f.format[x]===!1?g.format[x]==null:fe(f.format[x],g.format[x])))return!1;return f.prefix!=null&&!f.prefix.test(g.prefix)||f.suffix!=null&&!f.suffix.test(g.suffix)?!1:f.handler.call(this,n,g,f)!==!0})&&t.preventDefault()})}handleBackspace(t,e){const s=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(e.prefix)?2:1;if(t.index===0||this.quill.getLength()<=1)return;let i={};const[n]=this.quill.getLine(t.index);let l=new b().retain(t.index-s).delete(s);if(e.offset===0){const[o]=this.quill.getLine(t.index-1);if(o&&!(o.statics.blotName==="block"&&o.length()<=1)){const c=n.formats(),h=this.quill.getFormat(t.index-1,1);if(i=D.exports.AttributeMap.diff(c,h)||{},Object.keys(i).length>0){const d=new b().retain(t.index+n.length()-2).retain(1,i);l=l.compose(d)}}}this.quill.updateContents(l,u.sources.USER),this.quill.focus()}handleDelete(t,e){const s=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(e.suffix)?2:1;if(t.index>=this.quill.getLength()-s)return;let i={};const[n]=this.quill.getLine(t.index);let l=new b().retain(t.index).delete(s);if(e.offset>=n.length()-1){const[o]=this.quill.getLine(t.index+1);if(o){const a=n.formats(),c=this.quill.getFormat(t.index,1);i=D.exports.AttributeMap.diff(a,c)||{},Object.keys(i).length>0&&(l=l.retain(o.length()-1).retain(1,i))}}this.quill.updateContents(l,u.sources.USER),this.quill.focus()}handleDeleteRange(t){qe({range:t,quill:this.quill}),this.quill.focus()}handleEnter(t,e){const s=Object.keys(e.format).reduce((n,l)=>(this.quill.scroll.query(l,y.BLOCK)&&!Array.isArray(e.format[l])&&(n[l]=e.format[l]),n),{}),i=new b().retain(t.index).delete(t.length).insert(`
|
|
`,s);this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(t.index+1,u.sources.SILENT),this.quill.focus()}}const yi={bindings:{bold:Xt("bold"),italic:Xt("italic"),underline:Xt("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(r,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","+1",u.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(r,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","-1",u.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(r,t){t.format.indent!=null?this.quill.format("indent","-1",u.sources.USER):t.format.list!=null&&this.quill.format("list",!1,u.sources.USER)}},"indent code-block":Pe(!0),"outdent code-block":Pe(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(r){this.quill.deleteText(r.index-1,1,u.sources.USER)}},tab:{key:"Tab",handler(r,t){if(t.format.table)return!0;this.quill.history.cutoff();const e=new b().retain(r.index).delete(r.length).insert(" ");return this.quill.updateContents(e,u.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(r.index+1,u.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,u.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(r,t){const e={list:!1};t.format.indent&&(e.indent=!1),this.quill.formatLine(r.index,r.length,e,u.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(r){const[t,e]=this.quill.getLine(r.index),s={...t.formats(),list:"checked"},i=new b().retain(r.index).insert(`
|
|
`,s).retain(t.length()-e-1).retain(1,{list:"unchecked"});this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(r.index+1,u.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(r,t){const[e,s]=this.quill.getLine(r.index),i=new b().retain(r.index).insert(`
|
|
`,t.format).retain(e.length()-s-1).retain(1,{header:null});this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(r.index+1,u.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:"Backspace",format:["table"],collapsed:!0,offset:0,handler(){}},"table delete":{key:"Delete",format:["table"],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:"Enter",shiftKey:null,format:["table"],handler(r){const t=this.quill.getModule("table");if(t){const[e,s,i,n]=t.getTable(r),l=Ei(e,s,i,n);if(l==null)return;let o=e.offset();if(l<0){const a=new b().retain(o).insert(`
|
|
`);this.quill.updateContents(a,u.sources.USER),this.quill.setSelection(r.index+1,r.length,u.sources.SILENT)}else if(l>0){o+=e.length();const a=new b().retain(o).insert(`
|
|
`);this.quill.updateContents(a,u.sources.USER),this.quill.setSelection(o,u.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(r,t){const{event:e,line:s}=t,i=s.offset(this.quill.scroll);e.shiftKey?this.quill.setSelection(i-1,u.sources.USER):this.quill.setSelection(i+s.length(),u.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(r,t){if(this.quill.scroll.query("list")==null)return!0;const{length:e}=t.prefix,[s,i]=this.quill.getLine(r.index);if(i>e)return!0;let n;switch(t.prefix.trim()){case"[]":case"[ ]":n="unchecked";break;case"[x]":n="checked";break;case"-":case"*":n="bullet";break;default:n="ordered"}this.quill.insertText(r.index," ",u.sources.USER),this.quill.history.cutoff();const l=new b().retain(r.index-i).delete(e+1).retain(s.length()-2-i).retain(1,{list:n});return this.quill.updateContents(l,u.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(r.index-e,u.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(r){const[t,e]=this.quill.getLine(r.index);let s=2,i=t;for(;i!=null&&i.length()<=1&&i.formats()["code-block"];)if(i=i.prev,s-=1,s<=0){const n=new b().retain(r.index+t.length()-e-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(n,u.sources.USER),this.quill.setSelection(r.index-1,u.sources.SILENT),!1}return!0}},"embed left":It("ArrowLeft",!1),"embed left shift":It("ArrowLeft",!0),"embed right":It("ArrowRight",!1),"embed right shift":It("ArrowRight",!0),"table down":Fe(!1),"table up":Fe(!0)}};$t.DEFAULTS=yi;function Pe(r){return{key:"Tab",shiftKey:!r,format:{"code-block":!0},handler(t,e){let{event:s}=e;const i=this.quill.scroll.query("code-block"),{TAB:n}=i;if(t.length===0&&!s.shiftKey){this.quill.insertText(t.index,n,u.sources.USER),this.quill.setSelection(t.index+n.length,u.sources.SILENT);return}const l=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t);let{index:o,length:a}=t;l.forEach((c,h)=>{r?(c.insertAt(0,n),h===0?o+=n.length:a+=n.length):c.domNode.textContent.startsWith(n)&&(c.deleteAt(0,n.length),h===0?o-=n.length:a-=n.length)}),this.quill.update(u.sources.USER),this.quill.setSelection(o,a,u.sources.SILENT)}}}function It(r,t){return{key:r,shiftKey:t,altKey:null,[r==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(s){let{index:i}=s;r==="ArrowRight"&&(i+=s.length+1);const[n]=this.quill.getLeaf(i);return n instanceof S?(r==="ArrowLeft"?t?this.quill.setSelection(s.index-1,s.length+1,u.sources.USER):this.quill.setSelection(s.index-1,u.sources.USER):t?this.quill.setSelection(s.index,s.length+1,u.sources.USER):this.quill.setSelection(s.index+s.length+1,u.sources.USER),!1):!0}}}function Xt(r){return{key:r[0],shortKey:!0,handler(t,e){this.quill.format(r,!e.format[r],u.sources.USER)}}}function Fe(r){return{key:r?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(t,e){const s=r?"prev":"next",i=e.line,n=i.parent[s];if(n!=null){if(n.statics.blotName==="table-row"){let l=n.children.head,o=i;for(;o.prev!=null;)o=o.prev,l=l.next;const a=l.offset(this.quill.scroll)+Math.min(e.offset,l.length()-1);this.quill.setSelection(a,0,u.sources.USER)}}else{const l=i.table()[s];l!=null&&(r?this.quill.setSelection(l.offset(this.quill.scroll)+l.length()-1,0,u.sources.USER):this.quill.setSelection(l.offset(this.quill.scroll),0,u.sources.USER))}return!1}}}function Ni(r){if(typeof r=="string"||typeof r=="number")r={key:r};else if(typeof r=="object")r=ft(r);else return null;return r.shortKey&&(r[bi]=r.shortKey,delete r.shortKey),r}function qe(r){let{quill:t,range:e}=r;const s=t.getLines(e);let i={};if(s.length>1){const n=s[0].formats(),l=s[s.length-1].formats();i=D.exports.AttributeMap.diff(l,n)||{}}t.deleteText(e,u.sources.USER),Object.keys(i).length>0&&t.formatLine(e.index,1,i,u.sources.USER),t.setSelection(e.index,u.sources.SILENT)}function Ei(r,t,e,s){return t.prev==null&&t.next==null?e.prev==null&&e.next==null?s===0?-1:1:e.prev==null?-1:1:t.prev==null?-1:t.next==null?1:null}const xi=/font-weight:\s*normal/,qi=["P","OL","UL"],$e=r=>r&&qi.includes(r.tagName),Ai=r=>{Array.from(r.querySelectorAll("br")).filter(t=>$e(t.previousElementSibling)&&$e(t.nextElementSibling)).forEach(t=>{var e;(e=t.parentNode)==null||e.removeChild(t)})},vi=r=>{Array.from(r.querySelectorAll('b[style*="font-weight"]')).filter(t=>{var e;return(e=t.getAttribute("style"))==null?void 0:e.match(xi)}).forEach(t=>{var s;const e=r.createDocumentFragment();e.append(...t.childNodes),(s=t.parentNode)==null||s.replaceChild(e,t)})};function wi(r){r.querySelector('[id^="docs-internal-guid-"]')&&(vi(r),Ai(r))}const Li=/\bmso-list:[^;]*ignore/i,ki=/\bmso-list:[^;]*\bl(\d+)/i,Ti=/\bmso-list:[^;]*\blevel(\d+)/i,Si=(r,t)=>{const e=r.getAttribute("style"),s=e==null?void 0:e.match(ki);if(!s)return null;const i=Number(s[1]),n=e==null?void 0:e.match(Ti),l=n?Number(n[1]):1,o=new RegExp(`@list l${i}:level${l}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),a=t.match(o),c=a&&a[1]==="bullet"?"bullet":"ordered";return{id:i,indent:l,type:c,element:r}},Ci=r=>{var l,o;const t=Array.from(r.querySelectorAll("[style*=mso-list]")),e=[],s=[];t.forEach(a=>{(a.getAttribute("style")||"").match(Li)?e.push(a):s.push(a)}),e.forEach(a=>{var c;return(c=a.parentNode)==null?void 0:c.removeChild(a)});const i=r.documentElement.innerHTML,n=s.map(a=>Si(a,i)).filter(a=>a);for(;n.length;){const a=[];let c=n.shift();for(;c;)a.push(c),c=n.length&&((l=n[0])==null?void 0:l.element)===c.element.nextElementSibling&&n[0].id===c.id?n.shift():null;const h=document.createElement("ul");a.forEach(E=>{const g=document.createElement("li");g.setAttribute("data-list",E.type),E.indent>1&&g.setAttribute("class",`ql-indent-${E.indent-1}`),g.innerHTML=E.element.innerHTML,h.appendChild(g)});const d=(o=a[0])==null?void 0:o.element,{parentNode:N}=d!=null?d:{};d&&(N==null||N.replaceChild(h,d)),a.slice(1).forEach(E=>{let{element:g}=E;N==null||N.removeChild(g)})}};function Oi(r){r.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&Ci(r)}const Ri=[Oi,wi],Ii=r=>{r.documentElement&&Ri.forEach(t=>{t(r)})},Bi=W("quill:clipboard"),Di=[[Node.TEXT_NODE,Wi],[Node.TEXT_NODE,ze],["br",Fi],[Node.ELEMENT_NODE,ze],[Node.ELEMENT_NODE,Pi],[Node.ELEMENT_NODE,_i],[Node.ELEMENT_NODE,Ki],["li",zi],["ol, ul",ji],["pre",$i],["tr",Vi],["b",Yt("bold")],["i",Yt("italic")],["strike",Yt("strike")],["style",Hi]],Mi=[di,hs].reduce((r,t)=>(r[t.keyName]=t,r),{}),He=[as,Ne,ye,ds,gs,bs].reduce((r,t)=>(r[t.keyName]=t,r),{});class ys extends F{constructor(t,e){var s;super(t,e),this.quill.root.addEventListener("copy",i=>this.onCaptureCopy(i,!1)),this.quill.root.addEventListener("cut",i=>this.onCaptureCopy(i,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],Di.concat((s=this.options.matchers)!=null?s:[]).forEach(i=>{let[n,l]=i;this.addMatcher(n,l)})}addMatcher(t,e){this.matchers.push([t,e])}convert(t){let{html:e,text:s}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(i[L.blotName])return new b().insert(s||"",{[L.blotName]:i[L.blotName]});if(!e)return new b().insert(s||"",i);const n=this.convertHTML(e);return Lt(n,`
|
|
`)&&(n.ops[n.ops.length-1].attributes==null||i.table)?n.compose(new b().retain(n.length()-1).delete(1)):n}normalizeHTML(t){Ii(t)}convertHTML(t){const e=new DOMParser().parseFromString(t,"text/html");this.normalizeHTML(e);const s=e.body,i=new WeakMap,[n,l]=this.prepareMatching(s,i);return Ae(this.quill.scroll,s,n,l,i)}dangerouslyPasteHTML(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.sources.API;if(typeof t=="string"){const i=this.convert({html:t,text:""});this.quill.setContents(i,e),this.quill.setSelection(0,u.sources.SILENT)}else{const i=this.convert({html:e,text:""});this.quill.updateContents(new b().retain(t).concat(i),s),this.quill.setSelection(t+i.length(),u.sources.SILENT)}}onCaptureCopy(t){var l,o;let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(t.defaultPrevented)return;t.preventDefault();const[s]=this.quill.selection.getRange();if(s==null)return;const{html:i,text:n}=this.onCopy(s,e);(l=t.clipboardData)==null||l.setData("text/plain",n),(o=t.clipboardData)==null||o.setData("text/html",i),e&&qe({range:s,quill:this.quill})}normalizeURIList(t){return t.split(/\r?\n/).filter(e=>e[0]!=="#").join(`
|
|
`)}onCapturePaste(t){var l,o,a,c,h;if(t.defaultPrevented||!this.quill.isEnabled())return;t.preventDefault();const e=this.quill.getSelection(!0);if(e==null)return;const s=(l=t.clipboardData)==null?void 0:l.getData("text/html");let i=(o=t.clipboardData)==null?void 0:o.getData("text/plain");if(!s&&!i){const d=(a=t.clipboardData)==null?void 0:a.getData("text/uri-list");d&&(i=this.normalizeURIList(d))}const n=Array.from(((c=t.clipboardData)==null?void 0:c.files)||[]);if(!s&&n.length>0){this.quill.uploader.upload(e,n);return}if(s&&n.length>0){const d=new DOMParser().parseFromString(s,"text/html");if(d.body.childElementCount===1&&((h=d.body.firstElementChild)==null?void 0:h.tagName)==="IMG"){this.quill.uploader.upload(e,n);return}}this.onPaste(e,{html:s,text:i})}onCopy(t){const e=this.quill.getText(t);return{html:this.quill.getSemanticHTML(t),text:e}}onPaste(t,e){let{text:s,html:i}=e;const n=this.quill.getFormat(t.index),l=this.convert({text:s,html:i},n);Bi.log("onPaste",l,{text:s,html:i});const o=new b().retain(t.index).delete(t.length).concat(l);this.quill.updateContents(o,u.sources.USER),this.quill.setSelection(o.length()-t.length,u.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(t,e){const s=[],i=[];return this.matchers.forEach(n=>{const[l,o]=n;switch(l){case Node.TEXT_NODE:i.push(o);break;case Node.ELEMENT_NODE:s.push(o);break;default:Array.from(t.querySelectorAll(l)).forEach(a=>{if(e.has(a)){const c=e.get(a);c==null||c.push(o)}else e.set(a,[o])});break}}),[s,i]}}m(ys,"DEFAULTS",{matchers:[]});function rt(r,t,e,s){return s.query(t)?r.reduce((i,n)=>{if(!n.insert)return i;if(n.attributes&&n.attributes[t])return i.push(n);const l=e?{[t]:e}:{};return i.insert(n.insert,{...l,...n.attributes})},new b):r}function Lt(r,t){let e="";for(let s=r.ops.length-1;s>=0&&e.length<t.length;--s){const i=r.ops[s];if(typeof i.insert!="string")break;e=i.insert+e}return e.slice(-1*t.length)===t}function Q(r,t){if(!(r instanceof Element))return!1;const e=t.query(r);return e&&e.prototype instanceof S?!1:["address","article","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","iframe","li","main","nav","ol","output","p","pre","section","table","td","tr","ul","video"].includes(r.tagName.toLowerCase())}function Ui(r,t){return r.previousElementSibling&&r.nextElementSibling&&!Q(r.previousElementSibling,t)&&!Q(r.nextElementSibling,t)}const Bt=new WeakMap;function Ns(r){return r==null?!1:(Bt.has(r)||(r.tagName==="PRE"?Bt.set(r,!0):Bt.set(r,Ns(r.parentNode))),Bt.get(r))}function Ae(r,t,e,s,i){return t.nodeType===t.TEXT_NODE?s.reduce((n,l)=>l(t,n,r),new b):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((n,l)=>{let o=Ae(r,l,e,s,i);return l.nodeType===t.ELEMENT_NODE&&(o=e.reduce((a,c)=>c(l,a,r),o),o=(i.get(l)||[]).reduce((a,c)=>c(l,a,r),o)),n.concat(o)},new b):new b}function Yt(r){return(t,e,s)=>rt(e,r,!0,s)}function _i(r,t,e){const s=z.keys(r),i=_.keys(r),n=et.keys(r),l={};return s.concat(i).concat(n).forEach(o=>{let a=e.query(o,y.ATTRIBUTE);a!=null&&(l[a.attrName]=a.value(r),l[a.attrName])||(a=Mi[o],a!=null&&(a.attrName===o||a.keyName===o)&&(l[a.attrName]=a.value(r)||void 0),a=He[o],a!=null&&(a.attrName===o||a.keyName===o)&&(a=He[o],l[a.attrName]=a.value(r)||void 0))}),Object.entries(l).reduce((o,a)=>{let[c,h]=a;return rt(o,c,h,e)},t)}function Pi(r,t,e){const s=e.query(r);if(s==null)return t;if(s.prototype instanceof S){const i={},n=s.value(r);if(n!=null)return i[s.blotName]=n,new b().insert(i,s.formats(r,e))}else if(s.prototype instanceof qt&&!Lt(t,`
|
|
`)&&t.insert(`
|
|
`),"blotName"in s&&"formats"in s&&typeof s.formats=="function")return rt(t,s.blotName,s.formats(r,e),e);return t}function Fi(r,t){return Lt(t,`
|
|
`)||t.insert(`
|
|
`),t}function $i(r,t,e){const s=e.query("code-block"),i=s&&"formats"in s&&typeof s.formats=="function"?s.formats(r,e):!0;return rt(t,"code-block",i,e)}function Hi(){return new b}function zi(r,t,e){const s=e.query(r);if(s==null||s.blotName!=="list"||!Lt(t,`
|
|
`))return t;let i=-1,n=r.parentNode;for(;n!=null;)["OL","UL"].includes(n.tagName)&&(i+=1),n=n.parentNode;return i<=0?t:t.reduce((l,o)=>o.insert?o.attributes&&typeof o.attributes.indent=="number"?l.push(o):l.insert(o.insert,{indent:i,...o.attributes||{}}):l,new b)}function ji(r,t,e){const s=r;let i=s.tagName==="OL"?"ordered":"bullet";const n=s.getAttribute("data-checked");return n&&(i=n==="true"?"checked":"unchecked"),rt(t,"list",i,e)}function ze(r,t,e){if(!Lt(t,`
|
|
`)){if(Q(r,e)&&(r.childNodes.length>0||r instanceof HTMLParagraphElement))return t.insert(`
|
|
`);if(t.length()>0&&r.nextSibling){let s=r.nextSibling;for(;s!=null;){if(Q(s,e))return t.insert(`
|
|
`);const i=e.query(s);if(i&&i.prototype instanceof R)return t.insert(`
|
|
`);s=s.firstChild}}}return t}function Ki(r,t,e){var n;const s={},i=r.style||{};return i.fontStyle==="italic"&&(s.italic=!0),i.textDecoration==="underline"&&(s.underline=!0),i.textDecoration==="line-through"&&(s.strike=!0),(((n=i.fontWeight)==null?void 0:n.startsWith("bold"))||parseInt(i.fontWeight,10)>=700)&&(s.bold=!0),t=Object.entries(s).reduce((l,o)=>{let[a,c]=o;return rt(l,a,c,e)},t),parseFloat(i.textIndent||0)>0?new b().insert(" ").concat(t):t}function Vi(r,t,e){var i,n;const s=((i=r.parentElement)==null?void 0:i.tagName)==="TABLE"?r.parentElement:(n=r.parentElement)==null?void 0:n.parentElement;if(s!=null){const o=Array.from(s.querySelectorAll("tr")).indexOf(r)+1;return rt(t,"table",o,e)}return t}function Wi(r,t,e){var i;let s=r.data;if(((i=r.parentElement)==null?void 0:i.tagName)==="O:P")return t.insert(s.trim());if(!Ns(r)){if(s.trim().length===0&&s.includes(`
|
|
`)&&!Ui(r,e))return t;const n=(l,o)=>{const a=o.replace(/[^\u00a0]/g,"");return a.length<1&&l?" ":a};s=s.replace(/\r\n/g," ").replace(/\n/g," "),s=s.replace(/\s\s+/g,n.bind(n,!0)),(r.previousSibling==null&&r.parentElement!=null&&Q(r.parentElement,e)||r.previousSibling instanceof Element&&Q(r.previousSibling,e))&&(s=s.replace(/^\s+/,n.bind(n,!1))),(r.nextSibling==null&&r.parentElement!=null&&Q(r.parentElement,e)||r.nextSibling instanceof Element&&Q(r.nextSibling,e))&&(s=s.replace(/\s+$/,n.bind(n,!1)))}return t.insert(s)}class Es extends F{constructor(e,s){super(e,s);m(this,"lastRecorded",0);m(this,"ignoreChange",!1);m(this,"stack",{undo:[],redo:[]});m(this,"currentRange",null);this.quill.on(u.events.EDITOR_CHANGE,(i,n,l,o)=>{i===u.events.SELECTION_CHANGE?n&&o!==u.sources.SILENT&&(this.currentRange=n):i===u.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||o===u.sources.USER?this.record(n,l):this.transform(n)),this.currentRange=re(this.currentRange,n))}),this.quill.keyboard.addBinding({key:"z",shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:["z","Z"],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:"y",shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener("beforeinput",i=>{i.inputType==="historyUndo"?(this.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(this.redo(),i.preventDefault())})}change(e,s){if(this.stack[e].length===0)return;const i=this.stack[e].pop();if(!i)return;const n=this.quill.getContents(),l=i.delta.invert(n);this.stack[s].push({delta:l,range:re(i.range,l)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(i.delta,u.sources.USER),this.ignoreChange=!1,this.restoreSelection(i)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(e,s){if(e.ops.length===0)return;this.stack.redo=[];let i=e.invert(s),n=this.currentRange;const l=Date.now();if(this.lastRecorded+this.options.delay>l&&this.stack.undo.length>0){const o=this.stack.undo.pop();o&&(i=i.compose(o.delta),n=o.range)}else this.lastRecorded=l;i.length()!==0&&(this.stack.undo.push({delta:i,range:n}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(e){je(this.stack.undo,e),je(this.stack.redo,e)}undo(){this.change("undo","redo")}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,u.sources.USER);else{const s=Zi(this.quill.scroll,e.delta);this.quill.setSelection(s,u.sources.USER)}}}m(Es,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1});function je(r,t){let e=t;for(let s=r.length-1;s>=0;s-=1){const i=r[s];r[s]={delta:e.transform(i.delta,!0),range:i.range&&re(i.range,e)},e=i.delta.transform(e),r[s].delta.length()===0&&r.splice(s,1)}}function Gi(r,t){const e=t.ops[t.ops.length-1];return e==null?!1:e.insert!=null?typeof e.insert=="string"&&e.insert.endsWith(`
|
|
`):e.attributes!=null?Object.keys(e.attributes).some(s=>r.query(s,y.BLOCK)!=null):!1}function Zi(r,t){const e=t.reduce((i,n)=>i+(n.delete||0),0);let s=t.length()-e;return Gi(r,t)&&(s-=1),s}function re(r,t){if(!r)return r;const e=t.transformPosition(r.index),s=t.transformPosition(r.index+r.length);return{index:e,length:s-e}}class xs extends F{constructor(t,e){super(t,e),t.root.addEventListener("drop",s=>{var l;s.preventDefault();let i=null;if(document.caretRangeFromPoint)i=document.caretRangeFromPoint(s.clientX,s.clientY);else if(document.caretPositionFromPoint){const o=document.caretPositionFromPoint(s.clientX,s.clientY);i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.setEnd(o.offsetNode,o.offset)}const n=i&&t.selection.normalizeNative(i);if(n){const o=t.selection.normalizedToRange(n);(l=s.dataTransfer)!=null&&l.files&&this.upload(o,s.dataTransfer.files)}})}upload(t,e){const s=[];Array.from(e).forEach(i=>{var n;i&&((n=this.options.mimetypes)==null?void 0:n.includes(i.type))&&s.push(i)}),s.length>0&&this.options.handler.call(this,t,s)}}xs.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(r,t){const e=t.map(s=>new Promise(i=>{const n=new FileReader;n.onload=l=>{i(l.target.result)},n.readAsDataURL(s)}));Promise.all(e).then(s=>{const i=s.reduce((n,l)=>n.insert({image:l}),new b().retain(r.index).delete(r.length));this.quill.updateContents(i,p.sources.USER),this.quill.setSelection(r.index+s.length,p.sources.SILENT)})}};const Xi=["insertText","insertReplacementText"];class Yi extends F{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",s=>{this.handleBeforeInput(s)}),/Android/i.test(navigator.userAgent)||t.on(u.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(t){qe({range:t,quill:this.quill})}replaceText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(t.length===0)return!1;if(e){const s=this.quill.getFormat(t.index,1);this.deleteRange(t),this.quill.updateContents(new b().retain(t.index).insert(e,s),u.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,u.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!Xi.includes(t.inputType))return;const e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||e.collapsed===!0)return;const s=Qi(t);if(s==null)return;const i=this.quill.selection.normalizeNative(e),n=i?this.quill.selection.normalizedToRange(i):null;n&&this.replaceText(n,s)&&t.preventDefault()}handleCompositionStart(){const t=this.quill.getSelection();t&&this.replaceText(t)}}function Qi(r){var t;return typeof r.data=="string"?r.data:(t=r.dataTransfer)!=null&&t.types.includes("text/plain")?r.dataTransfer.getData("text/plain"):null}const Ji=/Mac/i.test(navigator.platform),tn=100,en=r=>!!(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"||r.key==="Home"||Ji&&r.key==="a"&&r.ctrlKey===!0);class sn extends F{constructor(e,s){super(e,s);m(this,"isListening",!1);m(this,"selectionChangeDeadline",0);this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(e,s){let{line:i,event:n}=s;if(!(i instanceof M)||!i.uiNode)return!0;const l=getComputedStyle(i.domNode).direction==="rtl";return l&&n.key!=="ArrowRight"||!l&&n.key!=="ArrowLeft"?!0:(this.quill.setSelection(e.index-1,e.length+(n.shiftKey?1:0),u.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",e=>{!e.defaultPrevented&&en(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+tn,this.isListening)return;this.isListening=!0;const e=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",e,{once:!0})}handleSelectionChange(){const e=document.getSelection();if(!e)return;const s=e.getRangeAt(0);if(s.collapsed!==!0||s.startOffset!==0)return;const i=this.quill.scroll.find(s.startContainer);if(!(i instanceof M)||!i.uiNode)return;const n=document.createRange();n.setStartAfter(i.uiNode),n.setEndAfter(i.uiNode),e.removeAllRanges(),e.addRange(n)}}u.register({"blots/block":v,"blots/block/embed":R,"blots/break":P,"blots/container":it,"blots/cursor":$,"blots/embed":pe,"blots/inline":I,"blots/scroll":ut,"blots/text":U,"modules/clipboard":ys,"modules/history":Es,"modules/keyboard":$t,"modules/uploader":xs,"modules/input":Yi,"modules/uiNode":sn});class nn extends _{add(t,e){let s=0;if(e==="+1"||e==="-1"){const i=this.value(t)||0;s=e==="+1"?i+1:i-1}else typeof e=="number"&&(s=e);return s===0?(this.remove(t),!0):super.add(t,s.toString())}canAdd(t,e){return super.canAdd(t,e)||super.canAdd(t,parseInt(e,10))}value(t){return parseInt(super.value(t),10)||void 0}}const rn=new nn("indent","ql-indent",{scope:y.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});class le extends v{}m(le,"blotName","blockquote"),m(le,"tagName","blockquote");class oe extends v{static formats(t){return this.tagName.indexOf(t.tagName)+1}}m(oe,"blotName","header"),m(oe,"tagName",["H1","H2","H3","H4","H5","H6"]);class kt extends it{}kt.blotName="list-container";kt.tagName="OL";class Tt extends v{static create(t){const e=super.create();return e.setAttribute("data-list",t),e}static formats(t){return t.getAttribute("data-list")||void 0}static register(){u.register(kt)}constructor(t,e){super(t,e);const s=e.ownerDocument.createElement("span"),i=n=>{if(!t.isEnabled())return;const l=this.statics.formats(e,t);l==="checked"?(this.format("list","unchecked"),n.preventDefault()):l==="unchecked"&&(this.format("list","checked"),n.preventDefault())};s.addEventListener("mousedown",i),s.addEventListener("touchstart",i),this.attachUI(s)}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-list",e):super.format(t,e)}}Tt.blotName="list";Tt.tagName="LI";kt.allowedChildren=[Tt];Tt.requiredContainer=kt;class vt extends I{static create(){return super.create()}static formats(){return!0}optimize(t){super.optimize(t),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}m(vt,"blotName","bold"),m(vt,"tagName",["STRONG","B"]);class ae extends vt{}m(ae,"blotName","italic"),m(ae,"tagName",["EM","I"]);class J extends I{static create(t){const e=super.create(t);return e.setAttribute("href",this.sanitize(t)),e.setAttribute("rel","noopener noreferrer"),e.setAttribute("target","_blank"),e}static formats(t){return t.getAttribute("href")}static sanitize(t){return qs(t,this.PROTOCOL_WHITELIST)?t:this.SANITIZED_URL}format(t,e){t!==this.statics.blotName||!e?super.format(t,e):this.domNode.setAttribute("href",this.constructor.sanitize(e))}}m(J,"blotName","link"),m(J,"tagName","A"),m(J,"SANITIZED_URL","about:blank"),m(J,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"]);function qs(r,t){const e=document.createElement("a");e.href=r;const s=e.href.slice(0,e.href.indexOf(":"));return t.indexOf(s)>-1}class ce extends I{static create(t){return t==="super"?document.createElement("sup"):t==="sub"?document.createElement("sub"):super.create(t)}static formats(t){if(t.tagName==="SUB")return"sub";if(t.tagName==="SUP")return"super"}}m(ce,"blotName","script"),m(ce,"tagName",["SUB","SUP"]);class he extends vt{}m(he,"blotName","strike"),m(he,"tagName",["S","STRIKE"]);class ue extends I{}m(ue,"blotName","underline"),m(ue,"tagName","U");class Dt extends pe{static create(t){if(window.katex==null)throw new Error("Formula module requires KaTeX.");const e=super.create(t);return typeof t=="string"&&(window.katex.render(t,e,{throwOnError:!1,errorColor:"#f00"}),e.setAttribute("data-value",t)),e}static value(t){return t.getAttribute("data-value")}html(){const{formula:t}=this.value();return`<span>${t}</span>`}}m(Dt,"blotName","formula"),m(Dt,"className","ql-formula"),m(Dt,"tagName","SPAN");const Ke=["alt","height","width"];class de extends S{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Ke.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static match(t){return/\.(jpe?g|gif|png)$/.test(t)||/^data:image\/.+;base64/.test(t)}static sanitize(t){return qs(t,["http","https","data"])?t:"//:0"}static value(t){return t.getAttribute("src")}format(t,e){Ke.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}}m(de,"blotName","image"),m(de,"tagName","IMG");const Ve=["height","width"];class Mt extends R{static create(t){const e=super.create(t);return e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Ve.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static sanitize(t){return J.sanitize(t)}static value(t){return t.getAttribute("src")}format(t,e){Ve.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}html(){const{video:t}=this.value();return`<a href="${t}">${t}</a>`}}m(Mt,"blotName","video"),m(Mt,"className","ql-video"),m(Mt,"tagName","IFRAME");const Et=new _("code-token","hljs",{scope:y.INLINE});class K extends I{static formats(t,e){for(;t!=null&&t!==e.domNode;){if(t.classList&&t.classList.contains(L.className))return super.formats(t,e);t=t.parentNode}}constructor(t,e,s){super(t,e,s),Et.add(this.domNode,s)}format(t,e){t!==K.blotName?super.format(t,e):e?Et.add(this.domNode,e):(Et.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),Et.value(this.domNode)||this.unwrap()}}K.blotName="code-token";K.className="ql-token";class O extends L{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("data-language",t),e}static formats(t){return t.getAttribute("data-language")||"plain"}static register(){}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-language",e):super.format(t,e)}replaceWith(t,e){return this.formatAt(0,this.length(),K.blotName,!1),super.replaceWith(t,e)}}class xt extends nt{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(t,e){t===O.blotName&&(this.forceNext=!0,this.children.forEach(s=>{s.format(t,e)}))}formatAt(t,e,s,i){s===O.blotName&&(this.forceNext=!0),super.formatAt(t,e,s,i)}highlight(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;const i=`${Array.from(this.domNode.childNodes).filter(l=>l!==this.uiNode).map(l=>l.textContent).join(`
|
|
`)}
|
|
`,n=O.formats(this.children.head.domNode);if(e||this.forceNext||this.cachedText!==i){if(i.trim().length>0||this.cachedText==null){const l=this.children.reduce((a,c)=>a.concat(ns(c,!1)),new b),o=t(i,n);l.diff(o).reduce((a,c)=>{let{retain:h,attributes:d}=c;return h?(d&&Object.keys(d).forEach(N=>{[O.blotName,K.blotName].includes(N)&&this.formatAt(a,h,N,d[N])}),a+h):a},0)}this.cachedText=i,this.forceNext=!1}}html(t,e){const[s]=this.children.find(t);return`<pre data-language="${s?O.formats(s.domNode):"plain"}">
|
|
${Ft(this.code(t,e))}
|
|
</pre>`}optimize(t){if(super.optimize(t),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){const e=O.formats(this.children.head.domNode);e!==this.uiNode.value&&(this.uiNode.value=e)}}}xt.allowedChildren=[O];O.requiredContainer=xt;O.allowedChildren=[K,$,U,P];const ln=(r,t,e)=>{if(typeof r.versionString=="string"){const s=r.versionString.split(".")[0];if(parseInt(s,10)>=11)return r.highlight(e,{language:t}).value}return r.highlight(t,e).value};class As extends F{static register(){u.register(K,!0),u.register(O,!0),u.register(xt,!0)}constructor(t,e){if(super(t,e),this.options.hljs==null)throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");this.languages=this.options.languages.reduce((s,i)=>{let{key:n}=i;return s[n]=!0,s},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(u.events.SCROLL_BLOT_MOUNT,t=>{if(!(t instanceof xt))return;const e=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(s=>{let{key:i,label:n}=s;const l=e.ownerDocument.createElement("option");l.textContent=n,l.setAttribute("value",i),e.appendChild(l)}),e.addEventListener("change",()=>{t.format(O.blotName,e.value),this.quill.root.focus(),this.highlight(t,!0)}),t.uiNode==null&&(t.attachUI(e),t.children.head&&(e.value=O.formats(t.children.head.domNode)))})}initTimer(){let t=null;this.quill.on(u.events.SCROLL_OPTIMIZE,()=>{t&&clearTimeout(t),t=setTimeout(()=>{this.highlight(),t=null},this.options.interval)})}highlight(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(u.sources.USER);const s=this.quill.getSelection();(t==null?this.quill.scroll.descendants(xt):[t]).forEach(n=>{n.highlight(this.highlightBlot,e)}),this.quill.update(u.sources.SILENT),s!=null&&this.quill.setSelection(s,u.sources.SILENT)}highlightBlot(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"plain";if(e=this.languages[e]?e:"plain",e==="plain")return Ft(t).split(`
|
|
`).reduce((i,n,l)=>(l!==0&&i.insert(`
|
|
`,{[L.blotName]:e}),i.insert(n)),new b);const s=this.quill.root.ownerDocument.createElement("div");return s.classList.add(L.className),s.innerHTML=ln(this.options.hljs,e,t),Ae(this.quill.scroll,s,[(i,n)=>{const l=Et.value(i);return l?n.compose(new b().retain(n.length(),{[K.blotName]:l})):n}],[(i,n)=>i.data.split(`
|
|
`).reduce((l,o,a)=>(a!==0&&l.insert(`
|
|
`,{[L.blotName]:e}),l.insert(o)),n)],new WeakMap)}}As.DEFAULTS={hljs:(()=>window.hljs)(),interval:1e3,languages:[{key:"plain",label:"Plain"},{key:"bash",label:"Bash"},{key:"cpp",label:"C++"},{key:"cs",label:"C#"},{key:"css",label:"CSS"},{key:"diff",label:"Diff"},{key:"xml",label:"HTML/XML"},{key:"java",label:"Java"},{key:"javascript",label:"JavaScript"},{key:"markdown",label:"Markdown"},{key:"php",label:"PHP"},{key:"python",label:"Python"},{key:"ruby",label:"Ruby"},{key:"sql",label:"SQL"}]};const ke=class extends v{static create(t){const e=super.create();return t?e.setAttribute("data-row",t):e.setAttribute("data-row",ve()),e}static formats(t){if(t.hasAttribute("data-row"))return t.getAttribute("data-row")}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(t,e){t===ke.blotName&&e?this.domNode.setAttribute("data-row",e):super.format(t,e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}};let T=ke;m(T,"blotName","table"),m(T,"tagName","TD");class V extends it{checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){const t=this.children.head.formats(),e=this.children.tail.formats(),s=this.next.children.head.formats(),i=this.next.children.tail.formats();return t.table===e.table&&t.table===s.table&&t.table===i.table}return!1}optimize(t){super.optimize(t),this.children.forEach(e=>{if(e.next==null)return;const s=e.formats(),i=e.next.formats();if(s.table!==i.table){const n=this.splitAfter(e);n&&n.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}m(V,"blotName","table-row"),m(V,"tagName","TR");class H extends it{}m(H,"blotName","table-body"),m(H,"tagName","TBODY");class bt extends it{balanceCells(){const t=this.descendants(V),e=t.reduce((s,i)=>Math.max(i.children.length,s),0);t.forEach(s=>{new Array(e-s.children.length).fill(0).forEach(()=>{let i;s.children.head!=null&&(i=T.formats(s.children.head.domNode));const n=this.scroll.create(T.blotName,i);s.appendChild(n),n.optimize()})})}cells(t){return this.rows().map(e=>e.children.at(t))}deleteColumn(t){const[e]=this.descendant(H);e==null||e.children.head==null||e.children.forEach(s=>{const i=s.children.at(t);i!=null&&i.remove()})}insertColumn(t){const[e]=this.descendant(H);e==null||e.children.head==null||e.children.forEach(s=>{const i=s.children.at(t),n=T.formats(s.children.head.domNode),l=this.scroll.create(T.blotName,n);s.insertBefore(l,i)})}insertRow(t){const[e]=this.descendant(H);if(e==null||e.children.head==null)return;const s=ve(),i=this.scroll.create(V.blotName);e.children.head.children.forEach(()=>{const l=this.scroll.create(T.blotName,s);i.appendChild(l)});const n=e.children.at(t);e.insertBefore(i,n)}rows(){const t=this.children.head;return t==null?[]:t.children.map(e=>e)}}m(bt,"blotName","table-container"),m(bt,"tagName","TABLE");bt.allowedChildren=[H];H.requiredContainer=bt;H.allowedChildren=[V];V.requiredContainer=H;V.allowedChildren=[T];T.requiredContainer=V;function ve(){return`row-${Math.random().toString(36).slice(2,6)}`}class on extends F{static register(){u.register(T),u.register(V),u.register(H),u.register(bt)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(bt).forEach(t=>{t.balanceCells()})}deleteColumn(){const[t,,e]=this.getTable();e!=null&&(t.deleteColumn(e.cellOffset()),this.quill.update(u.sources.USER))}deleteRow(){const[,t]=this.getTable();t!=null&&(t.remove(),this.quill.update(u.sources.USER))}deleteTable(){const[t]=this.getTable();if(t==null)return;const e=t.offset();t.remove(),this.quill.update(u.sources.USER),this.quill.setSelection(e,u.sources.SILENT)}getTable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(t==null)return[null,null,null,-1];const[e,s]=this.quill.getLine(t.index);if(e==null||e.statics.blotName!==T.blotName)return[null,null,null,-1];const i=e.parent;return[i.parent.parent,i,e,s]}insertColumn(t){const e=this.quill.getSelection();if(!e)return;const[s,i,n]=this.getTable(e);if(n==null)return;const l=n.cellOffset();s.insertColumn(l+t),this.quill.update(u.sources.USER);let o=i.rowOffset();t===0&&(o+=1),this.quill.setSelection(e.index+o,e.length,u.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(t){const e=this.quill.getSelection();if(!e)return;const[s,i,n]=this.getTable(e);if(n==null)return;const l=i.rowOffset();s.insertRow(l+t),this.quill.update(u.sources.USER),t>0?this.quill.setSelection(e,u.sources.SILENT):this.quill.setSelection(e.index+i.children.length,e.length,u.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(t,e){const s=this.quill.getSelection();if(s==null)return;const i=new Array(t).fill(0).reduce(n=>{const l=new Array(e).fill(`
|
|
`).join("");return n.insert(l,{table:ve()})},new b().retain(s.index));this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(s.index,u.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(u.events.SCROLL_OPTIMIZE,t=>{t.some(e=>["TD","TR","TBODY","TABLE"].includes(e.target.tagName)?(this.quill.once(u.events.TEXT_CHANGE,(s,i,n)=>{n===u.sources.USER&&this.balanceTables()}),!0):!1)})}}const We=W("quill:toolbar");class we extends F{constructor(t,e){var s,i;if(super(t,e),Array.isArray(this.options.container)){const n=document.createElement("div");n.setAttribute("role","toolbar"),an(n,this.options.container),(i=(s=t.container)==null?void 0:s.parentNode)==null||i.insertBefore(n,t.container),this.container=n}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){We.error("Container required for toolbar",this.options);return}this.container.classList.add("ql-toolbar"),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(n=>{var o;const l=(o=this.options.handlers)==null?void 0:o[n];l&&this.addHandler(n,l)}),Array.from(this.container.querySelectorAll("button, select")).forEach(n=>{this.attach(n)}),this.quill.on(u.events.EDITOR_CHANGE,()=>{const[n]=this.quill.selection.getRange();this.update(n)})}addHandler(t,e){this.handlers[t]=e}attach(t){let e=Array.from(t.classList).find(i=>i.indexOf("ql-")===0);if(!e)return;if(e=e.slice(3),t.tagName==="BUTTON"&&t.setAttribute("type","button"),this.handlers[e]==null&&this.quill.scroll.query(e)==null){We.warn("ignoring attaching to nonexistent format",e,t);return}const s=t.tagName==="SELECT"?"change":"click";t.addEventListener(s,i=>{let n;if(t.tagName==="SELECT"){if(t.selectedIndex<0)return;const o=t.options[t.selectedIndex];o.hasAttribute("selected")?n=!1:n=o.value||!1}else t.classList.contains("ql-active")?n=!1:n=t.value||!t.hasAttribute("value"),i.preventDefault();this.quill.focus();const[l]=this.quill.selection.getRange();if(this.handlers[e]!=null)this.handlers[e].call(this,n);else if(this.quill.scroll.query(e).prototype instanceof S){if(n=prompt(`Enter ${e}`),!n)return;this.quill.updateContents(new b().retain(l.index).delete(l.length).insert({[e]:n}),u.sources.USER)}else this.quill.format(e,n,u.sources.USER);this.update(l)}),this.controls.push([e,t])}update(t){const e=t==null?{}:this.quill.getFormat(t);this.controls.forEach(s=>{const[i,n]=s;if(n.tagName==="SELECT"){let l=null;if(t==null)l=null;else if(e[i]==null)l=n.querySelector("option[selected]");else if(!Array.isArray(e[i])){let o=e[i];typeof o=="string"&&(o=o.replace(/"/g,'\\"')),l=n.querySelector(`option[value="${o}"]`)}l==null?(n.value="",n.selectedIndex=-1):l.selected=!0}else if(t==null)n.classList.remove("ql-active"),n.setAttribute("aria-pressed","false");else if(n.hasAttribute("value")){const l=e[i],o=l===n.getAttribute("value")||l!=null&&l.toString()===n.getAttribute("value")||l==null&&!n.getAttribute("value");n.classList.toggle("ql-active",o),n.setAttribute("aria-pressed",o.toString())}else{const l=e[i]!=null;n.classList.toggle("ql-active",l),n.setAttribute("aria-pressed",l.toString())}})}}we.DEFAULTS={};function Ge(r,t,e){const s=document.createElement("button");s.setAttribute("type","button"),s.classList.add(`ql-${t}`),s.setAttribute("aria-pressed","false"),e!=null?(s.value=e,s.setAttribute("aria-label",`${t}: ${e}`)):s.setAttribute("aria-label",t),r.appendChild(s)}function an(r,t){Array.isArray(t[0])||(t=[t]),t.forEach(e=>{const s=document.createElement("span");s.classList.add("ql-formats"),e.forEach(i=>{if(typeof i=="string")Ge(s,i);else{const n=Object.keys(i)[0],l=i[n];Array.isArray(l)?cn(s,n,l):Ge(s,n,l)}}),r.appendChild(s)})}function cn(r,t,e){const s=document.createElement("select");s.classList.add(`ql-${t}`),e.forEach(i=>{const n=document.createElement("option");i!==!1?n.setAttribute("value",String(i)):n.setAttribute("selected","selected"),s.appendChild(n)}),r.appendChild(s)}we.DEFAULTS={container:null,handlers:{clean(){const r=this.quill.getSelection();if(r!=null)if(r.length===0){const t=this.quill.getFormat();Object.keys(t).forEach(e=>{this.quill.scroll.query(e,y.INLINE)!=null&&this.quill.format(e,!1,u.sources.USER)})}else this.quill.removeFormat(r,u.sources.USER)},direction(r){const{align:t}=this.quill.getFormat();r==="rtl"&&t==null?this.quill.format("align","right",u.sources.USER):!r&&t==="right"&&this.quill.format("align",!1,u.sources.USER),this.quill.format("direction",r,u.sources.USER)},indent(r){const t=this.quill.getSelection(),e=this.quill.getFormat(t),s=parseInt(e.indent||0,10);if(r==="+1"||r==="-1"){let i=r==="+1"?1:-1;e.direction==="rtl"&&(i*=-1),this.quill.format("indent",s+i,u.sources.USER)}},link(r){r===!0&&(r=prompt("Enter link URL:")),this.quill.format("link",r,u.sources.USER)},list(r){const t=this.quill.getSelection(),e=this.quill.getFormat(t);r==="check"?e.list==="checked"||e.list==="unchecked"?this.quill.format("list",!1,u.sources.USER):this.quill.format("list","unchecked",u.sources.USER):this.quill.format("list",r,u.sources.USER)}}};const hn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="3" x2="13" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="9" y1="4" y2="4"/></svg>',un='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="14" x2="4" y1="14" y2="14"/><line class="ql-stroke" x1="12" x2="6" y1="4" y2="4"/></svg>',dn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="15" x2="5" y1="14" y2="14"/><line class="ql-stroke" x1="15" x2="9" y1="4" y2="4"/></svg>',fn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="15" x2="3" y1="14" y2="14"/><line class="ql-stroke" x1="15" x2="3" y1="4" y2="4"/></svg>',mn='<svg viewbox="0 0 18 18"><g class="ql-fill ql-color-label"><polygon points="6 6.868 6 6 5 6 5 7 5.942 7 6 6.868"/><rect height="1" width="1" x="4" y="4"/><polygon points="6.817 5 6 5 6 6 6.38 6 6.817 5"/><rect height="1" width="1" x="2" y="6"/><rect height="1" width="1" x="3" y="5"/><rect height="1" width="1" x="4" y="7"/><polygon points="4 11.439 4 11 3 11 3 12 3.755 12 4 11.439"/><rect height="1" width="1" x="2" y="12"/><rect height="1" width="1" x="2" y="9"/><rect height="1" width="1" x="2" y="15"/><polygon points="4.63 10 4 10 4 11 4.192 11 4.63 10"/><rect height="1" width="1" x="3" y="8"/><path d="M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z"/><path d="M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z"/><path d="M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z"/><rect height="1" width="1" x="12" y="2"/><rect height="1" width="1" x="11" y="3"/><path d="M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z"/><rect height="1" width="1" x="2" y="3"/><rect height="1" width="1" x="6" y="2"/><rect height="1" width="1" x="3" y="2"/><rect height="1" width="1" x="5" y="3"/><rect height="1" width="1" x="9" y="2"/><rect height="1" width="1" x="15" y="14"/><polygon points="13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174"/><rect height="1" width="1" x="13" y="7"/><rect height="1" width="1" x="15" y="5"/><rect height="1" width="1" x="14" y="6"/><rect height="1" width="1" x="15" y="8"/><rect height="1" width="1" x="14" y="9"/><path d="M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z"/><rect height="1" width="1" x="14" y="3"/><polygon points="12 6.868 12 6 11.62 6 12 6.868"/><rect height="1" width="1" x="15" y="2"/><rect height="1" width="1" x="12" y="5"/><rect height="1" width="1" x="13" y="4"/><polygon points="12.933 9 13 9 13 8 12.495 8 12.933 9"/><rect height="1" width="1" x="9" y="14"/><rect height="1" width="1" x="8" y="15"/><path d="M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z"/><rect height="1" width="1" x="5" y="15"/><path d="M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z"/><rect height="1" width="1" x="11" y="15"/><path d="M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z"/><rect height="1" width="1" x="14" y="15"/><rect height="1" width="1" x="15" y="11"/></g><polyline class="ql-stroke" points="5.5 13 9 5 12.5 13"/><line class="ql-stroke" x1="11.63" x2="6.38" y1="11" y2="11"/></svg>',gn='<svg viewbox="0 0 18 18"><rect class="ql-fill ql-stroke" height="3" width="3" x="4" y="5"/><rect class="ql-fill ql-stroke" height="3" width="3" x="11" y="5"/><path class="ql-even ql-fill ql-stroke" d="M7,8c0,4.031-3,5-3,5"/><path class="ql-even ql-fill ql-stroke" d="M14,8c0,4.031-3,5-3,5"/></svg>',pn='<svg viewbox="0 0 18 18"><path class="ql-stroke" d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"/><path class="ql-stroke" d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"/></svg>',bn='<svg class="" viewbox="0 0 18 18"><line class="ql-stroke" x1="5" x2="13" y1="3" y2="3"/><line class="ql-stroke" x1="6" x2="9.35" y1="12" y2="3"/><line class="ql-stroke" x1="11" x2="15" y1="11" y2="15"/><line class="ql-stroke" x1="15" x2="11" y1="11" y2="15"/><rect class="ql-fill" height="1" rx="0.5" ry="0.5" width="7" x="2" y="14"/></svg>',Ze='<svg viewbox="0 0 18 18"><polyline class="ql-even ql-stroke" points="5 7 3 9 5 11"/><polyline class="ql-even ql-stroke" points="13 7 15 9 13 11"/><line class="ql-stroke" x1="10" x2="8" y1="5" y2="13"/></svg>',yn='<svg viewbox="0 0 18 18"><line class="ql-color-label ql-stroke ql-transparent" x1="3" x2="15" y1="15" y2="15"/><polyline class="ql-stroke" points="5.5 11 9 3 12.5 11"/><line class="ql-stroke" x1="11.63" x2="6.38" y1="9" y2="9"/></svg>',Nn='<svg viewbox="0 0 18 18"><polygon class="ql-stroke ql-fill" points="3 11 5 9 3 7 3 11"/><line class="ql-stroke ql-fill" x1="15" x2="11" y1="4" y2="4"/><path class="ql-fill" d="M11,3a3,3,0,0,0,0,6h1V3H11Z"/><rect class="ql-fill" height="11" width="1" x="11" y="4"/><rect class="ql-fill" height="11" width="1" x="13" y="4"/></svg>',En='<svg viewbox="0 0 18 18"><polygon class="ql-stroke ql-fill" points="15 12 13 10 15 8 15 12"/><line class="ql-stroke ql-fill" x1="9" x2="5" y1="4" y2="4"/><path class="ql-fill" d="M5,3A3,3,0,0,0,5,9H6V3H5Z"/><rect class="ql-fill" height="11" width="1" x="5" y="4"/><rect class="ql-fill" height="11" width="1" x="7" y="4"/></svg>',xn='<svg viewbox="0 0 18 18"><path class="ql-fill" d="M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z"/><rect class="ql-fill" height="1.6" rx="0.8" ry="0.8" width="5" x="5.15" y="6.2"/><path class="ql-fill" d="M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z"/></svg>',qn='<svg viewBox="0 0 18 18"><path class="ql-fill" d="M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z"/></svg>',An='<svg viewBox="0 0 18 18"><path class="ql-fill" d="M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"/></svg>',vn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="13" y1="4" y2="4"/><line class="ql-stroke" x1="5" x2="11" y1="14" y2="14"/><line class="ql-stroke" x1="8" x2="10" y1="14" y2="4"/></svg>',wn='<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="10" width="12" x="3" y="4"/><circle class="ql-fill" cx="6" cy="7" r="1"/><polyline class="ql-even ql-fill" points="5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12"/></svg>',Ln='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-fill ql-stroke" points="3 7 3 11 5 9 3 7"/></svg>',kn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-stroke" points="5 7 5 11 3 9 5 7"/></svg>',Tn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="11" y1="7" y2="11"/><path class="ql-even ql-stroke" d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"/><path class="ql-even ql-stroke" d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"/></svg>',Sn='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="6" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="6" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="6" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="3" y1="4" y2="4"/><line class="ql-stroke" x1="3" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="3" x2="3" y1="14" y2="14"/></svg>',Cn='<svg class="" viewbox="0 0 18 18"><line class="ql-stroke" x1="9" x2="15" y1="4" y2="4"/><polyline class="ql-stroke" points="3 4 4 5 6 3"/><line class="ql-stroke" x1="9" x2="15" y1="14" y2="14"/><polyline class="ql-stroke" points="3 14 4 15 6 13"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-stroke" points="3 9 4 10 6 8"/></svg>',On='<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="7" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="7" x2="15" y1="14" y2="14"/><line class="ql-stroke ql-thin" x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path class="ql-fill" d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"/><path class="ql-stroke ql-thin" d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"/><path class="ql-stroke ql-thin" d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"/></svg>',Rn='<svg viewbox="0 0 18 18"><path class="ql-fill" d="M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z"/><path class="ql-fill" d="M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z"/></svg>',In='<svg viewbox="0 0 18 18"><path class="ql-fill" d="M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z"/><path class="ql-fill" d="M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z"/></svg>',Bn='<svg viewbox="0 0 18 18"><line class="ql-stroke ql-thin" x1="15.5" x2="2.5" y1="8.5" y2="9.5"/><path class="ql-fill" d="M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z"/><path class="ql-fill" d="M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z"/></svg>',Dn='<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="12" width="12" x="3" y="3"/><rect class="ql-fill" height="2" width="3" x="5" y="5"/><rect class="ql-fill" height="2" width="4" x="9" y="5"/><g class="ql-fill ql-transparent"><rect height="2" width="3" x="5" y="8"/><rect height="2" width="4" x="9" y="8"/><rect height="2" width="3" x="5" y="11"/><rect height="2" width="4" x="9" y="11"/></g></svg>',Mn='<svg viewbox="0 0 18 18"><path class="ql-stroke" d="M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3"/><rect class="ql-fill" height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/></svg>',Un='<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="12" width="12" x="3" y="3"/><rect class="ql-fill" height="12" width="1" x="5" y="3"/><rect class="ql-fill" height="12" width="1" x="12" y="3"/><rect class="ql-fill" height="2" width="8" x="5" y="8"/><rect class="ql-fill" height="1" width="3" x="3" y="5"/><rect class="ql-fill" height="1" width="3" x="3" y="7"/><rect class="ql-fill" height="1" width="3" x="3" y="10"/><rect class="ql-fill" height="1" width="3" x="3" y="12"/><rect class="ql-fill" height="1" width="3" x="12" y="5"/><rect class="ql-fill" height="1" width="3" x="12" y="7"/><rect class="ql-fill" height="1" width="3" x="12" y="10"/><rect class="ql-fill" height="1" width="3" x="12" y="12"/></svg>';var wt={align:{"":hn,center:un,right:dn,justify:fn},background:mn,blockquote:gn,bold:pn,clean:bn,code:Ze,"code-block":Ze,color:yn,direction:{"":Nn,rtl:En},formula:xn,header:{1:qn,2:An},italic:vn,image:wn,indent:{"+1":Ln,"-1":kn},link:Tn,list:{bullet:Sn,check:Cn,ordered:On},script:{sub:Rn,super:In},strike:Bn,table:Dn,underline:Mn,video:Un};const _n='<svg viewbox="0 0 18 18"><polygon class="ql-stroke" points="7 11 9 13 11 11 7 11"/><polygon class="ql-stroke" points="7 7 9 5 11 7 7 7"/></svg>';let Xe=0;function Ye(r,t){r.setAttribute(t,`${r.getAttribute(t)!=="true"}`)}class Ht{constructor(t){this.select=t,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",()=>{this.togglePicker()}),this.label.addEventListener("keydown",e=>{switch(e.key){case"Enter":this.togglePicker();break;case"Escape":this.escape(),e.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),Ye(this.label,"aria-expanded"),Ye(this.options,"aria-hidden")}buildItem(t){const e=document.createElement("span");e.tabIndex="0",e.setAttribute("role","button"),e.classList.add("ql-picker-item");const s=t.getAttribute("value");return s&&e.setAttribute("data-value",s),t.textContent&&e.setAttribute("data-label",t.textContent),e.addEventListener("click",()=>{this.selectItem(e,!0)}),e.addEventListener("keydown",i=>{switch(i.key){case"Enter":this.selectItem(e,!0),i.preventDefault();break;case"Escape":this.escape(),i.preventDefault();break}}),e}buildLabel(){const t=document.createElement("span");return t.classList.add("ql-picker-label"),t.innerHTML=_n,t.tabIndex="0",t.setAttribute("role","button"),t.setAttribute("aria-expanded","false"),this.container.appendChild(t),t}buildOptions(){const t=document.createElement("span");t.classList.add("ql-picker-options"),t.setAttribute("aria-hidden","true"),t.tabIndex="-1",t.id=`ql-picker-options-${Xe}`,Xe+=1,this.label.setAttribute("aria-controls",t.id),this.options=t,Array.from(this.select.options).forEach(e=>{const s=this.buildItem(e);t.appendChild(s),e.selected===!0&&this.selectItem(s)}),this.container.appendChild(t)}buildPicker(){Array.from(this.select.attributes).forEach(t=>{this.container.setAttribute(t.name,t.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}selectItem(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const s=this.container.querySelector(".ql-selected");t!==s&&(s!=null&&s.classList.remove("ql-selected"),t!=null&&(t.classList.add("ql-selected"),this.select.selectedIndex=Array.from(t.parentNode.children).indexOf(t),t.hasAttribute("data-value")?this.label.setAttribute("data-value",t.getAttribute("data-value")):this.label.removeAttribute("data-value"),t.hasAttribute("data-label")?this.label.setAttribute("data-label",t.getAttribute("data-label")):this.label.removeAttribute("data-label"),e&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let t;if(this.select.selectedIndex>-1){const s=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];t=this.select.options[this.select.selectedIndex],this.selectItem(s)}else this.selectItem(null);const e=t!=null&&t!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",e)}}class vs extends Ht{constructor(t,e){super(t),this.label.innerHTML=e,this.container.classList.add("ql-color-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).slice(0,7).forEach(s=>{s.classList.add("ql-primary")})}buildItem(t){const e=super.buildItem(t);return e.style.backgroundColor=t.getAttribute("value")||"",e}selectItem(t,e){super.selectItem(t,e);const s=this.label.querySelector(".ql-color-label"),i=t&&t.getAttribute("data-value")||"";s&&(s.tagName==="line"?s.style.stroke=i:s.style.fill=i)}}class ws extends Ht{constructor(t,e){super(t),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(s=>{s.innerHTML=e[s.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(t,e){super.selectItem(t,e);const s=t||this.defaultItem;if(s!=null){if(this.label.innerHTML===s.innerHTML)return;this.label.innerHTML=s.innerHTML}}}const Pn=r=>{const{overflowY:t}=getComputedStyle(r,null);return t!=="visible"&&t!=="clip"};class Ls{constructor(t,e){this.quill=t,this.boundsContainer=e||document.body,this.root=t.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,Pn(this.quill.root)&&this.quill.root.addEventListener("scroll",()=>{this.root.style.marginTop=`${-1*this.quill.root.scrollTop}px`}),this.hide()}hide(){this.root.classList.add("ql-hidden")}position(t){const e=t.left+t.width/2-this.root.offsetWidth/2,s=t.bottom+this.quill.root.scrollTop;this.root.style.left=`${e}px`,this.root.style.top=`${s}px`,this.root.classList.remove("ql-flip");const i=this.boundsContainer.getBoundingClientRect(),n=this.root.getBoundingClientRect();let l=0;if(n.right>i.right&&(l=i.right-n.right,this.root.style.left=`${e+l}px`),n.left<i.left&&(l=i.left-n.left,this.root.style.left=`${e+l}px`),n.bottom>i.bottom){const o=n.bottom-n.top,a=t.bottom-t.top+o;this.root.style.top=`${s-a}px`,this.root.classList.add("ql-flip")}return l}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}const Fn=[!1,"center","right","justify"],$n=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],Hn=[!1,"serif","monospace"],zn=["1","2","3",!1],jn=["small",!1,"large","huge"];class St extends Y{constructor(t,e){super(t,e);const s=i=>{if(!document.body.contains(t.root)){document.body.removeEventListener("click",s);return}this.tooltip!=null&&!this.tooltip.root.contains(i.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(n=>{n.container.contains(i.target)||n.close()})};t.emitter.listenDOM("click",document.body,s)}addModule(t){const e=super.addModule(t);return t==="toolbar"&&this.extendToolbar(e),e}buildButtons(t,e){Array.from(t).forEach(s=>{(s.getAttribute("class")||"").split(/\s+/).forEach(n=>{if(!!n.startsWith("ql-")&&(n=n.slice(3),e[n]!=null))if(n==="direction")s.innerHTML=e[n][""]+e[n].rtl;else if(typeof e[n]=="string")s.innerHTML=e[n];else{const l=s.value||"";l!=null&&e[n][l]&&(s.innerHTML=e[n][l])}})})}buildPickers(t,e){this.pickers=Array.from(t).map(i=>{if(i.classList.contains("ql-align")&&(i.querySelector("option")==null&&Nt(i,Fn),typeof e.align=="object"))return new ws(i,e.align);if(i.classList.contains("ql-background")||i.classList.contains("ql-color")){const n=i.classList.contains("ql-background")?"background":"color";return i.querySelector("option")==null&&Nt(i,$n,n==="background"?"#ffffff":"#000000"),new vs(i,e[n])}return i.querySelector("option")==null&&(i.classList.contains("ql-font")?Nt(i,Hn):i.classList.contains("ql-header")?Nt(i,zn):i.classList.contains("ql-size")&&Nt(i,jn)),new Ht(i)});const s=()=>{this.pickers.forEach(i=>{i.update()})};this.quill.on(p.events.EDITOR_CHANGE,s)}}St.DEFAULTS=tt({},Y.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let r=this.container.querySelector("input.ql-image[type=file]");r==null&&(r=document.createElement("input"),r.setAttribute("type","file"),r.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),r.classList.add("ql-image"),r.addEventListener("change",()=>{const t=this.quill.getSelection(!0);this.quill.uploader.upload(t,r.files),r.value=""}),this.container.appendChild(r)),r.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});class ks extends Ls{constructor(t,e){super(t,e),this.textbox=this.root.querySelector('input[type="text"]'),this.listen()}listen(){this.textbox.addEventListener("keydown",t=>{t.key==="Enter"?(this.save(),t.preventDefault()):t.key==="Escape"&&(this.cancel(),t.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),this.textbox==null)return;e!=null?this.textbox.value=e:t!==this.root.getAttribute("data-mode")&&(this.textbox.value="");const s=this.quill.getBounds(this.quill.selection.savedRange);s!=null&&this.position(s),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${t}`)||""),this.root.setAttribute("data-mode",t)}restoreFocus(){this.quill.focus()}save(){let{value:t}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{const{scrollTop:e}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",t,p.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",t,p.sources.USER)),this.quill.root.scrollTop=e;break}case"video":t=Kn(t);case"formula":{if(!t)break;const e=this.quill.getSelection(!0);if(e!=null){const s=e.index+e.length;this.quill.insertEmbed(s,this.root.getAttribute("data-mode"),t,p.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(s+1," ",p.sources.USER),this.quill.setSelection(s+2,p.sources.USER)}break}}this.textbox.value="",this.hide()}}function Kn(r){let t=r.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||r.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return t?`${t[1]||"https"}://www.youtube.com/embed/${t[2]}?showinfo=0`:(t=r.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${t[1]||"https"}://player.vimeo.com/video/${t[2]}/`:r}function Nt(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t.forEach(s=>{const i=document.createElement("option");s===e?i.setAttribute("selected","selected"):i.setAttribute("value",String(s)),r.appendChild(i)})}const Vn=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]];class Ts extends ks{constructor(t,e){super(t,e),this.quill.on(p.events.EDITOR_CHANGE,(s,i,n,l)=>{if(s===p.events.SELECTION_CHANGE)if(i!=null&&i.length>0&&l===p.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;const o=this.quill.getLines(i.index,i.length);if(o.length===1){const a=this.quill.getBounds(i);a!=null&&this.position(a)}else{const a=o[o.length-1],c=this.quill.getIndex(a),h=Math.min(a.length()-1,i.index+i.length-c),d=this.quill.getBounds(new st(c,h));d!=null&&this.position(d)}}else document.activeElement!==this.textbox&&this.quill.hasFocus()&&this.hide()})}listen(){super.listen(),this.root.querySelector(".ql-close").addEventListener("click",()=>{this.root.classList.remove("ql-editing")}),this.quill.on(p.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;const t=this.quill.getSelection();if(t!=null){const e=this.quill.getBounds(t);e!=null&&this.position(e)}},1)})}cancel(){this.show()}position(t){const e=super.position(t),s=this.root.querySelector(".ql-tooltip-arrow");return s.style.marginLeft="",e!==0&&(s.style.marginLeft=`${-1*e-s.offsetWidth/2}px`),e}}m(Ts,"TEMPLATE",['<span class="ql-tooltip-arrow"></span>','<div class="ql-tooltip-editor">','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-close"></a>',"</div>"].join(""));class Ss extends St{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=Vn),super(t,e),this.quill.container.classList.add("ql-bubble")}extendToolbar(t){this.tooltip=new Ts(this.quill,this.options.bounds),t.container!=null&&(this.tooltip.root.appendChild(t.container),this.buildButtons(t.container.querySelectorAll("button"),wt),this.buildPickers(t.container.querySelectorAll("select"),wt))}}Ss.DEFAULTS=tt({},St.DEFAULTS,{modules:{toolbar:{handlers:{link(r){r?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});const Wn=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]];class Cs extends ks{constructor(){super(...arguments);m(this,"preview",this.root.querySelector("a.ql-preview"))}listen(){super.listen(),this.root.querySelector("a.ql-action").addEventListener("click",e=>{this.root.classList.contains("ql-editing")?this.save():this.edit("link",this.preview.textContent),e.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",e=>{if(this.linkRange!=null){const s=this.linkRange;this.restoreFocus(),this.quill.formatText(s,"link",!1,p.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(p.events.SELECTION_CHANGE,(e,s,i)=>{if(e!=null){if(e.length===0&&i===p.sources.USER){const[n,l]=this.quill.scroll.descendant(J,e.index);if(n!=null){this.linkRange=new st(e.index-l,n.length());const o=J.formats(n.domNode);this.preview.textContent=o,this.preview.setAttribute("href",o),this.show();const a=this.quill.getBounds(this.linkRange);a!=null&&this.position(a);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}}m(Cs,"TEMPLATE",['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-action"></a>','<a class="ql-remove"></a>'].join(""));class Os extends St{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=Wn),super(t,e),this.quill.container.classList.add("ql-snow")}extendToolbar(t){t.container!=null&&(t.container.classList.add("ql-snow"),this.buildButtons(t.container.querySelectorAll("button"),wt),this.buildPickers(t.container.querySelectorAll("select"),wt),this.tooltip=new Cs(this.quill,this.options.bounds),t.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(e,s)=>{t.handlers.link.call(t,!s.format.link)}))}}Os.DEFAULTS=tt({},St.DEFAULTS,{modules:{toolbar:{handlers:{link(r){if(r){const t=this.quill.getSelection();if(t==null||t.length===0)return;let e=this.quill.getText(t);/^\S+@\S+\.\S+$/.test(e)&&e.indexOf("mailto:")!==0&&(e=`mailto:${e}`);const{tooltip:s}=this.quill.theme;s.edit("link",e)}else this.quill.format("link",!1)}}}}});u.register({"attributors/attribute/direction":hs,"attributors/class/align":os,"attributors/class/background":mi,"attributors/class/color":fi,"attributors/class/direction":us,"attributors/class/font":ms,"attributors/class/size":ps,"attributors/style/align":as,"attributors/style/background":Ne,"attributors/style/color":ye,"attributors/style/direction":ds,"attributors/style/font":gs,"attributors/style/size":bs},!0);u.register({"formats/align":os,"formats/direction":us,"formats/indent":rn,"formats/background":Ne,"formats/color":ye,"formats/font":ms,"formats/size":ps,"formats/blockquote":le,"formats/code-block":L,"formats/header":oe,"formats/list":Tt,"formats/bold":vt,"formats/code":Ee,"formats/italic":ae,"formats/link":J,"formats/script":ce,"formats/strike":he,"formats/underline":ue,"formats/formula":Dt,"formats/image":de,"formats/video":Mt,"modules/syntax":As,"modules/table":on,"modules/toolbar":we,"themes/bubble":Ss,"themes/snow":Os,"ui/icons":wt,"ui/picker":Ht,"ui/icon-picker":ws,"ui/color-picker":vs,"ui/tooltip":Ls},!0);export{u as Q};
|