var ra=Object.defineProperty;var sa=(n,t,e)=>t in n?ra(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var x=(n,t,e)=>sa(n,typeof t!="symbol"?t+"":t,e);import{j as En}from"./vendor-animation-0s3FMHwK.js";import{j as Yt,k as zl,c as de,r as Ue}from"./vendor-react-BVs3cwbi.js";var Kl=typeof global=="object"&&global&&global.Object===Object&&global,ia=typeof self=="object"&&self&&self.Object===Object&&self,kt=Kl||ia||Function("return this")(),ee=kt.Symbol,Gl=Object.prototype,la=Gl.hasOwnProperty,oa=Gl.toString,bn=ee?ee.toStringTag:void 0;function aa(n){var t=la.call(n,bn),e=n[bn];try{n[bn]=void 0;var r=!0}catch{}var s=oa.call(n);return r&&(t?n[bn]=e:delete n[bn]),s}var ca=Object.prototype,ua=ca.toString;function ha(n){return ua.call(n)}var fa="[object Null]",da="[object Undefined]",Ui=ee?ee.toStringTag:void 0;function Xe(n){return n==null?n===void 0?da:fa:Ui&&Ui in Object(n)?aa(n):ha(n)}function Ut(n){return n!=null&&typeof n=="object"}var pe=Array.isArray;function ne(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function Vl(n){return n}var ga="[object AsyncFunction]",pa="[object Function]",ma="[object GeneratorFunction]",ba="[object Proxy]";function yi(n){if(!ne(n))return!1;var t=Xe(n);return t==pa||t==ma||t==ga||t==ba}var Rs=kt["__core-js_shared__"],Fi=function(){var n=/[^.]+$/.exec(Rs&&Rs.keys&&Rs.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function ya(n){return!!Fi&&Fi in n}var va=Function.prototype,Ea=va.toString;function ye(n){if(n!=null){try{return Ea.call(n)}catch{}try{return n+""}catch{}}return""}var Aa=/[\\^$.*+?()[\]{}|]/g,Na=/^\[object .+?Constructor\]$/,wa=Function.prototype,Ta=Object.prototype,xa=wa.toString,La=Ta.hasOwnProperty,Sa=RegExp("^"+xa.call(La).replace(Aa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _a(n){if(!ne(n)||ya(n))return!1;var t=yi(n)?Sa:Na;return t.test(ye(n))}function Oa(n,t){return n?.[t]}function ve(n,t){var e=Oa(n,t);return _a(e)?e:void 0}var Gs=ve(kt,"WeakMap"),Hi=Object.create,Ca=function(){function n(){}return function(t){if(!ne(t))return{};if(Hi)return Hi(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}();function qa(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function Ia(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e0){if(++t>=Ra)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function Da(n){return function(){return n}}var Ar=function(){try{var n=ve(Object,"defineProperty");return n({},"",{}),n}catch{}}(),ja=Ar?function(n,t){return Ar(n,"toString",{configurable:!0,enumerable:!1,value:Da(t),writable:!0})}:Vl,Pa=Ma(ja);function $a(n,t){for(var e=-1,r=n==null?0:n.length;++e-1&&n%1==0&&n-1&&n%1==0&&n<=Wa}function Sr(n){return n!=null&&Xl(n.length)&&!yi(n)}function Za(n,t,e){if(!ne(e))return!1;var r=typeof t;return(r=="number"?Sr(e)&&Wl(t,e.length):r=="string"&&t in e)?Rn(e[t],n):!1}function Xa(n){return Va(function(t,e){var r=-1,s=e.length,i=s>1?e[s-1]:void 0,l=s>2?e[2]:void 0;for(i=n.length>3&&typeof i=="function"?(s--,i):void 0,l&&Za(e[0],e[1],l)&&(i=s<3?void 0:i,s=1),t=Object(t);++r-1}function iu(n,t){var e=this.__data__,r=_r(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}function zt(n){var t=-1,e=n==null?0:n.length;for(this.clear();++ta))return!1;var h=i.get(n),f=i.get(t);if(h&&f)return h==t&&f==n;var b=-1,g=!0,p=e&Zh?new wr:void 0;for(i.set(n,t),i.set(t,n);++b(n[n.TYPE=3]="TYPE",n[n.LEVEL=12]="LEVEL",n[n.ATTRIBUTE=13]="ATTRIBUTE",n[n.BLOT=14]="BLOT",n[n.INLINE=7]="INLINE",n[n.BLOCK=11]="BLOCK",n[n.BLOCK_BLOT=10]="BLOCK_BLOT",n[n.INLINE_BLOT=6]="INLINE_BLOT",n[n.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",n[n.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",n[n.ANY=15]="ANY",n))(C||{});class It{constructor(t,e,r={}){this.attrName=t,this.keyName=e;const s=C.TYPE&C.ATTRIBUTE;this.scope=r.scope!=null?r.scope&C.LEVEL|s:C.ATTRIBUTE,r.whitelist!=null&&(this.whitelist=r.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 He extends Error{constructor(t){t="[Parchment] "+t,super(t),this.message=t,this.name=this.constructor.name}}const mo=class ti{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 r=null;try{r=t.parentNode}catch{return null}return this.find(r,e)}return null}create(t,e,r){const s=this.query(e);if(s==null)throw new He(`Unable to create ${e} blot`);const i=s,l=e instanceof Node||e.nodeType===Node.TEXT_NODE?e:i.create(r),a=new i(t,l,r);return ti.blots.set(a.domNode,a),a}find(t,e=!1){return ti.find(t,e)}query(t,e=C.ANY){let r;return typeof t=="string"?r=this.types[t]||this.attributes[t]:t instanceof Text||t.nodeType===Node.TEXT_NODE?r=this.types.text:typeof t=="number"?t&C.LEVEL&C.BLOCK?r=this.types.block:t&C.LEVEL&C.INLINE&&(r=this.types.inline):t instanceof Element&&((t.getAttribute("class")||"").split(/\s+/).some(s=>(r=this.classes[s],!!r)),r=r||this.tags[t.tagName]),r==null?null:"scope"in r&&e&C.LEVEL&r.scope&&e&C.TYPE&r.scope?r:null}register(...t){return t.map(e=>{const r="blotName"in e,s="attrName"in e;if(!r&&!s)throw new He("Invalid definition");if(r&&e.blotName==="abstract")throw new He("Cannot register abstract class");const i=r?e.blotName:s?e.attrName:void 0;return this.types[i]=e,s?typeof e.keyName=="string"&&(this.attributes[e.keyName]=e):r&&(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})}};mo.blots=new WeakMap;let Ge=mo;function fl(n,t){return(n.getAttribute("class")||"").split(/\s+/).filter(e=>e.indexOf(`${t}-`)===0)}class xf extends It{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){fl(t,this.keyName).forEach(e=>{t.classList.remove(e)}),t.classList.length===0&&t.removeAttribute("class")}value(t){const e=(fl(t,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(t,e)?e:""}}const Nt=xf;function Ms(n){const t=n.split("-"),e=t.slice(1).map(r=>r[0].toUpperCase()+r.slice(1)).join("");return t[0]+e}class Lf extends It{static keys(t){return(t.getAttribute("style")||"").split(";").map(e=>e.split(":")[0].trim())}add(t,e){return this.canAdd(t,e)?(t.style[Ms(this.keyName)]=e,!0):!1}remove(t){t.style[Ms(this.keyName)]="",t.getAttribute("style")||t.removeAttribute("style")}value(t){const e=t.style[Ms(this.keyName)];return this.canAdd(t,e)?e:""}}const re=Lf;class Sf{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=Ge.find(this.domNode);if(t==null)return;const e=It.keys(this.domNode),r=Nt.keys(this.domNode),s=re.keys(this.domNode);e.concat(r).concat(s).forEach(i=>{const l=t.scroll.query(i,C.ATTRIBUTE);l instanceof It&&(this.attributes[l.attrName]=l)})}copy(t){Object.keys(this.attributes).forEach(e=>{const r=this.attributes[e].value(this.domNode);t.format(e,r)})}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 Cr=Sf,bo=class{constructor(t,e){this.scroll=t,this.domNode=e,Ge.blots.set(e,this),this.prev=null,this.next=null}static create(t){if(this.tagName==null)throw new He("Blot definition missing tagName");let e,r;return Array.isArray(this.tagName)?(typeof t=="string"?(r=t.toUpperCase(),parseInt(r,10).toString()===r&&(r=parseInt(r,10))):typeof t=="number"&&(r=t),typeof r=="number"?e=document.createElement(this.tagName[r-1]):r&&this.tagName.indexOf(r)>-1?e=document.createElement(r):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),Ge.blots.delete(this.domNode)}deleteAt(t,e){this.isolate(t,e).remove()}formatAt(t,e,r,s){const i=this.isolate(t,e);if(this.scroll.query(r,C.BLOT)!=null&&s)i.wrap(r,s);else if(this.scroll.query(r,C.ATTRIBUTE)!=null){const l=this.scroll.create(this.statics.scope);i.wrap(l),l.format(r,s)}}insertAt(t,e,r){const s=r==null?this.scroll.create("text",e):this.scroll.create(e,r),i=this.split(t);this.parent.insertBefore(s,i||void 0)}isolate(t,e){const r=this.split(t);if(r==null)throw new Error("Attempt to isolate at end");return r.split(e),r}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 r=typeof t=="string"?this.scroll.create(t,e):t;return this.parent!=null&&(this.parent.insertBefore(r,this.next||void 0),this.remove()),r}split(t,e){return t===0?this:this.next}update(t,e){}wrap(t,e){const r=typeof t=="string"?this.scroll.create(t,e):t;if(this.parent!=null&&this.parent.insertBefore(r,this.next||void 0),typeof r.appendChild!="function")throw new He(`Cannot wrap ${t}`);return r.appendChild(this),r}};bo.blotName="abstract";let yo=bo;const vo=class extends yo{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 r=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return t>0&&(r+=1),[this.parent.domNode,r]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};vo.scope=C.INLINE_BLOT;let _f=vo;const Q=_f;class Of{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 r=e();for(;r&&t>0;)t-=1,r=e();return r}contains(t){const e=this.iterator();let r=e();for(;r;){if(r===t)return!0;r=e()}return!1}indexOf(t){const e=this.iterator();let r=e(),s=0;for(;r;){if(r===t)return s;s+=1,r=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,r=this.head;for(;r!=null;){if(r===t)return e;e+=r.length(),r=r.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 r=this.iterator();let s=r();for(;s;){const i=s.length();if(tl?r(c,t-l,Math.min(e,l+h-t)):r(c,0,Math.min(h,t+e-l)),l+=h,c=a()}}map(t){return this.reduce((e,r)=>(e.push(t(r)),e),[])}reduce(t,e){const r=this.iterator();let s=r();for(;s;)e=t(e,s),s=r();return e}}function dl(n,t){const e=t.find(n);if(e)return e;try{return t.create(n)}catch{const r=t.create(C.INLINE);return Array.from(n.childNodes).forEach(s=>{r.domNode.appendChild(s)}),n.parentNode&&n.parentNode.replaceChild(r.domNode,n),r.attach(),r}}const Eo=class Zt extends yo{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,Zt.uiClass&&this.uiNode.classList.add(Zt.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new Of,Array.from(this.domNode.childNodes).filter(t=>t!==this.uiNode).reverse().forEach(t=>{try{const e=dl(t,this.scroll);this.insertBefore(e,this.children.head||void 0)}catch(e){if(e instanceof He)return;throw e}})}deleteAt(t,e){if(t===0&&e===this.length())return this.remove();this.children.forEachAt(t,e,(r,s,i)=>{r.deleteAt(s,i)})}descendant(t,e=0){const[r,s]=this.children.find(e);return t.blotName==null&&t(r)||t.blotName!=null&&r instanceof t?[r,s]:r instanceof Zt?r.descendant(t,s):[null,-1]}descendants(t,e=0,r=Number.MAX_VALUE){let s=[],i=r;return this.children.forEachAt(e,r,(l,a,c)=>{(t.blotName==null&&t(l)||t.blotName!=null&&l instanceof t)&&s.push(l),l instanceof Zt&&(s=s.concat(l.descendants(t,a,i))),i-=c}),s}detach(){this.children.forEach(t=>{t.detach()}),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach(e=>{t||this.statics.allowedChildren.some(r=>e instanceof r)||(e.statics.scope===C.BLOCK_BLOT?(e.next!=null&&this.splitAfter(e),e.prev!=null&&this.splitAfter(e.prev),e.parent.unwrap(),t=!0):e instanceof Zt?e.unwrap():e.remove())})}formatAt(t,e,r,s){this.children.forEachAt(t,e,(i,l,a)=>{i.formatAt(l,a,r,s)})}insertAt(t,e,r){const[s,i]=this.children.find(t);if(s)s.insertAt(i,e,r);else{const l=r==null?this.scroll.create("text",e):this.scroll.create(e,r);this.appendChild(l)}}insertBefore(t,e){t.parent!=null&&t.parent.children.remove(t);let r=null;this.children.insertBefore(t,e||null),t.parent=this,e!=null&&(r=e.domNode),(this.domNode.parentNode!==t.domNode||this.domNode.nextSibling!==r)&&this.domNode.insertBefore(t.domNode,r),t.attach()}length(){return this.children.reduce((t,e)=>t+e.length(),0)}moveChildren(t,e){this.children.forEach(r=>{t.insertBefore(r,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[r,s]=this.children.find(t,e),i=[[this,t]];return r instanceof Zt?i.concat(r.path(s,e)):(r!=null&&i.push([r,s]),i)}removeChild(t){this.children.remove(t)}replaceWith(t,e){const r=typeof t=="string"?this.scroll.create(t,e):t;return r instanceof Zt&&this.moveChildren(r),super.replaceWith(r)}split(t,e=!1){if(!e){if(t===0)return this;if(t===this.length())return this.next}const r=this.clone();return this.parent&&this.parent.insertBefore(r,this.next||void 0),this.children.forEachAt(t,this.length(),(s,i,l)=>{const a=s.split(i,e);a!=null&&r.appendChild(a)}),r}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 r=[],s=[];t.forEach(i=>{i.target===this.domNode&&i.type==="childList"&&(r.push(...i.addedNodes),s.push(...i.removedNodes))}),s.forEach(i=>{if(i.parentNode!=null&&i.tagName!=="IFRAME"&&document.body.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;const l=this.scroll.find(i);l!=null&&(l.domNode.parentNode==null||l.domNode.parentNode===this.domNode)&&l.detach()}),r.filter(i=>i.parentNode===this.domNode&&i!==this.uiNode).sort((i,l)=>i===l?0:i.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(i=>{let l=null;i.nextSibling!=null&&(l=this.scroll.find(i.nextSibling));const a=dl(i,this.scroll);(a.next!==l||a.next==null)&&(a.parent!=null&&a.parent.removeChild(this),this.insertBefore(a,l||void 0))}),this.enforceAllowedChildren()}};Eo.uiClass="";let Cf=Eo;const Et=Cf;function qf(n,t){if(Object.keys(n).length!==Object.keys(t).length)return!1;for(const e in n)if(n[e]!==t[e])return!1;return!0}const Be=class Me extends Et{static create(t){return super.create(t)}static formats(t,e){const r=e.query(Me.blotName);if(!(r!=null&&t.tagName===r.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 Cr(this.domNode)}format(t,e){if(t===this.statics.blotName&&!e)this.children.forEach(r=>{r instanceof Me||(r=r.wrap(Me.blotName,!0)),this.attributes.copy(r)}),this.unwrap();else{const r=this.scroll.query(t,C.INLINE);if(r==null)return;r instanceof It?this.attributes.attribute(r,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,r,s){this.formats()[r]!=null||this.scroll.query(r,C.ATTRIBUTE)?this.isolate(t,e).format(r,s):super.formatAt(t,e,r,s)}optimize(t){super.optimize(t);const e=this.formats();if(Object.keys(e).length===0)return this.unwrap();const r=this.next;r instanceof Me&&r.prev===this&&qf(e,r.formats())&&(r.moveChildren(this),r.remove())}replaceWith(t,e){const r=super.replaceWith(t,e);return this.attributes.copy(r),r}update(t,e){super.update(t,e),t.some(r=>r.target===this.domNode&&r.type==="attributes")&&this.attributes.build()}wrap(t,e){const r=super.wrap(t,e);return r instanceof Me&&this.attributes.move(r),r}};Be.allowedChildren=[Be,Q],Be.blotName="inline",Be.scope=C.INLINE_BLOT,Be.tagName="SPAN";let If=Be;const Ti=If,De=class ei extends Et{static create(t){return super.create(t)}static formats(t,e){const r=e.query(ei.blotName);if(!(r!=null&&t.tagName===r.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 Cr(this.domNode)}format(t,e){const r=this.scroll.query(t,C.BLOCK);r!=null&&(r instanceof It?this.attributes.attribute(r,e):t===this.statics.blotName&&!e?this.replaceWith(ei.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,r,s){this.scroll.query(r,C.BLOCK)!=null?this.format(r,s):super.formatAt(t,e,r,s)}insertAt(t,e,r){if(r==null||this.scroll.query(e,C.INLINE)!=null)super.insertAt(t,e,r);else{const s=this.split(t);if(s!=null){const i=this.scroll.create(e,r);s.parent.insertBefore(i,s)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(t,e){const r=super.replaceWith(t,e);return this.attributes.copy(r),r}update(t,e){super.update(t,e),t.some(r=>r.target===this.domNode&&r.type==="attributes")&&this.attributes.build()}};De.blotName="block",De.scope=C.BLOCK_BLOT,De.tagName="P",De.allowedChildren=[Ti,De,Q];let Rf=De;const _n=Rf,ni=class extends Et{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(t,e){super.deleteAt(t,e),this.enforceAllowedChildren()}formatAt(t,e,r,s){super.formatAt(t,e,r,s),this.enforceAllowedChildren()}insertAt(t,e,r){super.insertAt(t,e,r),this.enforceAllowedChildren()}optimize(t){super.optimize(t),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};ni.blotName="container",ni.scope=C.BLOCK_BLOT;let kf=ni;const qr=kf;class Bf extends Q{static formats(t,e){}format(t,e){super.formatAt(0,this.length(),t,e)}formatAt(t,e,r,s){t===0&&e===this.length()?this.format(r,s):super.formatAt(t,e,r,s)}formats(){return this.statics.formats(this.domNode,this.scroll)}}const lt=Bf,Mf={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},Df=100,je=class extends Et{constructor(t,e){super(null,e),this.registry=t,this.scroll=this,this.build(),this.observer=new MutationObserver(r=>{this.update(r)}),this.observer.observe(this.domNode,Mf),this.attach()}create(t,e){return this.registry.create(this,t,e)}find(t,e=!1){const r=this.registry.find(t,e);return r?r.scroll===this?r:e?this.find(r.scroll.domNode.parentNode,!0):null:null}query(t,e=C.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(r=>{r.remove()}):super.deleteAt(t,e)}formatAt(t,e,r,s){this.update(),super.formatAt(t,e,r,s)}insertAt(t,e,r){this.update(),super.insertAt(t,e,r)}optimize(t=[],e={}){super.optimize(e);const r=e.mutationsMap||new WeakMap;let s=Array.from(this.observer.takeRecords());for(;s.length>0;)t.push(s.pop());const i=(c,h=!0)=>{c==null||c===this||c.domNode.parentNode!=null&&(r.has(c.domNode)||r.set(c.domNode,[]),h&&i(c.parent))},l=c=>{r.has(c.domNode)&&(c instanceof Et&&c.children.forEach(l),r.delete(c.domNode),c.optimize(e))};let a=t;for(let c=0;a.length>0;c+=1){if(c>=Df)throw new Error("[Parchment] Maximum optimize iterations reached");for(a.forEach(h=>{const f=this.find(h.target,!0);f!=null&&(f.domNode===h.target&&(h.type==="childList"?(i(this.find(h.previousSibling,!1)),Array.from(h.addedNodes).forEach(b=>{const g=this.find(b,!1);i(g,!1),g instanceof Et&&g.children.forEach(p=>{i(p,!1)})})):h.type==="attributes"&&i(f.prev)),i(f))}),this.children.forEach(l),a=Array.from(this.observer.takeRecords()),s=a.slice();s.length>0;)t.push(s.pop())}}update(t,e={}){t=t||this.observer.takeRecords();const r=new WeakMap;t.map(s=>{const i=this.find(s.target,!0);return i==null?null:r.has(i.domNode)?(r.get(i.domNode).push(s),null):(r.set(i.domNode,[s]),i)}).forEach(s=>{s!=null&&s!==this&&r.has(s.domNode)&&s.update(r.get(s.domNode)||[],e)}),e.mutationsMap=r,r.has(this.domNode)&&super.update(r.get(this.domNode),e),this.optimize(t,e)}};je.blotName="scroll",je.defaultChild=_n,je.allowedChildren=[_n,qr],je.scope=C.BLOCK_BLOT,je.tagName="DIV";let jf=je;const xi=jf,ri=class Ao extends Q{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,r){r==null?(this.text=this.text.slice(0,t)+e+this.text.slice(t),this.domNode.data=this.text):super.insertAt(t,e,r)}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 Ao&&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 r=this.scroll.create(this.domNode.splitText(t));return this.parent.insertBefore(r,this.next||void 0),this.text=this.statics.value(this.domNode),r}update(t,e){t.some(r=>r.type==="characterData"&&r.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};ri.blotName="text",ri.scope=C.INLINE_BLOT;let Pf=ri;const Tr=Pf,$f=Object.freeze(Object.defineProperty({__proto__:null,Attributor:It,AttributorStore:Cr,BlockBlot:_n,ClassAttributor:Nt,ContainerBlot:qr,EmbedBlot:lt,InlineBlot:Ti,LeafBlot:Q,ParentBlot:Et,Registry:Ge,Scope:C,ScrollBlot:xi,StyleAttributor:re,TextBlot:Tr},Symbol.toStringTag,{value:"Module"}));var si={exports:{}},it=-1,et=1,K=0;function On(n,t,e,r,s){if(n===t)return n?[[K,n]]:[];if(e!=null){var i=Zf(n,t,e);if(i)return i}var l=Li(n,t),a=n.substring(0,l);n=n.substring(l),t=t.substring(l),l=Ir(n,t);var c=n.substring(n.length-l);n=n.substring(0,n.length-l),t=t.substring(0,t.length-l);var h=Uf(n,t);return a&&h.unshift([K,a]),c&&h.push([K,c]),Si(h,s),r&&zf(h),h}function Uf(n,t){var e;if(!n)return[[et,t]];if(!t)return[[it,n]];var r=n.length>t.length?n:t,s=n.length>t.length?t:n,i=r.indexOf(s);if(i!==-1)return e=[[et,r.substring(0,i)],[K,s],[et,r.substring(i+s.length)]],n.length>t.length&&(e[0][0]=e[2][0]=it),e;if(s.length===1)return[[it,n],[et,t]];var l=Hf(n,t);if(l){var a=l[0],c=l[1],h=l[2],f=l[3],b=l[4],g=On(a,h),p=On(c,f);return g.concat([[K,b]],p)}return Ff(n,t)}function Ff(n,t){for(var e=n.length,r=t.length,s=Math.ceil((e+r)/2),i=s,l=2*s,a=new Array(l),c=new Array(l),h=0;he)p+=2;else if(_>r)g+=2;else if(b){var L=i+f-A;if(L>=0&&L=I)return gl(n,t,T,_)}}}for(var k=-E+m;k<=E-y;k+=2){var L=i+k,I;k===-E||k!==E&&c[L-1]e)y+=2;else if(U>r)m+=2;else if(!b){var w=i+f-k;if(w>=0&&w=I)return gl(n,t,T,_)}}}}return[[it,n],[et,t]]}function gl(n,t,e,r){var s=n.substring(0,e),i=t.substring(0,r),l=n.substring(e),a=t.substring(r),c=On(s,i),h=On(l,a);return c.concat(h)}function Li(n,t){if(!n||!t||n.charAt(0)!==t.charAt(0))return 0;for(var e=0,r=Math.min(n.length,t.length),s=r,i=0;er?n=n.substring(e-r):et.length?n:t,r=n.length>t.length?t:n;if(e.length<4||r.length*2=p.length?[T,_,L,I,w]:null}var i=s(e,r,Math.ceil(e.length/4)),l=s(e,r,Math.ceil(e.length/2)),a;if(!i&&!l)return null;l?i?a=i[4].length>l[4].length?i:l:a=l:a=i;var c,h,f,b;n.length>t.length?(c=a[0],h=a[1],f=a[2],b=a[3]):(f=a[0],b=a[1],c=a[2],h=a[3]);var g=a[4];return[c,h,f,b,g]}function zf(n){for(var t=!1,e=[],r=0,s=null,i=0,l=0,a=0,c=0,h=0;i0?e[r-1]:-1,l=0,a=0,c=0,h=0,s=null,t=!0)),i++;for(t&&Si(n),Vf(n),i=1;i=p?(g>=f.length/2||g>=b.length/2)&&(n.splice(i,0,[K,b.substring(0,g)]),n[i-1][1]=f.substring(0,f.length-g),n[i+1][1]=b.substring(g),i++):(p>=f.length/2||p>=b.length/2)&&(n.splice(i,0,[K,f.substring(0,p)]),n[i-1][0]=et,n[i-1][1]=b.substring(0,b.length-p),n[i+1][0]=it,n[i+1][1]=f.substring(p),i++),i++}i++}}var ml=/[^a-zA-Z0-9]/,bl=/\s/,yl=/[\r\n]/,Kf=/\n\r?\n$/,Gf=/^\r?\n\r?\n/;function Vf(n){function t(p,m){if(!p||!m)return 6;var y=p.charAt(p.length-1),E=m.charAt(0),A=y.match(ml),w=E.match(ml),T=A&&y.match(bl),_=w&&E.match(bl),L=T&&y.match(yl),I=_&&E.match(yl),k=L&&p.match(Kf),U=I&&m.match(Gf);return k||U?5:L||I?4:A&&!T&&_?3:T||_?2:A||w?1:0}for(var e=1;e=b&&(b=g,c=r,h=s,f=i)}n[e-1][1]!=c&&(c?n[e-1][1]=c:(n.splice(e-1,1),e--),n[e][1]=h,f?n[e+1][1]=f:(n.splice(e+1,1),e--))}e++}}function Si(n,t){n.push([K,""]);for(var e=0,r=0,s=0,i="",l="",a;e=0&&xo(n[c][1])){var h=n[c][1].slice(-1);if(n[c][1]=n[c][1].slice(0,-1),i=h+i,l=h+l,!n[c][1]){n.splice(c,1),e--;var f=c-1;n[f]&&n[f][0]===et&&(s++,l=n[f][1]+l,f--),n[f]&&n[f][0]===it&&(r++,i=n[f][1]+i,f--),c=f}}if(To(n[e][1])){var h=n[e][1].charAt(0);n[e][1]=n[e][1].slice(1),i+=h,l+=h}}if(e0||l.length>0){i.length>0&&l.length>0&&(a=Li(l,i),a!==0&&(c>=0?n[c][1]+=l.substring(0,a):(n.splice(0,0,[K,l.substring(0,a)]),e++),l=l.substring(a),i=i.substring(a)),a=Ir(l,i),a!==0&&(n[e][1]=l.substring(l.length-a)+n[e][1],l=l.substring(0,l.length-a),i=i.substring(0,i.length-a)));var b=s+r;i.length===0&&l.length===0?(n.splice(e-b,b),e=e-b):i.length===0?(n.splice(e-b,b,[et,l]),e=e-b+1):l.length===0?(n.splice(e-b,b,[it,i]),e=e-b+1):(n.splice(e-b,b,[it,i],[et,l]),e=e-b+2)}e!==0&&n[e-1][0]===K?(n[e-1][1]+=n[e][1],n.splice(e,1)):e++,s=0,r=0,i="",l="";break}}n[n.length-1][1]===""&&n.pop();var g=!1;for(e=1;e=55296&&n<=56319}function wo(n){return n>=56320&&n<=57343}function To(n){return wo(n.charCodeAt(0))}function xo(n){return No(n.charCodeAt(n.length-1))}function Wf(n){for(var t=[],e=0;e0&&t.push(n[e]);return t}function Ds(n,t,e,r){return xo(n)||To(r)?null:Wf([[K,n],[it,t],[et,e],[K,r]])}function Zf(n,t,e){var r=typeof e=="number"?{index:e,length:0}:e.oldRange,s=typeof e=="number"?null:e.newRange,i=n.length,l=t.length;if(r.length===0&&(s===null||s.length===0)){var a=r.index,c=n.slice(0,a),h=n.slice(a),f=s?s.index:null;t:{var b=a+l-i;if(f!==null&&f!==b||b<0||b>l)break t;var g=t.slice(0,b),p=t.slice(b);if(p!==h)break t;var m=Math.min(a,b),y=c.slice(0,m),E=g.slice(0,m);if(y!==E)break t;var A=c.slice(m),w=g.slice(m);return Ds(y,A,w,h)}t:{if(f!==null&&f!==a)break t;var T=a,g=t.slice(0,T),p=t.slice(T);if(g!==c)break t;var _=Math.min(i-T,l-T),L=h.slice(h.length-_),I=p.slice(p.length-_);if(L!==I)break t;var A=h.slice(0,h.length-_),w=p.slice(0,p.length-_);return Ds(c,A,w,L)}}if(r.length>0&&s&&s.length===0)t:{var y=n.slice(0,r.index),L=n.slice(r.index+r.length),m=y.length,_=L.length;if(l-1}function rs(o,u){var d=this.__data__,v=qe(d,o);return v<0?d.push([o,u]):d[v][1]=u,this}G.prototype.clear=Jr,G.prototype.delete=ts,G.prototype.get=es,G.prototype.has=ns,G.prototype.set=rs;function Z(o){var u=-1,d=o?o.length:0;for(this.clear();++u-1&&o%1==0&&o-1&&o%1==0&&o<=s}function _t(o){var u=typeof o;return!!o&&(u=="object"||u=="function")}function cr(o){return!!o&&typeof o=="object"}function mn(o){return ke(o)?Ce(o):ys(o)}function qs(){return[]}function Is(){return!1}n.exports=ir})(xr,xr.exports);var Lo=xr.exports,Lr={exports:{}};Lr.exports;(function(n,t){var e=200,r="__lodash_hash_undefined__",s=1,i=2,l=9007199254740991,a="[object Arguments]",c="[object Array]",h="[object AsyncFunction]",f="[object Boolean]",b="[object Date]",g="[object Error]",p="[object Function]",m="[object GeneratorFunction]",y="[object Map]",E="[object Number]",A="[object Null]",w="[object Object]",T="[object Promise]",_="[object Proxy]",L="[object RegExp]",I="[object Set]",k="[object String]",U="[object Symbol]",Bt="[object Undefined]",Gt="[object WeakMap]",se="[object ArrayBuffer]",ie="[object DataView]",jn="[object Float32Array]",Pn="[object Float64Array]",$n="[object Int8Array]",Pr="[object Int16Array]",$r="[object Int32Array]",Ur="[object Uint8Array]",Fr="[object Uint8ClampedArray]",j="[object Uint16Array]",Hr="[object Uint32Array]",zr=/[\\^$.*+?()[\]{}|]/g,dt=/^\[object .+?Constructor\]$/,Un=/^(?:0|[1-9]\d*)$/,P={};P[jn]=P[Pn]=P[$n]=P[Pr]=P[$r]=P[Ur]=P[Fr]=P[j]=P[Hr]=!0,P[a]=P[c]=P[se]=P[f]=P[ie]=P[b]=P[g]=P[p]=P[y]=P[E]=P[w]=P[L]=P[I]=P[k]=P[Gt]=!1;var Fn=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt,Kr=typeof self=="object"&&self&&self.Object===Object&&self,gt=Fn||Kr||Function("return this")(),Hn=t&&!t.nodeType&&t,zn=Hn&&!0&&n&&!n.nodeType&&n,Ye=zn&&zn.exports===Hn,Qe=Ye&&Fn.process,Kn=function(){try{return Qe&&Qe.binding&&Qe.binding("util")}catch{}}(),Je=Kn&&Kn.isTypedArray;function Gn(o,u){for(var d=-1,v=o==null?0:o.length,R=0,q=[];++d-1}function as(o,u){var d=this.__data__,v=Ie(d,o);return v<0?(++this.size,d.push([o,u])):d[v][1]=u,this}Z.prototype.clear=ss,Z.prototype.delete=is,Z.prototype.get=ls,Z.prototype.has=os,Z.prototype.set=as;function nt(o){var u=-1,d=o==null?0:o.length;for(this.clear();++uB))return!1;var D=q.get(o);if(D&&q.get(u))return D==u;var X=-1,rt=!0,z=d&i?new Ce:void 0;for(q.set(o,u),q.set(u,o);++X-1&&o%1==0&&o-1&&o%1==0&&o<=l}function ar(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function _t(o){return o!=null&&typeof o=="object"}var cr=Je?Vr(Je):As;function mn(o){return gn(o)?ys(o):Ns(o)}function qs(){return[]}function Is(){return!1}n.exports=Cs})(Lr,Lr.exports);var So=Lr.exports,_i={};Object.defineProperty(_i,"__esModule",{value:!0});const Yf=Lo,Qf=So;var ii;(function(n){function t(i={},l={},a=!1){typeof i!="object"&&(i={}),typeof l!="object"&&(l={});let c=Yf(l);a||(c=Object.keys(c).reduce((h,f)=>(c[f]!=null&&(h[f]=c[f]),h),{}));for(const h in i)i[h]!==void 0&&l[h]===void 0&&(c[h]=i[h]);return Object.keys(c).length>0?c:void 0}n.compose=t;function e(i={},l={}){typeof i!="object"&&(i={}),typeof l!="object"&&(l={});const a=Object.keys(i).concat(Object.keys(l)).reduce((c,h)=>(Qf(i[h],l[h])||(c[h]=l[h]===void 0?null:l[h]),c),{});return Object.keys(a).length>0?a:void 0}n.diff=e;function r(i={},l={}){i=i||{};const a=Object.keys(l).reduce((c,h)=>(l[h]!==i[h]&&i[h]!==void 0&&(c[h]=l[h]),c),{});return Object.keys(i).reduce((c,h)=>(i[h]!==l[h]&&l[h]===void 0&&(c[h]=null),c),a)}n.invert=r;function s(i,l,a=!1){if(typeof i!="object")return l;if(typeof l!="object")return;if(!a)return l;const c=Object.keys(l).reduce((h,f)=>(i[f]===void 0&&(h[f]=l[f]),h),{});return Object.keys(c).length>0?c:void 0}n.transform=s})(ii||(ii={}));_i.default=ii;var kr={};Object.defineProperty(kr,"__esModule",{value:!0});var li;(function(n){function t(e){return typeof e.delete=="number"?e.delete:typeof e.retain=="number"?e.retain:typeof e.retain=="object"&&e.retain!==null?1:typeof e.insert=="string"?e.insert.length:1}n.length=t})(li||(li={}));kr.default=li;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});const vl=kr;class Jf{constructor(t){this.ops=t,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(t){t||(t=1/0);const e=this.ops[this.index];if(e){const r=this.offset,s=vl.default.length(e);if(t>=s-r?(t=s-r,this.index+=1,this.offset=0):this.offset+=t,typeof e.delete=="number")return{delete:t};{const i={};return e.attributes&&(i.attributes=e.attributes),typeof e.retain=="number"?i.retain=t:typeof e.retain=="object"&&e.retain!==null?i.retain=e.retain:typeof e.insert=="string"?i.insert=e.insert.substr(r,t):i.insert=e.insert,i}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?vl.default.length(this.ops[this.index])-this.offset:1/0}peekType(){const t=this.ops[this.index];return t?typeof t.delete=="number"?"delete":typeof t.retain=="number"||typeof t.retain=="object"&&t.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{const t=this.offset,e=this.index,r=this.next(),s=this.ops.slice(this.index);return this.offset=t,this.index=e,[r].concat(s)}}else return[]}}Oi.default=Jf;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.AttributeMap=t.OpIterator=t.Op=void 0;const e=Xf,r=Lo,s=So,i=_i;t.AttributeMap=i.default;const l=kr;t.Op=l.default;const a=Oi;t.OpIterator=a.default;const c="\0",h=(b,g)=>{if(typeof b!="object"||b===null)throw new Error(`cannot retain a ${typeof b}`);if(typeof g!="object"||g===null)throw new Error(`cannot retain a ${typeof g}`);const p=Object.keys(b)[0];if(!p||p!==Object.keys(g)[0])throw new Error(`embed types not matched: ${p} != ${Object.keys(g)[0]}`);return[p,b[p],g[p]]};class f{constructor(g){Array.isArray(g)?this.ops=g:g!=null&&Array.isArray(g.ops)?this.ops=g.ops:this.ops=[]}static registerEmbed(g,p){this.handlers[g]=p}static unregisterEmbed(g){delete this.handlers[g]}static getHandler(g){const p=this.handlers[g];if(!p)throw new Error(`no handlers for embed type "${g}"`);return p}insert(g,p){const m={};return typeof g=="string"&&g.length===0?this:(m.insert=g,p!=null&&typeof p=="object"&&Object.keys(p).length>0&&(m.attributes=p),this.push(m))}delete(g){return g<=0?this:this.push({delete:g})}retain(g,p){if(typeof g=="number"&&g<=0)return this;const m={retain:g};return p!=null&&typeof p=="object"&&Object.keys(p).length>0&&(m.attributes=p),this.push(m)}push(g){let p=this.ops.length,m=this.ops[p-1];if(g=r(g),typeof m=="object"){if(typeof g.delete=="number"&&typeof m.delete=="number")return this.ops[p-1]={delete:m.delete+g.delete},this;if(typeof m.delete=="number"&&g.insert!=null&&(p-=1,m=this.ops[p-1],typeof m!="object"))return this.ops.unshift(g),this;if(s(g.attributes,m.attributes)){if(typeof g.insert=="string"&&typeof m.insert=="string")return this.ops[p-1]={insert:m.insert+g.insert},typeof g.attributes=="object"&&(this.ops[p-1].attributes=g.attributes),this;if(typeof g.retain=="number"&&typeof m.retain=="number")return this.ops[p-1]={retain:m.retain+g.retain},typeof g.attributes=="object"&&(this.ops[p-1].attributes=g.attributes),this}}return p===this.ops.length?this.ops.push(g):this.ops.splice(p,0,g),this}chop(){const g=this.ops[this.ops.length-1];return g&&typeof g.retain=="number"&&!g.attributes&&this.ops.pop(),this}filter(g){return this.ops.filter(g)}forEach(g){this.ops.forEach(g)}map(g){return this.ops.map(g)}partition(g){const p=[],m=[];return this.forEach(y=>{(g(y)?p:m).push(y)}),[p,m]}reduce(g,p){return this.ops.reduce(g,p)}changeLength(){return this.reduce((g,p)=>p.insert?g+l.default.length(p):p.delete?g-p.delete:g,0)}length(){return this.reduce((g,p)=>g+l.default.length(p),0)}slice(g=0,p=1/0){const m=[],y=new a.default(this.ops);let E=0;for(;E0&&m.next(E.retain-w)}const A=new f(y);for(;p.hasNext()||m.hasNext();)if(m.peekType()==="insert")A.push(m.next());else if(p.peekType()==="delete")A.push(p.next());else{const w=Math.min(p.peekLength(),m.peekLength()),T=p.next(w),_=m.next(w);if(_.retain){const L={};if(typeof T.retain=="number")L.retain=typeof _.retain=="number"?w:_.retain;else if(typeof _.retain=="number")T.retain==null?L.insert=T.insert:L.retain=T.retain;else{const k=T.retain==null?"insert":"retain",[U,Bt,Gt]=h(T[k],_.retain),se=f.getHandler(U);L[k]={[U]:se.compose(Bt,Gt,k==="retain")}}const I=i.default.compose(T.attributes,_.attributes,typeof T.retain=="number");if(I&&(L.attributes=I),A.push(L),!m.hasNext()&&s(A.ops[A.ops.length-1],L)){const k=new f(p.rest());return A.concat(k).chop()}}else typeof _.delete=="number"&&(typeof T.retain=="number"||typeof T.retain=="object"&&T.retain!==null)&&A.push(_)}return A.chop()}concat(g){const p=new f(this.ops.slice());return g.ops.length>0&&(p.push(g.ops[0]),p.ops=p.ops.concat(g.ops.slice(1))),p}diff(g,p){if(this.ops===g.ops)return new f;const m=[this,g].map(T=>T.map(_=>{if(_.insert!=null)return typeof _.insert=="string"?_.insert:c;const L=T===g?"on":"with";throw new Error("diff() called "+L+" non-document")}).join("")),y=new f,E=e(m[0],m[1],p,!0),A=new a.default(this.ops),w=new a.default(g.ops);return E.forEach(T=>{let _=T[1].length;for(;_>0;){let L=0;switch(T[0]){case e.INSERT:L=Math.min(w.peekLength(),_),y.push(w.next(L));break;case e.DELETE:L=Math.min(_,A.peekLength()),A.next(L),y.delete(L);break;case e.EQUAL:L=Math.min(A.peekLength(),w.peekLength(),_);const I=A.next(L),k=w.next(L);s(I.insert,k.insert)?y.retain(L,i.default.diff(I.attributes,k.attributes)):y.push(k).delete(L);break}_-=L}}),y.chop()}eachLine(g,p=` `){const m=new a.default(this.ops);let y=new f,E=0;for(;m.hasNext();){if(m.peekType()!=="insert")return;const A=m.peek(),w=l.default.length(A)-m.peekLength(),T=typeof A.insert=="string"?A.insert.indexOf(p,w)-w:-1;if(T<0)y.push(m.next());else if(T>0)y.push(m.next(T));else{if(g(y,m.next(1).attributes||{},E)===!1)return;E+=1,y=new f}}y.length()>0&&g(y,{},E)}invert(g){const p=new f;return this.reduce((m,y)=>{if(y.insert)p.delete(l.default.length(y));else{if(typeof y.retain=="number"&&y.attributes==null)return p.retain(y.retain),m+y.retain;if(y.delete||typeof y.retain=="number"){const E=y.delete||y.retain;return g.slice(m,m+E).forEach(w=>{y.delete?p.push(w):y.retain&&y.attributes&&p.retain(l.default.length(w),i.default.invert(y.attributes,w.attributes))}),m+E}else if(typeof y.retain=="object"&&y.retain!==null){const E=g.slice(m,m+1),A=new a.default(E.ops).next(),[w,T,_]=h(y.retain,A.insert),L=f.getHandler(w);return p.retain({[w]:L.invert(T,_)},i.default.invert(y.attributes,A.attributes)),m+1}}return m},0),p.chop()}transform(g,p=!1){if(p=!!p,typeof g=="number")return this.transformPosition(g,p);const m=g,y=new a.default(this.ops),E=new a.default(m.ops),A=new f;for(;y.hasNext()||E.hasNext();)if(y.peekType()==="insert"&&(p||E.peekType()!=="insert"))A.retain(l.default.length(y.next()));else if(E.peekType()==="insert")A.push(E.next());else{const w=Math.min(y.peekLength(),E.peekLength()),T=y.next(w),_=E.next(w);if(T.delete)continue;if(_.delete)A.push(_);else{const L=T.retain,I=_.retain;let k=typeof I=="object"&&I!==null?I:w;if(typeof L=="object"&&L!==null&&typeof I=="object"&&I!==null){const U=Object.keys(L)[0];if(U===Object.keys(I)[0]){const Bt=f.getHandler(U);Bt&&(k={[U]:Bt.transform(L[U],I[U],p)})}}A.retain(k,i.default.transform(T.attributes,_.attributes,p))}}return A.chop()}transformPosition(g,p=!1){p=!!p;const m=new a.default(this.ops);let y=0;for(;m.hasNext()&&y<=g;){const E=m.peekLength(),A=m.peekType();if(m.next(),A==="delete"){g-=Math.min(E,g-y);continue}else A==="insert"&&(y":">",'"':""","'":"'"};function Br(n){return n.replace(/[&<>"']/g,t=>td[t])}const Ot=class Ot extends Ti{static compare(t,e){const r=Ot.order.indexOf(t),s=Ot.order.indexOf(e);return r>=0||s>=0?r-s:t===e?0:t0){const e=this.parent.isolate(this.offset(),this.length());this.moveChildren(e),e.wrap(this)}}};x(Ot,"allowedChildren",[Ot,wt,lt,At]),x(Ot,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]);let Rt=Ot;const El=1;class W extends _n{constructor(){super(...arguments);x(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=_o(this)),this.cache.delta}deleteAt(e,r){super.deleteAt(e,r),this.cache={}}formatAt(e,r,s,i){r<=0||(this.scroll.query(s,C.BLOCK)?e+r===this.length()&&this.format(s,i):super.formatAt(e,Math.min(r,this.length()-e-1),s,i),this.cache={})}insertAt(e,r,s){if(s!=null){super.insertAt(e,r,s),this.cache={};return}if(r.length===0)return;const i=r.split(` `),l=i.shift();l.length>0&&(e(a=a.split(c,!0),a.insertAt(0,h),h.length),e+l.length)}insertBefore(e,r){const{head:s}=this.children;super.insertBefore(e,r),s instanceof wt&&s.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+El),this.cache.length}moveChildren(e,r){super.moveChildren(e,r),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 r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(r&&(e===0||e>=this.length()-El)){const i=this.clone();return e===0?(this.parent.insertBefore(i,this),this):(this.parent.insertBefore(i,this.next),i)}const s=super.split(e,r);return this.cache={},s}}W.blotName="block";W.tagName="P";W.defaultChild=wt;W.allowedChildren=[wt,Rt,lt,At];class ht extends lt{attach(){super.attach(),this.attributes=new Cr(this.domNode)}delta(){return new O().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const r=this.scroll.query(t,C.BLOCK_ATTRIBUTE);r!=null&&this.attributes.attribute(r,e)}formatAt(t,e,r,s){this.format(r,s)}insertAt(t,e,r){if(r!=null){super.insertAt(t,e,r);return}const s=e.split(` `),i=s.pop(),l=s.map(c=>{const h=this.scroll.create(W.blotName);return h.insertAt(0,c),h}),a=this.split(t);l.forEach(c=>{this.parent.insertBefore(c,a)}),i&&this.parent.insertBefore(this.scroll.create("text",i),a)}}ht.scope=C.BLOCK_BLOT;function _o(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return n.descendants(Q).reduce((e,r)=>r.length()===0?e:e.insert(r.value(),ct(r,{},t)),new O).insert(` `,ct(n))}function ct(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return n==null||("formats"in n&&typeof n.formats=="function"&&(t={...t,...n.formats()},e&&delete t["code-token"]),n.parent==null||n.parent.statics.blotName==="scroll"||n.parent.statics.scope!==n.statics.scope)?t:ct(n.parent,t,e)}const at=class at extends lt{static value(){}constructor(t,e,r){super(t,e),this.selection=r,this.textNode=document.createTextNode(at.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 r=this,s=0;for(;r!=null&&r.statics.scope!==C.BLOCK_BLOT;)s+=r.offset(r.parent),r=r.parent;r!=null&&(this.savedLength=at.CONTENTS.length,r.optimize(),r.formatAt(s,at.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 At?this.prev:null,r=e?e.length():0,s=this.next instanceof At?this.next:null,i=s?s.text:"",{textNode:l}=this,a=l.data.split(at.CONTENTS).join("");l.data=at.CONTENTS;let c;if(e)c=e,(a||s)&&(e.insertAt(e.length(),a+i),s&&s.remove());else if(s)c=s,s.insertAt(0,a);else{const h=document.createTextNode(a);c=this.scroll.create(h),this.parent.insertBefore(c,this)}if(this.remove(),t){const h=(g,p)=>e&&g===e.domNode?p:g===l?r+p-1:s&&g===s.domNode?r+a.length+p:null,f=h(t.start.node,t.start.offset),b=h(t.end.node,t.end.offset);if(f!==null&&b!==null)return{startNode:c.domNode,startOffset:f,endNode:c.domNode,endOffset:b}}return null}update(t,e){if(t.some(r=>r.type==="characterData"&&r.target===this.textNode)){const r=this.restore();r&&(e.range=r)}}optimize(t){super.optimize(t);let{parent:e}=this;for(;e;){if(e.domNode.tagName==="A"){this.savedLength=at.CONTENTS.length,e.isolate(this.offset(e),this.length()).unwrap(),this.savedLength=0;break}e=e.parent}}value(){return""}};x(at,"blotName","cursor"),x(at,"className","ql-cursor"),x(at,"tagName","span"),x(at,"CONTENTS","\uFEFF");let Ve=at;var Oo={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(c,h,f){this.fn=c,this.context=h,this.once=f||!1}function i(c,h,f,b,g){if(typeof f!="function")throw new TypeError("The listener must be a function");var p=new s(f,b||c,g),m=e?e+h:h;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],p]:c._events[m].push(p):(c._events[m]=p,c._eventsCount++),c}function l(c,h){--c._eventsCount===0?c._events=new r:delete c._events[h]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],f,b;if(this._eventsCount===0)return h;for(b in f=this._events)t.call(f,b)&&h.push(e?b.slice(1):b);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(f)):h},a.prototype.listeners=function(h){var f=e?e+h:h,b=this._events[f];if(!b)return[];if(b.fn)return[b.fn];for(var g=0,p=b.length,m=new Array(p);g1?t-1:0),r=1;r(t[e]=Co.bind(console,e,n),t),{})}Kt.level=n=>{ci=n};Co.level=Kt.level;const js=Kt("quill:events"),rd=["selectionchange","mousedown","mouseup","click"];rd.forEach(n=>{document.addEventListener(n,function(){for(var t=arguments.length,e=new Array(t),r=0;r{const i=oi.get(s);i&&i.emitter&&i.emitter.handleDOM(...e)})})});class S extends nd{constructor(){super(),this.domListeners={},this.on("error",js.error)}emit(){for(var t=arguments.length,e=new Array(t),r=0;r1?e-1:0),s=1;s{let{node:l,handler:a}=i;(t.target===l||l.contains(t.target))&&a(t,...r)})}listenDOM(t,e,r){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:e,handler:r})}}x(S,"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"}),x(S,"sources",{API:"api",SILENT:"silent",USER:"user"});const Ps=Kt("quill:selection");class be{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=t,this.length=e}}class sd{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 be(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,S.sources.USER),1)}),this.emitter.on(S.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;const r=this.getNativeRange();r!=null&&r.start.node!==this.cursor.textNode&&this.emitter.once(S.events.SCROLL_UPDATE,(s,i)=>{try{this.root.contains(r.start.node)&&this.root.contains(r.end.node)&&this.setNativeRange(r.start.node,r.start.offset,r.end.node,r.end.offset);const l=i.some(a=>a.type==="characterData"||a.type==="childList"||a.type==="attributes"&&a.target===this.root);this.update(l?S.sources.SILENT:s)}catch{}})}),this.emitter.on(S.events.SCROLL_OPTIMIZE,(r,s)=>{if(s.range){const{startNode:i,startOffset:l,endNode:a,endOffset:c}=s.range;this.setNativeRange(i,l,a,c),this.update(S.sources.SILENT)}}),this.update(S.sources.SILENT)}handleComposition(){this.emitter.on(S.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(S.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(S.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(t,e){this.scroll.update();const r=this.getNativeRange();if(!(r==null||!r.native.collapsed||this.scroll.query(t,C.BLOCK))){if(r.start.node!==this.cursor.textNode){const s=this.scroll.find(r.start.node,!1);if(s==null)return;if(s instanceof Q){const i=s.split(r.start.offset);s.parent.insertBefore(this.cursor,i)}else s.insertBefore(this.cursor,r.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 r=this.scroll.length();t=Math.min(t,r-1),e=Math.min(t+e,r-1)-t;let s,[i,l]=this.scroll.leaf(t);if(i==null)return null;if(e>0&&l===i.length()){const[f]=this.scroll.leaf(t+1);if(f){const[b]=this.scroll.line(t),[g]=this.scroll.line(t+1);b===g&&(i=f,l=0)}}[s,l]=i.position(l,!0);const a=document.createRange();if(e>0)return a.setStart(s,l),[i,l]=this.scroll.leaf(t+e),i==null?null:([s,l]=i.position(l,!0),a.setEnd(s,l),a.getBoundingClientRect());let c="left",h;if(s instanceof Text){if(!s.data.length)return null;l0&&(c="right")}return{bottom:h.top+h.height,height:h.height,left:h[c],right:h[c],top:h.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 r=this.normalizeNative(e);return Ps.info("getNativeRange",r),r}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&&$s(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 r=e.map(l=>{const[a,c]=l,h=this.scroll.find(a,!0),f=h.offset(this.scroll);return c===0?f:h instanceof Q?f+h.index(a,c):f+h.length()}),s=Math.min(Math.max(...r),this.scroll.length()-1),i=Math.min(s,...r);return new be(i,s-i)}normalizeNative(t){if(!$s(this.root,t.startContainer)||!t.collapsed&&!$s(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(r=>{let{node:s,offset:i}=r;for(;!(s instanceof Text)&&s.childNodes.length>0;)if(s.childNodes.length>i)s=s.childNodes[i],i=0;else if(s.childNodes.length===i)s=s.lastChild,s instanceof Text?i=s.data.length:s.childNodes.length>0?i=s.childNodes.length:i=s.childNodes.length+1;else break;r.node=s,r.offset=i}),e}rangeToNative(t){const e=this.scroll.length(),r=(s,i)=>{s=Math.min(e-1,s);const[l,a]=this.scroll.leaf(s);return l?l.position(a,i):[null,-1]};return[...r(t.index,!1),...r(t.index+t.length,!0)]}setNativeRange(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(Ps.info("setNativeRange",t,e,r,s),t!=null&&(this.root.parentNode==null||t.parentNode==null||r.parentNode==null))return;const l=document.getSelection();if(l!=null)if(t!=null){this.hasFocus()||this.root.focus({preventScroll:!0});const{native:a}=this.getNativeRange()||{};if(a==null||i||t!==a.startContainer||e!==a.startOffset||r!==a.endContainer||s!==a.endOffset){t instanceof Element&&t.tagName==="BR"&&(e=Array.from(t.parentNode.childNodes).indexOf(t),t=t.parentNode),r instanceof Element&&r.tagName==="BR"&&(s=Array.from(r.parentNode.childNodes).indexOf(r),r=r.parentNode);const c=document.createRange();c.setStart(t,e),c.setEnd(r,s),l.removeAllRanges(),l.addRange(c)}}else l.removeAllRanges(),this.root.blur()}setRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:S.sources.API;if(typeof e=="string"&&(r=e,e=!1),Ps.info("setRange",t),t!=null){const s=this.rangeToNative(t);this.setNativeRange(...s,e)}else this.setNativeRange(null);this.update(r)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:S.sources.USER;const e=this.lastRange,[r,s]=this.getRange();if(this.lastRange=r,this.lastNative=s,this.lastRange!=null&&(this.savedRange=this.lastRange),!Xt(e,this.lastRange)){if(!this.composing&&s!=null&&s.native.collapsed&&s.start.node!==this.cursor.textNode){const l=this.cursor.restore();l&&this.setNativeRange(l.startNode,l.startOffset,l.endNode,l.endOffset)}const i=[S.events.SELECTION_CHANGE,Fe(this.lastRange),Fe(e),t];this.emitter.emit(S.events.EDITOR_CHANGE,...i),t!==S.sources.SILENT&&this.emitter.emit(...i)}}}function $s(n,t){try{t.parentNode}catch{return!1}return n.contains(t)}const id=/^[ -~]*$/;class ld{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();const r=Al(t),s=new O;return ad(r.ops.slice()).reduce((l,a)=>{const c=ft.Op.length(a);let h=a.attributes||{},f=!1,b=!1;if(a.insert!=null){if(s.retain(c),typeof a.insert=="string"){const m=a.insert;b=!m.endsWith(` `)&&(e<=l||!!this.scroll.descendant(ht,l)[0]),this.scroll.insertAt(l,m);const[y,E]=this.scroll.line(l);let A=te({},ct(y));if(y instanceof W){const[w]=y.descendant(Q,E);w&&(A=te(A,ct(w)))}h=ft.AttributeMap.diff(A,h)||{}}else if(typeof a.insert=="object"){const m=Object.keys(a.insert)[0];if(m==null)return l;const y=this.scroll.query(m,C.INLINE)!=null;if(y)(e<=l||this.scroll.descendant(ht,l)[0])&&(b=!0);else if(l>0){const[E,A]=this.scroll.descendant(Q,l-1);E instanceof At?E.value()[A]!==` `&&(f=!0):E instanceof lt&&E.statics.scope===C.INLINE_BLOT&&(f=!0)}if(this.scroll.insertAt(l,m,a.insert[m]),y){const[E]=this.scroll.descendant(Q,l);if(E){const A=te({},ct(E));h=ft.AttributeMap.diff(A,h)||{}}}}e+=c}else if(s.push(a),a.retain!==null&&typeof a.retain=="object"){const m=Object.keys(a.retain)[0];if(m==null)return l;this.scroll.updateEmbedAt(l,m,a.retain[m])}Object.keys(h).forEach(m=>{this.scroll.formatAt(l,c,m,h[m])});const g=f?1:0,p=b?1:0;return e+=g+p,s.retain(g),s.delete(p),l+c+g+p},0),s.reduce((l,a)=>typeof a.delete=="number"?(this.scroll.deleteAt(l,a.delete),l):l+ft.Op.length(a),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(r)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update(new O().retain(t).delete(e))}formatLine(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(r).forEach(i=>{this.scroll.lines(t,Math.max(e,1)).forEach(l=>{l.format(i,r[i])})}),this.scroll.optimize();const s=new O().retain(t).retain(e,Fe(r));return this.update(s)}formatText(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(r).forEach(i=>{this.scroll.formatAt(t,e,i,r[i])});const s=new O().retain(t).retain(e,Fe(r));return this.update(s)}getContents(t,e){return this.delta.slice(t,t+e)}getDelta(){return this.scroll.lines().reduce((t,e)=>t.concat(e.delta()),new O)}getFormat(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=[],s=[];e===0?this.scroll.path(t).forEach(a=>{const[c]=a;c instanceof W?r.push(c):c instanceof Q&&s.push(c)}):(r=this.scroll.lines(t,e),s=this.scroll.descendants(Q,t,e));const[i,l]=[r,s].map(a=>{const c=a.shift();if(c==null)return{};let h=ct(c);for(;Object.keys(h).length>0;){const f=a.shift();if(f==null)return h;h=od(ct(f),h)}return h});return{...i,...l}}getHTML(t,e){const[r,s]=this.scroll.line(t);if(r){const i=r.length();return r.length()>=s+e&&!(s===0&&e===i)?Cn(r,s,e,!0):Cn(this.scroll,t,e,!0)}return""}getText(t,e){return this.getContents(t,e).filter(r=>typeof r.insert=="string").map(r=>r.insert).join("")}insertContents(t,e){const r=Al(e),s=new O().retain(t).concat(r);return this.scroll.insertContents(t,r),this.update(s)}insertEmbed(t,e,r){return this.scroll.insertAt(t,e,r),this.update(new O().retain(t).insert({[e]:r}))}insertText(t,e){let r=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(r).forEach(s=>{this.scroll.formatAt(t,e.length,s,r[s])}),this.update(new O().retain(t).insert(e,Fe(r)))}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?.statics.blotName!==W.blotName)return!1;const e=t;return e.children.length>1?!1:e.children.head instanceof wt}removeFormat(t,e){const r=this.getText(t,e),[s,i]=this.scroll.line(t+e);let l=0,a=new O;s!=null&&(l=s.length()-i,a=s.delta().slice(i,i+l-1).insert(` `));const h=this.getContents(t,e+l).diff(new O().insert(r).concat(a)),f=new O().retain(t).concat(h);return this.applyDelta(f)}update(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;const s=this.delta;if(e.length===1&&e[0].type==="characterData"&&e[0].target.data.match(id)&&this.scroll.find(e[0].target)){const i=this.scroll.find(e[0].target),l=ct(i),a=i.offset(this.scroll),c=e[0].oldValue.replace(Ve.CONTENTS,""),h=new O().insert(c),f=new O().insert(i.value()),b=r&&{oldRange:Nl(r.oldRange,-a),newRange:Nl(r.newRange,-a)};t=new O().retain(a).concat(h.diff(f,b)).reduce((p,m)=>m.insert?p.insert(m.insert,l):p.push(m),new O),this.delta=s.compose(t)}else this.delta=this.getDelta(),(!t||!Xt(s.compose(t),this.delta))&&(t=s.diff(this.delta,r));return t}}function Pe(n,t,e){if(n.length===0){const[p]=Us(e.pop());return t<=0?``:`${Pe([],t-1,e)}`}const[{child:r,offset:s,length:i,indent:l,type:a},...c]=n,[h,f]=Us(a);if(l>t)return e.push(a),l===t+1?`<${h}>${Cn(r,s,i)}${Pe(c,l,e)}`:`<${h}>
  • ${Pe(n,t+1,e)}`;const b=e[e.length-1];if(l===t&&a===b)return`
  • ${Cn(r,s,i)}${Pe(c,l,e)}`;const[g]=Us(e.pop());return`${Pe(n,t-1,e)}`}function Cn(n,t,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in n&&typeof n.html=="function")return n.html(t,e);if(n instanceof At)return Br(n.value().slice(t,t+e)).replaceAll(" "," ");if(n instanceof Et){if(n.statics.blotName==="list-container"){const h=[];return n.children.forEachAt(t,e,(f,b,g)=>{const p="formats"in f&&typeof f.formats=="function"?f.formats():{};h.push({child:f,offset:b,length:g,indent:p.indent||0,type:p.list})}),Pe(h,-1,[])}const s=[];if(n.children.forEachAt(t,e,(h,f,b)=>{s.push(Cn(h,f,b))}),r||n.statics.blotName==="list")return s.join("");const{outerHTML:i,innerHTML:l}=n.domNode,[a,c]=i.split(`>${l}<`);return a==="${s.join("")}<${c}`:`${a}>${s.join("")}<${c}`}return n.domNode instanceof Element?n.domNode.outerHTML:""}function od(n,t){return Object.keys(t).reduce((e,r)=>{if(n[r]==null)return e;const s=t[r];return s===n[r]?e[r]=s:Array.isArray(s)?s.indexOf(n[r])<0?e[r]=s.concat([n[r]]):e[r]=s:e[r]=[s,n[r]],e},{})}function Us(n){const t=n==="ordered"?"ol":"ul";switch(n){case"checked":return[t,' data-list="checked"'];case"unchecked":return[t,' data-list="unchecked"'];default:return[t,""]}}function Al(n){return n.reduce((t,e)=>{if(typeof e.insert=="string"){const r=e.insert.replace(/\r\n/g,` `).replace(/\r/g,` `);return t.insert(r,e.attributes)}return t.push(e)},new O)}function Nl(n,t){let{index:e,length:r}=n;return new be(e+t,r)}function ad(n){const t=[];return n.forEach(e=>{typeof e.insert=="string"?e.insert.split(` `).forEach((s,i)=>{i&&t.push({insert:` `,attributes:e.attributes}),s&&t.push({insert:s,attributes:e.attributes})}):t.push(e)}),t}class Tt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=t,this.options=e}}x(Tt,"DEFAULTS",{});const dr="\uFEFF";class Ci extends lt{constructor(t,e){super(t,e),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(r=>{this.contentNode.appendChild(r)}),this.leftGuard=document.createTextNode(dr),this.rightGuard=document.createTextNode(dr),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,r;const s=t.data.split(dr).join("");if(t===this.leftGuard)if(this.prev instanceof At){const i=this.prev.length();this.prev.insertAt(i,s),e={startNode:this.prev.domNode,startOffset:i+s.length}}else r=document.createTextNode(s),this.parent.insertBefore(this.scroll.create(r),this),e={startNode:r,startOffset:s.length};else t===this.rightGuard&&(this.next instanceof At?(this.next.insertAt(0,s),e={startNode:this.next.domNode,startOffset:s.length}):(r=document.createTextNode(s),this.parent.insertBefore(this.scroll.create(r),this.next),e={startNode:r,startOffset:s.length}));return t.data=dr,e}update(t,e){t.forEach(r=>{if(r.type==="characterData"&&(r.target===this.leftGuard||r.target===this.rightGuard)){const s=this.restore(r.target);s&&(e.range=s)}})}}class cd{constructor(t,e){x(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 Ci)&&(this.emitter.emit(S.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(S.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(S.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(S.events.COMPOSITION_END,t),this.isComposing=!1}}const wn=class wn{constructor(t,e){x(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]}};x(wn,"DEFAULTS",{modules:{}}),x(wn,"themes",{default:wn});let We=wn;const ud=n=>n.parentElement||n.getRootNode().host||null,hd=n=>{const t=n.getBoundingClientRect(),e="offsetWidth"in n&&Math.abs(t.width)/n.offsetWidth||1,r="offsetHeight"in n&&Math.abs(t.height)/n.offsetHeight||1;return{top:t.top,right:t.left+n.clientWidth*e,bottom:t.top+n.clientHeight*r,left:t.left}},gr=n=>{const t=parseInt(n,10);return Number.isNaN(t)?0:t},wl=(n,t,e,r,s,i)=>nr?0:nr?t-n>r-e?n+s-e:t-r+i:0,fd=(n,t)=>{const e=n.ownerDocument;let r=t,s=n;for(;s;){const i=s===e.body,l=i?{top:0,right:window.visualViewport?.width??e.documentElement.clientWidth,bottom:window.visualViewport?.height??e.documentElement.clientHeight,left:0}:hd(s),a=getComputedStyle(s),c=wl(r.left,r.right,l.left,l.right,gr(a.scrollPaddingLeft),gr(a.scrollPaddingRight)),h=wl(r.top,r.bottom,l.top,l.bottom,gr(a.scrollPaddingTop),gr(a.scrollPaddingBottom));if(c||h)if(i)e.defaultView?.scrollBy(c,h);else{const{scrollLeft:f,scrollTop:b}=s;h&&(s.scrollTop+=h),c&&(s.scrollLeft+=c);const g=s.scrollLeft-f,p=s.scrollTop-b;r={left:r.left-g,top:r.top-p,right:r.right-g,bottom:r.bottom-p}}s=i||a.position==="fixed"?null:ud(s)}},dd=100,gd=["block","break","cursor","inline","scroll","text"],pd=(n,t,e)=>{const r=new Ge;return gd.forEach(s=>{const i=t.query(s);i&&r.register(i)}),n.forEach(s=>{let i=t.query(s);i||e.error(`Cannot register "${s}" specified in "formats" config. Are you sure it was registered?`);let l=0;for(;i;)if(r.register(i),i="blotName"in i?i.requiredContainer??null:null,l+=1,l>dd){e.error(`Cycle detected in registering blot requiredContainer: "${s}"`);break}}),r},ze=Kt("quill"),pr=new Ge;Et.uiClass="ql-ui";var st;let N=(st=class{static debug(t){t===!0&&(t="log"),Kt.level(t)}static find(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return oi.get(t)||pr.find(t,e)}static import(t){return this.imports[t]==null&&ze.error(`Cannot import ${t}. Are you sure it was registered?`),this.imports[t]}static register(){if(typeof(arguments.length<=0?void 0:arguments[0])!="string"){const t=arguments.length<=0?void 0:arguments[0],e=!!(!(arguments.length<=1)&&arguments[1]),r="attrName"in t?t.attrName:t.blotName;typeof r=="string"?this.register(`formats/${r}`,t,e):Object.keys(t).forEach(s=>{this.register(s,t[s],e)})}else{const t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1],r=!!(!(arguments.length<=2)&&arguments[2]);this.imports[t]!=null&&!r&&ze.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&typeof e!="boolean"&&e.blotName!=="abstract"&&pr.register(e),typeof e.register=="function"&&e.register(pr)}}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=md(t,e),this.container=this.options.container,this.container==null){ze.error("Invalid Quill container",t);return}this.options.debug&&st.debug(this.options.debug);const r=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",oi.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new S;const s=xi.blotName,i=this.options.registry.query(s);if(!i||!("blotName"in i))throw new Error(`Cannot initialize Quill without "${s}" blot`);if(this.scroll=new i(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new ld(this.scroll),this.selection=new sd(this.scroll,this.emitter),this.composition=new cd(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(S.events.EDITOR_CHANGE,l=>{l===S.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(S.events.SCROLL_UPDATE,(l,a)=>{const c=this.selection.lastRange,[h]=this.selection.getRange(),f=c&&h?{oldRange:c,newRange:h}:void 0;bt.call(this,()=>this.editor.update(null,a,f),l)}),this.emitter.on(S.events.SCROLL_EMBED_UPDATE,(l,a)=>{const c=this.selection.lastRange,[h]=this.selection.getRange(),f=c&&h?{oldRange:c,newRange:h}:void 0;bt.call(this,()=>{const b=new O().retain(l.offset(this)).retain({[l.statics.blotName]:a});return this.editor.update(b,[],f)},st.sources.USER)}),r){const l=this.clipboard.convert({html:`${r}


    `,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 r=t;t=document.createElement("div"),t.classList.add(r)}return this.container.insertBefore(t,e),t}blur(){this.selection.setRange(null)}deleteText(t,e,r){return[t,e,,r]=$t(t,e,r),bt.call(this,()=>this.editor.deleteText(t,e),r,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(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.selection.focus(),t.preventScroll||this.scrollSelectionIntoView()}format(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:S.sources.API;return bt.call(this,()=>{const s=this.getSelection(!0);let i=new O;if(s==null)return i;if(this.scroll.query(t,C.BLOCK))i=this.editor.formatLine(s.index,s.length,{[t]:e});else{if(s.length===0)return this.selection.format(t,e),i;i=this.editor.formatText(s.index,s.length,{[t]:e})}return this.setSelection(s,S.sources.SILENT),i},r)}formatLine(t,e,r,s,i){let l;return[t,e,l,i]=$t(t,e,r,s,i),bt.call(this,()=>this.editor.formatLine(t,e,l),i,t,0)}formatText(t,e,r,s,i){let l;return[t,e,l,i]=$t(t,e,r,s,i),bt.call(this,()=>this.editor.formatText(t,e,l),i,t,0)}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=null;if(typeof t=="number"?r=this.selection.getBounds(t,e):r=this.selection.getBounds(t.index,t.length),!r)return null;const s=this.container.getBoundingClientRect();return{bottom:r.bottom-s.top,height:r.height,left:r.left-s.left,right:r.right-s.left,top:r.top-s.top,width:r.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]=$t(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??this.getLength()-t),[t,e]=$t(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??this.getLength()-t),[t,e]=$t(t,e),this.editor.getText(t,e)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:st.sources.API;return bt.call(this,()=>this.editor.insertEmbed(t,e,r),s,t)}insertText(t,e,r,s,i){let l;return[t,,l,i]=$t(t,0,r,s,i),bt.call(this,()=>this.editor.insertText(t,e,l),i,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,r){return[t,e,,r]=$t(t,e,r),bt.call(this,()=>this.editor.removeFormat(t,e),r,t)}scrollRectIntoView(t){fd(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]:S.sources.API;return bt.call(this,()=>{t=new O(t);const r=this.getLength(),s=this.editor.deleteText(0,r),i=this.editor.insertContents(0,t),l=this.editor.deleteText(this.getLength()-1,1);return s.compose(i).compose(l)},e)}setSelection(t,e,r){t==null?this.selection.setRange(null,e||st.sources.API):([t,e,,r]=$t(t,e,r),this.selection.setRange(new be(Math.max(0,t),e),r),r!==S.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:S.sources.API;const r=new O().insert(t);return this.setContents(r,e)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:S.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]:S.sources.API;return bt.call(this,()=>(t=new O(t),this.editor.applyDelta(t)),e,!0)}},x(st,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:pr,theme:"default"}),x(st,"events",S.events),x(st,"sources",S.sources),x(st,"version","2.0.3"),x(st,"imports",{delta:O,parchment:$f,"core/module":Tt,"core/theme":We}),st);function Tl(n){return typeof n=="string"?document.querySelector(n):n}function Fs(n){return Object.entries(n??{}).reduce((t,e)=>{let[r,s]=e;return{...t,[r]:s===!0?{}:s}},{})}function xl(n){return Object.fromEntries(Object.entries(n).filter(t=>t[1]!==void 0))}function md(n,t){const e=Tl(n);if(!e)throw new Error("Invalid Quill container");const s=!t.theme||t.theme===N.DEFAULTS.theme?We:N.import(`themes/${t.theme}`);if(!s)throw new Error(`Invalid theme ${t.theme}. Did you register it?`);const{modules:i,...l}=N.DEFAULTS,{modules:a,...c}=s.DEFAULTS;let h=Fs(t.modules);h!=null&&h.toolbar&&h.toolbar.constructor!==Object&&(h={...h,toolbar:{container:h.toolbar}});const f=te({},Fs(i),Fs(a),h),b={...l,...xl(c),...xl(t)};let g=t.registry;return g?t.formats&&ze.warn('Ignoring "formats" option because "registry" is specified'):g=t.formats?pd(t.formats,b.registry,ze):b.registry,{...b,registry:g,container:e,theme:s,modules:Object.entries(f).reduce((p,m)=>{let[y,E]=m;if(!E)return p;const A=N.import(`modules/${y}`);return A==null?(ze.error(`Cannot load ${y} module. Are you sure you registered it?`),p):{...p,[y]:te({},A.DEFAULTS||{},E)}},{}),bounds:Tl(b.bounds)}}function bt(n,t,e,r){if(!this.isEnabled()&&t===S.sources.USER&&!this.allowReadOnlyEdits)return new O;let s=e==null?null:this.getSelection();const i=this.editor.delta,l=n();if(s!=null&&(e===!0&&(e=s.index),r==null?s=Ll(s,l,t):r!==0&&(s=Ll(s,e,r,t)),this.setSelection(s,S.sources.SILENT)),l.length()>0){const a=[S.events.TEXT_CHANGE,l,i,t];this.emitter.emit(S.events.EDITOR_CHANGE,...a),t!==S.sources.SILENT&&this.emitter.emit(...a)}return l}function $t(n,t,e,r,s){let i={};return typeof n.index=="number"&&typeof n.length=="number"?typeof t!="number"?(s=r,r=e,e=t,t=n.length,n=n.index):(t=n.length,n=n.index):typeof t!="number"&&(s=r,r=e,e=t,t=0),typeof e=="object"?(i=e,s=r):typeof e=="string"&&(r!=null?i[e]=r:s=e),s=s||S.sources.API,[n,t,i,s]}function Ll(n,t,e,r){const s=typeof e=="number"?e:0;if(n==null)return null;let i,l;return t&&typeof t.transformPosition=="function"?[i,l]=[n.index,n.index+n.length].map(a=>t.transformPosition(a,r!==S.sources.USER)):[i,l]=[n.index,n.index+n.length].map(a=>a=0?a+s:Math.max(t,a+s)),new be(i,l-i)}class Ae extends qr{}function Sl(n){return n instanceof W||n instanceof ht}function _l(n){return typeof n.updateContent=="function"}class $e extends xi{constructor(t,e,r){let{emitter:s}=r;super(t,e),this.emitter=s,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",i=>this.handleDragStart(i))}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(S.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(S.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,e){this.emitter.emit(S.events.SCROLL_EMBED_UPDATE,t,e)}deleteAt(t,e){const[r,s]=this.line(t),[i]=this.line(t+e);if(super.deleteAt(t,e),i!=null&&r!==i&&s>0){if(r instanceof ht||i instanceof ht){this.optimize();return}const l=i.children.head instanceof wt?null:i.children.head;r.moveChildren(i,l),r.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,r,s){super.formatAt(t,e,r,s),this.optimize()}insertAt(t,e,r){if(t>=this.length())if(r==null||this.scroll.query(e,C.BLOCK)==null){const s=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(s),r==null&&e.endsWith(` `)?s.insertAt(0,e.slice(0,-1),r):s.insertAt(0,e,r)}else{const s=this.scroll.create(e,r);this.appendChild(s)}else super.insertAt(t,e,r);this.optimize()}insertBefore(t,e){if(t.statics.scope===C.INLINE_BLOT){const r=this.scroll.create(this.statics.defaultChild.blotName);r.appendChild(t),super.insertBefore(r,e)}else super.insertBefore(t,e)}insertContents(t,e){const r=this.deltaToRenderBlocks(e.concat(new O().insert(` `))),s=r.pop();if(s==null)return;this.batchStart();const i=r.shift();if(i){const c=i.type==="block"&&(i.delta.length()===0||!this.descendant(ht,t)[0]&&t{this.formatAt(b-1,1,m,p[m])}),t=b}let[l,a]=this.children.find(t);if(r.length&&(l&&(l=l.split(a),a=0),r.forEach(c=>{if(c.type==="block"){const h=this.createBlock(c.attributes,l||void 0);Hs(h,0,c.delta)}else{const h=this.create(c.key,c.value);this.insertBefore(h,l||void 0),Object.keys(c.attributes).forEach(f=>{h.format(f,c.attributes[f])})}})),s.type==="block"&&s.delta.length()){const c=l?l.offset(l.scroll)+a:this.length();Hs(this,c,s.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[r,s]=e;return r instanceof Q?[r,s]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(Sl,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 r=(s,i,l)=>{let a=[],c=l;return s.children.forEachAt(i,l,(h,f,b)=>{Sl(h)?a.push(h):h instanceof qr&&(a=a.concat(r(h,f,c))),c-=b}),a};return r(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(S.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=S.sources.USER;typeof t=="string"&&(e=t),Array.isArray(t)||(t=this.observer.takeRecords()),t=t.filter(r=>{let{target:s}=r;const i=this.find(s,!0);return i&&!_l(i)}),t.length>0&&this.emitter.emit(S.events.SCROLL_BEFORE_UPDATE,e,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(S.events.SCROLL_UPDATE,e,t)}updateEmbedAt(t,e,r){const[s]=this.descendant(i=>i instanceof ht,t);s&&s.statics.blotName===e&&_l(s)&&s.updateContent(r)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){const e=[];let r=new O;return t.forEach(s=>{const i=s?.insert;if(i)if(typeof i=="string"){const l=i.split(` `);l.slice(0,-1).forEach(c=>{r.insert(c,s.attributes),e.push({type:"block",delta:r,attributes:s.attributes??{}}),r=new O});const a=l[l.length-1];a&&r.insert(a,s.attributes)}else{const l=Object.keys(i)[0];if(!l)return;this.query(l,C.INLINE)?r.push(s):(r.length()&&e.push({type:"block",delta:r,attributes:{}}),r=new O,e.push({type:"blockEmbed",key:l,value:i[l],attributes:s.attributes??{}}))}}),r.length()&&e.push({type:"block",delta:r,attributes:{}}),e}createBlock(t,e){let r;const s={};Object.entries(t).forEach(a=>{let[c,h]=a;this.query(c,C.BLOCK&C.BLOT)!=null?r=c:s[c]=h});const i=this.create(r||this.statics.defaultChild.blotName,r?t[r]:void 0);this.insertBefore(i,e||void 0);const l=i.length();return Object.entries(s).forEach(a=>{let[c,h]=a;i.formatAt(0,l,c,h)}),i}}x($e,"blotName","scroll"),x($e,"className","ql-editor"),x($e,"tagName","DIV"),x($e,"defaultChild",W),x($e,"allowedChildren",[W,ht,Ae]);function Hs(n,t,e){e.reduce((r,s)=>{const i=ft.Op.length(s);let l=s.attributes||{};if(s.insert!=null){if(typeof s.insert=="string"){const a=s.insert;n.insertAt(r,a);const[c]=n.descendant(Q,r),h=ct(c);l=ft.AttributeMap.diff(h,l)||{}}else if(typeof s.insert=="object"){const a=Object.keys(s.insert)[0];if(a==null)return r;if(n.insertAt(r,a,s.insert[a]),n.scroll.query(a,C.INLINE)!=null){const[h]=n.descendant(Q,r),f=ct(h);l=ft.AttributeMap.diff(f,l)||{}}}}return Object.keys(l).forEach(a=>{n.formatAt(r,i,a,l[a])}),r+i},t)}const qi={scope:C.BLOCK,whitelist:["right","center","justify"]},bd=new It("align","align",qi),qo=new Nt("align","ql-align",qi),Io=new re("align","text-align",qi);class Ro extends re{value(t){let e=super.value(t);return e.startsWith("rgb(")?(e=e.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${e.split(",").map(s=>`00${parseInt(s,10).toString(16)}`.slice(-2)).join("")}`):e}}const yd=new Nt("color","ql-color",{scope:C.INLINE}),Ii=new Ro("color","color",{scope:C.INLINE}),vd=new Nt("background","ql-bg",{scope:C.INLINE}),Ri=new Ro("background","background-color",{scope:C.INLINE});class Ne extends Ae{static create(t){const e=super.create(t);return e.setAttribute("spellcheck","false"),e}code(t,e){return this.children.map(r=>r.length()<=1?"":r.domNode.innerText).join(` `).slice(t,t+e)}html(t,e){return`
    ${Br(this.code(t,e))}
    
    `}}class J extends W{static register(){N.register(Ne)}}x(J,"TAB"," ");class ki extends Rt{}ki.blotName="code";ki.tagName="CODE";J.blotName="code-block";J.className="ql-code-block";J.tagName="DIV";Ne.blotName="code-block-container";Ne.className="ql-code-block-container";Ne.tagName="DIV";Ne.allowedChildren=[J];J.allowedChildren=[At,wt,Ve];J.requiredContainer=Ne;const Bi={scope:C.BLOCK,whitelist:["rtl"]},ko=new It("direction","dir",Bi),Bo=new Nt("direction","ql-direction",Bi),Mo=new re("direction","direction",Bi),Do={scope:C.INLINE,whitelist:["serif","monospace"]},jo=new Nt("font","ql-font",Do);class Ed extends re{value(t){return super.value(t).replace(/["']/g,"")}}const Po=new Ed("font","font-family",Do),$o=new Nt("size","ql-size",{scope:C.INLINE,whitelist:["small","large","huge"]}),Uo=new re("size","font-size",{scope:C.INLINE,whitelist:["10px","18px","32px"]}),Ad=Kt("quill:keyboard"),Nd=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey";class Mr extends Tt{static match(t,e){return["altKey","ctrlKey","metaKey","shiftKey"].some(r=>!!e[r]!==t[r]&&e[r]!==null)?!1:e.key===t.key||e.key===t.which}constructor(t,e){super(t,e),this.bindings={},Object.keys(this.options.bindings).forEach(r=>{this.options.bindings[r]&&this.addBinding(this.options.bindings[r])}),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]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=Td(t);if(s==null){Ad.warn("Attempted to add invalid keyboard binding",s);return}typeof e=="function"&&(e={handler:e}),typeof r=="function"&&(r={handler:r}),(Array.isArray(s.key)?s.key:[s.key]).forEach(l=>{const a={...s,key:l,...e,...r};this.bindings[a.key]=this.bindings[a.key]||[],this.bindings[a.key].push(a)})}listen(){this.quill.root.addEventListener("keydown",t=>{if(t.defaultPrevented||t.isComposing||t.keyCode===229&&(t.key==="Enter"||t.key==="Backspace"))return;const s=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(A=>Mr.match(t,A));if(s.length===0)return;const i=N.find(t.target,!0);if(i&&i.scroll!==this.quill.scroll)return;const l=this.quill.getSelection();if(l==null||!this.quill.hasFocus())return;const[a,c]=this.quill.getLine(l.index),[h,f]=this.quill.getLeaf(l.index),[b,g]=l.length===0?[h,f]:this.quill.getLeaf(l.index+l.length),p=h instanceof Tr?h.value().slice(0,f):"",m=b instanceof Tr?b.value().slice(g):"",y={collapsed:l.length===0,empty:l.length===0&&a.length()<=1,format:this.quill.getFormat(l),line:a,offset:c,prefix:p,suffix:m,event:t};s.some(A=>{if(A.collapsed!=null&&A.collapsed!==y.collapsed||A.empty!=null&&A.empty!==y.empty||A.offset!=null&&A.offset!==y.offset)return!1;if(Array.isArray(A.format)){if(A.format.every(w=>y.format[w]==null))return!1}else if(typeof A.format=="object"&&!Object.keys(A.format).every(w=>A.format[w]===!0?y.format[w]!=null:A.format[w]===!1?y.format[w]==null:Xt(A.format[w],y.format[w])))return!1;return A.prefix!=null&&!A.prefix.test(y.prefix)||A.suffix!=null&&!A.suffix.test(y.suffix)?!1:A.handler.call(this,l,y,A)!==!0})&&t.preventDefault()})}handleBackspace(t,e){const r=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(e.prefix)?2:1;if(t.index===0||this.quill.getLength()<=1)return;let s={};const[i]=this.quill.getLine(t.index);let l=new O().retain(t.index-r).delete(r);if(e.offset===0){const[a]=this.quill.getLine(t.index-1);if(a&&!(a.statics.blotName==="block"&&a.length()<=1)){const h=i.formats(),f=this.quill.getFormat(t.index-1,1);if(s=ft.AttributeMap.diff(h,f)||{},Object.keys(s).length>0){const b=new O().retain(t.index+i.length()-2).retain(1,s);l=l.compose(b)}}}this.quill.updateContents(l,N.sources.USER),this.quill.focus()}handleDelete(t,e){const r=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(e.suffix)?2:1;if(t.index>=this.quill.getLength()-r)return;let s={};const[i]=this.quill.getLine(t.index);let l=new O().retain(t.index).delete(r);if(e.offset>=i.length()-1){const[a]=this.quill.getLine(t.index+1);if(a){const c=i.formats(),h=this.quill.getFormat(t.index,1);s=ft.AttributeMap.diff(c,h)||{},Object.keys(s).length>0&&(l=l.retain(a.length()-1).retain(1,s))}}this.quill.updateContents(l,N.sources.USER),this.quill.focus()}handleDeleteRange(t){Mi({range:t,quill:this.quill}),this.quill.focus()}handleEnter(t,e){const r=Object.keys(e.format).reduce((i,l)=>(this.quill.scroll.query(l,C.BLOCK)&&!Array.isArray(e.format[l])&&(i[l]=e.format[l]),i),{}),s=new O().retain(t.index).delete(t.length).insert(` `,r);this.quill.updateContents(s,N.sources.USER),this.quill.setSelection(t.index+1,N.sources.SILENT),this.quill.focus()}}const wd={bindings:{bold:zs("bold"),italic:zs("italic"),underline:zs("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(n,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","+1",N.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(n,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","-1",N.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(n,t){t.format.indent!=null?this.quill.format("indent","-1",N.sources.USER):t.format.list!=null&&this.quill.format("list",!1,N.sources.USER)}},"indent code-block":Ol(!0),"outdent code-block":Ol(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(n){this.quill.deleteText(n.index-1,1,N.sources.USER)}},tab:{key:"Tab",handler(n,t){if(t.format.table)return!0;this.quill.history.cutoff();const e=new O().retain(n.index).delete(n.length).insert(" ");return this.quill.updateContents(e,N.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(n.index+1,N.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,N.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(n,t){const e={list:!1};t.format.indent&&(e.indent=!1),this.quill.formatLine(n.index,n.length,e,N.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(n){const[t,e]=this.quill.getLine(n.index),r={...t.formats(),list:"checked"},s=new O().retain(n.index).insert(` `,r).retain(t.length()-e-1).retain(1,{list:"unchecked"});this.quill.updateContents(s,N.sources.USER),this.quill.setSelection(n.index+1,N.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(n,t){const[e,r]=this.quill.getLine(n.index),s=new O().retain(n.index).insert(` `,t.format).retain(e.length()-r-1).retain(1,{header:null});this.quill.updateContents(s,N.sources.USER),this.quill.setSelection(n.index+1,N.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(n){const t=this.quill.getModule("table");if(t){const[e,r,s,i]=t.getTable(n),l=xd(e,r,s,i);if(l==null)return;let a=e.offset();if(l<0){const c=new O().retain(a).insert(` `);this.quill.updateContents(c,N.sources.USER),this.quill.setSelection(n.index+1,n.length,N.sources.SILENT)}else if(l>0){a+=e.length();const c=new O().retain(a).insert(` `);this.quill.updateContents(c,N.sources.USER),this.quill.setSelection(a,N.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(n,t){const{event:e,line:r}=t,s=r.offset(this.quill.scroll);e.shiftKey?this.quill.setSelection(s-1,N.sources.USER):this.quill.setSelection(s+r.length(),N.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(n,t){if(this.quill.scroll.query("list")==null)return!0;const{length:e}=t.prefix,[r,s]=this.quill.getLine(n.index);if(s>e)return!0;let i;switch(t.prefix.trim()){case"[]":case"[ ]":i="unchecked";break;case"[x]":i="checked";break;case"-":case"*":i="bullet";break;default:i="ordered"}this.quill.insertText(n.index," ",N.sources.USER),this.quill.history.cutoff();const l=new O().retain(n.index-s).delete(e+1).retain(r.length()-2-s).retain(1,{list:i});return this.quill.updateContents(l,N.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(n.index-e,N.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(n){const[t,e]=this.quill.getLine(n.index);let r=2,s=t;for(;s!=null&&s.length()<=1&&s.formats()["code-block"];)if(s=s.prev,r-=1,r<=0){const i=new O().retain(n.index+t.length()-e-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(i,N.sources.USER),this.quill.setSelection(n.index-1,N.sources.SILENT),!1}return!0}},"embed left":mr("ArrowLeft",!1),"embed left shift":mr("ArrowLeft",!0),"embed right":mr("ArrowRight",!1),"embed right shift":mr("ArrowRight",!0),"table down":Cl(!1),"table up":Cl(!0)}};Mr.DEFAULTS=wd;function Ol(n){return{key:"Tab",shiftKey:!n,format:{"code-block":!0},handler(t,e){let{event:r}=e;const s=this.quill.scroll.query("code-block"),{TAB:i}=s;if(t.length===0&&!r.shiftKey){this.quill.insertText(t.index,i,N.sources.USER),this.quill.setSelection(t.index+i.length,N.sources.SILENT);return}const l=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t);let{index:a,length:c}=t;l.forEach((h,f)=>{n?(h.insertAt(0,i),f===0?a+=i.length:c+=i.length):h.domNode.textContent.startsWith(i)&&(h.deleteAt(0,i.length),f===0?a-=i.length:c-=i.length)}),this.quill.update(N.sources.USER),this.quill.setSelection(a,c,N.sources.SILENT)}}}function mr(n,t){return{key:n,shiftKey:t,altKey:null,[n==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(r){let{index:s}=r;n==="ArrowRight"&&(s+=r.length+1);const[i]=this.quill.getLeaf(s);return i instanceof lt?(n==="ArrowLeft"?t?this.quill.setSelection(r.index-1,r.length+1,N.sources.USER):this.quill.setSelection(r.index-1,N.sources.USER):t?this.quill.setSelection(r.index,r.length+1,N.sources.USER):this.quill.setSelection(r.index+r.length+1,N.sources.USER),!1):!0}}}function zs(n){return{key:n[0],shortKey:!0,handler(t,e){this.quill.format(n,!e.format[n],N.sources.USER)}}}function Cl(n){return{key:n?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(t,e){const r=n?"prev":"next",s=e.line,i=s.parent[r];if(i!=null){if(i.statics.blotName==="table-row"){let l=i.children.head,a=s;for(;a.prev!=null;)a=a.prev,l=l.next;const c=l.offset(this.quill.scroll)+Math.min(e.offset,l.length()-1);this.quill.setSelection(c,0,N.sources.USER)}}else{const l=s.table()[r];l!=null&&(n?this.quill.setSelection(l.offset(this.quill.scroll)+l.length()-1,0,N.sources.USER):this.quill.setSelection(l.offset(this.quill.scroll),0,N.sources.USER))}return!1}}}function Td(n){if(typeof n=="string"||typeof n=="number")n={key:n};else if(typeof n=="object")n=Fe(n);else return null;return n.shortKey&&(n[Nd]=n.shortKey,delete n.shortKey),n}function Mi(n){let{quill:t,range:e}=n;const r=t.getLines(e);let s={};if(r.length>1){const i=r[0].formats(),l=r[r.length-1].formats();s=ft.AttributeMap.diff(l,i)||{}}t.deleteText(e,N.sources.USER),Object.keys(s).length>0&&t.formatLine(e.index,1,s,N.sources.USER),t.setSelection(e.index,N.sources.SILENT)}function xd(n,t,e,r){return t.prev==null&&t.next==null?e.prev==null&&e.next==null?r===0?-1:1:e.prev==null?-1:1:t.prev==null?-1:t.next==null?1:null}const Ld=/font-weight:\s*normal/,Sd=["P","OL","UL"],ql=n=>n&&Sd.includes(n.tagName),_d=n=>{Array.from(n.querySelectorAll("br")).filter(t=>ql(t.previousElementSibling)&&ql(t.nextElementSibling)).forEach(t=>{t.parentNode?.removeChild(t)})},Od=n=>{Array.from(n.querySelectorAll('b[style*="font-weight"]')).filter(t=>t.getAttribute("style")?.match(Ld)).forEach(t=>{const e=n.createDocumentFragment();e.append(...t.childNodes),t.parentNode?.replaceChild(e,t)})};function Cd(n){n.querySelector('[id^="docs-internal-guid-"]')&&(Od(n),_d(n))}const qd=/\bmso-list:[^;]*ignore/i,Id=/\bmso-list:[^;]*\bl(\d+)/i,Rd=/\bmso-list:[^;]*\blevel(\d+)/i,kd=(n,t)=>{const e=n.getAttribute("style"),r=e?.match(Id);if(!r)return null;const s=Number(r[1]),i=e?.match(Rd),l=i?Number(i[1]):1,a=new RegExp(`@list l${s}:level${l}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),c=t.match(a),h=c&&c[1]==="bullet"?"bullet":"ordered";return{id:s,indent:l,type:h,element:n}},Bd=n=>{const t=Array.from(n.querySelectorAll("[style*=mso-list]")),e=[],r=[];t.forEach(l=>{(l.getAttribute("style")||"").match(qd)?e.push(l):r.push(l)}),e.forEach(l=>l.parentNode?.removeChild(l));const s=n.documentElement.innerHTML,i=r.map(l=>kd(l,s)).filter(l=>l);for(;i.length;){const l=[];let a=i.shift();for(;a;)l.push(a),a=i.length&&i[0]?.element===a.element.nextElementSibling&&i[0].id===a.id?i.shift():null;const c=document.createElement("ul");l.forEach(b=>{const g=document.createElement("li");g.setAttribute("data-list",b.type),b.indent>1&&g.setAttribute("class",`ql-indent-${b.indent-1}`),g.innerHTML=b.element.innerHTML,c.appendChild(g)});const h=l[0]?.element,{parentNode:f}=h??{};h&&f?.replaceChild(c,h),l.slice(1).forEach(b=>{let{element:g}=b;f?.removeChild(g)})}};function Md(n){n.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&Bd(n)}const Dd=[Md,Cd],jd=n=>{n.documentElement&&Dd.forEach(t=>{t(n)})},Pd=Kt("quill:clipboard"),$d=[[Node.TEXT_NODE,Qd],[Node.TEXT_NODE,Rl],["br",Kd],[Node.ELEMENT_NODE,Rl],[Node.ELEMENT_NODE,zd],[Node.ELEMENT_NODE,Hd],[Node.ELEMENT_NODE,Xd],["li",Wd],["ol, ul",Zd],["pre",Gd],["tr",Yd],["b",Ks("bold")],["i",Ks("italic")],["strike",Ks("strike")],["style",Vd]],Ud=[bd,ko].reduce((n,t)=>(n[t.keyName]=t,n),{}),Il=[Io,Ri,Ii,Mo,Po,Uo].reduce((n,t)=>(n[t.keyName]=t,n),{});class Fo extends Tt{constructor(t,e){super(t,e),this.quill.root.addEventListener("copy",r=>this.onCaptureCopy(r,!1)),this.quill.root.addEventListener("cut",r=>this.onCaptureCopy(r,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],$d.concat(this.options.matchers??[]).forEach(r=>{let[s,i]=r;this.addMatcher(s,i)})}addMatcher(t,e){this.matchers.push([t,e])}convert(t){let{html:e,text:r}=t,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(s[J.blotName])return new O().insert(r||"",{[J.blotName]:s[J.blotName]});if(!e)return new O().insert(r||"",s);const i=this.convertHTML(e);return kn(i,` `)&&(i.ops[i.ops.length-1].attributes==null||s.table)?i.compose(new O().retain(i.length()-1).delete(1)):i}normalizeHTML(t){jd(t)}convertHTML(t){const e=new DOMParser().parseFromString(t,"text/html");this.normalizeHTML(e);const r=e.body,s=new WeakMap,[i,l]=this.prepareMatching(r,s);return Di(this.quill.scroll,r,i,l,s)}dangerouslyPasteHTML(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:N.sources.API;if(typeof t=="string"){const s=this.convert({html:t,text:""});this.quill.setContents(s,e),this.quill.setSelection(0,N.sources.SILENT)}else{const s=this.convert({html:e,text:""});this.quill.updateContents(new O().retain(t).concat(s),r),this.quill.setSelection(t+s.length(),N.sources.SILENT)}}onCaptureCopy(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(t.defaultPrevented)return;t.preventDefault();const[r]=this.quill.selection.getRange();if(r==null)return;const{html:s,text:i}=this.onCopy(r,e);t.clipboardData?.setData("text/plain",i),t.clipboardData?.setData("text/html",s),e&&Mi({range:r,quill:this.quill})}normalizeURIList(t){return t.split(/\r?\n/).filter(e=>e[0]!=="#").join(` `)}onCapturePaste(t){if(t.defaultPrevented||!this.quill.isEnabled())return;t.preventDefault();const e=this.quill.getSelection(!0);if(e==null)return;const r=t.clipboardData?.getData("text/html");let s=t.clipboardData?.getData("text/plain");if(!r&&!s){const l=t.clipboardData?.getData("text/uri-list");l&&(s=this.normalizeURIList(l))}const i=Array.from(t.clipboardData?.files||[]);if(!r&&i.length>0){this.quill.uploader.upload(e,i);return}if(r&&i.length>0){const l=new DOMParser().parseFromString(r,"text/html");if(l.body.childElementCount===1&&l.body.firstElementChild?.tagName==="IMG"){this.quill.uploader.upload(e,i);return}}this.onPaste(e,{html:r,text:s})}onCopy(t){const e=this.quill.getText(t);return{html:this.quill.getSemanticHTML(t),text:e}}onPaste(t,e){let{text:r,html:s}=e;const i=this.quill.getFormat(t.index),l=this.convert({text:r,html:s},i);Pd.log("onPaste",l,{text:r,html:s});const a=new O().retain(t.index).delete(t.length).concat(l);this.quill.updateContents(a,N.sources.USER),this.quill.setSelection(a.length()-t.length,N.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(t,e){const r=[],s=[];return this.matchers.forEach(i=>{const[l,a]=i;switch(l){case Node.TEXT_NODE:s.push(a);break;case Node.ELEMENT_NODE:r.push(a);break;default:Array.from(t.querySelectorAll(l)).forEach(c=>{e.has(c)?e.get(c)?.push(a):e.set(c,[a])});break}}),[r,s]}}x(Fo,"DEFAULTS",{matchers:[]});function we(n,t,e,r){return r.query(t)?n.reduce((s,i)=>{if(!i.insert)return s;if(i.attributes&&i.attributes[t])return s.push(i);const l=e?{[t]:e}:{};return s.insert(i.insert,{...l,...i.attributes})},new O):n}function kn(n,t){let e="";for(let r=n.ops.length-1;r>=0&&e.lengthl(t,i,n),new O):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((i,l)=>{let a=Di(n,l,e,r,s);return l.nodeType===t.ELEMENT_NODE&&(a=e.reduce((c,h)=>h(l,c,n),a),a=(s.get(l)||[]).reduce((c,h)=>h(l,c,n),a)),i.concat(a)},new O):new O}function Ks(n){return(t,e,r)=>we(e,n,!0,r)}function Hd(n,t,e){const r=It.keys(n),s=Nt.keys(n),i=re.keys(n),l={};return r.concat(s).concat(i).forEach(a=>{let c=e.query(a,C.ATTRIBUTE);c!=null&&(l[c.attrName]=c.value(n),l[c.attrName])||(c=Ud[a],c!=null&&(c.attrName===a||c.keyName===a)&&(l[c.attrName]=c.value(n)||void 0),c=Il[a],c!=null&&(c.attrName===a||c.keyName===a)&&(c=Il[a],l[c.attrName]=c.value(n)||void 0))}),Object.entries(l).reduce((a,c)=>{let[h,f]=c;return we(a,h,f,e)},t)}function zd(n,t,e){const r=e.query(n);if(r==null)return t;if(r.prototype instanceof lt){const s={},i=r.value(n);if(i!=null)return s[r.blotName]=i,new O().insert(s,r.formats(n,e))}else if(r.prototype instanceof _n&&!kn(t,` `)&&t.insert(` `),"blotName"in r&&"formats"in r&&typeof r.formats=="function")return we(t,r.blotName,r.formats(n,e),e);return t}function Kd(n,t){return kn(t,` `)||t.insert(` `),t}function Gd(n,t,e){const r=e.query("code-block"),s=r&&"formats"in r&&typeof r.formats=="function"?r.formats(n,e):!0;return we(t,"code-block",s,e)}function Vd(){return new O}function Wd(n,t,e){const r=e.query(n);if(r==null||r.blotName!=="list"||!kn(t,` `))return t;let s=-1,i=n.parentNode;for(;i!=null;)["OL","UL"].includes(i.tagName)&&(s+=1),i=i.parentNode;return s<=0?t:t.reduce((l,a)=>a.insert?a.attributes&&typeof a.attributes.indent=="number"?l.push(a):l.insert(a.insert,{indent:s,...a.attributes||{}}):l,new O)}function Zd(n,t,e){const r=n;let s=r.tagName==="OL"?"ordered":"bullet";const i=r.getAttribute("data-checked");return i&&(s=i==="true"?"checked":"unchecked"),we(t,"list",s,e)}function Rl(n,t,e){if(!kn(t,` `)){if(Qt(n,e)&&(n.childNodes.length>0||n instanceof HTMLParagraphElement))return t.insert(` `);if(t.length()>0&&n.nextSibling){let r=n.nextSibling;for(;r!=null;){if(Qt(r,e))return t.insert(` `);const s=e.query(r);if(s&&s.prototype instanceof ht)return t.insert(` `);r=r.firstChild}}}return t}function Xd(n,t,e){const r={},s=n.style||{};return s.fontStyle==="italic"&&(r.italic=!0),s.textDecoration==="underline"&&(r.underline=!0),s.textDecoration==="line-through"&&(r.strike=!0),(s.fontWeight?.startsWith("bold")||parseInt(s.fontWeight,10)>=700)&&(r.bold=!0),t=Object.entries(r).reduce((i,l)=>{let[a,c]=l;return we(i,a,c,e)},t),parseFloat(s.textIndent||0)>0?new O().insert(" ").concat(t):t}function Yd(n,t,e){const r=n.parentElement?.tagName==="TABLE"?n.parentElement:n.parentElement?.parentElement;if(r!=null){const i=Array.from(r.querySelectorAll("tr")).indexOf(n)+1;return we(t,"table",i,e)}return t}function Qd(n,t,e){let r=n.data;if(n.parentElement?.tagName==="O:P")return t.insert(r.trim());if(!Ho(n)){if(r.trim().length===0&&r.includes(` `)&&!Fd(n,e))return t;r=r.replace(/[^\S\u00a0]/g," "),r=r.replace(/ {2,}/g," "),(n.previousSibling==null&&n.parentElement!=null&&Qt(n.parentElement,e)||n.previousSibling instanceof Element&&Qt(n.previousSibling,e))&&(r=r.replace(/^ /,"")),(n.nextSibling==null&&n.parentElement!=null&&Qt(n.parentElement,e)||n.nextSibling instanceof Element&&Qt(n.nextSibling,e))&&(r=r.replace(/ $/,"")),r=r.replaceAll(" "," ")}return t.insert(r)}class zo extends Tt{constructor(e,r){super(e,r);x(this,"lastRecorded",0);x(this,"ignoreChange",!1);x(this,"stack",{undo:[],redo:[]});x(this,"currentRange",null);this.quill.on(N.events.EDITOR_CHANGE,(s,i,l,a)=>{s===N.events.SELECTION_CHANGE?i&&a!==N.sources.SILENT&&(this.currentRange=i):s===N.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||a===N.sources.USER?this.record(i,l):this.transform(i)),this.currentRange=ui(this.currentRange,i))}),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",s=>{s.inputType==="historyUndo"?(this.undo(),s.preventDefault()):s.inputType==="historyRedo"&&(this.redo(),s.preventDefault())})}change(e,r){if(this.stack[e].length===0)return;const s=this.stack[e].pop();if(!s)return;const i=this.quill.getContents(),l=s.delta.invert(i);this.stack[r].push({delta:l,range:ui(s.range,l)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(s.delta,N.sources.USER),this.ignoreChange=!1,this.restoreSelection(s)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(e,r){if(e.ops.length===0)return;this.stack.redo=[];let s=e.invert(r),i=this.currentRange;const l=Date.now();if(this.lastRecorded+this.options.delay>l&&this.stack.undo.length>0){const a=this.stack.undo.pop();a&&(s=s.compose(a.delta),i=a.range)}else this.lastRecorded=l;s.length()!==0&&(this.stack.undo.push({delta:s,range:i}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(e){kl(this.stack.undo,e),kl(this.stack.redo,e)}undo(){this.change("undo","redo")}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,N.sources.USER);else{const r=tg(this.quill.scroll,e.delta);this.quill.setSelection(r,N.sources.USER)}}}x(zo,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1});function kl(n,t){let e=t;for(let r=n.length-1;r>=0;r-=1){const s=n[r];n[r]={delta:e.transform(s.delta,!0),range:s.range&&ui(s.range,e)},e=s.delta.transform(e),n[r].delta.length()===0&&n.splice(r,1)}}function Jd(n,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(r=>n.query(r,C.BLOCK)!=null):!1}function tg(n,t){const e=t.reduce((s,i)=>s+(i.delete||0),0);let r=t.length()-e;return Jd(n,t)&&(r-=1),r}function ui(n,t){if(!n)return n;const e=t.transformPosition(n.index),r=t.transformPosition(n.index+n.length);return{index:e,length:r-e}}class Ko extends Tt{constructor(t,e){super(t,e),t.root.addEventListener("drop",r=>{r.preventDefault();let s=null;if(document.caretRangeFromPoint)s=document.caretRangeFromPoint(r.clientX,r.clientY);else if(document.caretPositionFromPoint){const l=document.caretPositionFromPoint(r.clientX,r.clientY);s=document.createRange(),s.setStart(l.offsetNode,l.offset),s.setEnd(l.offsetNode,l.offset)}const i=s&&t.selection.normalizeNative(s);if(i){const l=t.selection.normalizedToRange(i);r.dataTransfer?.files&&this.upload(l,r.dataTransfer.files)}})}upload(t,e){const r=[];Array.from(e).forEach(s=>{s&&this.options.mimetypes?.includes(s.type)&&r.push(s)}),r.length>0&&this.options.handler.call(this,t,r)}}Ko.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(n,t){if(!this.quill.scroll.query("image"))return;const e=t.map(r=>new Promise(s=>{const i=new FileReader;i.onload=()=>{s(i.result)},i.readAsDataURL(r)}));Promise.all(e).then(r=>{const s=r.reduce((i,l)=>i.insert({image:l}),new O().retain(n.index).delete(n.length));this.quill.updateContents(s,S.sources.USER),this.quill.setSelection(n.index+r.length,S.sources.SILENT)})}};const eg=["insertText","insertReplacementText"];class ng extends Tt{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",r=>{this.handleBeforeInput(r)}),/Android/i.test(navigator.userAgent)||t.on(N.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(t){Mi({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 r=this.quill.getFormat(t.index,1);this.deleteRange(t),this.quill.updateContents(new O().retain(t.index).insert(e,r),N.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,N.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!eg.includes(t.inputType))return;const e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||e.collapsed===!0)return;const r=rg(t);if(r==null)return;const s=this.quill.selection.normalizeNative(e),i=s?this.quill.selection.normalizedToRange(s):null;i&&this.replaceText(i,r)&&t.preventDefault()}handleCompositionStart(){const t=this.quill.getSelection();t&&this.replaceText(t)}}function rg(n){return typeof n.data=="string"?n.data:n.dataTransfer?.types.includes("text/plain")?n.dataTransfer.getData("text/plain"):null}const sg=/Mac/i.test(navigator.platform),ig=100,lg=n=>!!(n.key==="ArrowLeft"||n.key==="ArrowRight"||n.key==="ArrowUp"||n.key==="ArrowDown"||n.key==="Home"||sg&&n.key==="a"&&n.ctrlKey===!0);class og extends Tt{constructor(e,r){super(e,r);x(this,"isListening",!1);x(this,"selectionChangeDeadline",0);this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(e,r){let{line:s,event:i}=r;if(!(s instanceof Et)||!s.uiNode)return!0;const l=getComputedStyle(s.domNode).direction==="rtl";return l&&i.key!=="ArrowRight"||!l&&i.key!=="ArrowLeft"?!0:(this.quill.setSelection(e.index-1,e.length+(i.shiftKey?1:0),N.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",e=>{!e.defaultPrevented&&lg(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+ig,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 r=e.getRangeAt(0);if(r.collapsed!==!0||r.startOffset!==0)return;const s=this.quill.scroll.find(r.startContainer);if(!(s instanceof Et)||!s.uiNode)return;const i=document.createRange();i.setStartAfter(s.uiNode),i.setEndAfter(s.uiNode),e.removeAllRanges(),e.addRange(i)}}N.register({"blots/block":W,"blots/block/embed":ht,"blots/break":wt,"blots/container":Ae,"blots/cursor":Ve,"blots/embed":Ci,"blots/inline":Rt,"blots/scroll":$e,"blots/text":At,"modules/clipboard":Fo,"modules/history":zo,"modules/keyboard":Mr,"modules/uploader":Ko,"modules/input":ng,"modules/uiNode":og});class ag extends Nt{add(t,e){let r=0;if(e==="+1"||e==="-1"){const s=this.value(t)||0;r=e==="+1"?s+1:s-1}else typeof e=="number"&&(r=e);return r===0?(this.remove(t),!0):super.add(t,r.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 cg=new ag("indent","ql-indent",{scope:C.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});class hi extends W{}x(hi,"blotName","blockquote"),x(hi,"tagName","blockquote");class fi extends W{static formats(t){return this.tagName.indexOf(t.tagName)+1}}x(fi,"blotName","header"),x(fi,"tagName",["H1","H2","H3","H4","H5","H6"]);class Bn extends Ae{}Bn.blotName="list-container";Bn.tagName="OL";class Mn extends W{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(){N.register(Bn)}constructor(t,e){super(t,e);const r=e.ownerDocument.createElement("span"),s=i=>{if(!t.isEnabled())return;const l=this.statics.formats(e,t);l==="checked"?(this.format("list","unchecked"),i.preventDefault()):l==="unchecked"&&(this.format("list","checked"),i.preventDefault())};r.addEventListener("mousedown",s),r.addEventListener("touchstart",s),this.attachUI(r)}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-list",e):super.format(t,e)}}Mn.blotName="list";Mn.tagName="LI";Bn.allowedChildren=[Mn];Mn.requiredContainer=Bn;class qn extends Rt{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)}}x(qn,"blotName","bold"),x(qn,"tagName",["STRONG","B"]);class di extends qn{}x(di,"blotName","italic"),x(di,"tagName",["EM","I"]);class Jt extends Rt{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 Go(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))}}x(Jt,"blotName","link"),x(Jt,"tagName","A"),x(Jt,"SANITIZED_URL","about:blank"),x(Jt,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"]);function Go(n,t){const e=document.createElement("a");e.href=n;const r=e.href.slice(0,e.href.indexOf(":"));return t.indexOf(r)>-1}class gi extends Rt{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"}}x(gi,"blotName","script"),x(gi,"tagName",["SUB","SUP"]);class pi extends qn{}x(pi,"blotName","strike"),x(pi,"tagName",["S","STRIKE"]);class mi extends Rt{}x(mi,"blotName","underline"),x(mi,"tagName","U");class vr extends Ci{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`${t}`}}x(vr,"blotName","formula"),x(vr,"className","ql-formula"),x(vr,"tagName","SPAN");const Bl=["alt","height","width"];class bi extends lt{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Bl.reduce((e,r)=>(t.hasAttribute(r)&&(e[r]=t.getAttribute(r)),e),{})}static match(t){return/\.(jpe?g|gif|png)$/.test(t)||/^data:image\/.+;base64/.test(t)}static sanitize(t){return Go(t,["http","https","data"])?t:"//:0"}static value(t){return t.getAttribute("src")}format(t,e){Bl.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}}x(bi,"blotName","image"),x(bi,"tagName","IMG");const Ml=["height","width"];class Er extends ht{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 Ml.reduce((e,r)=>(t.hasAttribute(r)&&(e[r]=t.getAttribute(r)),e),{})}static sanitize(t){return Jt.sanitize(t)}static value(t){return t.getAttribute("src")}format(t,e){Ml.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}html(){const{video:t}=this.value();return`${t}`}}x(Er,"blotName","video"),x(Er,"className","ql-video"),x(Er,"tagName","IFRAME");const vn=new Nt("code-token","hljs",{scope:C.INLINE});class Ft extends Rt{static formats(t,e){for(;t!=null&&t!==e.domNode;){if(t.classList&&t.classList.contains(J.className))return super.formats(t,e);t=t.parentNode}}constructor(t,e,r){super(t,e,r),vn.add(this.domNode,r)}format(t,e){t!==Ft.blotName?super.format(t,e):e?vn.add(this.domNode,e):(vn.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),vn.value(this.domNode)||this.unwrap()}}Ft.blotName="code-token";Ft.className="ql-token";class ut extends J{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(),Ft.blotName,!1),super.replaceWith(t,e)}}class Nn extends Ne{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(t,e){t===ut.blotName&&(this.forceNext=!0,this.children.forEach(r=>{r.format(t,e)}))}formatAt(t,e,r,s){r===ut.blotName&&(this.forceNext=!0),super.formatAt(t,e,r,s)}highlight(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;const s=`${Array.from(this.domNode.childNodes).filter(l=>l!==this.uiNode).map(l=>l.textContent).join(` `)} `,i=ut.formats(this.children.head.domNode);if(e||this.forceNext||this.cachedText!==s){if(s.trim().length>0||this.cachedText==null){const l=this.children.reduce((c,h)=>c.concat(_o(h,!1)),new O),a=t(s,i);l.diff(a).reduce((c,h)=>{let{retain:f,attributes:b}=h;return f?(b&&Object.keys(b).forEach(g=>{[ut.blotName,Ft.blotName].includes(g)&&this.formatAt(c,f,g,b[g])}),c+f):c},0)}this.cachedText=s,this.forceNext=!1}}html(t,e){const[r]=this.children.find(t);return`
    ${Br(this.code(t,e))}
    
    `}optimize(t){if(super.optimize(t),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){const e=ut.formats(this.children.head.domNode);e!==this.uiNode.value&&(this.uiNode.value=e)}}}Nn.allowedChildren=[ut];ut.requiredContainer=Nn;ut.allowedChildren=[Ft,Ve,At,wt];const ug=(n,t,e)=>{if(typeof n.versionString=="string"){const r=n.versionString.split(".")[0];if(parseInt(r,10)>=11)return n.highlight(e,{language:t}).value}return n.highlight(t,e).value};class Vo extends Tt{static register(){N.register(Ft,!0),N.register(ut,!0),N.register(Nn,!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((r,s)=>{let{key:i}=s;return r[i]=!0,r},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(N.events.SCROLL_BLOT_MOUNT,t=>{if(!(t instanceof Nn))return;const e=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(r=>{let{key:s,label:i}=r;const l=e.ownerDocument.createElement("option");l.textContent=i,l.setAttribute("value",s),e.appendChild(l)}),e.addEventListener("change",()=>{t.format(ut.blotName,e.value),this.quill.root.focus(),this.highlight(t,!0)}),t.uiNode==null&&(t.attachUI(e),t.children.head&&(e.value=ut.formats(t.children.head.domNode)))})}initTimer(){let t=null;this.quill.on(N.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(N.sources.USER);const r=this.quill.getSelection();(t==null?this.quill.scroll.descendants(Nn):[t]).forEach(i=>{i.highlight(this.highlightBlot,e)}),this.quill.update(N.sources.SILENT),r!=null&&this.quill.setSelection(r,N.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 Br(t).split(` `).reduce((s,i,l)=>(l!==0&&s.insert(` `,{[J.blotName]:e}),s.insert(i)),new O);const r=this.quill.root.ownerDocument.createElement("div");return r.classList.add(J.className),r.innerHTML=ug(this.options.hljs,e,t),Di(this.quill.scroll,r,[(s,i)=>{const l=vn.value(s);return l?i.compose(new O().retain(i.length(),{[Ft.blotName]:l})):i}],[(s,i)=>s.data.split(` `).reduce((l,a,c)=>(c!==0&&l.insert(` `,{[J.blotName]:e}),l.insert(a)),i)],new WeakMap)}}Vo.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 Tn=class Tn extends W{static create(t){const e=super.create();return t?e.setAttribute("data-row",t):e.setAttribute("data-row",ji()),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===Tn.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()}};x(Tn,"blotName","table"),x(Tn,"tagName","TD");let vt=Tn;class Ht extends Ae{checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){const t=this.children.head.formats(),e=this.children.tail.formats(),r=this.next.children.head.formats(),s=this.next.children.tail.formats();return t.table===e.table&&t.table===r.table&&t.table===s.table}return!1}optimize(t){super.optimize(t),this.children.forEach(e=>{if(e.next==null)return;const r=e.formats(),s=e.next.formats();if(r.table!==s.table){const i=this.splitAfter(e);i&&i.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}x(Ht,"blotName","table-row"),x(Ht,"tagName","TR");class qt extends Ae{}x(qt,"blotName","table-body"),x(qt,"tagName","TBODY");class Ze extends Ae{balanceCells(){const t=this.descendants(Ht),e=t.reduce((r,s)=>Math.max(s.children.length,r),0);t.forEach(r=>{new Array(e-r.children.length).fill(0).forEach(()=>{let s;r.children.head!=null&&(s=vt.formats(r.children.head.domNode));const i=this.scroll.create(vt.blotName,s);r.appendChild(i),i.optimize()})})}cells(t){return this.rows().map(e=>e.children.at(t))}deleteColumn(t){const[e]=this.descendant(qt);e==null||e.children.head==null||e.children.forEach(r=>{const s=r.children.at(t);s?.remove()})}insertColumn(t){const[e]=this.descendant(qt);e==null||e.children.head==null||e.children.forEach(r=>{const s=r.children.at(t),i=vt.formats(r.children.head.domNode),l=this.scroll.create(vt.blotName,i);r.insertBefore(l,s)})}insertRow(t){const[e]=this.descendant(qt);if(e==null||e.children.head==null)return;const r=ji(),s=this.scroll.create(Ht.blotName);e.children.head.children.forEach(()=>{const l=this.scroll.create(vt.blotName,r);s.appendChild(l)});const i=e.children.at(t);e.insertBefore(s,i)}rows(){const t=this.children.head;return t==null?[]:t.children.map(e=>e)}}x(Ze,"blotName","table-container"),x(Ze,"tagName","TABLE");Ze.allowedChildren=[qt];qt.requiredContainer=Ze;qt.allowedChildren=[Ht];Ht.requiredContainer=qt;Ht.allowedChildren=[vt];vt.requiredContainer=Ht;function ji(){return`row-${Math.random().toString(36).slice(2,6)}`}class hg extends Tt{static register(){N.register(vt),N.register(Ht),N.register(qt),N.register(Ze)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(Ze).forEach(t=>{t.balanceCells()})}deleteColumn(){const[t,,e]=this.getTable();e!=null&&(t.deleteColumn(e.cellOffset()),this.quill.update(N.sources.USER))}deleteRow(){const[,t]=this.getTable();t!=null&&(t.remove(),this.quill.update(N.sources.USER))}deleteTable(){const[t]=this.getTable();if(t==null)return;const e=t.offset();t.remove(),this.quill.update(N.sources.USER),this.quill.setSelection(e,N.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,r]=this.quill.getLine(t.index);if(e==null||e.statics.blotName!==vt.blotName)return[null,null,null,-1];const s=e.parent;return[s.parent.parent,s,e,r]}insertColumn(t){const e=this.quill.getSelection();if(!e)return;const[r,s,i]=this.getTable(e);if(i==null)return;const l=i.cellOffset();r.insertColumn(l+t),this.quill.update(N.sources.USER);let a=s.rowOffset();t===0&&(a+=1),this.quill.setSelection(e.index+a,e.length,N.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(t){const e=this.quill.getSelection();if(!e)return;const[r,s,i]=this.getTable(e);if(i==null)return;const l=s.rowOffset();r.insertRow(l+t),this.quill.update(N.sources.USER),t>0?this.quill.setSelection(e,N.sources.SILENT):this.quill.setSelection(e.index+s.children.length,e.length,N.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(t,e){const r=this.quill.getSelection();if(r==null)return;const s=new Array(t).fill(0).reduce(i=>{const l=new Array(e).fill(` `).join("");return i.insert(l,{table:ji()})},new O().retain(r.index));this.quill.updateContents(s,N.sources.USER),this.quill.setSelection(r.index,N.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(N.events.SCROLL_OPTIMIZE,t=>{t.some(e=>["TD","TR","TBODY","TABLE"].includes(e.target.tagName)?(this.quill.once(N.events.TEXT_CHANGE,(r,s,i)=>{i===N.sources.USER&&this.balanceTables()}),!0):!1)})}}const Dl=Kt("quill:toolbar");class Pi extends Tt{constructor(t,e){if(super(t,e),Array.isArray(this.options.container)){const r=document.createElement("div");r.setAttribute("role","toolbar"),fg(r,this.options.container),t.container?.parentNode?.insertBefore(r,t.container),this.container=r}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){Dl.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(r=>{const s=this.options.handlers?.[r];s&&this.addHandler(r,s)}),Array.from(this.container.querySelectorAll("button, select")).forEach(r=>{this.attach(r)}),this.quill.on(N.events.EDITOR_CHANGE,()=>{const[r]=this.quill.selection.getRange();this.update(r)})}addHandler(t,e){this.handlers[t]=e}attach(t){let e=Array.from(t.classList).find(s=>s.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){Dl.warn("ignoring attaching to nonexistent format",e,t);return}const r=t.tagName==="SELECT"?"change":"click";t.addEventListener(r,s=>{let i;if(t.tagName==="SELECT"){if(t.selectedIndex<0)return;const a=t.options[t.selectedIndex];a.hasAttribute("selected")?i=!1:i=a.value||!1}else t.classList.contains("ql-active")?i=!1:i=t.value||!t.hasAttribute("value"),s.preventDefault();this.quill.focus();const[l]=this.quill.selection.getRange();if(this.handlers[e]!=null)this.handlers[e].call(this,i);else if(this.quill.scroll.query(e).prototype instanceof lt){if(i=prompt(`Enter ${e}`),!i)return;this.quill.updateContents(new O().retain(l.index).delete(l.length).insert({[e]:i}),N.sources.USER)}else this.quill.format(e,i,N.sources.USER);this.update(l)}),this.controls.push([e,t])}update(t){const e=t==null?{}:this.quill.getFormat(t);this.controls.forEach(r=>{const[s,i]=r;if(i.tagName==="SELECT"){let l=null;if(t==null)l=null;else if(e[s]==null)l=i.querySelector("option[selected]");else if(!Array.isArray(e[s])){let a=e[s];typeof a=="string"&&(a=a.replace(/"/g,'\\"')),l=i.querySelector(`option[value="${a}"]`)}l==null?(i.value="",i.selectedIndex=-1):l.selected=!0}else if(t==null)i.classList.remove("ql-active"),i.setAttribute("aria-pressed","false");else if(i.hasAttribute("value")){const l=e[s],a=l===i.getAttribute("value")||l!=null&&l.toString()===i.getAttribute("value")||l==null&&!i.getAttribute("value");i.classList.toggle("ql-active",a),i.setAttribute("aria-pressed",a.toString())}else{const l=e[s]!=null;i.classList.toggle("ql-active",l),i.setAttribute("aria-pressed",l.toString())}})}}Pi.DEFAULTS={};function jl(n,t,e){const r=document.createElement("button");r.setAttribute("type","button"),r.classList.add(`ql-${t}`),r.setAttribute("aria-pressed","false"),e!=null?(r.value=e,r.setAttribute("aria-label",`${t}: ${e}`)):r.setAttribute("aria-label",t),n.appendChild(r)}function fg(n,t){Array.isArray(t[0])||(t=[t]),t.forEach(e=>{const r=document.createElement("span");r.classList.add("ql-formats"),e.forEach(s=>{if(typeof s=="string")jl(r,s);else{const i=Object.keys(s)[0],l=s[i];Array.isArray(l)?dg(r,i,l):jl(r,i,l)}}),n.appendChild(r)})}function dg(n,t,e){const r=document.createElement("select");r.classList.add(`ql-${t}`),e.forEach(s=>{const i=document.createElement("option");s!==!1?i.setAttribute("value",String(s)):i.setAttribute("selected","selected"),r.appendChild(i)}),n.appendChild(r)}Pi.DEFAULTS={container:null,handlers:{clean(){const n=this.quill.getSelection();if(n!=null)if(n.length===0){const t=this.quill.getFormat();Object.keys(t).forEach(e=>{this.quill.scroll.query(e,C.INLINE)!=null&&this.quill.format(e,!1,N.sources.USER)})}else this.quill.removeFormat(n.index,n.length,N.sources.USER)},direction(n){const{align:t}=this.quill.getFormat();n==="rtl"&&t==null?this.quill.format("align","right",N.sources.USER):!n&&t==="right"&&this.quill.format("align",!1,N.sources.USER),this.quill.format("direction",n,N.sources.USER)},indent(n){const t=this.quill.getSelection(),e=this.quill.getFormat(t),r=parseInt(e.indent||0,10);if(n==="+1"||n==="-1"){let s=n==="+1"?1:-1;e.direction==="rtl"&&(s*=-1),this.quill.format("indent",r+s,N.sources.USER)}},link(n){n===!0&&(n=prompt("Enter link URL:")),this.quill.format("link",n,N.sources.USER)},list(n){const t=this.quill.getSelection(),e=this.quill.getFormat(t);n==="check"?e.list==="checked"||e.list==="unchecked"?this.quill.format("list",!1,N.sources.USER):this.quill.format("list","unchecked",N.sources.USER):this.quill.format("list",n,N.sources.USER)}}};const gg='',pg='',mg='',bg='',yg='',vg='',Eg='',Ag='',Pl='',Ng='',wg='',Tg='',xg='',Lg='',Sg='',_g='',Og='',Cg='',qg='',Ig='',Rg='',kg='',Bg='',Mg='',Dg='',jg='',Pg='',$g='',Ug='',Fg='',Hg='',zg='',Kg='',In={align:{"":gg,center:pg,right:mg,justify:bg},background:yg,blockquote:vg,bold:Eg,clean:Ag,code:Pl,"code-block":Pl,color:Ng,direction:{"":wg,rtl:Tg},formula:xg,header:{1:Lg,2:Sg,3:_g,4:Og,5:Cg,6:qg},italic:Ig,image:Rg,indent:{"+1":kg,"-1":Bg},link:Mg,list:{bullet:Dg,check:jg,ordered:Pg},script:{sub:$g,super:Ug},strike:Fg,table:Hg,underline:zg,video:Kg},Gg='';let $l=0;function Ul(n,t){n.setAttribute(t,`${n.getAttribute(t)!=="true"}`)}class Dr{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"),Ul(this.label,"aria-expanded"),Ul(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 r=t.getAttribute("value");return r&&e.setAttribute("data-value",r),t.textContent&&e.setAttribute("data-label",t.textContent),e.addEventListener("click",()=>{this.selectItem(e,!0)}),e.addEventListener("keydown",s=>{switch(s.key){case"Enter":this.selectItem(e,!0),s.preventDefault();break;case"Escape":this.escape(),s.preventDefault();break}}),e}buildLabel(){const t=document.createElement("span");return t.classList.add("ql-picker-label"),t.innerHTML=Gg,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-${$l}`,$l+=1,this.label.setAttribute("aria-controls",t.id),this.options=t,Array.from(this.select.options).forEach(e=>{const r=this.buildItem(e);t.appendChild(r),e.selected===!0&&this.selectItem(r)}),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 r=this.container.querySelector(".ql-selected");t!==r&&(r?.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 r=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];t=this.select.options[this.select.selectedIndex],this.selectItem(r)}else this.selectItem(null);const e=t!=null&&t!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",e)}}class Wo extends Dr{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(r=>{r.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 r=this.label.querySelector(".ql-color-label"),s=t&&t.getAttribute("data-value")||"";r&&(r.tagName==="line"?r.style.stroke=s:r.style.fill=s)}}class Zo extends Dr{constructor(t,e){super(t),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(r=>{r.innerHTML=e[r.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(t,e){super.selectItem(t,e);const r=t||this.defaultItem;if(r!=null){if(this.label.innerHTML===r.innerHTML)return;this.label.innerHTML=r.innerHTML}}}const Vg=n=>{const{overflowY:t}=getComputedStyle(n,null);return t!=="visible"&&t!=="clip"};class Xo{constructor(t,e){this.quill=t,this.boundsContainer=e||document.body,this.root=t.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,Vg(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,r=t.bottom+this.quill.root.scrollTop;this.root.style.left=`${e}px`,this.root.style.top=`${r}px`,this.root.classList.remove("ql-flip");const s=this.boundsContainer.getBoundingClientRect(),i=this.root.getBoundingClientRect();let l=0;if(i.right>s.right&&(l=s.right-i.right,this.root.style.left=`${e+l}px`),i.lefts.bottom){const a=i.bottom-i.top,c=t.bottom-t.top+a;this.root.style.top=`${r-c}px`,this.root.classList.add("ql-flip")}return l}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}const Wg=[!1,"center","right","justify"],Zg=["#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"],Xg=[!1,"serif","monospace"],Yg=["1","2","3",!1],Qg=["small",!1,"large","huge"];class Dn extends We{constructor(t,e){super(t,e);const r=s=>{if(!document.body.contains(t.root)){document.body.removeEventListener("click",r);return}this.tooltip!=null&&!this.tooltip.root.contains(s.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(i=>{i.container.contains(s.target)||i.close()})};t.emitter.listenDOM("click",document.body,r)}addModule(t){const e=super.addModule(t);return t==="toolbar"&&this.extendToolbar(e),e}buildButtons(t,e){Array.from(t).forEach(r=>{(r.getAttribute("class")||"").split(/\s+/).forEach(i=>{if(i.startsWith("ql-")&&(i=i.slice(3),e[i]!=null))if(i==="direction")r.innerHTML=e[i][""]+e[i].rtl;else if(typeof e[i]=="string")r.innerHTML=e[i];else{const l=r.value||"";l!=null&&e[i][l]&&(r.innerHTML=e[i][l])}})})}buildPickers(t,e){this.pickers=Array.from(t).map(s=>{if(s.classList.contains("ql-align")&&(s.querySelector("option")==null&&yn(s,Wg),typeof e.align=="object"))return new Zo(s,e.align);if(s.classList.contains("ql-background")||s.classList.contains("ql-color")){const i=s.classList.contains("ql-background")?"background":"color";return s.querySelector("option")==null&&yn(s,Zg,i==="background"?"#ffffff":"#000000"),new Wo(s,e[i])}return s.querySelector("option")==null&&(s.classList.contains("ql-font")?yn(s,Xg):s.classList.contains("ql-header")?yn(s,Yg):s.classList.contains("ql-size")&&yn(s,Qg)),new Dr(s)});const r=()=>{this.pickers.forEach(s=>{s.update()})};this.quill.on(S.events.EDITOR_CHANGE,r)}}Dn.DEFAULTS=te({},We.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let n=this.container.querySelector("input.ql-image[type=file]");n==null&&(n=document.createElement("input"),n.setAttribute("type","file"),n.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),n.classList.add("ql-image"),n.addEventListener("change",()=>{const t=this.quill.getSelection(!0);this.quill.uploader.upload(t,n.files),n.value=""}),this.container.appendChild(n)),n.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});class Yo extends Xo{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 r=this.quill.getBounds(this.quill.selection.savedRange);r!=null&&this.position(r),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${t}`)||""),this.root.setAttribute("data-mode",t)}restoreFocus(){this.quill.focus({preventScroll:!0})}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,S.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",t,S.sources.USER)),this.quill.root.scrollTop=e;break}case"video":t=Jg(t);case"formula":{if(!t)break;const e=this.quill.getSelection(!0);if(e!=null){const r=e.index+e.length;this.quill.insertEmbed(r,this.root.getAttribute("data-mode"),t,S.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(r+1," ",S.sources.USER),this.quill.setSelection(r+2,S.sources.USER)}break}}this.textbox.value="",this.hide()}}function Jg(n){let t=n.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||n.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return t?`${t[1]||"https"}://www.youtube.com/embed/${t[2]}?showinfo=0`:(t=n.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${t[1]||"https"}://player.vimeo.com/video/${t[2]}/`:n}function yn(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t.forEach(r=>{const s=document.createElement("option");r===e?s.setAttribute("selected","selected"):s.setAttribute("value",String(r)),n.appendChild(s)})}const tp=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]];class Qo extends Yo{constructor(t,e){super(t,e),this.quill.on(S.events.EDITOR_CHANGE,(r,s,i,l)=>{if(r===S.events.SELECTION_CHANGE)if(s!=null&&s.length>0&&l===S.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;const a=this.quill.getLines(s.index,s.length);if(a.length===1){const c=this.quill.getBounds(s);c!=null&&this.position(c)}else{const c=a[a.length-1],h=this.quill.getIndex(c),f=Math.min(c.length()-1,s.index+s.length-h),b=this.quill.getBounds(new be(h,f));b!=null&&this.position(b)}}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(S.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),r=this.root.querySelector(".ql-tooltip-arrow");return r.style.marginLeft="",e!==0&&(r.style.marginLeft=`${-1*e-r.offsetWidth/2}px`),e}}x(Qo,"TEMPLATE",['','
    ','','',"
    "].join(""));class Jo extends Dn{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=tp),super(t,e),this.quill.container.classList.add("ql-bubble")}extendToolbar(t){this.tooltip=new Qo(this.quill,this.options.bounds),t.container!=null&&(this.tooltip.root.appendChild(t.container),this.buildButtons(t.container.querySelectorAll("button"),In),this.buildPickers(t.container.querySelectorAll("select"),In))}}Jo.DEFAULTS=te({},Dn.DEFAULTS,{modules:{toolbar:{handlers:{link(n){n?this.quill.theme.tooltip.edit():this.quill.format("link",!1,N.sources.USER)}}}}});const ep=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]];class ta extends Yo{constructor(){super(...arguments);x(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 r=this.linkRange;this.restoreFocus(),this.quill.formatText(r,"link",!1,S.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(S.events.SELECTION_CHANGE,(e,r,s)=>{if(e!=null){if(e.length===0&&s===S.sources.USER){const[i,l]=this.quill.scroll.descendant(Jt,e.index);if(i!=null){this.linkRange=new be(e.index-l,i.length());const a=Jt.formats(i.domNode);this.preview.textContent=a,this.preview.setAttribute("href",a),this.show();const c=this.quill.getBounds(this.linkRange);c!=null&&this.position(c);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}}x(ta,"TEMPLATE",['','','',''].join(""));class ea extends Dn{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=ep),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"),In),this.buildPickers(t.container.querySelectorAll("select"),In),this.tooltip=new ta(this.quill,this.options.bounds),t.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(e,r)=>{t.handlers.link.call(t,!r.format.link)}))}}ea.DEFAULTS=te({},Dn.DEFAULTS,{modules:{toolbar:{handlers:{link(n){if(n){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:r}=this.quill.theme;r.edit("link",e)}else this.quill.format("link",!1,N.sources.USER)}}}}});N.register({"attributors/attribute/direction":ko,"attributors/class/align":qo,"attributors/class/background":vd,"attributors/class/color":yd,"attributors/class/direction":Bo,"attributors/class/font":jo,"attributors/class/size":$o,"attributors/style/align":Io,"attributors/style/background":Ri,"attributors/style/color":Ii,"attributors/style/direction":Mo,"attributors/style/font":Po,"attributors/style/size":Uo},!0);N.register({"formats/align":qo,"formats/direction":Bo,"formats/indent":cg,"formats/background":Ri,"formats/color":Ii,"formats/font":jo,"formats/size":$o,"formats/blockquote":hi,"formats/code-block":J,"formats/header":fi,"formats/list":Mn,"formats/bold":qn,"formats/code":ki,"formats/italic":di,"formats/link":Jt,"formats/script":gi,"formats/strike":pi,"formats/underline":mi,"formats/formula":vr,"formats/image":bi,"formats/video":Er,"modules/syntax":Vo,"modules/table":hg,"modules/toolbar":Pi,"themes/bubble":Jo,"themes/snow":ea,"ui/icons":In,"ui/picker":Dr,"ui/icon-picker":Zo,"ui/color-picker":Wo,"ui/tooltip":Xo},!0);var jr=class extends de.Component{constructor(n){super(n),this.editingAreaRef=Ue.createRef(),this.containerRef=Ue.createRef(),this.dirtyProps=["modules","formats","bounds","theme","children"],this.cleanProps=["id","className","style","placeholder","tabIndex","onChange","onChangeSelection","onFocus","onBlur","onKeyPress","onKeyDown","onKeyUp","useSemanticHTML"],this.state={generation:0},this.selection=null,this.onEditorChange=(e,r,s,i)=>{e==="text-change"?this.onEditorChangeText?.(this.props.useSemanticHTML!==!1?this.editor.getSemanticHTML():this.editor.root.innerHTML,r,i,this.unprivilegedEditor):e==="selection-change"&&this.onEditorChangeSelection?.(r,i,this.unprivilegedEditor)};const t=this.isControlled()?n.value:n.defaultValue;this.value=t??""}validateProps(n){if(de.Children.count(n.children)>1)throw new Error("The Quill editing area can only be composed of a single React element.");if(de.Children.count(n.children)&&de.Children.only(n.children)?.type==="textarea")throw new Error("Quill does not support editing on a