import{a as L,b as Ut,c as Xs,d as Ft,e as jc,f as ot}from"./chunk-DAQOROHW.js";var al=Ft((A2,ol)=>{"use strict";var at=-1,Z=1,P=0;function cr(r,t,e,s,n){if(r===t)return r?[[P,r]]:[];if(e!=null){var i=_g(r,t,e);if(i)return i}var o=dn(r,t),a=r.substring(0,o);r=r.substring(o),t=t.substring(o),o=is(r,t);var l=r.substring(r.length-o);r=r.substring(0,r.length-o),t=t.substring(0,t.length-o);var u=Eg(r,t);return a&&u.unshift([P,a]),l&&u.push([P,l]),pn(u,n),s&&wg(u),u}function Eg(r,t){var e;if(!r)return[[Z,t]];if(!t)return[[at,r]];var s=r.length>t.length?r:t,n=r.length>t.length?t:r,i=s.indexOf(n);if(i!==-1)return e=[[Z,s.substring(0,i)],[P,n],[Z,s.substring(i+n.length)]],r.length>t.length&&(e[0][0]=e[2][0]=at),e;if(n.length===1)return[[at,r],[Z,t]];var o=Ng(r,t);if(o){var a=o[0],l=o[1],u=o[2],c=o[3],f=o[4],h=cr(a,u),p=cr(l,c);return h.concat([[P,f]],p)}return Tg(r,t)}function Tg(r,t){for(var e=r.length,s=t.length,n=Math.ceil((e+s)/2),i=n,o=2*n,a=new Array(o),l=new Array(o),u=0;ue)p+=2;else if(T>s)h+=2;else if(f){var N=i+c-g;if(N>=0&&N=_)return Qa(r,t,E,T)}}}for(var Y=-v+m;Y<=v-y;Y+=2){var N=i+Y,_;Y===-v||Y!==v&&l[N-1]e)y+=2;else if(mt>s)m+=2;else if(!f){var A=i+c-Y;if(A>=0&&A=_)return Qa(r,t,E,T)}}}}return[[at,r],[Z,t]]}function Qa(r,t,e,s){var n=r.substring(0,e),i=t.substring(0,s),o=r.substring(e),a=t.substring(s),l=cr(n,i),u=cr(o,a);return l.concat(u)}function dn(r,t){if(!r||!t||r.charAt(0)!==t.charAt(0))return 0;for(var e=0,s=Math.min(r.length,t.length),n=s,i=0;es?r=r.substring(e-s):et.length?r:t,s=r.length>t.length?t:r;if(e.length<4||s.length*2=p.length?[E,T,N,_,A]:null}var i=n(e,s,Math.ceil(e.length/4)),o=n(e,s,Math.ceil(e.length/2)),a;if(!i&&!o)return null;o?i?a=i[4].length>o[4].length?i:o:a=o:a=i;var l,u,c,f;r.length>t.length?(l=a[0],u=a[1],c=a[2],f=a[3]):(c=a[0],f=a[1],l=a[2],u=a[3]);var h=a[4];return[l,u,c,f,h]}function wg(r){for(var t=!1,e=[],s=0,n=null,i=0,o=0,a=0,l=0,u=0;i0?e[s-1]:-1,o=0,a=0,l=0,u=0,n=null,t=!0)),i++;for(t&&pn(r),Og(r),i=1;i=p?(h>=c.length/2||h>=f.length/2)&&(r.splice(i,0,[P,f.substring(0,h)]),r[i-1][1]=c.substring(0,c.length-h),r[i+1][1]=f.substring(h),i++):(p>=c.length/2||p>=f.length/2)&&(r.splice(i,0,[P,c.substring(0,p)]),r[i-1][0]=Z,r[i-1][1]=f.substring(0,f.length-p),r[i+1][0]=at,r[i+1][1]=c.substring(p),i++),i++}i++}}var Ja=/[^a-zA-Z0-9]/,tl=/\s/,el=/[\r\n]/,Sg=/\n\r?\n$/,Lg=/^\r?\n\r?\n/;function Og(r){function t(p,m){if(!p||!m)return 6;var y=p.charAt(p.length-1),v=m.charAt(0),g=y.match(Ja),A=v.match(Ja),E=g&&y.match(tl),T=A&&v.match(tl),N=E&&y.match(el),_=T&&v.match(el),Y=N&&p.match(Sg),mt=_&&m.match(Lg);return Y||mt?5:N||_?4:g&&!E&&T?3:E||T?2:g||A?1:0}for(var e=1;e=f&&(f=h,l=s,u=n,c=i)}r[e-1][1]!=l&&(l?r[e-1][1]=l:(r.splice(e-1,1),e--),r[e][1]=u,c?r[e+1][1]=c:(r.splice(e+1,1),e--))}e++}}function pn(r,t){r.push([P,""]);for(var e=0,s=0,n=0,i="",o="",a;e=0&&il(r[l][1])){var u=r[l][1].slice(-1);if(r[l][1]=r[l][1].slice(0,-1),i=u+i,o=u+o,!r[l][1]){r.splice(l,1),e--;var c=l-1;r[c]&&r[c][0]===Z&&(n++,o=r[c][1]+o,c--),r[c]&&r[c][0]===at&&(s++,i=r[c][1]+i,c--),l=c}}if(nl(r[e][1])){var u=r[e][1].charAt(0);r[e][1]=r[e][1].slice(1),i+=u,o+=u}}if(e0||o.length>0){i.length>0&&o.length>0&&(a=dn(o,i),a!==0&&(l>=0?r[l][1]+=o.substring(0,a):(r.splice(0,0,[P,o.substring(0,a)]),e++),o=o.substring(a),i=i.substring(a)),a=is(o,i),a!==0&&(r[e][1]=o.substring(o.length-a)+r[e][1],o=o.substring(0,o.length-a),i=i.substring(0,i.length-a)));var f=n+s;i.length===0&&o.length===0?(r.splice(e-f,f),e=e-f):i.length===0?(r.splice(e-f,f,[Z,o]),e=e-f+1):o.length===0?(r.splice(e-f,f,[at,i]),e=e-f+1):(r.splice(e-f,f,[at,i],[Z,o]),e=e-f+2)}e!==0&&r[e-1][0]===P?(r[e-1][1]+=r[e][1],r.splice(e,1)):e++,n=0,s=0,i="",o="";break}}r[r.length-1][1]===""&&r.pop();var h=!1;for(e=1;e=55296&&r<=56319}function sl(r){return r>=56320&&r<=57343}function nl(r){return sl(r.charCodeAt(0))}function il(r){return rl(r.charCodeAt(r.length-1))}function Cg(r){for(var t=[],e=0;e0&&t.push(r[e]);return t}function hn(r,t,e,s){return il(r)||nl(s)?null:Cg([[P,r],[at,t],[Z,e],[P,s]])}function _g(r,t,e){var s=typeof e=="number"?{index:e,length:0}:e.oldRange,n=typeof e=="number"?null:e.newRange,i=r.length,o=t.length;if(s.length===0&&(n===null||n.length===0)){var a=s.index,l=r.slice(0,a),u=r.slice(a),c=n?n.index:null;t:{var f=a+o-i;if(c!==null&&c!==f||f<0||f>o)break t;var h=t.slice(0,f),p=t.slice(f);if(p!==u)break t;var m=Math.min(a,f),y=l.slice(0,m),v=h.slice(0,m);if(y!==v)break t;var g=l.slice(m),A=h.slice(m);return hn(y,g,A,u)}t:{if(c!==null&&c!==a)break t;var E=a,h=t.slice(0,E),p=t.slice(E);if(h!==l)break t;var T=Math.min(i-E,o-E),N=u.slice(u.length-T),_=p.slice(p.length-T);if(N!==_)break t;var g=u.slice(0,u.length-T),A=p.slice(0,p.length-T);return hn(l,g,A,N)}}if(s.length>0&&n&&n.length===0)t:{var y=r.slice(0,s.index),N=r.slice(s.index+s.length),m=y.length,T=N.length;if(o{"use strict";var qg=200,xl="__lodash_hash_undefined__",vl=9007199254740991,En="[object Arguments]",Ig="[object Array]",Al="[object Boolean]",El="[object Date]",kg="[object Error]",Tn="[object Function]",Tl="[object GeneratorFunction]",as="[object Map]",Nl="[object Number]",Nn="[object Object]",ll="[object Promise]",wl="[object RegExp]",ls="[object Set]",Sl="[object String]",Ll="[object Symbol]",gn="[object WeakMap]",Ol="[object ArrayBuffer]",us="[object DataView]",Cl="[object Float32Array]",_l="[object Float64Array]",ql="[object Int8Array]",Il="[object Int16Array]",kl="[object Int32Array]",Rl="[object Uint8Array]",Bl="[object Uint8ClampedArray]",Ml="[object Uint16Array]",Dl="[object Uint32Array]",Rg=/[\\^$.*+?()[\]{}|]/g,Bg=/\w*$/,Mg=/^\[object .+?Constructor\]$/,Dg=/^(?:0|[1-9]\d*)$/,S={};S[En]=S[Ig]=S[Ol]=S[us]=S[Al]=S[El]=S[Cl]=S[_l]=S[ql]=S[Il]=S[kl]=S[as]=S[Nl]=S[Nn]=S[wl]=S[ls]=S[Sl]=S[Ll]=S[Rl]=S[Bl]=S[Ml]=S[Dl]=!0;S[kg]=S[Tn]=S[gn]=!1;var jg=typeof global=="object"&&global&&global.Object===Object&&global,Pg=typeof self=="object"&&self&&self.Object===Object&&self,_t=jg||Pg||Function("return this")(),jl=typeof fr=="object"&&fr&&!fr.nodeType&&fr,ul=jl&&typeof He=="object"&&He&&!He.nodeType&&He,Ug=ul&&ul.exports===jl;function Fg(r,t){return r.set(t[0],t[1]),r}function Hg(r,t){return r.add(t),r}function zg(r,t){for(var e=-1,s=r?r.length:0;++e-1}function g1(r,t){var e=this.__data__,s=hs(e,r);return s<0?e.push([r,t]):e[s][1]=t,this}qt.prototype.clear=h1;qt.prototype.delete=d1;qt.prototype.get=p1;qt.prototype.has=m1;qt.prototype.set=g1;function ze(r){var t=-1,e=r?r.length:0;for(this.clear();++t-1&&r%1==0&&r-1&&r%1==0&&r<=vl}function ps(r){var t=typeof r;return!!r&&(t=="object"||t=="function")}function e0(r){return!!r&&typeof r=="object"}function On(r){return Vl(r)?L1(r):k1(r)}function r0(){return[]}function s0(){return!1}He.exports=X1});var Fn=Ft((pr,Ve)=>{"use strict";var n0=200,Un="__lodash_hash_undefined__",Es=1,ou=2,au=9007199254740991,ms="[object Arguments]",kn="[object Array]",i0="[object AsyncFunction]",lu="[object Boolean]",uu="[object Date]",cu="[object Error]",fu="[object Function]",o0="[object GeneratorFunction]",gs="[object Map]",hu="[object Number]",a0="[object Null]",Ge="[object Object]",Zl="[object Promise]",l0="[object Proxy]",du="[object RegExp]",bs="[object Set]",pu="[object String]",u0="[object Symbol]",c0="[object Undefined]",Rn="[object WeakMap]",mu="[object ArrayBuffer]",ys="[object DataView]",f0="[object Float32Array]",h0="[object Float64Array]",d0="[object Int8Array]",p0="[object Int16Array]",m0="[object Int32Array]",g0="[object Uint8Array]",b0="[object Uint8ClampedArray]",y0="[object Uint16Array]",x0="[object Uint32Array]",v0=/[\\^$.*+?()[\]{}|]/g,A0=/^\[object .+?Constructor\]$/,E0=/^(?:0|[1-9]\d*)$/,C={};C[f0]=C[h0]=C[d0]=C[p0]=C[m0]=C[g0]=C[b0]=C[y0]=C[x0]=!0;C[ms]=C[kn]=C[mu]=C[lu]=C[ys]=C[uu]=C[cu]=C[fu]=C[gs]=C[hu]=C[Ge]=C[du]=C[bs]=C[pu]=C[Rn]=!1;var gu=typeof global=="object"&&global&&global.Object===Object&&global,T0=typeof self=="object"&&self&&self.Object===Object&&self,It=gu||T0||Function("return this")(),bu=typeof pr=="object"&&pr&&!pr.nodeType&&pr,Xl=bu&&typeof Ve=="object"&&Ve&&!Ve.nodeType&&Ve,yu=Xl&&Xl.exports===bu,_n=yu&&gu.process,Ql=(function(){try{return _n&&_n.binding&&_n.binding("util")}catch{}})(),Yl=Ql&&Ql.isTypedArray;function N0(r,t){for(var e=-1,s=r==null?0:r.length,n=0,i=[];++e-1}function tb(r,t){var e=this.__data__,s=Ns(e,r);return s<0?(++this.size,e.push([r,t])):e[s][1]=t,this}kt.prototype.clear=X0;kt.prototype.delete=Q0;kt.prototype.get=Y0;kt.prototype.has=J0;kt.prototype.set=tb;function me(r){var t=-1,e=r==null?0:r.length;for(this.clear();++ta))return!1;var u=i.get(r);if(u&&i.get(t))return u==t;var c=-1,f=!0,h=e&ou?new vs:void 0;for(i.set(r,t),i.set(t,r);++c-1&&r%1==0&&r-1&&r%1==0&&r<=au}function Lu(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}function br(r){return r!=null&&typeof r=="object"}var Ou=Yl?O0(Yl):bb;function qb(r){return Cb(r)?db(r):yb(r)}function Ib(){return[]}function kb(){return!1}Ve.exports=_b});var Cu=Ft(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});var Rb=Cn(),Bb=Fn(),Hn;(function(r){function t(i={},o={},a=!1){typeof i!="object"&&(i={}),typeof o!="object"&&(o={});let l=Rb(o);a||(l=Object.keys(l).reduce((u,c)=>(l[c]!=null&&(u[c]=l[c]),u),{}));for(let u in i)i[u]!==void 0&&o[u]===void 0&&(l[u]=i[u]);return Object.keys(l).length>0?l:void 0}r.compose=t;function e(i={},o={}){typeof i!="object"&&(i={}),typeof o!="object"&&(o={});let a=Object.keys(i).concat(Object.keys(o)).reduce((l,u)=>(Bb(i[u],o[u])||(l[u]=o[u]===void 0?null:o[u]),l),{});return Object.keys(a).length>0?a:void 0}r.diff=e;function s(i={},o={}){i=i||{};let a=Object.keys(o).reduce((l,u)=>(o[u]!==i[u]&&i[u]!==void 0&&(l[u]=o[u]),l),{});return Object.keys(i).reduce((l,u)=>(i[u]!==o[u]&&o[u]===void 0&&(l[u]=null),l),a)}r.invert=s;function n(i,o,a=!1){if(typeof i!="object")return o;if(typeof o!="object")return;if(!a)return o;let l=Object.keys(o).reduce((u,c)=>(i[c]===void 0&&(u[c]=o[c]),u),{});return Object.keys(l).length>0?l:void 0}r.transform=n})(Hn||(Hn={}));zn.default=Hn});var Gn=Ft(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var $n;(function(r){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}r.length=t})($n||($n={}));Kn.default=$n});var qu=Ft(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});var _u=Gn(),Vn=class{constructor(t){this.ops=t,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(t){t||(t=1/0);let e=this.ops[this.index];if(e){let s=this.offset,n=_u.default.length(e);if(t>=n-s?(t=n-s,this.index+=1,this.offset=0):this.offset+=t,typeof e.delete=="number")return{delete:t};{let 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(s,t):i.insert=e.insert,i}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?_u.default.length(this.ops[this.index])-this.offset:1/0}peekType(){let 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);{let t=this.offset,e=this.index,s=this.next(),n=this.ops.slice(this.index);return this.offset=t,this.index=e,[s].concat(n)}}else return[]}};Wn.default=Vn});var lt=Ft((Bt,Ls)=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.AttributeMap=Bt.OpIterator=Bt.Op=void 0;var Ss=al(),Mb=Cn(),Zn=Fn(),be=Cu();Bt.AttributeMap=be.default;var Rt=Gn();Bt.Op=Rt.default;var ht=qu();Bt.OpIterator=ht.default;var Db="\0",Iu=(r,t)=>{if(typeof r!="object"||r===null)throw new Error(`cannot retain a ${typeof r}`);if(typeof t!="object"||t===null)throw new Error(`cannot retain a ${typeof t}`);let e=Object.keys(r)[0];if(!e||e!==Object.keys(t)[0])throw new Error(`embed types not matched: ${e} != ${Object.keys(t)[0]}`);return[e,r[e],t[e]]},Mt=class r{constructor(t){Array.isArray(t)?this.ops=t:t!=null&&Array.isArray(t.ops)?this.ops=t.ops:this.ops=[]}static registerEmbed(t,e){this.handlers[t]=e}static unregisterEmbed(t){delete this.handlers[t]}static getHandler(t){let e=this.handlers[t];if(!e)throw new Error(`no handlers for embed type "${t}"`);return e}insert(t,e){let s={};return typeof t=="string"&&t.length===0?this:(s.insert=t,e!=null&&typeof e=="object"&&Object.keys(e).length>0&&(s.attributes=e),this.push(s))}delete(t){return t<=0?this:this.push({delete:t})}retain(t,e){if(typeof t=="number"&&t<=0)return this;let s={retain:t};return e!=null&&typeof e=="object"&&Object.keys(e).length>0&&(s.attributes=e),this.push(s)}push(t){let e=this.ops.length,s=this.ops[e-1];if(t=Mb(t),typeof s=="object"){if(typeof t.delete=="number"&&typeof s.delete=="number")return this.ops[e-1]={delete:s.delete+t.delete},this;if(typeof s.delete=="number"&&t.insert!=null&&(e-=1,s=this.ops[e-1],typeof s!="object"))return this.ops.unshift(t),this;if(Zn(t.attributes,s.attributes)){if(typeof t.insert=="string"&&typeof s.insert=="string")return this.ops[e-1]={insert:s.insert+t.insert},typeof t.attributes=="object"&&(this.ops[e-1].attributes=t.attributes),this;if(typeof t.retain=="number"&&typeof s.retain=="number")return this.ops[e-1]={retain:s.retain+t.retain},typeof t.attributes=="object"&&(this.ops[e-1].attributes=t.attributes),this}}return e===this.ops.length?this.ops.push(t):this.ops.splice(e,0,t),this}chop(){let t=this.ops[this.ops.length-1];return t&&typeof t.retain=="number"&&!t.attributes&&this.ops.pop(),this}filter(t){return this.ops.filter(t)}forEach(t){this.ops.forEach(t)}map(t){return this.ops.map(t)}partition(t){let e=[],s=[];return this.forEach(n=>{(t(n)?e:s).push(n)}),[e,s]}reduce(t,e){return this.ops.reduce(t,e)}changeLength(){return this.reduce((t,e)=>e.insert?t+Rt.default.length(e):e.delete?t-e.delete:t,0)}length(){return this.reduce((t,e)=>t+Rt.default.length(e),0)}slice(t=0,e=1/0){let s=[],n=new ht.default(this.ops),i=0;for(;i0&&s.next(i.retain-a)}let o=new r(n);for(;e.hasNext()||s.hasNext();)if(s.peekType()==="insert")o.push(s.next());else if(e.peekType()==="delete")o.push(e.next());else{let a=Math.min(e.peekLength(),s.peekLength()),l=e.next(a),u=s.next(a);if(u.retain){let c={};if(typeof l.retain=="number")c.retain=typeof u.retain=="number"?a:u.retain;else if(typeof u.retain=="number")l.retain==null?c.insert=l.insert:c.retain=l.retain;else{let h=l.retain==null?"insert":"retain",[p,m,y]=Iu(l[h],u.retain),v=r.getHandler(p);c[h]={[p]:v.compose(m,y,h==="retain")}}let f=be.default.compose(l.attributes,u.attributes,typeof l.retain=="number");if(f&&(c.attributes=f),o.push(c),!s.hasNext()&&Zn(o.ops[o.ops.length-1],c)){let h=new r(e.rest());return o.concat(h).chop()}}else typeof u.delete=="number"&&(typeof l.retain=="number"||typeof l.retain=="object"&&l.retain!==null)&&o.push(u)}return o.chop()}concat(t){let e=new r(this.ops.slice());return t.ops.length>0&&(e.push(t.ops[0]),e.ops=e.ops.concat(t.ops.slice(1))),e}diff(t,e){if(this.ops===t.ops)return new r;let s=[this,t].map(l=>l.map(u=>{if(u.insert!=null)return typeof u.insert=="string"?u.insert:Db;let c=l===t?"on":"with";throw new Error("diff() called "+c+" non-document")}).join("")),n=new r,i=Ss(s[0],s[1],e,!0),o=new ht.default(this.ops),a=new ht.default(t.ops);return i.forEach(l=>{let u=l[1].length;for(;u>0;){let c=0;switch(l[0]){case Ss.INSERT:c=Math.min(a.peekLength(),u),n.push(a.next(c));break;case Ss.DELETE:c=Math.min(u,o.peekLength()),o.next(c),n.delete(c);break;case Ss.EQUAL:c=Math.min(o.peekLength(),a.peekLength(),u);let f=o.next(c),h=a.next(c);Zn(f.insert,h.insert)?n.retain(c,be.default.diff(f.attributes,h.attributes)):n.push(h).delete(c);break}u-=c}}),n.chop()}eachLine(t,e=` `){let s=new ht.default(this.ops),n=new r,i=0;for(;s.hasNext();){if(s.peekType()!=="insert")return;let o=s.peek(),a=Rt.default.length(o)-s.peekLength(),l=typeof o.insert=="string"?o.insert.indexOf(e,a)-a:-1;if(l<0)n.push(s.next());else if(l>0)n.push(s.next(l));else{if(t(n,s.next(1).attributes||{},i)===!1)return;i+=1,n=new r}}n.length()>0&&t(n,{},i)}invert(t){let e=new r;return this.reduce((s,n)=>{if(n.insert)e.delete(Rt.default.length(n));else{if(typeof n.retain=="number"&&n.attributes==null)return e.retain(n.retain),s+n.retain;if(n.delete||typeof n.retain=="number"){let i=n.delete||n.retain;return t.slice(s,s+i).forEach(a=>{n.delete?e.push(a):n.retain&&n.attributes&&e.retain(Rt.default.length(a),be.default.invert(n.attributes,a.attributes))}),s+i}else if(typeof n.retain=="object"&&n.retain!==null){let i=t.slice(s,s+1),o=new ht.default(i.ops).next(),[a,l,u]=Iu(n.retain,o.insert),c=r.getHandler(a);return e.retain({[a]:c.invert(l,u)},be.default.invert(n.attributes,o.attributes)),s+1}}return s},0),e.chop()}transform(t,e=!1){if(e=!!e,typeof t=="number")return this.transformPosition(t,e);let s=t,n=new ht.default(this.ops),i=new ht.default(s.ops),o=new r;for(;n.hasNext()||i.hasNext();)if(n.peekType()==="insert"&&(e||i.peekType()!=="insert"))o.retain(Rt.default.length(n.next()));else if(i.peekType()==="insert")o.push(i.next());else{let a=Math.min(n.peekLength(),i.peekLength()),l=n.next(a),u=i.next(a);if(l.delete)continue;if(u.delete)o.push(u);else{let c=l.retain,f=u.retain,h=typeof f=="object"&&f!==null?f:a;if(typeof c=="object"&&c!==null&&typeof f=="object"&&f!==null){let p=Object.keys(c)[0];if(p===Object.keys(f)[0]){let m=r.getHandler(p);m&&(h={[p]:m.transform(c[p],f[p],e)})}}o.retain(h,be.default.transform(l.attributes,u.attributes,e))}}return o.chop()}transformPosition(t,e=!1){e=!!e;let s=new ht.default(this.ops),n=0;for(;s.hasNext()&&n<=t;){let i=s.peekLength(),o=s.peekType();if(s.next(),o==="delete"){t-=Math.min(i,t-n);continue}else o==="insert"&&(n{"use strict";var Hb=Object.prototype.hasOwnProperty,X="~";function xr(){}Object.create&&(xr.prototype=Object.create(null),new xr().__proto__||(X=!1));function zb(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function Ru(r,t,e,s,n){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new zb(e,s||r,n),o=X?X+t:t;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function Os(r,t){--r._eventsCount===0?r._events=new xr:delete r._events[t]}function G(){this._events=new xr,this._eventsCount=0}G.prototype.eventNames=function(){var t=[],e,s;if(this._eventsCount===0)return t;for(s in e=this._events)Hb.call(e,s)&&t.push(X?s.slice(1):s);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};G.prototype.listeners=function(t){var e=X?X+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,i=s.length,o=new Array(i);n0){if(++t>=Lf)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var Xi=_f;function qf(r){return function(){return r}}var Qi=qf;var If=(function(){try{var r=J(Object,"defineProperty");return r({},"",{}),r}catch{}})(),Ee=If;var kf=Ee?function(r,t){return Ee(r,"toString",{configurable:!0,enumerable:!1,value:Qi(t),writable:!0})}:Rr,Yi=kf;var Rf=Xi(Yi),Ji=Rf;function Bf(r,t){for(var e=-1,s=r==null?0:r.length;++e-1&&r%1==0&&r-1&&r%1==0&&r<=Vf}var Ur=Wf;function Zf(r){return r!=null&&Ur(r.length)&&!Ae(r)}var Ht=Zf;function Xf(r,t,e){if(!z(e))return!1;var s=typeof t;return(s=="number"?Ht(e)&&jr(t,e.length):s=="string"&&t in e)?yt(e[t],r):!1}var no=Xf;function Qf(r){return so(function(t,e){var s=-1,n=e.length,i=n>1?e[n-1]:void 0,o=n>2?e[2]:void 0;for(i=r.length>3&&typeof i=="function"?(n--,i):void 0,o&&no(e[0],e[1],o)&&(i=n<3?void 0:i,n=1),t=Object(t);++s-1}var Oo=bd;function yd(r,t){var e=this.__data__,s=zt(e,r);return s<0?(++this.size,e.push([r,t])):e[s][1]=t,this}var Co=yd;function Ce(r){var t=-1,e=r==null?0:r.length;for(this.clear();++ta))return!1;var u=i.get(r),c=i.get(t);if(u&&c)return u==t&&c==r;var f=-1,h=!0,p=e&_m?new Na:void 0;for(i.set(r,t),i.set(t,r);++fW,AttributorStore:()=>ar,BlockBlot:()=>ue,ClassAttributor:()=>D,ContainerBlot:()=>Ue,EmbedBlot:()=>q,InlineBlot:()=>ns,LeafBlot:()=>j,ParentBlot:()=>et,Registry:()=>Xt,Scope:()=>b,ScrollBlot:()=>lr,StyleAttributor:()=>rt,TextBlot:()=>Fe});var b=(r=>(r[r.TYPE=3]="TYPE",r[r.LEVEL=12]="LEVEL",r[r.ATTRIBUTE=13]="ATTRIBUTE",r[r.BLOT=14]="BLOT",r[r.INLINE=7]="INLINE",r[r.BLOCK=11]="BLOCK",r[r.BLOCK_BLOT=10]="BLOCK_BLOT",r[r.INLINE_BLOT=6]="INLINE_BLOT",r[r.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",r[r.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",r[r.ANY=15]="ANY",r))(b||{}),W=class{constructor(t,e,s={}){this.attrName=t,this.keyName=e;let n=b.TYPE&b.ATTRIBUTE;this.scope=s.scope!=null?s.scope&b.LEVEL|n:b.ATTRIBUTE,s.whitelist!=null&&(this.whitelist=s.whitelist)}static keys(t){return Array.from(t.attributes).map(e=>e.name)}add(t,e){return this.canAdd(t,e)?(t.setAttribute(this.keyName,e),!0):!1}canAdd(t,e){return this.whitelist==null?!0:typeof e=="string"?this.whitelist.indexOf(e.replace(/["']/g,""))>-1:this.whitelist.indexOf(e)>-1}remove(t){t.removeAttribute(this.keyName)}value(t){let e=t.getAttribute(this.keyName);return this.canAdd(t,e)&&e?e:""}},Zt=class extends Error{constructor(t){t="[Parchment] "+t,super(t),this.message=t,this.name=this.constructor.name}},cg=(()=>{let r=class rn{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(e,s=!1){if(e==null)return null;if(this.blots.has(e))return this.blots.get(e)||null;if(s){let n=null;try{n=e.parentNode}catch{return null}return this.find(n,s)}return null}create(e,s,n){let i=this.query(s);if(i==null)throw new Zt(`Unable to create ${s} blot`);let o=i,a=s instanceof Node||s.nodeType===Node.TEXT_NODE?s:o.create(n),l=new o(e,a,n);return rn.blots.set(l.domNode,l),l}find(e,s=!1){return rn.find(e,s)}query(e,s=b.ANY){let n;return typeof e=="string"?n=this.types[e]||this.attributes[e]:e instanceof Text||e.nodeType===Node.TEXT_NODE?n=this.types.text:typeof e=="number"?e&b.LEVEL&b.BLOCK?n=this.types.block:e&b.LEVEL&b.INLINE&&(n=this.types.inline):e instanceof Element&&((e.getAttribute("class")||"").split(/\s+/).some(i=>(n=this.classes[i],!!n)),n=n||this.tags[e.tagName]),n==null?null:"scope"in n&&s&b.LEVEL&n.scope&&s&b.TYPE&n.scope?n:null}register(...e){return e.map(s=>{let n="blotName"in s,i="attrName"in s;if(!n&&!i)throw new Zt("Invalid definition");if(n&&s.blotName==="abstract")throw new Zt("Cannot register abstract class");let o=n?s.blotName:i?s.attrName:void 0;return this.types[o]=s,i?typeof s.keyName=="string"&&(this.attributes[s.keyName]=s):n&&(s.className&&(this.classes[s.className]=s),s.tagName&&(Array.isArray(s.tagName)?s.tagName=s.tagName.map(a=>a.toUpperCase()):s.tagName=s.tagName.toUpperCase(),(Array.isArray(s.tagName)?s.tagName:[s.tagName]).forEach(a=>{(this.tags[a]==null||s.className==null)&&(this.tags[a]=s)}))),s})}};return r.blots=new WeakMap,r})(),Xt=cg;function Ka(r,t){return(r.getAttribute("class")||"").split(/\s+/).filter(e=>e.indexOf(`${t}-`)===0)}var sn=class extends W{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){Ka(t,this.keyName).forEach(e=>{t.classList.remove(e)}),t.classList.length===0&&t.removeAttribute("class")}value(t){let e=(Ka(t,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(t,e)?e:""}},D=sn;function en(r){let t=r.split("-"),e=t.slice(1).map(s=>s[0].toUpperCase()+s.slice(1)).join("");return t[0]+e}var nn=class extends W{static keys(t){return(t.getAttribute("style")||"").split(";").map(e=>e.split(":")[0].trim())}add(t,e){return this.canAdd(t,e)?(t.style[en(this.keyName)]=e,!0):!1}remove(t){t.style[en(this.keyName)]="",t.getAttribute("style")||t.removeAttribute("style")}value(t){let e=t.style[en(this.keyName)];return this.canAdd(t,e)?e:""}},rt=nn,on=class{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={};let t=Xt.find(this.domNode);if(t==null)return;let e=W.keys(this.domNode),s=D.keys(this.domNode),n=rt.keys(this.domNode);e.concat(s).concat(n).forEach(i=>{let o=t.scroll.query(i,b.ATTRIBUTE);o instanceof W&&(this.attributes[o.attrName]=o)})}copy(t){Object.keys(this.attributes).forEach(e=>{let s=this.attributes[e].value(this.domNode);t.format(e,s)})}move(t){this.copy(t),Object.keys(this.attributes).forEach(e=>{this.attributes[e].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((t,e)=>(t[e]=this.attributes[e].value(this.domNode),t),{})}},ar=on,Va=class{constructor(t,e){this.scroll=t,this.domNode=e,Xt.blots.set(e,this),this.prev=null,this.next=null}static create(t){if(this.tagName==null)throw new Zt("Blot definition missing tagName");let e,s;return Array.isArray(this.tagName)?(typeof t=="string"?(s=t.toUpperCase(),parseInt(s,10).toString()===s&&(s=parseInt(s,10))):typeof t=="number"&&(s=t),typeof s=="number"?e=document.createElement(this.tagName[s-1]):s&&this.tagName.indexOf(s)>-1?e=document.createElement(s):e=document.createElement(this.tagName[0])):e=document.createElement(this.tagName),this.className&&e.classList.add(this.className),e}get statics(){return this.constructor}attach(){}clone(){let t=this.domNode.cloneNode(!1);return this.scroll.create(t)}detach(){this.parent!=null&&this.parent.removeChild(this),Xt.blots.delete(this.domNode)}deleteAt(t,e){this.isolate(t,e).remove()}formatAt(t,e,s,n){let i=this.isolate(t,e);if(this.scroll.query(s,b.BLOT)!=null&&n)i.wrap(s,n);else if(this.scroll.query(s,b.ATTRIBUTE)!=null){let o=this.scroll.create(this.statics.scope);i.wrap(o),o.format(s,n)}}insertAt(t,e,s){let n=s==null?this.scroll.create("text",e):this.scroll.create(e,s),i=this.split(t);this.parent.insertBefore(n,i||void 0)}isolate(t,e){let s=this.split(t);if(s==null)throw new Error("Attempt to isolate at end");return s.split(e),s}length(){return 1}offset(t=this.parent){return this.parent==null||this===t?0:this.parent.children.offset(this)+this.parent.offset(t)}optimize(t){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(t,e){let s=typeof t=="string"?this.scroll.create(t,e):t;return this.parent!=null&&(this.parent.insertBefore(s,this.next||void 0),this.remove()),s}split(t,e){return t===0?this:this.next}update(t,e){}wrap(t,e){let s=typeof t=="string"?this.scroll.create(t,e):t;if(this.parent!=null&&this.parent.insertBefore(s,this.next||void 0),typeof s.appendChild!="function")throw new Zt(`Cannot wrap ${t}`);return s.appendChild(this),s}};Va.blotName="abstract";var Wa=Va,Za=class extends Wa{static value(t){return!0}index(t,e){return this.domNode===t||this.domNode.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(e,1):-1}position(t,e){let s=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return t>0&&(s+=1),[this.parent.domNode,s]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};Za.scope=b.INLINE_BLOT;var fg=Za,j=fg,an=class{constructor(){this.head=null,this.tail=null,this.length=0}append(...t){if(this.insertBefore(t[0],null),t.length>1){let e=t.slice(1);this.append(...e)}}at(t){let e=this.iterator(),s=e();for(;s&&t>0;)t-=1,s=e();return s}contains(t){let e=this.iterator(),s=e();for(;s;){if(s===t)return!0;s=e()}return!1}indexOf(t){let e=this.iterator(),s=e(),n=0;for(;s;){if(s===t)return n;n+=1,s=e()}return-1}insertBefore(t,e){t!=null&&(this.remove(t),t.next=e,e!=null?(t.prev=e.prev,e.prev!=null&&(e.prev.next=t),e.prev=t,e===this.head&&(this.head=t)):this.tail!=null?(this.tail.next=t,t.prev=this.tail,this.tail=t):(t.prev=null,this.head=this.tail=t),this.length+=1)}offset(t){let e=0,s=this.head;for(;s!=null;){if(s===t)return e;e+=s.length(),s=s.next}return-1}remove(t){this.contains(t)&&(t.prev!=null&&(t.prev.next=t.next),t.next!=null&&(t.next.prev=t.prev),t===this.head&&(this.head=t.next),t===this.tail&&(this.tail=t.prev),this.length-=1)}iterator(t=this.head){return()=>{let e=t;return t!=null&&(t=t.next),e}}find(t,e=!1){let s=this.iterator(),n=s();for(;n;){let i=n.length();if(to?s(l,t-o,Math.min(e,o+u-t)):s(l,0,Math.min(u,t+e-o)),o+=u,l=a()}}map(t){return this.reduce((e,s)=>(e.push(t(s)),e),[])}reduce(t,e){let s=this.iterator(),n=s();for(;n;)e=t(e,n),n=s();return e}};function Ga(r,t){let e=t.find(r);if(e)return e;try{return t.create(r)}catch{let s=t.create(b.INLINE);return Array.from(r.childNodes).forEach(n=>{s.domNode.appendChild(n)}),r.parentNode&&r.parentNode.replaceChild(s.domNode,r),s.attach(),s}}var hg=(()=>{let r=class Wt extends Wa{constructor(e,s){super(e,s),this.uiNode=null,this.build()}appendChild(e){this.insertBefore(e)}attach(){super.attach(),this.children.forEach(e=>{e.attach()})}attachUI(e){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=e,Wt.uiClass&&this.uiNode.classList.add(Wt.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new an,Array.from(this.domNode.childNodes).filter(e=>e!==this.uiNode).reverse().forEach(e=>{try{let s=Ga(e,this.scroll);this.insertBefore(s,this.children.head||void 0)}catch(s){if(s instanceof Zt)return;throw s}})}deleteAt(e,s){if(e===0&&s===this.length())return this.remove();this.children.forEachAt(e,s,(n,i,o)=>{n.deleteAt(i,o)})}descendant(e,s=0){let[n,i]=this.children.find(s);return e.blotName==null&&e(n)||e.blotName!=null&&n instanceof e?[n,i]:n instanceof Wt?n.descendant(e,i):[null,-1]}descendants(e,s=0,n=Number.MAX_VALUE){let i=[],o=n;return this.children.forEachAt(s,n,(a,l,u)=>{(e.blotName==null&&e(a)||e.blotName!=null&&a instanceof e)&&i.push(a),a instanceof Wt&&(i=i.concat(a.descendants(e,l,o))),o-=u}),i}detach(){this.children.forEach(e=>{e.detach()}),super.detach()}enforceAllowedChildren(){let e=!1;this.children.forEach(s=>{e||this.statics.allowedChildren.some(n=>s instanceof n)||(s.statics.scope===b.BLOCK_BLOT?(s.next!=null&&this.splitAfter(s),s.prev!=null&&this.splitAfter(s.prev),s.parent.unwrap(),e=!0):s instanceof Wt?s.unwrap():s.remove())})}formatAt(e,s,n,i){this.children.forEachAt(e,s,(o,a,l)=>{o.formatAt(a,l,n,i)})}insertAt(e,s,n){let[i,o]=this.children.find(e);if(i)i.insertAt(o,s,n);else{let a=n==null?this.scroll.create("text",s):this.scroll.create(s,n);this.appendChild(a)}}insertBefore(e,s){e.parent!=null&&e.parent.children.remove(e);let n=null;this.children.insertBefore(e,s||null),e.parent=this,s!=null&&(n=s.domNode),(this.domNode.parentNode!==e.domNode||this.domNode.nextSibling!==n)&&this.domNode.insertBefore(e.domNode,n),e.attach()}length(){return this.children.reduce((e,s)=>e+s.length(),0)}moveChildren(e,s){this.children.forEach(n=>{e.insertBefore(n,s)})}optimize(e){if(super.optimize(e),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){let s=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(s)}else this.remove()}path(e,s=!1){let[n,i]=this.children.find(e,s),o=[[this,e]];return n instanceof Wt?o.concat(n.path(i,s)):(n!=null&&o.push([n,i]),o)}removeChild(e){this.children.remove(e)}replaceWith(e,s){let n=typeof e=="string"?this.scroll.create(e,s):e;return n instanceof Wt&&this.moveChildren(n),super.replaceWith(n)}split(e,s=!1){if(!s){if(e===0)return this;if(e===this.length())return this.next}let n=this.clone();return this.parent&&this.parent.insertBefore(n,this.next||void 0),this.children.forEachAt(e,this.length(),(i,o,a)=>{let l=i.split(o,s);l!=null&&n.appendChild(l)}),n}splitAfter(e){let s=this.clone();for(;e.next!=null;)s.appendChild(e.next);return this.parent&&this.parent.insertBefore(s,this.next||void 0),s}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(e,s){let n=[],i=[];e.forEach(o=>{o.target===this.domNode&&o.type==="childList"&&(n.push(...o.addedNodes),i.push(...o.removedNodes))}),i.forEach(o=>{if(o.parentNode!=null&&o.tagName!=="IFRAME"&&document.body.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;let a=this.scroll.find(o);a!=null&&(a.domNode.parentNode==null||a.domNode.parentNode===this.domNode)&&a.detach()}),n.filter(o=>o.parentNode===this.domNode&&o!==this.uiNode).sort((o,a)=>o===a?0:o.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(o=>{let a=null;o.nextSibling!=null&&(a=this.scroll.find(o.nextSibling));let l=Ga(o,this.scroll);(l.next!==a||l.next==null)&&(l.parent!=null&&l.parent.removeChild(this),this.insertBefore(l,a||void 0))}),this.enforceAllowedChildren()}};return r.uiClass="",r})(),dg=hg,et=dg;function pg(r,t){if(Object.keys(r).length!==Object.keys(t).length)return!1;for(let e in r)if(r[e]!==t[e])return!1;return!0}var Me=class De extends et{static create(t){return super.create(t)}static formats(t,e){let s=e.query(De.blotName);if(!(s!=null&&t.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(t,e){super(t,e),this.attributes=new ar(this.domNode)}format(t,e){if(t===this.statics.blotName&&!e)this.children.forEach(s=>{s instanceof De||(s=s.wrap(De.blotName,!0)),this.attributes.copy(s)}),this.unwrap();else{let s=this.scroll.query(t,b.INLINE);if(s==null)return;s instanceof W?this.attributes.attribute(s,e):e&&(t!==this.statics.blotName||this.formats()[t]!==e)&&this.replaceWith(t,e)}}formats(){let t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return e!=null&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,n){this.formats()[s]!=null||this.scroll.query(s,b.ATTRIBUTE)?this.isolate(t,e).format(s,n):super.formatAt(t,e,s,n)}optimize(t){super.optimize(t);let e=this.formats();if(Object.keys(e).length===0)return this.unwrap();let s=this.next;s instanceof De&&s.prev===this&&pg(e,s.formats())&&(s.moveChildren(this),s.remove())}replaceWith(t,e){let s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}wrap(t,e){let s=super.wrap(t,e);return s instanceof De&&this.attributes.move(s),s}};Me.allowedChildren=[Me,j],Me.blotName="inline",Me.scope=b.INLINE_BLOT,Me.tagName="SPAN";var mg=Me,ns=mg,je=class ln extends et{static create(t){return super.create(t)}static formats(t,e){let s=e.query(ln.blotName);if(!(s!=null&&t.tagName===s.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(t,e){super(t,e),this.attributes=new ar(this.domNode)}format(t,e){let s=this.scroll.query(t,b.BLOCK);s!=null&&(s instanceof W?this.attributes.attribute(s,e):t===this.statics.blotName&&!e?this.replaceWith(ln.blotName):e&&(t!==this.statics.blotName||this.formats()[t]!==e)&&this.replaceWith(t,e))}formats(){let t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return e!=null&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,n){this.scroll.query(s,b.BLOCK)!=null?this.format(s,n):super.formatAt(t,e,s,n)}insertAt(t,e,s){if(s==null||this.scroll.query(e,b.INLINE)!=null)super.insertAt(t,e,s);else{let n=this.split(t);if(n!=null){let i=this.scroll.create(e,s);n.parent.insertBefore(i,n)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(t,e){let s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(s=>s.target===this.domNode&&s.type==="attributes")&&this.attributes.build()}};je.blotName="block",je.scope=b.BLOCK_BLOT,je.tagName="P",je.allowedChildren=[ns,je,j];var gg=je,ue=gg,un=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,s,n){super.formatAt(t,e,s,n),this.enforceAllowedChildren()}insertAt(t,e,s){super.insertAt(t,e,s),this.enforceAllowedChildren()}optimize(t){super.optimize(t),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};un.blotName="container",un.scope=b.BLOCK_BLOT;var bg=un,Ue=bg,cn=class extends j{static formats(t,e){}format(t,e){super.formatAt(0,this.length(),t,e)}formatAt(t,e,s,n){t===0&&e===this.length()?this.format(s,n):super.formatAt(t,e,s,n)}formats(){return this.statics.formats(this.domNode,this.scroll)}},q=cn,yg={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},xg=100,Pe=class extends et{constructor(t,e){super(null,e),this.registry=t,this.scroll=this,this.build(),this.observer=new MutationObserver(s=>{this.update(s)}),this.observer.observe(this.domNode,yg),this.attach()}create(t,e){return this.registry.create(this,t,e)}find(t,e=!1){let s=this.registry.find(t,e);return s?s.scroll===this?s:e?this.find(s.scroll.domNode.parentNode,!0):null:null}query(t,e=b.ANY){return this.registry.query(t,e)}register(...t){return this.registry.register(...t)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(t,e){this.update(),t===0&&e===this.length()?this.children.forEach(s=>{s.remove()}):super.deleteAt(t,e)}formatAt(t,e,s,n){this.update(),super.formatAt(t,e,s,n)}insertAt(t,e,s){this.update(),super.insertAt(t,e,s)}optimize(t=[],e={}){super.optimize(e);let s=e.mutationsMap||new WeakMap,n=Array.from(this.observer.takeRecords());for(;n.length>0;)t.push(n.pop());let i=(l,u=!0)=>{l==null||l===this||l.domNode.parentNode!=null&&(s.has(l.domNode)||s.set(l.domNode,[]),u&&i(l.parent))},o=l=>{s.has(l.domNode)&&(l instanceof et&&l.children.forEach(o),s.delete(l.domNode),l.optimize(e))},a=t;for(let l=0;a.length>0;l+=1){if(l>=xg)throw new Error("[Parchment] Maximum optimize iterations reached");for(a.forEach(u=>{let c=this.find(u.target,!0);c!=null&&(c.domNode===u.target&&(u.type==="childList"?(i(this.find(u.previousSibling,!1)),Array.from(u.addedNodes).forEach(f=>{let h=this.find(f,!1);i(h,!1),h instanceof et&&h.children.forEach(p=>{i(p,!1)})})):u.type==="attributes"&&i(c.prev)),i(c))}),this.children.forEach(o),a=Array.from(this.observer.takeRecords()),n=a.slice();n.length>0;)t.push(n.pop())}}update(t,e={}){t=t||this.observer.takeRecords();let s=new WeakMap;t.map(n=>{let i=this.find(n.target,!0);return i==null?null:s.has(i.domNode)?(s.get(i.domNode).push(n),null):(s.set(i.domNode,[n]),i)}).forEach(n=>{n!=null&&n!==this&&s.has(n.domNode)&&n.update(s.get(n.domNode)||[],e)}),e.mutationsMap=s,s.has(this.domNode)&&super.update(s.get(this.domNode),e),this.optimize(t,e)}};Pe.blotName="scroll",Pe.defaultChild=ue,Pe.allowedChildren=[ue,Ue],Pe.scope=b.BLOCK_BLOT,Pe.tagName="DIV";var vg=Pe,lr=vg,fn=class Xa extends j{static create(t){return document.createTextNode(t)}static value(t){return t.data}constructor(t,e){super(t,e),this.text=this.statics.value(this.domNode)}deleteAt(t,e){this.domNode.data=this.text=this.text.slice(0,t)+this.text.slice(t+e)}index(t,e){return this.domNode===t?e:-1}insertAt(t,e,s){s==null?(this.text=this.text.slice(0,t)+e+this.text.slice(t),this.domNode.data=this.text):super.insertAt(t,e,s)}length(){return this.text.length}optimize(t){super.optimize(t),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof Xa&&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}let s=this.scroll.create(this.domNode.splitText(t));return this.parent.insertBefore(s,this.next||void 0),this.text=this.statics.value(this.domNode),s}update(t,e){t.some(s=>s.type==="characterData"&&s.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};fn.blotName="text",fn.scope=b.INLINE_BLOT;var Ag=fn,Fe=Ag;var ee=ot(lt(),1);var I=ot(lt(),1);var Xn=ot(lt(),1);var jb=(()=>{class r extends q{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}return r.blotName="break",r.tagName="BR",r})(),$=jb;var R=class extends Fe{},Pb={"&":"&","<":"<",">":">",'"':""","'":"'"};function ye(r){return r.replace(/[&<>"']/g,t=>Pb[t])}var Ub=(()=>{class r extends ns{static allowedChildren=[r,$,q,R];static order=["cursor","inline","link","underline","strike","italic","bold","script","code"];static compare(e,s){let n=r.order.indexOf(e),i=r.order.indexOf(s);return n>=0||i>=0?n-i:e===s?0:e0){let s=this.parent.isolate(this.offset(),this.length());this.moveChildren(s),s.wrap(this)}}}return r})(),K=Ub;var ku=1,B=(()=>{class r extends ue{cache={};delta(){return this.cache.delta==null&&(this.cache.delta=Qn(this)),this.cache.delta}deleteAt(e,s){super.deleteAt(e,s),this.cache={}}formatAt(e,s,n,i){s<=0||(this.scroll.query(n,b.BLOCK)?e+s===this.length()&&this.format(n,i):super.formatAt(e,Math.min(s,this.length()-e-1),n,i),this.cache={})}insertAt(e,s,n){if(n!=null){super.insertAt(e,s,n),this.cache={};return}if(s.length===0)return;let i=s.split(` `),o=i.shift();o.length>0&&(e(a=a.split(l,!0),a.insertAt(0,u),u.length),e+o.length)}insertBefore(e,s){let{head:n}=this.children;super.insertBefore(e,s),n instanceof $&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+ku),this.cache.length}moveChildren(e,s){super.moveChildren(e,s),this.cache={}}optimize(e){super.optimize(e),this.cache={}}path(e){return super.path(e,!0)}removeChild(e){super.removeChild(e),this.cache={}}split(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(s&&(e===0||e>=this.length()-ku)){let i=this.clone();return e===0?(this.parent.insertBefore(i,this),this):(this.parent.insertBefore(i,this.next),i)}let n=super.split(e,s);return this.cache={},n}}return r.blotName="block",r.tagName="P",r.defaultChild=$,r.allowedChildren=[$,K,q,R],r})(),U=class extends q{attach(){super.attach(),this.attributes=new ar(this.domNode)}delta(){return new Xn.default().insert(this.value(),L(L({},this.formats()),this.attributes.values()))}format(t,e){let s=this.scroll.query(t,b.BLOCK_ATTRIBUTE);s!=null&&this.attributes.attribute(s,e)}formatAt(t,e,s,n){this.format(s,n)}insertAt(t,e,s){if(s!=null){super.insertAt(t,e,s);return}let n=e.split(` `),i=n.pop(),o=n.map(l=>{let u=this.scroll.create(B.blotName);return u.insertAt(0,l),u}),a=this.split(t);o.forEach(l=>{this.parent.insertBefore(l,a)}),i&&this.parent.insertBefore(this.scroll.create("text",i),a)}};U.scope=b.BLOCK_BLOT;function Qn(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return r.descendants(j).reduce((e,s)=>s.length()===0?e:e.insert(s.value(),st(s,{},t)),new Xn.default).insert(` `,st(r))}function st(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return r==null||("formats"in r&&typeof r.formats=="function"&&(t=L(L({},t),r.formats()),e&&delete t["code-token"]),r.parent==null||r.parent.statics.blotName==="scroll"||r.parent.statics.scope!==r.statics.scope)?t:st(r.parent,t,e)}var Fb=(()=>{class r extends q{static blotName="cursor";static className="ql-cursor";static tagName="span";static CONTENTS="\uFEFF";static value(){}constructor(e,s,n){super(e,s),this.selection=n,this.textNode=document.createTextNode(r.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(e,s){if(this.savedLength!==0){super.format(e,s);return}let n=this,i=0;for(;n!=null&&n.statics.scope!==b.BLOCK_BLOT;)i+=n.offset(n.parent),n=n.parent;n!=null&&(this.savedLength=r.CONTENTS.length,n.optimize(),n.formatAt(i,r.CONTENTS.length,e,s),this.savedLength=0)}index(e,s){return e===this.textNode?0:super.index(e,s)}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;let e=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);let s=this.prev instanceof R?this.prev:null,n=s?s.length():0,i=this.next instanceof R?this.next:null,o=i?i.text:"",{textNode:a}=this,l=a.data.split(r.CONTENTS).join("");a.data=r.CONTENTS;let u;if(s)u=s,(l||i)&&(s.insertAt(s.length(),l+o),i&&i.remove());else if(i)u=i,i.insertAt(0,l);else{let c=document.createTextNode(l);u=this.scroll.create(c),this.parent.insertBefore(u,this)}if(this.remove(),e){let c=(p,m)=>s&&p===s.domNode?m:p===a?n+m-1:i&&p===i.domNode?n+l.length+m:null,f=c(e.start.node,e.start.offset),h=c(e.end.node,e.end.offset);if(f!==null&&h!==null)return{startNode:u.domNode,startOffset:f,endNode:u.domNode,endOffset:h}}return null}update(e,s){if(e.some(n=>n.type==="characterData"&&n.target===this.textNode)){let n=this.restore();n&&(s.range=n)}}optimize(e){super.optimize(e);let{parent:s}=this;for(;s;){if(s.domNode.tagName==="A"){this.savedLength=r.CONTENTS.length,s.isolate(this.offset(s),this.length()).unwrap(),this.savedLength=0;break}s=s.parent}}value(){return""}}return r})(),te=Fb;var Jn=ot(Bu(),1);var vr=new WeakMap;var ti=["error","warn","log","info"],ei="warn";function Mu(r){if(ei&&ti.indexOf(r)<=ti.indexOf(ei)){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s(t[e]=Mu.bind(console,e,r),t),{})}ri.level=r=>{ei=r};Mu.level=ri.level;var ut=ri;var si=ut("quill:events"),$b=["selectionchange","mousedown","mouseup","click"];$b.forEach(r=>{document.addEventListener(r,function(){for(var t=arguments.length,e=new Array(t),s=0;s{let i=vr.get(n);i&&i.emitter&&i.emitter.handleDOM(...e)})})});var Kb=(()=>{class r extends Jn.default{static 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"};static sources={API:"api",SILENT:"silent",USER:"user"};constructor(){super(),this.domListeners={},this.on("error",si.error)}emit(){for(var e=arguments.length,s=new Array(e),n=0;n1?s-1:0),i=1;i{let{node:a,handler:l}=o;(e.target===a||a.contains(e.target))&&l(e,...n)})}listenDOM(e,s,n){this.domListeners[e]||(this.domListeners[e]=[]),this.domListeners[e].push({node:s,handler:n})}}return r})(),x=Kb;var ni=ut("quill:selection"),Q=class{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=t,this.length=e}},oi=class{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 Q(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,x.sources.USER),1)}),this.emitter.on(x.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;let s=this.getNativeRange();s!=null&&s.start.node!==this.cursor.textNode&&this.emitter.once(x.events.SCROLL_UPDATE,(n,i)=>{try{this.root.contains(s.start.node)&&this.root.contains(s.end.node)&&this.setNativeRange(s.start.node,s.start.offset,s.end.node,s.end.offset);let o=i.some(a=>a.type==="characterData"||a.type==="childList"||a.type==="attributes"&&a.target===this.root);this.update(o?x.sources.SILENT:n)}catch{}})}),this.emitter.on(x.events.SCROLL_OPTIMIZE,(s,n)=>{if(n.range){let{startNode:i,startOffset:o,endNode:a,endOffset:l}=n.range;this.setNativeRange(i,o,a,l),this.update(x.sources.SILENT)}}),this.update(x.sources.SILENT)}handleComposition(){this.emitter.on(x.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(x.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){let 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(x.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(t,e){this.scroll.update();let s=this.getNativeRange();if(!(s==null||!s.native.collapsed||this.scroll.query(t,b.BLOCK))){if(s.start.node!==this.cursor.textNode){let n=this.scroll.find(s.start.node,!1);if(n==null)return;if(n instanceof j){let i=n.split(s.start.offset);n.parent.insertBefore(this.cursor,i)}else n.insertBefore(this.cursor,s.start.node);this.cursor.attach()}this.cursor.format(t,e),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=this.scroll.length();t=Math.min(t,s-1),e=Math.min(t+e,s-1)-t;let n,[i,o]=this.scroll.leaf(t);if(i==null)return null;if(e>0&&o===i.length()){let[c]=this.scroll.leaf(t+1);if(c){let[f]=this.scroll.line(t),[h]=this.scroll.line(t+1);f===h&&(i=c,o=0)}}[n,o]=i.position(o,!0);let a=document.createRange();if(e>0)return a.setStart(n,o),[i,o]=this.scroll.leaf(t+e),i==null?null:([n,o]=i.position(o,!0),a.setEnd(n,o),a.getBoundingClientRect());let l="left",u;if(n instanceof Text){if(!n.data.length)return null;o0&&(l="right")}return{bottom:u.top+u.height,height:u.height,left:u[l],right:u[l],top:u.top,width:0}}getNativeRange(){let t=document.getSelection();if(t==null||t.rangeCount<=0)return null;let e=t.getRangeAt(0);if(e==null)return null;let s=this.normalizeNative(e);return ni.info("getNativeRange",s),s}getRange(){let t=this.scroll.domNode;if("isConnected"in t&&!t.isConnected)return[null,null];let e=this.getNativeRange();return e==null?[null,null]:[this.normalizedToRange(e),e]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&ii(this.root,document.activeElement)}normalizedToRange(t){let e=[[t.start.node,t.start.offset]];t.native.collapsed||e.push([t.end.node,t.end.offset]);let s=e.map(o=>{let[a,l]=o,u=this.scroll.find(a,!0),c=u.offset(this.scroll);return l===0?c:u instanceof j?c+u.index(a,l):c+u.length()}),n=Math.min(Math.max(...s),this.scroll.length()-1),i=Math.min(n,...s);return new Q(i,n-i)}normalizeNative(t){if(!ii(this.root,t.startContainer)||!t.collapsed&&!ii(this.root,t.endContainer))return null;let e={start:{node:t.startContainer,offset:t.startOffset},end:{node:t.endContainer,offset:t.endOffset},native:t};return[e.start,e.end].forEach(s=>{let{node:n,offset:i}=s;for(;!(n instanceof Text)&&n.childNodes.length>0;)if(n.childNodes.length>i)n=n.childNodes[i],i=0;else if(n.childNodes.length===i)n=n.lastChild,n instanceof Text?i=n.data.length:n.childNodes.length>0?i=n.childNodes.length:i=n.childNodes.length+1;else break;s.node=n,s.offset=i}),e}rangeToNative(t){let e=this.scroll.length(),s=(n,i)=>{n=Math.min(e-1,n);let[o,a]=this.scroll.leaf(n);return o?o.position(a,i):[null,-1]};return[...s(t.index,!1),...s(t.index+t.length,!0)]}setNativeRange(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(ni.info("setNativeRange",t,e,s,n),t!=null&&(this.root.parentNode==null||t.parentNode==null||s.parentNode==null))return;let o=document.getSelection();if(o!=null)if(t!=null){this.hasFocus()||this.root.focus({preventScroll:!0});let{native:a}=this.getNativeRange()||{};if(a==null||i||t!==a.startContainer||e!==a.startOffset||s!==a.endContainer||n!==a.endOffset){t instanceof Element&&t.tagName==="BR"&&(e=Array.from(t.parentNode.childNodes).indexOf(t),t=t.parentNode),s instanceof Element&&s.tagName==="BR"&&(n=Array.from(s.parentNode.childNodes).indexOf(s),s=s.parentNode);let l=document.createRange();l.setStart(t,e),l.setEnd(s,n),o.removeAllRanges(),o.addRange(l)}}else o.removeAllRanges(),this.root.blur()}setRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:x.sources.API;if(typeof e=="string"&&(s=e,e=!1),ni.info("setRange",t),t!=null){let n=this.rangeToNative(t);this.setNativeRange(...n,e)}else this.setNativeRange(null);this.update(s)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:x.sources.USER,e=this.lastRange,[s,n]=this.getRange();if(this.lastRange=s,this.lastNative=n,this.lastRange!=null&&(this.savedRange=this.lastRange),!le(e,this.lastRange)){if(!this.composing&&n!=null&&n.native.collapsed&&n.start.node!==this.cursor.textNode){let o=this.cursor.restore();o&&this.setNativeRange(o.startNode,o.startOffset,o.endNode,o.endOffset)}let i=[x.events.SELECTION_CHANGE,At(this.lastRange),At(e),t];this.emitter.emit(x.events.EDITOR_CHANGE,...i),t!==x.sources.SILENT&&this.emitter.emit(...i)}}};function ii(r,t){try{t.parentNode}catch{return!1}return r.contains(t)}var Du=oi;var Gb=/^[ -~]*$/,li=class{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();let s=ju(t),n=new I.default;return Wb(s.ops.slice()).reduce((o,a)=>{let l=I.Op.length(a),u=a.attributes||{},c=!1,f=!1;if(a.insert!=null){if(n.retain(l),typeof a.insert=="string"){let m=a.insert;f=!m.endsWith(` `)&&(e<=o||!!this.scroll.descendant(U,o)[0]),this.scroll.insertAt(o,m);let[y,v]=this.scroll.line(o),g=tt({},st(y));if(y instanceof B){let[A]=y.descendant(j,v);A&&(g=tt(g,st(A)))}u=I.AttributeMap.diff(g,u)||{}}else if(typeof a.insert=="object"){let m=Object.keys(a.insert)[0];if(m==null)return o;let y=this.scroll.query(m,b.INLINE)!=null;if(y)(e<=o||this.scroll.descendant(U,o)[0])&&(f=!0);else if(o>0){let[v,g]=this.scroll.descendant(j,o-1);v instanceof R?v.value()[g]!==` `&&(c=!0):v instanceof q&&v.statics.scope===b.INLINE_BLOT&&(c=!0)}if(this.scroll.insertAt(o,m,a.insert[m]),y){let[v]=this.scroll.descendant(j,o);if(v){let g=tt({},st(v));u=I.AttributeMap.diff(g,u)||{}}}}e+=l}else if(n.push(a),a.retain!==null&&typeof a.retain=="object"){let m=Object.keys(a.retain)[0];if(m==null)return o;this.scroll.updateEmbedAt(o,m,a.retain[m])}Object.keys(u).forEach(m=>{this.scroll.formatAt(o,l,m,u[m])});let h=c?1:0,p=f?1:0;return e+=h+p,n.retain(h),n.delete(p),o+l+h+p},0),n.reduce((o,a)=>typeof a.delete=="number"?(this.scroll.deleteAt(o,a.delete),o):o+I.Op.length(a),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(s)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update(new I.default().retain(t).delete(e))}formatLine(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(s).forEach(i=>{this.scroll.lines(t,Math.max(e,1)).forEach(o=>{o.format(i,s[i])})}),this.scroll.optimize();let n=new I.default().retain(t).retain(e,At(s));return this.update(n)}formatText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(s).forEach(i=>{this.scroll.formatAt(t,e,i,s[i])});let n=new I.default().retain(t).retain(e,At(s));return this.update(n)}getContents(t,e){return this.delta.slice(t,t+e)}getDelta(){return this.scroll.lines().reduce((t,e)=>t.concat(e.delta()),new I.default)}getFormat(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=[],n=[];e===0?this.scroll.path(t).forEach(a=>{let[l]=a;l instanceof B?s.push(l):l instanceof j&&n.push(l)}):(s=this.scroll.lines(t,e),n=this.scroll.descendants(j,t,e));let[i,o]=[s,n].map(a=>{let l=a.shift();if(l==null)return{};let u=st(l);for(;Object.keys(u).length>0;){let c=a.shift();if(c==null)return u;u=Vb(st(c),u)}return u});return L(L({},i),o)}getHTML(t,e){let[s,n]=this.scroll.line(t);if(s){let i=s.length();return s.length()>=n+e&&!(n===0&&e===i)?Ar(s,n,e,!0):Ar(this.scroll,t,e,!0)}return""}getText(t,e){return this.getContents(t,e).filter(s=>typeof s.insert=="string").map(s=>s.insert).join("")}insertContents(t,e){let s=ju(e),n=new I.default().retain(t).concat(s);return this.scroll.insertContents(t,s),this.update(n)}insertEmbed(t,e,s){return this.scroll.insertAt(t,e,s),this.update(new I.default().retain(t).insert({[e]:s}))}insertText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return e=e.replace(/\r\n/g,` `).replace(/\r/g,` `),this.scroll.insertAt(t,e),Object.keys(s).forEach(n=>{this.scroll.formatAt(t,e.length,n,s[n])}),this.update(new I.default().retain(t).insert(e,At(s)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;let t=this.scroll.children.head;if(t?.statics.blotName!==B.blotName)return!1;let e=t;return e.children.length>1?!1:e.children.head instanceof $}removeFormat(t,e){let s=this.getText(t,e),[n,i]=this.scroll.line(t+e),o=0,a=new I.default;n!=null&&(o=n.length()-i,a=n.delta().slice(i,i+o-1).insert(` `));let u=this.getContents(t,e+o).diff(new I.default().insert(s).concat(a)),c=new I.default().retain(t).concat(u);return this.applyDelta(c)}update(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,n=this.delta;if(e.length===1&&e[0].type==="characterData"&&e[0].target.data.match(Gb)&&this.scroll.find(e[0].target)){let i=this.scroll.find(e[0].target),o=st(i),a=i.offset(this.scroll),l=e[0].oldValue.replace(te.CONTENTS,""),u=new I.default().insert(l),c=new I.default().insert(i.value()),f=s&&{oldRange:Pu(s.oldRange,-a),newRange:Pu(s.newRange,-a)};t=new I.default().retain(a).concat(u.diff(c,f)).reduce((p,m)=>m.insert?p.insert(m.insert,o):p.push(m),new I.default),this.delta=n.compose(t)}else this.delta=this.getDelta(),(!t||!le(n.compose(t),this.delta))&&(t=n.diff(this.delta,s));return t}};function Ze(r,t,e){if(r.length===0){let[p]=ai(e.pop());return t<=0?``:`${Ze([],t-1,e)}`}let[{child:s,offset:n,length:i,indent:o,type:a},...l]=r,[u,c]=ai(a);if(o>t)return e.push(a),o===t+1?`<${u}>${Ar(s,n,i)}${Ze(l,o,e)}`:`<${u}>
  • ${Ze(r,t+1,e)}`;let f=e[e.length-1];if(o===t&&a===f)return`
  • ${Ar(s,n,i)}${Ze(l,o,e)}`;let[h]=ai(e.pop());return`${Ze(r,t-1,e)}`}function Ar(r,t,e){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in r&&typeof r.html=="function")return r.html(t,e);if(r instanceof R)return ye(r.value().slice(t,t+e)).replaceAll(" "," ");if(r instanceof et){if(r.statics.blotName==="list-container"){let u=[];return r.children.forEachAt(t,e,(c,f,h)=>{let p="formats"in c&&typeof c.formats=="function"?c.formats():{};u.push({child:c,offset:f,length:h,indent:p.indent||0,type:p.list})}),Ze(u,-1,[])}let n=[];if(r.children.forEachAt(t,e,(u,c,f)=>{n.push(Ar(u,c,f))}),s||r.statics.blotName==="list")return n.join("");let{outerHTML:i,innerHTML:o}=r.domNode,[a,l]=i.split(`>${o}<`);return a==="${n.join("")}<${l}`:`${a}>${n.join("")}<${l}`}return r.domNode instanceof Element?r.domNode.outerHTML:""}function Vb(r,t){return Object.keys(t).reduce((e,s)=>{if(r[s]==null)return e;let n=t[s];return n===r[s]?e[s]=n:Array.isArray(n)?n.indexOf(r[s])<0?e[s]=n.concat([r[s]]):e[s]=n:e[s]=[n,r[s]],e},{})}function ai(r){let t=r==="ordered"?"ol":"ul";switch(r){case"checked":return[t,' data-list="checked"'];case"unchecked":return[t,' data-list="unchecked"'];default:return[t,""]}}function ju(r){return r.reduce((t,e)=>{if(typeof e.insert=="string"){let s=e.insert.replace(/\r\n/g,` `).replace(/\r/g,` `);return t.insert(s,e.attributes)}return t.push(e)},new I.default)}function Pu(r,t){let{index:e,length:s}=r;return new Q(e+t,s)}function Wb(r){let t=[];return r.forEach(e=>{typeof e.insert=="string"?e.insert.split(` `).forEach((n,i)=>{i&&t.push({insert:` `,attributes:e.attributes}),n&&t.push({insert:n,attributes:e.attributes})}):t.push(e)}),t}var Uu=li;var Zb=(()=>{class r{static DEFAULTS={};constructor(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=e,this.options=s}}return r})(),k=Zb;var Cs="\uFEFF",ui=class extends q{constructor(t,e){super(t,e),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(s=>{this.contentNode.appendChild(s)}),this.leftGuard=document.createTextNode(Cs),this.rightGuard=document.createTextNode(Cs),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(t,e){return t===this.leftGuard?0:t===this.rightGuard?1:super.index(t,e)}restore(t){let e=null,s,n=t.data.split(Cs).join("");if(t===this.leftGuard)if(this.prev instanceof R){let i=this.prev.length();this.prev.insertAt(i,n),e={startNode:this.prev.domNode,startOffset:i+n.length}}else s=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(s),this),e={startNode:s,startOffset:n.length};else t===this.rightGuard&&(this.next instanceof R?(this.next.insertAt(0,n),e={startNode:this.next.domNode,startOffset:n.length}):(s=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(s),this.next),e={startNode:s,startOffset:n.length}));return t.data=Cs,e}update(t,e){t.forEach(s=>{if(s.type==="characterData"&&(s.target===this.leftGuard||s.target===this.rightGuard)){let n=this.restore(s.target);n&&(e.range=n)}})}},Xe=ui;var ci=class{isComposing=!1;constructor(t,e){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){let e=t.target instanceof Node?this.scroll.find(t.target,!0):null;e&&!(e instanceof Xe)&&(this.emitter.emit(x.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(x.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(x.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(x.events.COMPOSITION_END,t),this.isComposing=!1}},Fu=ci;var Xb=(()=>{class r{static DEFAULTS={modules:{}};static themes={default:r};modules={};constructor(e,s){this.quill=e,this.options=s}init(){Object.keys(this.options.modules).forEach(e=>{this.modules[e]==null&&this.addModule(e)})}addModule(e){let s=this.quill.constructor.import(`modules/${e}`);return this.modules[e]=new s(this.quill,this.options.modules[e]||{}),this.modules[e]}}return r})(),Qe=Xb;var Qb=r=>r.parentElement||r.getRootNode().host||null,Yb=r=>{let t=r.getBoundingClientRect(),e="offsetWidth"in r&&Math.abs(t.width)/r.offsetWidth||1,s="offsetHeight"in r&&Math.abs(t.height)/r.offsetHeight||1;return{top:t.top,right:t.left+r.clientWidth*e,bottom:t.top+r.clientHeight*s,left:t.left}},_s=r=>{let t=parseInt(r,10);return Number.isNaN(t)?0:t},Hu=(r,t,e,s,n,i)=>rs?0:rs?t-r>s-e?r+n-e:t-s+i:0,Jb=(r,t)=>{let e=r.ownerDocument,s=t,n=r;for(;n;){let i=n===e.body,o=i?{top:0,right:window.visualViewport?.width??e.documentElement.clientWidth,bottom:window.visualViewport?.height??e.documentElement.clientHeight,left:0}:Yb(n),a=getComputedStyle(n),l=Hu(s.left,s.right,o.left,o.right,_s(a.scrollPaddingLeft),_s(a.scrollPaddingRight)),u=Hu(s.top,s.bottom,o.top,o.bottom,_s(a.scrollPaddingTop),_s(a.scrollPaddingBottom));if(l||u)if(i)e.defaultView?.scrollBy(l,u);else{let{scrollLeft:c,scrollTop:f}=n;u&&(n.scrollTop+=u),l&&(n.scrollLeft+=l);let h=n.scrollLeft-c,p=n.scrollTop-f;s={left:s.left-h,top:s.top-p,right:s.right-h,bottom:s.bottom-p}}n=i||a.position==="fixed"?null:Qb(n)}},zu=Jb;var ty=100,ey=["block","break","cursor","inline","scroll","text"],ry=(r,t,e)=>{let s=new Xt;return ey.forEach(n=>{let i=t.query(n);i&&s.register(i)}),r.forEach(n=>{let i=t.query(n);i||e.error(`Cannot register "${n}" specified in "formats" config. Are you sure it was registered?`);let o=0;for(;i;)if(s.register(i),i="blotName"in i?i.requiredContainer??null:null,o+=1,o>ty){e.error(`Cycle detected in registering blot requiredContainer: "${n}"`);break}}),s},$u=ry;var Ye=ut("quill"),qs=new Xt;et.uiClass="ql-ui";var d=class r{static DEFAULTS={bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:qs,theme:"default"};static events=x.events;static sources=x.sources;static version="2.0.3";static imports={delta:ee.default,parchment:ur,"core/module":k,"core/theme":Qe};static debug(t){t===!0&&(t="log"),ut.level(t)}static find(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return vr.get(t)||qs.find(t,e)}static import(t){return this.imports[t]==null&&Ye.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"){let t=arguments.length<=0?void 0:arguments[0],e=!!(!(arguments.length<=1)&&arguments[1]),s="attrName"in t?t.attrName:t.blotName;typeof s=="string"?this.register(`formats/${s}`,t,e):Object.keys(t).forEach(n=>{this.register(n,t[n],e)})}else{let t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1],s=!!(!(arguments.length<=2)&&arguments[2]);this.imports[t]!=null&&!s&&Ye.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&typeof e!="boolean"&&e.blotName!=="abstract"&&qs.register(e),typeof e.register=="function"&&e.register(qs)}}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=sy(t,e),this.container=this.options.container,this.container==null){Ye.error("Invalid Quill container",t);return}this.options.debug&&r.debug(this.options.debug);let s=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",vr.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new x;let n=lr.blotName,i=this.options.registry.query(n);if(!i||!("blotName"in i))throw new Error(`Cannot initialize Quill without "${n}" blot`);if(this.scroll=new i(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new Uu(this.scroll),this.selection=new Du(this.scroll,this.emitter),this.composition=new Fu(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(x.events.EDITOR_CHANGE,o=>{o===x.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(x.events.SCROLL_UPDATE,(o,a)=>{let l=this.selection.lastRange,[u]=this.selection.getRange(),c=l&&u?{oldRange:l,newRange:u}:void 0;bt.call(this,()=>this.editor.update(null,a,c),o)}),this.emitter.on(x.events.SCROLL_EMBED_UPDATE,(o,a)=>{let l=this.selection.lastRange,[u]=this.selection.getRange(),c=l&&u?{oldRange:l,newRange:u}:void 0;bt.call(this,()=>{let f=new ee.default().retain(o.offset(this)).retain({[o.statics.blotName]:a});return this.editor.update(f,[],c)},r.sources.USER)}),s){let o=this.clipboard.convert({html:`${s}


    `,text:` `});this.setContents(o)}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"){let s=t;t=document.createElement("div"),t.classList.add(s)}return this.container.insertBefore(t,e),t}blur(){this.selection.setRange(null)}deleteText(t,e,s){return[t,e,,s]=Dt(t,e,s),bt.call(this,()=>this.editor.deleteText(t,e),s,t,-1*e)}disable(){this.enable(!1)}editReadOnly(t){this.allowReadOnlyEdits=!0;let 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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:x.sources.API;return bt.call(this,()=>{let n=this.getSelection(!0),i=new ee.default;if(n==null)return i;if(this.scroll.query(t,b.BLOCK))i=this.editor.formatLine(n.index,n.length,{[t]:e});else{if(n.length===0)return this.selection.format(t,e),i;i=this.editor.formatText(n.index,n.length,{[t]:e})}return this.setSelection(n,x.sources.SILENT),i},s)}formatLine(t,e,s,n,i){let o;return[t,e,o,i]=Dt(t,e,s,n,i),bt.call(this,()=>this.editor.formatLine(t,e,o),i,t,0)}formatText(t,e,s,n,i){let o;return[t,e,o,i]=Dt(t,e,s,n,i),bt.call(this,()=>this.editor.formatText(t,e,o),i,t,0)}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=null;if(typeof t=="number"?s=this.selection.getBounds(t,e):s=this.selection.getBounds(t.index,t.length),!s)return null;let n=this.container.getBoundingClientRect();return{bottom:s.bottom-n.top,height:s.height,left:s.left-n.left,right:s.right-n.left,top:s.top-n.top,width:s.width}}getContents(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-t;return[t,e]=Dt(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]&&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]=Dt(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]=Dt(t,e),this.editor.getText(t,e)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,e,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r.sources.API;return bt.call(this,()=>this.editor.insertEmbed(t,e,s),n,t)}insertText(t,e,s,n,i){let o;return[t,,o,i]=Dt(t,0,s,n,i),bt.call(this,()=>this.editor.insertText(t,e,o),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,s){return[t,e,,s]=Dt(t,e,s),bt.call(this,()=>this.editor.removeFormat(t,e),s,t)}scrollRectIntoView(t){zu(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(){let 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]:x.sources.API;return bt.call(this,()=>{t=new ee.default(t);let s=this.getLength(),n=this.editor.deleteText(0,s),i=this.editor.insertContents(0,t),o=this.editor.deleteText(this.getLength()-1,1);return n.compose(i).compose(o)},e)}setSelection(t,e,s){t==null?this.selection.setRange(null,e||r.sources.API):([t,e,,s]=Dt(t,e,s),this.selection.setRange(new Q(Math.max(0,t),e),s),s!==x.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:x.sources.API,s=new ee.default().insert(t);return this.setContents(s,e)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:x.sources.USER,e=this.scroll.update(t);return this.selection.update(t),e}updateContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:x.sources.API;return bt.call(this,()=>(t=new ee.default(t),this.editor.applyDelta(t)),e,!0)}};function Ku(r){return typeof r=="string"?document.querySelector(r):r}function fi(r){return Object.entries(r??{}).reduce((t,e)=>{let[s,n]=e;return Ut(L({},t),{[s]:n===!0?{}:n})},{})}function Gu(r){return Object.fromEntries(Object.entries(r).filter(t=>t[1]!==void 0))}function sy(r,t){let e=Ku(r);if(!e)throw new Error("Invalid Quill container");let n=!t.theme||t.theme===d.DEFAULTS.theme?Qe:d.import(`themes/${t.theme}`);if(!n)throw new Error(`Invalid theme ${t.theme}. Did you register it?`);let p=d.DEFAULTS,{modules:i}=p,o=Xs(p,["modules"]),m=n.DEFAULTS,{modules:a}=m,l=Xs(m,["modules"]),u=fi(t.modules);u!=null&&u.toolbar&&u.toolbar.constructor!==Object&&(u=Ut(L({},u),{toolbar:{container:u.toolbar}}));let c=tt({},fi(i),fi(a),u),f=L(L(L({},o),Gu(l)),Gu(t)),h=t.registry;return h?t.formats&&Ye.warn('Ignoring "formats" option because "registry" is specified'):h=t.formats?$u(t.formats,f.registry,Ye):f.registry,Ut(L({},f),{registry:h,container:e,theme:n,modules:Object.entries(c).reduce((y,v)=>{let[g,A]=v;if(!A)return y;let E=d.import(`modules/${g}`);return E==null?(Ye.error(`Cannot load ${g} module. Are you sure you registered it?`),y):Ut(L({},y),{[g]:tt({},E.DEFAULTS||{},A)})},{}),bounds:Ku(f.bounds)})}function bt(r,t,e,s){if(!this.isEnabled()&&t===x.sources.USER&&!this.allowReadOnlyEdits)return new ee.default;let n=e==null?null:this.getSelection(),i=this.editor.delta,o=r();if(n!=null&&(e===!0&&(e=n.index),s==null?n=Vu(n,o,t):s!==0&&(n=Vu(n,e,s,t)),this.setSelection(n,x.sources.SILENT)),o.length()>0){let a=[x.events.TEXT_CHANGE,o,i,t];this.emitter.emit(x.events.EDITOR_CHANGE,...a),t!==x.sources.SILENT&&this.emitter.emit(...a)}return o}function Dt(r,t,e,s,n){let i={};return typeof r.index=="number"&&typeof r.length=="number"?typeof t!="number"?(n=s,s=e,e=t,t=r.length,r=r.index):(t=r.length,r=r.index):typeof t!="number"&&(n=s,s=e,e=t,t=0),typeof e=="object"?(i=e,n=s):typeof e=="string"&&(s!=null?i[e]=s:n=e),n=n||x.sources.API,[r,t,i,n]}function Vu(r,t,e,s){let n=typeof e=="number"?e:0;if(r==null)return null;let i,o;return t&&typeof t.transformPosition=="function"?[i,o]=[r.index,r.index+r.length].map(a=>t.transformPosition(a,s!==x.sources.USER)):[i,o]=[r.index,r.index+r.length].map(a=>a=0?a+n:Math.max(t,a+n)),new Q(i,o-i)}var hi=class extends Ue{},dt=hi;var pt=ot(lt(),1);function Wu(r){return r instanceof B||r instanceof U}function Zu(r){return typeof r.updateContent=="function"}var ny=(()=>{class r extends lr{static blotName="scroll";static className="ql-editor";static tagName="DIV";static defaultChild=B;static allowedChildren=[B,U,dt];constructor(e,s,n){let{emitter:i}=n;super(e,s),this.emitter=i,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",o=>this.handleDragStart(o))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;let e=this.batch;this.batch=!1,this.update(e)}emitMount(e){this.emitter.emit(x.events.SCROLL_BLOT_MOUNT,e)}emitUnmount(e){this.emitter.emit(x.events.SCROLL_BLOT_UNMOUNT,e)}emitEmbedUpdate(e,s){this.emitter.emit(x.events.SCROLL_EMBED_UPDATE,e,s)}deleteAt(e,s){let[n,i]=this.line(e),[o]=this.line(e+s);if(super.deleteAt(e,s),o!=null&&n!==o&&i>0){if(n instanceof U||o instanceof U){this.optimize();return}let a=o.children.head instanceof $?null:o.children.head;n.moveChildren(o,a),n.remove()}this.optimize()}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",e?"true":"false")}formatAt(e,s,n,i){super.formatAt(e,s,n,i),this.optimize()}insertAt(e,s,n){if(e>=this.length())if(n==null||this.scroll.query(s,b.BLOCK)==null){let i=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(i),n==null&&s.endsWith(` `)?i.insertAt(0,s.slice(0,-1),n):i.insertAt(0,s,n)}else{let i=this.scroll.create(s,n);this.appendChild(i)}else super.insertAt(e,s,n);this.optimize()}insertBefore(e,s){if(e.statics.scope===b.INLINE_BLOT){let n=this.scroll.create(this.statics.defaultChild.blotName);n.appendChild(e),super.insertBefore(n,s)}else super.insertBefore(e,s)}insertContents(e,s){let n=this.deltaToRenderBlocks(s.concat(new pt.default().insert(` `))),i=n.pop();if(i==null)return;this.batchStart();let o=n.shift();if(o){let u=o.type==="block"&&(o.delta.length()===0||!this.descendant(U,e)[0]&&e{this.formatAt(h-1,1,y,m[y])}),e=h}let[a,l]=this.children.find(e);if(n.length&&(a&&(a=a.split(l),l=0),n.forEach(u=>{if(u.type==="block"){let c=this.createBlock(u.attributes,a||void 0);di(c,0,u.delta)}else{let c=this.create(u.key,u.value);this.insertBefore(c,a||void 0),Object.keys(u.attributes).forEach(f=>{c.format(f,u.attributes[f])})}})),i.type==="block"&&i.delta.length()){let u=a?a.offset(a.scroll)+l:this.length();di(this,u,i.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(e){let s=this.path(e).pop();if(!s)return[null,-1];let[n,i]=s;return n instanceof j?[n,i]:[null,-1]}line(e){return e===this.length()?this.line(e-1):this.descendant(Wu,e)}lines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,n=(i,o,a)=>{let l=[],u=a;return i.children.forEachAt(o,a,(c,f,h)=>{Wu(c)?l.push(c):c instanceof Ue&&(l=l.concat(n(c,f,u))),u-=h}),l};return n(this,e,s)}optimize(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(e,s),e.length>0&&this.emitter.emit(x.events.SCROLL_OPTIMIZE,e,s))}path(e){return super.path(e).slice(1)}remove(){}update(e){if(this.batch){Array.isArray(e)&&(this.batch=this.batch.concat(e));return}let s=x.sources.USER;typeof e=="string"&&(s=e),Array.isArray(e)||(e=this.observer.takeRecords()),e=e.filter(n=>{let{target:i}=n,o=this.find(i,!0);return o&&!Zu(o)}),e.length>0&&this.emitter.emit(x.events.SCROLL_BEFORE_UPDATE,s,e),super.update(e.concat([])),e.length>0&&this.emitter.emit(x.events.SCROLL_UPDATE,s,e)}updateEmbedAt(e,s,n){let[i]=this.descendant(o=>o instanceof U,e);i&&i.statics.blotName===s&&Zu(i)&&i.updateContent(n)}handleDragStart(e){e.preventDefault()}deltaToRenderBlocks(e){let s=[],n=new pt.default;return e.forEach(i=>{let o=i?.insert;if(o)if(typeof o=="string"){let a=o.split(` `);a.slice(0,-1).forEach(u=>{n.insert(u,i.attributes),s.push({type:"block",delta:n,attributes:i.attributes??{}}),n=new pt.default});let l=a[a.length-1];l&&n.insert(l,i.attributes)}else{let a=Object.keys(o)[0];if(!a)return;this.query(a,b.INLINE)?n.push(i):(n.length()&&s.push({type:"block",delta:n,attributes:{}}),n=new pt.default,s.push({type:"blockEmbed",key:a,value:o[a],attributes:i.attributes??{}}))}}),n.length()&&s.push({type:"block",delta:n,attributes:{}}),s}createBlock(e,s){let n,i={};Object.entries(e).forEach(l=>{let[u,c]=l;this.query(u,b.BLOCK&b.BLOT)!=null?n=u:i[u]=c});let o=this.create(n||this.statics.defaultChild.blotName,n?e[n]:void 0);this.insertBefore(o,s||void 0);let a=o.length();return Object.entries(i).forEach(l=>{let[u,c]=l;o.formatAt(0,a,u,c)}),o}}return r})();function di(r,t,e){e.reduce((s,n)=>{let i=pt.Op.length(n),o=n.attributes||{};if(n.insert!=null){if(typeof n.insert=="string"){let a=n.insert;r.insertAt(s,a);let[l]=r.descendant(j,s),u=st(l);o=pt.AttributeMap.diff(u,o)||{}}else if(typeof n.insert=="object"){let a=Object.keys(n.insert)[0];if(a==null)return s;if(r.insertAt(s,a,n.insert[a]),r.scroll.query(a,b.INLINE)!=null){let[u]=r.descendant(j,s),c=st(u);o=pt.AttributeMap.diff(c,o)||{}}}}return Object.keys(o).forEach(a=>{r.formatAt(s,i,a,o[a])}),s+i},t)}var Xu=ny;var nt=ot(lt(),1);var pi={scope:b.BLOCK,whitelist:["right","center","justify"]},Qu=new W("align","align",pi),mi=new D("align","ql-align",pi),Is=new rt("align","text-align",pi);var Er=class extends rt{value(t){let e=super.value(t);return e.startsWith("rgb(")?(e=e.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${e.split(",").map(n=>`00${parseInt(n,10).toString(16)}`.slice(-2)).join("")}`):e}},Yu=new D("color","ql-color",{scope:b.INLINE}),Tr=new Er("color","color",{scope:b.INLINE});var Ju=new D("background","ql-bg",{scope:b.INLINE}),Nr=new Er("background","background-color",{scope:b.INLINE});var Tt=class extends dt{static create(t){let e=super.create(t);return e.setAttribute("spellcheck","false"),e}code(t,e){return this.children.map(s=>s.length()<=1?"":s.domNode.innerText).join(` `).slice(t,t+e)}html(t,e){return`
    ${ye(this.code(t,e))}
    
    `}},F=(()=>{class r extends B{static TAB=" ";static register(){d.register(Tt)}}return r})(),tc=(()=>{class r extends K{}return r.blotName="code",r.tagName="CODE",r})();F.blotName="code-block";F.className="ql-code-block";F.tagName="DIV";Tt.blotName="code-block-container";Tt.className="ql-code-block-container";Tt.tagName="DIV";Tt.allowedChildren=[F];F.allowedChildren=[R,$,te];F.requiredContainer=Tt;var gi={scope:b.BLOCK,whitelist:["rtl"]},ks=new W("direction","dir",gi),bi=new D("direction","ql-direction",gi),Rs=new rt("direction","direction",gi);var ec={scope:b.INLINE,whitelist:["serif","monospace"]},xi=new D("font","ql-font",ec),yi=class extends rt{value(t){return super.value(t).replace(/["']/g,"")}},Bs=new yi("font","font-family",ec);var vi=new D("size","ql-size",{scope:b.INLINE,whitelist:["small","large","huge"]}),Ms=new rt("size","font-size",{scope:b.INLINE,whitelist:["10px","18px","32px"]});var V=ot(lt(),1);var iy=ut("quill:keyboard"),oy=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",wr=class r extends k{static match(t,e){return["altKey","ctrlKey","metaKey","shiftKey"].some(s=>!!e[s]!==t[s]&&e[s]!==null)?!1:e.key===t.key||e.key===t.which}constructor(t,e){super(t,e),this.bindings={},Object.keys(this.options.bindings).forEach(s=>{this.options.bindings[s]&&this.addBinding(this.options.bindings[s])}),this.addBinding({key:"Enter",shiftKey:null},this.handleEnter),this.addBinding({key:"Enter",metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:"Backspace"},{collapsed:!0},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0},this.handleDelete)):(this.addBinding({key:"Backspace"},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:"Backspace"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Delete"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Backspace",altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=ly(t);if(n==null){iy.warn("Attempted to add invalid keyboard binding",n);return}typeof e=="function"&&(e={handler:e}),typeof s=="function"&&(s={handler:s}),(Array.isArray(n.key)?n.key:[n.key]).forEach(o=>{let a=L(L(Ut(L({},n),{key:o}),e),s);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;let n=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(g=>r.match(t,g));if(n.length===0)return;let i=d.find(t.target,!0);if(i&&i.scroll!==this.quill.scroll)return;let o=this.quill.getSelection();if(o==null||!this.quill.hasFocus())return;let[a,l]=this.quill.getLine(o.index),[u,c]=this.quill.getLeaf(o.index),[f,h]=o.length===0?[u,c]:this.quill.getLeaf(o.index+o.length),p=u instanceof Fe?u.value().slice(0,c):"",m=f instanceof Fe?f.value().slice(h):"",y={collapsed:o.length===0,empty:o.length===0&&a.length()<=1,format:this.quill.getFormat(o),line:a,offset:l,prefix:p,suffix:m,event:t};n.some(g=>{if(g.collapsed!=null&&g.collapsed!==y.collapsed||g.empty!=null&&g.empty!==y.empty||g.offset!=null&&g.offset!==y.offset)return!1;if(Array.isArray(g.format)){if(g.format.every(A=>y.format[A]==null))return!1}else if(typeof g.format=="object"&&!Object.keys(g.format).every(A=>g.format[A]===!0?y.format[A]!=null:g.format[A]===!1?y.format[A]==null:le(g.format[A],y.format[A])))return!1;return g.prefix!=null&&!g.prefix.test(y.prefix)||g.suffix!=null&&!g.suffix.test(y.suffix)?!1:g.handler.call(this,o,y,g)!==!0})&&t.preventDefault()})}handleBackspace(t,e){let s=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(e.prefix)?2:1;if(t.index===0||this.quill.getLength()<=1)return;let n={},[i]=this.quill.getLine(t.index),o=new V.default().retain(t.index-s).delete(s);if(e.offset===0){let[a]=this.quill.getLine(t.index-1);if(a&&!(a.statics.blotName==="block"&&a.length()<=1)){let u=i.formats(),c=this.quill.getFormat(t.index-1,1);if(n=V.AttributeMap.diff(u,c)||{},Object.keys(n).length>0){let f=new V.default().retain(t.index+i.length()-2).retain(1,n);o=o.compose(f)}}}this.quill.updateContents(o,d.sources.USER),this.quill.focus()}handleDelete(t,e){let s=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(e.suffix)?2:1;if(t.index>=this.quill.getLength()-s)return;let n={},[i]=this.quill.getLine(t.index),o=new V.default().retain(t.index).delete(s);if(e.offset>=i.length()-1){let[a]=this.quill.getLine(t.index+1);if(a){let l=i.formats(),u=this.quill.getFormat(t.index,1);n=V.AttributeMap.diff(l,u)||{},Object.keys(n).length>0&&(o=o.retain(a.length()-1).retain(1,n))}}this.quill.updateContents(o,d.sources.USER),this.quill.focus()}handleDeleteRange(t){Sr({range:t,quill:this.quill}),this.quill.focus()}handleEnter(t,e){let s=Object.keys(e.format).reduce((i,o)=>(this.quill.scroll.query(o,b.BLOCK)&&!Array.isArray(e.format[o])&&(i[o]=e.format[o]),i),{}),n=new V.default().retain(t.index).delete(t.length).insert(` `,s);this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(t.index+1,d.sources.SILENT),this.quill.focus()}},ay={bindings:{bold:Ai("bold"),italic:Ai("italic"),underline:Ai("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(r,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","+1",d.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(r,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","-1",d.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(r,t){t.format.indent!=null?this.quill.format("indent","-1",d.sources.USER):t.format.list!=null&&this.quill.format("list",!1,d.sources.USER)}},"indent code-block":rc(!0),"outdent code-block":rc(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(r){this.quill.deleteText(r.index-1,1,d.sources.USER)}},tab:{key:"Tab",handler(r,t){if(t.format.table)return!0;this.quill.history.cutoff();let e=new V.default().retain(r.index).delete(r.length).insert(" ");return this.quill.updateContents(e,d.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(r.index+1,d.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,d.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(r,t){let e={list:!1};t.format.indent&&(e.indent=!1),this.quill.formatLine(r.index,r.length,e,d.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(r){let[t,e]=this.quill.getLine(r.index),s=Ut(L({},t.formats()),{list:"checked"}),n=new V.default().retain(r.index).insert(` `,s).retain(t.length()-e-1).retain(1,{list:"unchecked"});this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(r.index+1,d.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(r,t){let[e,s]=this.quill.getLine(r.index),n=new V.default().retain(r.index).insert(` `,t.format).retain(e.length()-s-1).retain(1,{header:null});this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(r.index+1,d.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:"Backspace",format:["table"],collapsed:!0,offset:0,handler(){}},"table delete":{key:"Delete",format:["table"],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:"Enter",shiftKey:null,format:["table"],handler(r){let t=this.quill.getModule("table");if(t){let[e,s,n,i]=t.getTable(r),o=uy(e,s,n,i);if(o==null)return;let a=e.offset();if(o<0){let l=new V.default().retain(a).insert(` `);this.quill.updateContents(l,d.sources.USER),this.quill.setSelection(r.index+1,r.length,d.sources.SILENT)}else if(o>0){a+=e.length();let l=new V.default().retain(a).insert(` `);this.quill.updateContents(l,d.sources.USER),this.quill.setSelection(a,d.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(r,t){let{event:e,line:s}=t,n=s.offset(this.quill.scroll);e.shiftKey?this.quill.setSelection(n-1,d.sources.USER):this.quill.setSelection(n+s.length(),d.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(r,t){if(this.quill.scroll.query("list")==null)return!0;let{length:e}=t.prefix,[s,n]=this.quill.getLine(r.index);if(n>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(r.index," ",d.sources.USER),this.quill.history.cutoff();let o=new V.default().retain(r.index-n).delete(e+1).retain(s.length()-2-n).retain(1,{list:i});return this.quill.updateContents(o,d.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(r.index-e,d.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(r){let[t,e]=this.quill.getLine(r.index),s=2,n=t;for(;n!=null&&n.length()<=1&&n.formats()["code-block"];)if(n=n.prev,s-=1,s<=0){let i=new V.default().retain(r.index+t.length()-e-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(i,d.sources.USER),this.quill.setSelection(r.index-1,d.sources.SILENT),!1}return!0}},"embed left":Ds("ArrowLeft",!1),"embed left shift":Ds("ArrowLeft",!0),"embed right":Ds("ArrowRight",!1),"embed right shift":Ds("ArrowRight",!0),"table down":sc(!1),"table up":sc(!0)}};wr.DEFAULTS=ay;function rc(r){return{key:"Tab",shiftKey:!r,format:{"code-block":!0},handler(t,e){let{event:s}=e,n=this.quill.scroll.query("code-block"),{TAB:i}=n;if(t.length===0&&!s.shiftKey){this.quill.insertText(t.index,i,d.sources.USER),this.quill.setSelection(t.index+i.length,d.sources.SILENT);return}let o=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t),{index:a,length:l}=t;o.forEach((u,c)=>{r?(u.insertAt(0,i),c===0?a+=i.length:l+=i.length):u.domNode.textContent.startsWith(i)&&(u.deleteAt(0,i.length),c===0?a-=i.length:l-=i.length)}),this.quill.update(d.sources.USER),this.quill.setSelection(a,l,d.sources.SILENT)}}}function Ds(r,t){return{key:r,shiftKey:t,altKey:null,[r==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(s){let{index:n}=s;r==="ArrowRight"&&(n+=s.length+1);let[i]=this.quill.getLeaf(n);return i instanceof q?(r==="ArrowLeft"?t?this.quill.setSelection(s.index-1,s.length+1,d.sources.USER):this.quill.setSelection(s.index-1,d.sources.USER):t?this.quill.setSelection(s.index,s.length+1,d.sources.USER):this.quill.setSelection(s.index+s.length+1,d.sources.USER),!1):!0}}}function Ai(r){return{key:r[0],shortKey:!0,handler(t,e){this.quill.format(r,!e.format[r],d.sources.USER)}}}function sc(r){return{key:r?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(t,e){let s=r?"prev":"next",n=e.line,i=n.parent[s];if(i!=null){if(i.statics.blotName==="table-row"){let o=i.children.head,a=n;for(;a.prev!=null;)a=a.prev,o=o.next;let l=o.offset(this.quill.scroll)+Math.min(e.offset,o.length()-1);this.quill.setSelection(l,0,d.sources.USER)}}else{let o=n.table()[s];o!=null&&(r?this.quill.setSelection(o.offset(this.quill.scroll)+o.length()-1,0,d.sources.USER):this.quill.setSelection(o.offset(this.quill.scroll),0,d.sources.USER))}return!1}}}function ly(r){if(typeof r=="string"||typeof r=="number")r={key:r};else if(typeof r=="object")r=At(r);else return null;return r.shortKey&&(r[oy]=r.shortKey,delete r.shortKey),r}function Sr(r){let{quill:t,range:e}=r,s=t.getLines(e),n={};if(s.length>1){let i=s[0].formats(),o=s[s.length-1].formats();n=V.AttributeMap.diff(o,i)||{}}t.deleteText(e,d.sources.USER),Object.keys(n).length>0&&t.formatLine(e.index,1,n,d.sources.USER),t.setSelection(e.index,d.sources.SILENT)}function uy(r,t,e,s){return t.prev==null&&t.next==null?e.prev==null&&e.next==null?s===0?-1:1:e.prev==null?-1:1:t.prev==null?-1:t.next==null?1:null}var cy=/font-weight:\s*normal/,fy=["P","OL","UL"],nc=r=>r&&fy.includes(r.tagName),hy=r=>{Array.from(r.querySelectorAll("br")).filter(t=>nc(t.previousElementSibling)&&nc(t.nextElementSibling)).forEach(t=>{t.parentNode?.removeChild(t)})},dy=r=>{Array.from(r.querySelectorAll('b[style*="font-weight"]')).filter(t=>t.getAttribute("style")?.match(cy)).forEach(t=>{let e=r.createDocumentFragment();e.append(...t.childNodes),t.parentNode?.replaceChild(e,t)})};function Ei(r){r.querySelector('[id^="docs-internal-guid-"]')&&(dy(r),hy(r))}var py=/\bmso-list:[^;]*ignore/i,my=/\bmso-list:[^;]*\bl(\d+)/i,gy=/\bmso-list:[^;]*\blevel(\d+)/i,by=(r,t)=>{let e=r.getAttribute("style"),s=e?.match(my);if(!s)return null;let n=Number(s[1]),i=e?.match(gy),o=i?Number(i[1]):1,a=new RegExp(`@list l${n}:level${o}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),l=t.match(a),u=l&&l[1]==="bullet"?"bullet":"ordered";return{id:n,indent:o,type:u,element:r}},yy=r=>{let t=Array.from(r.querySelectorAll("[style*=mso-list]")),e=[],s=[];t.forEach(o=>{(o.getAttribute("style")||"").match(py)?e.push(o):s.push(o)}),e.forEach(o=>o.parentNode?.removeChild(o));let n=r.documentElement.innerHTML,i=s.map(o=>by(o,n)).filter(o=>o);for(;i.length;){let o=[],a=i.shift();for(;a;)o.push(a),a=i.length&&i[0]?.element===a.element.nextElementSibling&&i[0].id===a.id?i.shift():null;let l=document.createElement("ul");o.forEach(f=>{let h=document.createElement("li");h.setAttribute("data-list",f.type),f.indent>1&&h.setAttribute("class",`ql-indent-${f.indent-1}`),h.innerHTML=f.element.innerHTML,l.appendChild(h)});let u=o[0]?.element,{parentNode:c}=u??{};u&&c?.replaceChild(l,u),o.slice(1).forEach(f=>{let{element:h}=f;c?.removeChild(h)})}};function Ti(r){r.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&yy(r)}var xy=[Ti,Ei],vy=r=>{r.documentElement&&xy.forEach(t=>{t(r)})},ic=vy;var Ay=ut("quill:clipboard"),Ey=[[Node.TEXT_NODE,Ry],[Node.TEXT_NODE,ac],["br",Ly],[Node.ELEMENT_NODE,ac],[Node.ELEMENT_NODE,Sy],[Node.ELEMENT_NODE,wy],[Node.ELEMENT_NODE,Iy],["li",_y],["ol, ul",qy],["pre",Oy],["tr",ky],["b",Ni("bold")],["i",Ni("italic")],["strike",Ni("strike")],["style",Cy]],Ty=[Qu,ks].reduce((r,t)=>(r[t.keyName]=t,r),{}),oc=[Is,Nr,Tr,Rs,Bs,Ms].reduce((r,t)=>(r[t.keyName]=t,r),{}),lc=(()=>{class r extends k{static DEFAULTS={matchers:[]};constructor(e,s){super(e,s),this.quill.root.addEventListener("copy",n=>this.onCaptureCopy(n,!1)),this.quill.root.addEventListener("cut",n=>this.onCaptureCopy(n,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],Ey.concat(this.options.matchers??[]).forEach(n=>{let[i,o]=n;this.addMatcher(i,o)})}addMatcher(e,s){this.matchers.push([e,s])}convert(e){let{html:s,text:n}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(i[F.blotName])return new nt.default().insert(n||"",{[F.blotName]:i[F.blotName]});if(!s)return new nt.default().insert(n||"",i);let o=this.convertHTML(s);return Lr(o,` `)&&(o.ops[o.ops.length-1].attributes==null||i.table)?o.compose(new nt.default().retain(o.length()-1).delete(1)):o}normalizeHTML(e){ic(e)}convertHTML(e){let s=new DOMParser().parseFromString(e,"text/html");this.normalizeHTML(s);let n=s.body,i=new WeakMap,[o,a]=this.prepareMatching(n,i);return Ps(this.quill.scroll,n,o,a,i)}dangerouslyPasteHTML(e,s){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:d.sources.API;if(typeof e=="string"){let i=this.convert({html:e,text:""});this.quill.setContents(i,s),this.quill.setSelection(0,d.sources.SILENT)}else{let i=this.convert({html:s,text:""});this.quill.updateContents(new nt.default().retain(e).concat(i),n),this.quill.setSelection(e+i.length(),d.sources.SILENT)}}onCaptureCopy(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.defaultPrevented)return;e.preventDefault();let[n]=this.quill.selection.getRange();if(n==null)return;let{html:i,text:o}=this.onCopy(n,s);e.clipboardData?.setData("text/plain",o),e.clipboardData?.setData("text/html",i),s&&Sr({range:n,quill:this.quill})}normalizeURIList(e){return e.split(/\r?\n/).filter(s=>s[0]!=="#").join(` `)}onCapturePaste(e){if(e.defaultPrevented||!this.quill.isEnabled())return;e.preventDefault();let s=this.quill.getSelection(!0);if(s==null)return;let n=e.clipboardData?.getData("text/html"),i=e.clipboardData?.getData("text/plain");if(!n&&!i){let a=e.clipboardData?.getData("text/uri-list");a&&(i=this.normalizeURIList(a))}let o=Array.from(e.clipboardData?.files||[]);if(!n&&o.length>0){this.quill.uploader.upload(s,o);return}if(n&&o.length>0){let a=new DOMParser().parseFromString(n,"text/html");if(a.body.childElementCount===1&&a.body.firstElementChild?.tagName==="IMG"){this.quill.uploader.upload(s,o);return}}this.onPaste(s,{html:n,text:i})}onCopy(e){let s=this.quill.getText(e);return{html:this.quill.getSemanticHTML(e),text:s}}onPaste(e,s){let{text:n,html:i}=s,o=this.quill.getFormat(e.index),a=this.convert({text:n,html:i},o);Ay.log("onPaste",a,{text:n,html:i});let l=new nt.default().retain(e.index).delete(e.length).concat(a);this.quill.updateContents(l,d.sources.USER),this.quill.setSelection(l.length()-e.length,d.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(e,s){let n=[],i=[];return this.matchers.forEach(o=>{let[a,l]=o;switch(a){case Node.TEXT_NODE:i.push(l);break;case Node.ELEMENT_NODE:n.push(l);break;default:Array.from(e.querySelectorAll(a)).forEach(u=>{s.has(u)?s.get(u)?.push(l):s.set(u,[l])});break}}),[n,i]}}return r})();function xe(r,t,e,s){return s.query(t)?r.reduce((n,i)=>{if(!i.insert)return n;if(i.attributes&&i.attributes[t])return n.push(i);let o=e?{[t]:e}:{};return n.insert(i.insert,L(L({},o),i.attributes))},new nt.default):r}function Lr(r,t){let e="";for(let s=r.ops.length-1;s>=0&&e.lengtho(t,i,r),new nt.default):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((i,o)=>{let a=Ps(r,o,e,s,n);return o.nodeType===t.ELEMENT_NODE&&(a=e.reduce((l,u)=>u(o,l,r),a),a=(n.get(o)||[]).reduce((l,u)=>u(o,l,r),a)),i.concat(a)},new nt.default):new nt.default}function Ni(r){return(t,e,s)=>xe(e,r,!0,s)}function wy(r,t,e){let s=W.keys(r),n=D.keys(r),i=rt.keys(r),o={};return s.concat(n).concat(i).forEach(a=>{let l=e.query(a,b.ATTRIBUTE);l!=null&&(o[l.attrName]=l.value(r),o[l.attrName])||(l=Ty[a],l!=null&&(l.attrName===a||l.keyName===a)&&(o[l.attrName]=l.value(r)||void 0),l=oc[a],l!=null&&(l.attrName===a||l.keyName===a)&&(l=oc[a],o[l.attrName]=l.value(r)||void 0))}),Object.entries(o).reduce((a,l)=>{let[u,c]=l;return xe(a,u,c,e)},t)}function Sy(r,t,e){let s=e.query(r);if(s==null)return t;if(s.prototype instanceof q){let n={},i=s.value(r);if(i!=null)return n[s.blotName]=i,new nt.default().insert(n,s.formats(r,e))}else if(s.prototype instanceof ue&&!Lr(t,` `)&&t.insert(` `),"blotName"in s&&"formats"in s&&typeof s.formats=="function")return xe(t,s.blotName,s.formats(r,e),e);return t}function Ly(r,t){return Lr(t,` `)||t.insert(` `),t}function Oy(r,t,e){let s=e.query("code-block"),n=s&&"formats"in s&&typeof s.formats=="function"?s.formats(r,e):!0;return xe(t,"code-block",n,e)}function Cy(){return new nt.default}function _y(r,t,e){let s=e.query(r);if(s==null||s.blotName!=="list"||!Lr(t,` `))return t;let n=-1,i=r.parentNode;for(;i!=null;)["OL","UL"].includes(i.tagName)&&(n+=1),i=i.parentNode;return n<=0?t:t.reduce((o,a)=>a.insert?a.attributes&&typeof a.attributes.indent=="number"?o.push(a):o.insert(a.insert,L({indent:n},a.attributes||{})):o,new nt.default)}function qy(r,t,e){let s=r,n=s.tagName==="OL"?"ordered":"bullet",i=s.getAttribute("data-checked");return i&&(n=i==="true"?"checked":"unchecked"),xe(t,"list",n,e)}function ac(r,t,e){if(!Lr(t,` `)){if(re(r,e)&&(r.childNodes.length>0||r instanceof HTMLParagraphElement))return t.insert(` `);if(t.length()>0&&r.nextSibling){let s=r.nextSibling;for(;s!=null;){if(re(s,e))return t.insert(` `);let n=e.query(s);if(n&&n.prototype instanceof U)return t.insert(` `);s=s.firstChild}}}return t}function Iy(r,t,e){let s={},n=r.style||{};return n.fontStyle==="italic"&&(s.italic=!0),n.textDecoration==="underline"&&(s.underline=!0),n.textDecoration==="line-through"&&(s.strike=!0),(n.fontWeight?.startsWith("bold")||parseInt(n.fontWeight,10)>=700)&&(s.bold=!0),t=Object.entries(s).reduce((i,o)=>{let[a,l]=o;return xe(i,a,l,e)},t),parseFloat(n.textIndent||0)>0?new nt.default().insert(" ").concat(t):t}function ky(r,t,e){let s=r.parentElement?.tagName==="TABLE"?r.parentElement:r.parentElement?.parentElement;if(s!=null){let i=Array.from(s.querySelectorAll("tr")).indexOf(r)+1;return xe(t,"table",i,e)}return t}function Ry(r,t,e){let s=r.data;if(r.parentElement?.tagName==="O:P")return t.insert(s.trim());if(!uc(r)){if(s.trim().length===0&&s.includes(` `)&&!Ny(r,e))return t;s=s.replace(/[^\S\u00a0]/g," "),s=s.replace(/ {2,}/g," "),(r.previousSibling==null&&r.parentElement!=null&&re(r.parentElement,e)||r.previousSibling instanceof Element&&re(r.previousSibling,e))&&(s=s.replace(/^ /,"")),(r.nextSibling==null&&r.parentElement!=null&&re(r.parentElement,e)||r.nextSibling instanceof Element&&re(r.nextSibling,e))&&(s=s.replace(/ $/,"")),s=s.replaceAll("\xA0"," ")}return t.insert(s)}var fc=(()=>{class r extends k{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};lastRecorded=0;ignoreChange=!1;stack={undo:[],redo:[]};currentRange=null;constructor(e,s){super(e,s),this.quill.on(d.events.EDITOR_CHANGE,(n,i,o,a)=>{n===d.events.SELECTION_CHANGE?i&&a!==d.sources.SILENT&&(this.currentRange=i):n===d.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||a===d.sources.USER?this.record(i,o):this.transform(i)),this.currentRange=wi(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",n=>{n.inputType==="historyUndo"?(this.undo(),n.preventDefault()):n.inputType==="historyRedo"&&(this.redo(),n.preventDefault())})}change(e,s){if(this.stack[e].length===0)return;let n=this.stack[e].pop();if(!n)return;let i=this.quill.getContents(),o=n.delta.invert(i);this.stack[s].push({delta:o,range:wi(n.range,o)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,d.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(e,s){if(e.ops.length===0)return;this.stack.redo=[];let n=e.invert(s),i=this.currentRange,o=Date.now();if(this.lastRecorded+this.options.delay>o&&this.stack.undo.length>0){let a=this.stack.undo.pop();a&&(n=n.compose(a.delta),i=a.range)}else this.lastRecorded=o;n.length()!==0&&(this.stack.undo.push({delta:n,range:i}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(e){cc(this.stack.undo,e),cc(this.stack.redo,e)}undo(){this.change("undo","redo")}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,d.sources.USER);else{let s=My(this.quill.scroll,e.delta);this.quill.setSelection(s,d.sources.USER)}}}return r})();function cc(r,t){let e=t;for(let s=r.length-1;s>=0;s-=1){let n=r[s];r[s]={delta:e.transform(n.delta,!0),range:n.range&&wi(n.range,e)},e=n.delta.transform(e),r[s].delta.length()===0&&r.splice(s,1)}}function By(r,t){let e=t.ops[t.ops.length-1];return e==null?!1:e.insert!=null?typeof e.insert=="string"&&e.insert.endsWith(` `):e.attributes!=null?Object.keys(e.attributes).some(s=>r.query(s,b.BLOCK)!=null):!1}function My(r,t){let e=t.reduce((n,i)=>n+(i.delete||0),0),s=t.length()-e;return By(r,t)&&(s-=1),s}function wi(r,t){if(!r)return r;let e=t.transformPosition(r.index),s=t.transformPosition(r.index+r.length);return{index:e,length:s-e}}var hc=ot(lt(),1);var Dy=(()=>{class r extends k{constructor(e,s){super(e,s),e.root.addEventListener("drop",n=>{n.preventDefault();let i=null;if(document.caretRangeFromPoint)i=document.caretRangeFromPoint(n.clientX,n.clientY);else if(document.caretPositionFromPoint){let a=document.caretPositionFromPoint(n.clientX,n.clientY);i=document.createRange(),i.setStart(a.offsetNode,a.offset),i.setEnd(a.offsetNode,a.offset)}let o=i&&e.selection.normalizeNative(i);if(o){let a=e.selection.normalizedToRange(o);n.dataTransfer?.files&&this.upload(a,n.dataTransfer.files)}})}upload(e,s){let n=[];Array.from(s).forEach(i=>{i&&this.options.mimetypes?.includes(i.type)&&n.push(i)}),n.length>0&&this.options.handler.call(this,e,n)}}return r.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(t,e){if(!this.quill.scroll.query("image"))return;let s=e.map(n=>new Promise(i=>{let o=new FileReader;o.onload=()=>{i(o.result)},o.readAsDataURL(n)}));Promise.all(s).then(n=>{let i=n.reduce((o,a)=>o.insert({image:a}),new hc.default().retain(t.index).delete(t.length));this.quill.updateContents(i,x.sources.USER),this.quill.setSelection(t.index+n.length,x.sources.SILENT)})}},r})(),dc=Dy;var se=ot(lt(),1);var pc=ot(lt(),1);var jy=["insertText","insertReplacementText"],Si=class extends k{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",s=>{this.handleBeforeInput(s)}),/Android/i.test(navigator.userAgent)||t.on(d.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(t){Sr({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){let s=this.quill.getFormat(t.index,1);this.deleteRange(t),this.quill.updateContents(new pc.default().retain(t.index).insert(e,s),d.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,d.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!jy.includes(t.inputType))return;let e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||e.collapsed===!0)return;let s=Py(t);if(s==null)return;let n=this.quill.selection.normalizeNative(e),i=n?this.quill.selection.normalizedToRange(n):null;i&&this.replaceText(i,s)&&t.preventDefault()}handleCompositionStart(){let t=this.quill.getSelection();t&&this.replaceText(t)}};function Py(r){return typeof r.data=="string"?r.data:r.dataTransfer?.types.includes("text/plain")?r.dataTransfer.getData("text/plain"):null}var mc=Si;var Uy=/Mac/i.test(navigator.platform),Fy=100,Hy=r=>!!(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"||r.key==="Home"||Uy&&r.key==="a"&&r.ctrlKey===!0),Li=class extends k{isListening=!1;selectionChangeDeadline=0;constructor(t,e){super(t,e),this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(t,e){let{line:s,event:n}=e;if(!(s instanceof et)||!s.uiNode)return!0;let i=getComputedStyle(s.domNode).direction==="rtl";return i&&n.key!=="ArrowRight"||!i&&n.key!=="ArrowLeft"?!0:(this.quill.setSelection(t.index-1,t.length+(n.shiftKey?1:0),d.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",t=>{!t.defaultPrevented&&Hy(t)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+Fy,this.isListening)return;this.isListening=!0;let t=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",t,{once:!0})}handleSelectionChange(){let t=document.getSelection();if(!t)return;let e=t.getRangeAt(0);if(e.collapsed!==!0||e.startOffset!==0)return;let s=this.quill.scroll.find(e.startContainer);if(!(s instanceof et)||!s.uiNode)return;let n=document.createRange();n.setStartAfter(s.uiNode),n.setEndAfter(s.uiNode),t.removeAllRanges(),t.addRange(n)}},gc=Li;d.register({"blots/block":B,"blots/block/embed":U,"blots/break":$,"blots/container":dt,"blots/cursor":te,"blots/embed":Xe,"blots/inline":K,"blots/scroll":Xu,"blots/text":R,"modules/clipboard":lc,"modules/history":fc,"modules/keyboard":wr,"modules/uploader":dc,"modules/input":mc,"modules/uiNode":gc});var Us=d;var Oi=class extends D{add(t,e){let s=0;if(e==="+1"||e==="-1"){let n=this.value(t)||0;s=e==="+1"?n+1:n-1}else typeof e=="number"&&(s=e);return s===0?(this.remove(t),!0):super.add(t,s.toString())}canAdd(t,e){return super.canAdd(t,e)||super.canAdd(t,parseInt(e,10))}value(t){return parseInt(super.value(t),10)||void 0}},zy=new Oi("indent","ql-indent",{scope:b.BLOCK,whitelist:[1,2,3,4,5,6,7,8]}),bc=zy;var $y=(()=>{class r extends B{static blotName="blockquote";static tagName="blockquote"}return r})(),yc=$y;var Ky=(()=>{class r extends B{static blotName="header";static tagName=["H1","H2","H3","H4","H5","H6"];static formats(e){return this.tagName.indexOf(e.tagName)+1}}return r})(),xc=Ky;var Ci=(()=>{class r extends dt{}return r.blotName="list-container",r.tagName="OL",r})(),Fs=(()=>{class r extends B{static create(e){let s=super.create();return s.setAttribute("data-list",e),s}static formats(e){return e.getAttribute("data-list")||void 0}static register(){d.register(Ci)}constructor(e,s){super(e,s);let n=s.ownerDocument.createElement("span"),i=o=>{if(!e.isEnabled())return;let a=this.statics.formats(s,e);a==="checked"?(this.format("list","unchecked"),o.preventDefault()):a==="unchecked"&&(this.format("list","checked"),o.preventDefault())};n.addEventListener("mousedown",i),n.addEventListener("touchstart",i),this.attachUI(n)}format(e,s){e===this.statics.blotName&&s?this.domNode.setAttribute("data-list",s):super.format(e,s)}}return r.blotName="list",r.tagName="LI",r})();Ci.allowedChildren=[Fs];Fs.requiredContainer=Ci;var Gy=(()=>{class r extends K{static blotName="bold";static tagName=["STRONG","B"];static create(){return super.create()}static formats(){return!0}optimize(e){super.optimize(e),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}return r})(),Je=Gy;var Vy=(()=>{class r extends Je{static blotName="italic";static tagName=["EM","I"]}return r})(),vc=Vy;var ve=(()=>{class r extends K{static blotName="link";static tagName="A";static SANITIZED_URL="about:blank";static PROTOCOL_WHITELIST=["http","https","mailto","tel","sms"];static create(e){let s=super.create(e);return s.setAttribute("href",this.sanitize(e)),s.setAttribute("rel","noopener noreferrer"),s.setAttribute("target","_blank"),s}static formats(e){return e.getAttribute("href")}static sanitize(e){return _i(e,this.PROTOCOL_WHITELIST)?e:this.SANITIZED_URL}format(e,s){e!==this.statics.blotName||!s?super.format(e,s):this.domNode.setAttribute("href",this.constructor.sanitize(s))}}return r})();function _i(r,t){let e=document.createElement("a");e.href=r;let s=e.href.slice(0,e.href.indexOf(":"));return t.indexOf(s)>-1}var Wy=(()=>{class r extends K{static blotName="script";static tagName=["SUB","SUP"];static create(e){return e==="super"?document.createElement("sup"):e==="sub"?document.createElement("sub"):super.create(e)}static formats(e){if(e.tagName==="SUB")return"sub";if(e.tagName==="SUP")return"super"}}return r})(),Ac=Wy;var Zy=(()=>{class r extends Je{static blotName="strike";static tagName=["S","STRIKE"]}return r})(),Ec=Zy;var Xy=(()=>{class r extends K{static blotName="underline";static tagName="U"}return r})(),Tc=Xy;var Qy=(()=>{class r extends Xe{static blotName="formula";static className="ql-formula";static tagName="SPAN";static create(e){if(window.katex==null)throw new Error("Formula module requires KaTeX.");let s=super.create(e);return typeof e=="string"&&(window.katex.render(e,s,{throwOnError:!1,errorColor:"#f00"}),s.setAttribute("data-value",e)),s}static value(e){return e.getAttribute("data-value")}html(){let{formula:e}=this.value();return`${e}`}}return r})(),Nc=Qy;var wc=["alt","height","width"],Yy=(()=>{class r extends q{static blotName="image";static tagName="IMG";static create(e){let s=super.create(e);return typeof e=="string"&&s.setAttribute("src",this.sanitize(e)),s}static formats(e){return wc.reduce((s,n)=>(e.hasAttribute(n)&&(s[n]=e.getAttribute(n)),s),{})}static match(e){return/\.(jpe?g|gif|png)$/.test(e)||/^data:image\/.+;base64/.test(e)}static sanitize(e){return _i(e,["http","https","data"])?e:"//:0"}static value(e){return e.getAttribute("src")}format(e,s){wc.indexOf(e)>-1?s?this.domNode.setAttribute(e,s):this.domNode.removeAttribute(e):super.format(e,s)}}return r})(),Sc=Yy;var Lc=["height","width"],Jy=(()=>{class r extends U{static blotName="video";static className="ql-video";static tagName="IFRAME";static create(e){let s=super.create(e);return s.setAttribute("frameborder","0"),s.setAttribute("allowfullscreen","true"),s.setAttribute("src",this.sanitize(e)),s}static formats(e){return Lc.reduce((s,n)=>(e.hasAttribute(n)&&(s[n]=e.getAttribute(n)),s),{})}static sanitize(e){return ve.sanitize(e)}static value(e){return e.getAttribute("src")}format(e,s){Lc.indexOf(e)>-1?s?this.domNode.setAttribute(e,s):this.domNode.removeAttribute(e):super.format(e,s)}html(){let{video:e}=this.value();return`${e}`}}return r})(),Oc=Jy;var zs=ot(lt(),1);var Or=new D("code-token","hljs",{scope:b.INLINE}),Cr=(()=>{class r extends K{static formats(e,s){for(;e!=null&&e!==s.domNode;){if(e.classList&&e.classList.contains(F.className))return super.formats(e,s);e=e.parentNode}}constructor(e,s,n){super(e,s,n),Or.add(this.domNode,n)}format(e,s){e!==r.blotName?super.format(e,s):s?Or.add(this.domNode,s):(Or.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),Or.value(this.domNode)||this.unwrap()}}return r.blotName="code-token",r.className="ql-token",r})(),it=class extends F{static create(t){let 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(),Cr.blotName,!1),super.replaceWith(t,e)}},Hs=(()=>{class r extends Tt{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(e,s){e===it.blotName&&(this.forceNext=!0,this.children.forEach(n=>{n.format(e,s)}))}formatAt(e,s,n,i){n===it.blotName&&(this.forceNext=!0),super.formatAt(e,s,n,i)}highlight(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;let i=`${Array.from(this.domNode.childNodes).filter(a=>a!==this.uiNode).map(a=>a.textContent).join(` `)} `,o=it.formats(this.children.head.domNode);if(s||this.forceNext||this.cachedText!==i){if(i.trim().length>0||this.cachedText==null){let a=this.children.reduce((u,c)=>u.concat(Qn(c,!1)),new zs.default),l=e(i,o);a.diff(l).reduce((u,c)=>{let{retain:f,attributes:h}=c;return f?(h&&Object.keys(h).forEach(p=>{[it.blotName,Cr.blotName].includes(p)&&this.formatAt(u,f,p,h[p])}),u+f):u},0)}this.cachedText=i,this.forceNext=!1}}html(e,s){let[n]=this.children.find(e);return`
    ${ye(this.code(e,s))}
    
    `}optimize(e){if(super.optimize(e),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){let s=it.formats(this.children.head.domNode);s!==this.uiNode.value&&(this.uiNode.value=s)}}}return r.allowedChildren=[it],r})();it.requiredContainer=Hs;it.allowedChildren=[Cr,te,R,$];var tx=(r,t,e)=>{if(typeof r.versionString=="string"){let s=r.versionString.split(".")[0];if(parseInt(s,10)>=11)return r.highlight(e,{language:t}).value}return r.highlight(t,e).value},_r=class extends k{static register(){d.register(Cr,!0),d.register(it,!0),d.register(Hs,!0)}constructor(t,e){if(super(t,e),this.options.hljs==null)throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");this.languages=this.options.languages.reduce((s,n)=>{let{key:i}=n;return s[i]=!0,s},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(d.events.SCROLL_BLOT_MOUNT,t=>{if(!(t instanceof Hs))return;let e=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(s=>{let{key:n,label:i}=s,o=e.ownerDocument.createElement("option");o.textContent=i,o.setAttribute("value",n),e.appendChild(o)}),e.addEventListener("change",()=>{t.format(it.blotName,e.value),this.quill.root.focus(),this.highlight(t,!0)}),t.uiNode==null&&(t.attachUI(e),t.children.head&&(e.value=it.formats(t.children.head.domNode)))})}initTimer(){let t=null;this.quill.on(d.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(d.sources.USER);let s=this.quill.getSelection();(t==null?this.quill.scroll.descendants(Hs):[t]).forEach(i=>{i.highlight(this.highlightBlot,e)}),this.quill.update(d.sources.SILENT),s!=null&&this.quill.setSelection(s,d.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 ye(t).split(` `).reduce((n,i,o)=>(o!==0&&n.insert(` `,{[F.blotName]:e}),n.insert(i)),new zs.default);let s=this.quill.root.ownerDocument.createElement("div");return s.classList.add(F.className),s.innerHTML=tx(this.options.hljs,e,t),Ps(this.quill.scroll,s,[(n,i)=>{let o=Or.value(n);return o?i.compose(new zs.default().retain(i.length(),{[Cr.blotName]:o})):i}],[(n,i)=>n.data.split(` `).reduce((o,a,l)=>(l!==0&&o.insert(` `,{[F.blotName]:e}),o.insert(a)),i)],new WeakMap)}};_r.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"}]};var Cc=ot(lt(),1);var Nt=(()=>{class r extends B{static blotName="table";static tagName="TD";static create(e){let s=super.create();return e?s.setAttribute("data-row",e):s.setAttribute("data-row",Ks()),s}static formats(e){if(e.hasAttribute("data-row"))return e.getAttribute("data-row")}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(e,s){e===r.blotName&&s?this.domNode.setAttribute("data-row",s):super.format(e,s)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}return r})(),ne=(()=>{class r extends dt{static blotName="table-row";static tagName="TR";checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){let e=this.children.head.formats(),s=this.children.tail.formats(),n=this.next.children.head.formats(),i=this.next.children.tail.formats();return e.table===s.table&&e.table===n.table&&e.table===i.table}return!1}optimize(e){super.optimize(e),this.children.forEach(s=>{if(s.next==null)return;let n=s.formats(),i=s.next.formats();if(n.table!==i.table){let o=this.splitAfter(s);o&&o.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}return r})(),jt=(()=>{class r extends dt{static blotName="table-body";static tagName="TBODY"}return r})(),$s=(()=>{class r extends dt{static blotName="table-container";static tagName="TABLE";balanceCells(){let e=this.descendants(ne),s=e.reduce((n,i)=>Math.max(i.children.length,n),0);e.forEach(n=>{new Array(s-n.children.length).fill(0).forEach(()=>{let i;n.children.head!=null&&(i=Nt.formats(n.children.head.domNode));let o=this.scroll.create(Nt.blotName,i);n.appendChild(o),o.optimize()})})}cells(e){return this.rows().map(s=>s.children.at(e))}deleteColumn(e){let[s]=this.descendant(jt);s==null||s.children.head==null||s.children.forEach(n=>{let i=n.children.at(e);i?.remove()})}insertColumn(e){let[s]=this.descendant(jt);s==null||s.children.head==null||s.children.forEach(n=>{let i=n.children.at(e),o=Nt.formats(n.children.head.domNode),a=this.scroll.create(Nt.blotName,o);n.insertBefore(a,i)})}insertRow(e){let[s]=this.descendant(jt);if(s==null||s.children.head==null)return;let n=Ks(),i=this.scroll.create(ne.blotName);s.children.head.children.forEach(()=>{let a=this.scroll.create(Nt.blotName,n);i.appendChild(a)});let o=s.children.at(e);s.insertBefore(i,o)}rows(){let e=this.children.head;return e==null?[]:e.children.map(s=>s)}}return r.allowedChildren=[jt],r})();jt.requiredContainer=$s;jt.allowedChildren=[ne];ne.requiredContainer=jt;ne.allowedChildren=[Nt];Nt.requiredContainer=ne;function Ks(){return`row-${Math.random().toString(36).slice(2,6)}`}var qi=class extends k{static register(){d.register(Nt),d.register(ne),d.register(jt),d.register($s)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants($s).forEach(t=>{t.balanceCells()})}deleteColumn(){let[t,,e]=this.getTable();e!=null&&(t.deleteColumn(e.cellOffset()),this.quill.update(d.sources.USER))}deleteRow(){let[,t]=this.getTable();t!=null&&(t.remove(),this.quill.update(d.sources.USER))}deleteTable(){let[t]=this.getTable();if(t==null)return;let e=t.offset();t.remove(),this.quill.update(d.sources.USER),this.quill.setSelection(e,d.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];let[e,s]=this.quill.getLine(t.index);if(e==null||e.statics.blotName!==Nt.blotName)return[null,null,null,-1];let n=e.parent;return[n.parent.parent,n,e,s]}insertColumn(t){let e=this.quill.getSelection();if(!e)return;let[s,n,i]=this.getTable(e);if(i==null)return;let o=i.cellOffset();s.insertColumn(o+t),this.quill.update(d.sources.USER);let a=n.rowOffset();t===0&&(a+=1),this.quill.setSelection(e.index+a,e.length,d.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(t){let e=this.quill.getSelection();if(!e)return;let[s,n,i]=this.getTable(e);if(i==null)return;let o=n.rowOffset();s.insertRow(o+t),this.quill.update(d.sources.USER),t>0?this.quill.setSelection(e,d.sources.SILENT):this.quill.setSelection(e.index+n.children.length,e.length,d.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(t,e){let s=this.quill.getSelection();if(s==null)return;let n=new Array(t).fill(0).reduce(i=>{let o=new Array(e).fill(` `).join("");return i.insert(o,{table:Ks()})},new Cc.default().retain(s.index));this.quill.updateContents(n,d.sources.USER),this.quill.setSelection(s.index,d.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(d.events.SCROLL_OPTIMIZE,t=>{t.some(e=>["TD","TR","TBODY","TABLE"].includes(e.target.tagName)?(this.quill.once(d.events.TEXT_CHANGE,(s,n,i)=>{i===d.sources.USER&&this.balanceTables()}),!0):!1)})}},_c=qi;var kc=ot(lt(),1);var qc=ut("quill:toolbar"),Ii=(()=>{class r extends k{constructor(e,s){if(super(e,s),Array.isArray(this.options.container)){let n=document.createElement("div");n.setAttribute("role","toolbar"),ex(n,this.options.container),e.container?.parentNode?.insertBefore(n,e.container),this.container=n}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){qc.error("Container required for toolbar",this.options);return}this.container.classList.add("ql-toolbar"),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(n=>{let i=this.options.handlers?.[n];i&&this.addHandler(n,i)}),Array.from(this.container.querySelectorAll("button, select")).forEach(n=>{this.attach(n)}),this.quill.on(d.events.EDITOR_CHANGE,()=>{let[n]=this.quill.selection.getRange();this.update(n)})}addHandler(e,s){this.handlers[e]=s}attach(e){let s=Array.from(e.classList).find(i=>i.indexOf("ql-")===0);if(!s)return;if(s=s.slice(3),e.tagName==="BUTTON"&&e.setAttribute("type","button"),this.handlers[s]==null&&this.quill.scroll.query(s)==null){qc.warn("ignoring attaching to nonexistent format",s,e);return}let n=e.tagName==="SELECT"?"change":"click";e.addEventListener(n,i=>{let o;if(e.tagName==="SELECT"){if(e.selectedIndex<0)return;let l=e.options[e.selectedIndex];l.hasAttribute("selected")?o=!1:o=l.value||!1}else e.classList.contains("ql-active")?o=!1:o=e.value||!e.hasAttribute("value"),i.preventDefault();this.quill.focus();let[a]=this.quill.selection.getRange();if(this.handlers[s]!=null)this.handlers[s].call(this,o);else if(this.quill.scroll.query(s).prototype instanceof q){if(o=prompt(`Enter ${s}`),!o)return;this.quill.updateContents(new kc.default().retain(a.index).delete(a.length).insert({[s]:o}),d.sources.USER)}else this.quill.format(s,o,d.sources.USER);this.update(a)}),this.controls.push([s,e])}update(e){let s=e==null?{}:this.quill.getFormat(e);this.controls.forEach(n=>{let[i,o]=n;if(o.tagName==="SELECT"){let a=null;if(e==null)a=null;else if(s[i]==null)a=o.querySelector("option[selected]");else if(!Array.isArray(s[i])){let l=s[i];typeof l=="string"&&(l=l.replace(/"/g,'\\"')),a=o.querySelector(`option[value="${l}"]`)}a==null?(o.value="",o.selectedIndex=-1):a.selected=!0}else if(e==null)o.classList.remove("ql-active"),o.setAttribute("aria-pressed","false");else if(o.hasAttribute("value")){let a=s[i],l=a===o.getAttribute("value")||a!=null&&a.toString()===o.getAttribute("value")||a==null&&!o.getAttribute("value");o.classList.toggle("ql-active",l),o.setAttribute("aria-pressed",l.toString())}else{let a=s[i]!=null;o.classList.toggle("ql-active",a),o.setAttribute("aria-pressed",a.toString())}})}}return r.DEFAULTS={},r})();function Ic(r,t,e){let s=document.createElement("button");s.setAttribute("type","button"),s.classList.add(`ql-${t}`),s.setAttribute("aria-pressed","false"),e!=null?(s.value=e,s.setAttribute("aria-label",`${t}: ${e}`)):s.setAttribute("aria-label",t),r.appendChild(s)}function ex(r,t){Array.isArray(t[0])||(t=[t]),t.forEach(e=>{let s=document.createElement("span");s.classList.add("ql-formats"),e.forEach(n=>{if(typeof n=="string")Ic(s,n);else{let i=Object.keys(n)[0],o=n[i];Array.isArray(o)?rx(s,i,o):Ic(s,i,o)}}),r.appendChild(s)})}function rx(r,t,e){let s=document.createElement("select");s.classList.add(`ql-${t}`),e.forEach(n=>{let i=document.createElement("option");n!==!1?i.setAttribute("value",String(n)):i.setAttribute("selected","selected"),s.appendChild(i)}),r.appendChild(s)}Ii.DEFAULTS={container:null,handlers:{clean(){let r=this.quill.getSelection();if(r!=null)if(r.length===0){let t=this.quill.getFormat();Object.keys(t).forEach(e=>{this.quill.scroll.query(e,b.INLINE)!=null&&this.quill.format(e,!1,d.sources.USER)})}else this.quill.removeFormat(r.index,r.length,d.sources.USER)},direction(r){let{align:t}=this.quill.getFormat();r==="rtl"&&t==null?this.quill.format("align","right",d.sources.USER):!r&&t==="right"&&this.quill.format("align",!1,d.sources.USER),this.quill.format("direction",r,d.sources.USER)},indent(r){let t=this.quill.getSelection(),e=this.quill.getFormat(t),s=parseInt(e.indent||0,10);if(r==="+1"||r==="-1"){let n=r==="+1"?1:-1;e.direction==="rtl"&&(n*=-1),this.quill.format("indent",s+n,d.sources.USER)}},link(r){r===!0&&(r=prompt("Enter link URL:")),this.quill.format("link",r,d.sources.USER)},list(r){let t=this.quill.getSelection(),e=this.quill.getFormat(t);r==="check"?e.list==="checked"||e.list==="unchecked"?this.quill.format("list",!1,d.sources.USER):this.quill.format("list","unchecked",d.sources.USER):this.quill.format("list",r,d.sources.USER)}}};var sx='',nx='',ix='',ox='',ax='',lx='',ux='',cx='',Rc='',fx='',hx='',dx='',px='',mx='',gx='',bx='',yx='',xx='',vx='',Ax='',Ex='',Tx='',Nx='',wx='',Sx='',Lx='',Ox='',Cx='',_x='',qx='',Ix='',kx='',Rx='',ie={align:{"":sx,center:nx,right:ix,justify:ox},background:ax,blockquote:lx,bold:ux,clean:cx,code:Rc,"code-block":Rc,color:fx,direction:{"":hx,rtl:dx},formula:px,header:{1:mx,2:gx,3:bx,4:yx,5:xx,6:vx},italic:Ax,image:Ex,indent:{"+1":Tx,"-1":Nx},link:wx,list:{bullet:Sx,check:Lx,ordered:Ox},script:{sub:Cx,super:_x},strike:qx,table:Ix,underline:kx,video:Rx};var Bx='',Bc=0;function Mc(r,t){r.setAttribute(t,`${r.getAttribute(t)!=="true"}`)}var ki=class{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;default:}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),Mc(this.label,"aria-expanded"),Mc(this.options,"aria-hidden")}buildItem(t){let e=document.createElement("span");e.tabIndex="0",e.setAttribute("role","button"),e.classList.add("ql-picker-item");let s=t.getAttribute("value");return s&&e.setAttribute("data-value",s),t.textContent&&e.setAttribute("data-label",t.textContent),e.addEventListener("click",()=>{this.selectItem(e,!0)}),e.addEventListener("keydown",n=>{switch(n.key){case"Enter":this.selectItem(e,!0),n.preventDefault();break;case"Escape":this.escape(),n.preventDefault();break;default:}}),e}buildLabel(){let t=document.createElement("span");return t.classList.add("ql-picker-label"),t.innerHTML=Bx,t.tabIndex="0",t.setAttribute("role","button"),t.setAttribute("aria-expanded","false"),this.container.appendChild(t),t}buildOptions(){let t=document.createElement("span");t.classList.add("ql-picker-options"),t.setAttribute("aria-hidden","true"),t.tabIndex="-1",t.id=`ql-picker-options-${Bc}`,Bc+=1,this.label.setAttribute("aria-controls",t.id),this.options=t,Array.from(this.select.options).forEach(e=>{let s=this.buildItem(e);t.appendChild(s),e.selected===!0&&this.selectItem(s)}),this.container.appendChild(t)}buildPicker(){Array.from(this.select.attributes).forEach(t=>{this.container.setAttribute(t.name,t.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}selectItem(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=this.container.querySelector(".ql-selected");t!==s&&(s?.classList.remove("ql-selected"),t!=null&&(t.classList.add("ql-selected"),this.select.selectedIndex=Array.from(t.parentNode.children).indexOf(t),t.hasAttribute("data-value")?this.label.setAttribute("data-value",t.getAttribute("data-value")):this.label.removeAttribute("data-value"),t.hasAttribute("data-label")?this.label.setAttribute("data-label",t.getAttribute("data-label")):this.label.removeAttribute("data-label"),e&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let t;if(this.select.selectedIndex>-1){let s=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];t=this.select.options[this.select.selectedIndex],this.selectItem(s)}else this.selectItem(null);let e=t!=null&&t!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",e)}},oe=ki;var Ri=class extends oe{constructor(t,e){super(t),this.label.innerHTML=e,this.container.classList.add("ql-color-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).slice(0,7).forEach(s=>{s.classList.add("ql-primary")})}buildItem(t){let e=super.buildItem(t);return e.style.backgroundColor=t.getAttribute("value")||"",e}selectItem(t,e){super.selectItem(t,e);let s=this.label.querySelector(".ql-color-label"),n=t&&t.getAttribute("data-value")||"";s&&(s.tagName==="line"?s.style.stroke=n:s.style.fill=n)}},Gs=Ri;var Bi=class extends oe{constructor(t,e){super(t),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(s=>{s.innerHTML=e[s.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(t,e){super.selectItem(t,e);let s=t||this.defaultItem;if(s!=null){if(this.label.innerHTML===s.innerHTML)return;this.label.innerHTML=s.innerHTML}}},Vs=Bi;var Mx=r=>{let{overflowY:t}=getComputedStyle(r,null);return t!=="visible"&&t!=="clip"},Mi=class{constructor(t,e){this.quill=t,this.boundsContainer=e||document.body,this.root=t.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,Mx(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){let e=t.left+t.width/2-this.root.offsetWidth/2,s=t.bottom+this.quill.root.scrollTop;this.root.style.left=`${e}px`,this.root.style.top=`${s}px`,this.root.classList.remove("ql-flip");let n=this.boundsContainer.getBoundingClientRect(),i=this.root.getBoundingClientRect(),o=0;if(i.right>n.right&&(o=n.right-i.right,this.root.style.left=`${e+o}px`),i.leftn.bottom){let a=i.bottom-i.top,l=t.bottom-t.top+a;this.root.style.top=`${s-l}px`,this.root.classList.add("ql-flip")}return o}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}},Ws=Mi;var Dx=[!1,"center","right","justify"],jx=["#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"],Px=[!1,"serif","monospace"],Ux=["1","2","3",!1],Fx=["small",!1,"large","huge"],Pt=class extends Qe{constructor(t,e){super(t,e);let s=n=>{if(!document.body.contains(t.root)){document.body.removeEventListener("click",s);return}this.tooltip!=null&&!this.tooltip.root.contains(n.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(i=>{i.container.contains(n.target)||i.close()})};t.emitter.listenDOM("click",document.body,s)}addModule(t){let e=super.addModule(t);return t==="toolbar"&&this.extendToolbar(e),e}buildButtons(t,e){Array.from(t).forEach(s=>{(s.getAttribute("class")||"").split(/\s+/).forEach(i=>{if(i.startsWith("ql-")&&(i=i.slice(3),e[i]!=null))if(i==="direction")s.innerHTML=e[i][""]+e[i].rtl;else if(typeof e[i]=="string")s.innerHTML=e[i];else{let o=s.value||"";o!=null&&e[i][o]&&(s.innerHTML=e[i][o])}})})}buildPickers(t,e){this.pickers=Array.from(t).map(n=>{if(n.classList.contains("ql-align")&&(n.querySelector("option")==null&&qr(n,Dx),typeof e.align=="object"))return new Vs(n,e.align);if(n.classList.contains("ql-background")||n.classList.contains("ql-color")){let i=n.classList.contains("ql-background")?"background":"color";return n.querySelector("option")==null&&qr(n,jx,i==="background"?"#ffffff":"#000000"),new Gs(n,e[i])}return n.querySelector("option")==null&&(n.classList.contains("ql-font")?qr(n,Px):n.classList.contains("ql-header")?qr(n,Ux):n.classList.contains("ql-size")&&qr(n,Fx)),new oe(n)});let s=()=>{this.pickers.forEach(n=>{n.update()})};this.quill.on(x.events.EDITOR_CHANGE,s)}};Pt.DEFAULTS=tt({},Qe.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let r=this.container.querySelector("input.ql-image[type=file]");r==null&&(r=document.createElement("input"),r.setAttribute("type","file"),r.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),r.classList.add("ql-image"),r.addEventListener("change",()=>{let t=this.quill.getSelection(!0);this.quill.uploader.upload(t,r.files),r.value=""}),this.container.appendChild(r)),r.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});var tr=class extends Ws{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="");let s=this.quill.getBounds(this.quill.selection.savedRange);s!=null&&this.position(s),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${t}`)||""),this.root.setAttribute("data-mode",t)}restoreFocus(){this.quill.focus({preventScroll:!0})}save(){let{value:t}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{let{scrollTop:e}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",t,x.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",t,x.sources.USER)),this.quill.root.scrollTop=e;break}case"video":t=Hx(t);case"formula":{if(!t)break;let e=this.quill.getSelection(!0);if(e!=null){let s=e.index+e.length;this.quill.insertEmbed(s,this.root.getAttribute("data-mode"),t,x.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(s+1," ",x.sources.USER),this.quill.setSelection(s+2,x.sources.USER)}break}default:}this.textbox.value="",this.hide()}};function Hx(r){let t=r.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||r.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return t?`${t[1]||"https"}://www.youtube.com/embed/${t[2]}?showinfo=0`:(t=r.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${t[1]||"https"}://player.vimeo.com/video/${t[2]}/`:r}function qr(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t.forEach(s=>{let n=document.createElement("option");s===e?n.setAttribute("selected","selected"):n.setAttribute("value",String(s)),r.appendChild(n)})}var zx=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],Di=class extends tr{static TEMPLATE=['','
    ','','',"
    "].join("");constructor(t,e){super(t,e),this.quill.on(x.events.EDITOR_CHANGE,(s,n,i,o)=>{if(s===x.events.SELECTION_CHANGE)if(n!=null&&n.length>0&&o===x.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;let a=this.quill.getLines(n.index,n.length);if(a.length===1){let l=this.quill.getBounds(n);l!=null&&this.position(l)}else{let l=a[a.length-1],u=this.quill.getIndex(l),c=Math.min(l.length()-1,n.index+n.length-u),f=this.quill.getBounds(new Q(u,c));f!=null&&this.position(f)}}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(x.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;let t=this.quill.getSelection();if(t!=null){let e=this.quill.getBounds(t);e!=null&&this.position(e)}},1)})}cancel(){this.show()}position(t){let e=super.position(t),s=this.root.querySelector(".ql-tooltip-arrow");return s.style.marginLeft="",e!==0&&(s.style.marginLeft=`${-1*e-s.offsetWidth/2}px`),e}},Ir=class extends Pt{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=zx),super(t,e),this.quill.container.classList.add("ql-bubble")}extendToolbar(t){this.tooltip=new Di(this.quill,this.options.bounds),t.container!=null&&(this.tooltip.root.appendChild(t.container),this.buildButtons(t.container.querySelectorAll("button"),ie),this.buildPickers(t.container.querySelectorAll("select"),ie))}};Ir.DEFAULTS=tt({},Pt.DEFAULTS,{modules:{toolbar:{handlers:{link(r){r?this.quill.theme.tooltip.edit():this.quill.format("link",!1,d.sources.USER)}}}}});var $x=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],ji=class extends tr{static TEMPLATE=['','','',''].join("");preview=this.root.querySelector("a.ql-preview");listen(){super.listen(),this.root.querySelector("a.ql-action").addEventListener("click",t=>{this.root.classList.contains("ql-editing")?this.save():this.edit("link",this.preview.textContent),t.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",t=>{if(this.linkRange!=null){let e=this.linkRange;this.restoreFocus(),this.quill.formatText(e,"link",!1,x.sources.USER),delete this.linkRange}t.preventDefault(),this.hide()}),this.quill.on(x.events.SELECTION_CHANGE,(t,e,s)=>{if(t!=null){if(t.length===0&&s===x.sources.USER){let[n,i]=this.quill.scroll.descendant(ve,t.index);if(n!=null){this.linkRange=new Q(t.index-i,n.length());let o=ve.formats(n.domNode);this.preview.textContent=o,this.preview.setAttribute("href",o),this.show();let a=this.quill.getBounds(this.linkRange);a!=null&&this.position(a);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}},Zs=class extends Pt{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=$x),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"),ie),this.buildPickers(t.container.querySelectorAll("select"),ie),this.tooltip=new ji(this.quill,this.options.bounds),t.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(e,s)=>{t.handlers.link.call(t,!s.format.link)}))}};Zs.DEFAULTS=tt({},Pt.DEFAULTS,{modules:{toolbar:{handlers:{link(r){if(r){let 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}`);let{tooltip:s}=this.quill.theme;s.edit("link",e)}else this.quill.format("link",!1,d.sources.USER)}}}}});var Dc=Zs;Us.register({"attributors/attribute/direction":ks,"attributors/class/align":mi,"attributors/class/background":Ju,"attributors/class/color":Yu,"attributors/class/direction":bi,"attributors/class/font":xi,"attributors/class/size":vi,"attributors/style/align":Is,"attributors/style/background":Nr,"attributors/style/color":Tr,"attributors/style/direction":Rs,"attributors/style/font":Bs,"attributors/style/size":Ms},!0);Us.register({"formats/align":mi,"formats/direction":bi,"formats/indent":bc,"formats/background":Nr,"formats/color":Tr,"formats/font":xi,"formats/size":vi,"formats/blockquote":yc,"formats/code-block":F,"formats/header":xc,"formats/list":Fs,"formats/bold":Je,"formats/code":tc,"formats/italic":vc,"formats/link":ve,"formats/script":Ac,"formats/strike":Ec,"formats/underline":Tc,"formats/formula":Nc,"formats/image":Sc,"formats/video":Oc,"modules/syntax":_r,"modules/table":_c,"modules/toolbar":Ii,"themes/bubble":Ir,"themes/snow":Dc,"ui/icons":ie,"ui/picker":oe,"ui/icon-picker":Vs,"ui/color-picker":Gs,"ui/tooltip":Ws},!0);var A4=Us;var export_AttributeMap=se.AttributeMap;var export_Delta=se.default;var export_Op=se.Op;var export_OpIterator=se.OpIterator;export{export_AttributeMap as AttributeMap,export_Delta as Delta,k as Module,export_Op as Op,export_OpIterator as OpIterator,ur as Parchment,Q as Range,A4 as default};