1?s[a-1]:t;return f=typeof f=="function"?(s.pop(),f):t,mh(s,f)});function gh(s){var a=b(s);return a.__chain__=!0,a}function Pv(s,a){return a(s),s}function Ho(s,a){return a(s)}var Bv=Bn(function(s){var a=s.length,f=a?s[0]:0,p=this.__wrapped__,g=function(S){return Wa(S,s)};return a>1||this.__actions__.length||!(p instanceof pe)||!Fn(f)?this.thru(g):(p=p.slice(f,+f+(a?1:0)),p.__actions__.push({func:Ho,args:[g],thisArg:t}),new Vt(p,this.__chain__).thru(function(S){return a&&!S.length&&S.push(t),S}))});function Fv(){return gh(this)}function zv(){return new Vt(this.value(),this.__chain__)}function Hv(){this.__values__===t&&(this.__values__=_h(this.value()));var s=this.__index__>=this.__values__.length,a=s?t:this.__values__[this.__index__++];return{done:s,value:a}}function $v(){return this}function Uv(s){for(var a,f=this;f instanceof To;){var p=uh(f);p.__index__=0,p.__values__=t,a?g.__wrapped__=p:a=p;var g=p;f=f.__wrapped__}return g.__wrapped__=s,a}function Wv(){var s=this.__wrapped__;if(s instanceof pe){var a=s;return this.__actions__.length&&(a=new pe(this)),a=a.reverse(),a.__actions__.push({func:Ho,args:[yu],thisArg:t}),new Vt(a,this.__chain__)}return this.thru(yu)}function Vv(){return Dd(this.__wrapped__,this.__actions__)}var qv=Do(function(s,a,f){xe.call(s,f)?++s[f]:Ln(s,f,1)});function Kv(s,a,f){var p=ne(s)?qf:P1;return f&&ft(s,a,f)&&(a=t),p(s,G(a,3))}function Jv(s,a){var f=ne(s)?tr:md;return f(s,G(a,3))}var jv=Wd(ch),Gv=Wd(fh);function Yv(s,a){return Qe($o(s,a),1)}function Xv(s,a){return Qe($o(s,a),ze)}function Qv(s,a,f){return f=f===t?1:se(f),Qe($o(s,a),f)}function yh(s,a){var f=ne(s)?Ut:sr;return f(s,G(a,3))}function bh(s,a){var f=ne(s)?yy:pd;return f(s,G(a,3))}var Zv=Do(function(s,a,f){xe.call(s,f)?s[f].push(a):Ln(s,f,[a])});function eS(s,a,f,p){s=wt(s)?s:Mi(s),f=f&&!p?se(f):0;var g=s.length;return f<0&&(f=$e(g+f,0)),Ko(s)?f<=g&&s.indexOf(a,f)>-1:!!g&&pi(s,a,f)>-1}var tS=fe(function(s,a,f){var p=-1,g=typeof a=="function",S=wt(s)?O(s.length):[];return sr(s,function(w){S[++p]=g?_t(a,w,f):gs(w,a,f)}),S}),nS=Do(function(s,a,f){Ln(s,f,a)});function $o(s,a){var f=ne(s)?Ae:xd;return f(s,G(a,3))}function rS(s,a,f,p){return s==null?[]:(ne(a)||(a=a==null?[]:[a]),f=p?t:f,ne(f)||(f=f==null?[]:[f]),Td(s,a,f))}var iS=Do(function(s,a,f){s[f?0:1].push(a)},function(){return[[],[]]});function sS(s,a,f){var p=ne(s)?_a:Gf,g=arguments.length<3;return p(s,G(a,4),f,g,sr)}function oS(s,a,f){var p=ne(s)?by:Gf,g=arguments.length<3;return p(s,G(a,4),f,g,pd)}function lS(s,a){var f=ne(s)?tr:md;return f(s,Vo(G(a,3)))}function aS(s){var a=ne(s)?cd:eb;return a(s)}function uS(s,a,f){(f?ft(s,a,f):a===t)?a=1:a=se(a);var p=ne(s)?N1:tb;return p(s,a)}function cS(s){var a=ne(s)?D1:rb;return a(s)}function fS(s){if(s==null)return 0;if(wt(s))return Ko(s)?gi(s):s.length;var a=it(s);return a==vt||a==ut?s.size:Ga(s).length}function dS(s,a,f){var p=ne(s)?Na:ib;return f&&ft(s,a,f)&&(a=t),p(s,G(a,3))}var hS=fe(function(s,a){if(s==null)return[];var f=a.length;return f>1&&ft(s,a[0],a[1])?a=[]:f>2&&ft(a[0],a[1],a[2])&&(a=[a[0]]),Td(s,Qe(a,1),[])}),Uo=Jy||function(){return Xe.Date.now()};function pS(s,a){if(typeof a!="function")throw new Wt(l);return s=se(s),function(){if(--s<1)return a.apply(this,arguments)}}function vh(s,a,f){return a=f?t:a,a=s&&a==null?s.length:a,Pn(s,de,t,t,t,t,a)}function Sh(s,a){var f;if(typeof a!="function")throw new Wt(l);return s=se(s),function(){return--s>0&&(f=a.apply(this,arguments)),s<=1&&(a=t),f}}var vu=fe(function(s,a,f){var p=E;if(f.length){var g=rr(f,Ci(vu));p|=ie}return Pn(s,p,a,f,g)}),xh=fe(function(s,a,f){var p=E|_;if(f.length){var g=rr(f,Ci(xh));p|=ie}return Pn(a,p,s,f,g)});function wh(s,a,f){a=f?t:a;var p=Pn(s,K,t,t,t,t,t,a);return p.placeholder=wh.placeholder,p}function kh(s,a,f){a=f?t:a;var p=Pn(s,A,t,t,t,t,t,a);return p.placeholder=kh.placeholder,p}function Ch(s,a,f){var p,g,S,w,k,M,R=0,L=!1,P=!1,$=!0;if(typeof s!="function")throw new Wt(l);a=jt(a)||0,Oe(f)&&(L=!!f.leading,P="maxWait"in f,S=P?$e(jt(f.maxWait)||0,a):S,$="trailing"in f?!!f.trailing:$);function J(Pe){var ln=p,$n=g;return p=g=t,R=Pe,w=s.apply($n,ln),w}function Q(Pe){return R=Pe,k=xs(he,a),L?J(Pe):w}function le(Pe){var ln=Pe-M,$n=Pe-R,Wh=a-ln;return P?rt(Wh,S-$n):Wh}function Z(Pe){var ln=Pe-M,$n=Pe-R;return M===t||ln>=a||ln<0||P&&$n>=S}function he(){var Pe=Uo();if(Z(Pe))return ge(Pe);k=xs(he,le(Pe))}function ge(Pe){return k=t,$&&p?J(Pe):(p=g=t,w)}function Rt(){k!==t&&Rd(k),R=0,p=M=g=k=t}function dt(){return k===t?w:ge(Uo())}function Lt(){var Pe=Uo(),ln=Z(Pe);if(p=arguments,g=this,M=Pe,ln){if(k===t)return Q(M);if(P)return Rd(k),k=xs(he,a),J(M)}return k===t&&(k=xs(he,a)),w}return Lt.cancel=Rt,Lt.flush=dt,Lt}var mS=fe(function(s,a){return hd(s,1,a)}),gS=fe(function(s,a,f){return hd(s,jt(a)||0,f)});function yS(s){return Pn(s,oe)}function Wo(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new Wt(l);var f=function(){var p=arguments,g=a?a.apply(this,p):p[0],S=f.cache;if(S.has(g))return S.get(g);var w=s.apply(this,p);return f.cache=S.set(g,w)||S,w};return f.cache=new(Wo.Cache||Rn),f}Wo.Cache=Rn;function Vo(s){if(typeof s!="function")throw new Wt(l);return function(){var a=arguments;switch(a.length){case 0:return!s.call(this);case 1:return!s.call(this,a[0]);case 2:return!s.call(this,a[0],a[1]);case 3:return!s.call(this,a[0],a[1],a[2])}return!s.apply(this,a)}}function bS(s){return Sh(2,s)}var vS=sb(function(s,a){a=a.length==1&&ne(a[0])?Ae(a[0],Nt(G())):Ae(Qe(a,1),Nt(G()));var f=a.length;return fe(function(p){for(var g=-1,S=rt(p.length,f);++g=a}),Ur=bd(function(){return arguments}())?bd:function(s){return Ne(s)&&xe.call(s,"callee")&&!id.call(s,"callee")},ne=O.isArray,RS=zf?Nt(zf):U1;function wt(s){return s!=null&&qo(s.length)&&!zn(s)}function Le(s){return Ne(s)&&wt(s)}function LS(s){return s===!0||s===!1||Ne(s)&&ct(s)==Ar}var ur=Gy||Nu,PS=Hf?Nt(Hf):W1;function BS(s){return Ne(s)&&s.nodeType===1&&!ws(s)}function FS(s){if(s==null)return!0;if(wt(s)&&(ne(s)||typeof s=="string"||typeof s.splice=="function"||ur(s)||Ti(s)||Ur(s)))return!s.length;var a=it(s);if(a==vt||a==ut)return!s.size;if(Ss(s))return!Ga(s).length;for(var f in s)if(xe.call(s,f))return!1;return!0}function zS(s,a){return ys(s,a)}function HS(s,a,f){f=typeof f=="function"?f:t;var p=f?f(s,a):t;return p===t?ys(s,a,t,f):!!p}function xu(s){if(!Ne(s))return!1;var a=ct(s);return a==Or||a==Yn||typeof s.message=="string"&&typeof s.name=="string"&&!ws(s)}function $S(s){return typeof s=="number"&&od(s)}function zn(s){if(!Oe(s))return!1;var a=ct(s);return a==_r||a==Xi||a==ya||a==ro}function Mh(s){return typeof s=="number"&&s==se(s)}function qo(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=ke}function Oe(s){var a=typeof s;return s!=null&&(a=="object"||a=="function")}function Ne(s){return s!=null&&typeof s=="object"}var Eh=$f?Nt($f):q1;function US(s,a){return s===a||ja(s,a,fu(a))}function WS(s,a,f){return f=typeof f=="function"?f:t,ja(s,a,fu(a),f)}function VS(s){return Ah(s)&&s!=+s}function qS(s){if(Ab(s))throw new ee(o);return vd(s)}function KS(s){return s===null}function JS(s){return s==null}function Ah(s){return typeof s=="number"||Ne(s)&&ct(s)==Xn}function ws(s){if(!Ne(s)||ct(s)!=Ht)return!1;var a=bo(s);if(a===null)return!0;var f=xe.call(a,"constructor")&&a.constructor;return typeof f=="function"&&f instanceof f&&po.call(f)==Wy}var wu=Uf?Nt(Uf):K1;function jS(s){return Mh(s)&&s>=-ke&&s<=ke}var Oh=Wf?Nt(Wf):J1;function Ko(s){return typeof s=="string"||!ne(s)&&Ne(s)&&ct(s)==Qn}function It(s){return typeof s=="symbol"||Ne(s)&&ct(s)==_n}var Ti=Vf?Nt(Vf):j1;function GS(s){return s===t}function YS(s){return Ne(s)&&it(s)==Dr}function XS(s){return Ne(s)&&ct(s)==va}var QS=Po(Ya),ZS=Po(function(s,a){return s<=a});function _h(s){if(!s)return[];if(wt(s))return Ko(s)?rn(s):xt(s);if(us&&s[us])return Ny(s[us]());var a=it(s),f=a==vt?Ba:a==ut?co:Mi;return f(s)}function Hn(s){if(!s)return s===0?s:0;if(s=jt(s),s===ze||s===-ze){var a=s<0?-1:1;return a*Zs}return s===s?s:0}function se(s){var a=Hn(s),f=a%1;return a===a?f?a-f:a:0}function Nh(s){return s?Fr(se(s),0,bt):0}function jt(s){if(typeof s=="number")return s;if(It(s))return pn;if(Oe(s)){var a=typeof s.valueOf=="function"?s.valueOf():s;s=Oe(a)?a+"":a}if(typeof s!="string")return s===0?s:+s;s=Yf(s);var f=R0.test(s);return f||P0.test(s)?py(s.slice(2),f?2:8):I0.test(s)?pn:+s}function Dh(s){return gn(s,kt(s))}function ex(s){return s?Fr(se(s),-ke,ke):s===0?s:0}function Se(s){return s==null?"":Dt(s)}var tx=wi(function(s,a){if(Ss(a)||wt(a)){gn(a,We(a),s);return}for(var f in a)xe.call(a,f)&&ps(s,f,a[f])}),Ih=wi(function(s,a){gn(a,kt(a),s)}),Jo=wi(function(s,a,f,p){gn(a,kt(a),s,p)}),nx=wi(function(s,a,f,p){gn(a,We(a),s,p)}),rx=Bn(Wa);function ix(s,a){var f=xi(s);return a==null?f:fd(f,a)}var sx=fe(function(s,a){s=Ce(s);var f=-1,p=a.length,g=p>2?a[2]:t;for(g&&ft(a[0],a[1],g)&&(p=1);++f1),S}),gn(s,uu(s),f),p&&(f=qt(f,m|y|v,gb));for(var g=a.length;g--;)tu(f,a[g]);return f});function kx(s,a){return Lh(s,Vo(G(a)))}var Cx=Bn(function(s,a){return s==null?{}:X1(s,a)});function Lh(s,a){if(s==null)return{};var f=Ae(uu(s),function(p){return[p]});return a=G(a),Md(s,f,function(p,g){return a(p,g[0])})}function Tx(s,a,f){a=lr(a,s);var p=-1,g=a.length;for(g||(g=1,s=t);++pa){var p=s;s=a,a=p}if(f||s%1||a%1){var g=ld();return rt(s+g*(a-s+hy("1e-"+((g+"").length-1))),a)}return Qa(s,a)}var Px=ki(function(s,a,f){return a=a.toLowerCase(),s+(f?Fh(a):a)});function Fh(s){return Tu(Se(s).toLowerCase())}function zh(s){return s=Se(s),s&&s.replace(F0,My).replace(ry,"")}function Bx(s,a,f){s=Se(s),a=Dt(a);var p=s.length;f=f===t?p:Fr(se(f),0,p);var g=f;return f-=a.length,f>=0&&s.slice(f,g)==a}function Fx(s){return s=Se(s),s&&ss.test(s)?s.replace(is,Ey):s}function zx(s){return s=Se(s),s&&C0.test(s)?s.replace(Sa,"\\$&"):s}var Hx=ki(function(s,a,f){return s+(f?"-":"")+a.toLowerCase()}),$x=ki(function(s,a,f){return s+(f?" ":"")+a.toLowerCase()}),Ux=Ud("toLowerCase");function Wx(s,a,f){s=Se(s),a=se(a);var p=a?gi(s):0;if(!a||p>=a)return s;var g=(a-p)/2;return Lo(wo(g),f)+s+Lo(xo(g),f)}function Vx(s,a,f){s=Se(s),a=se(a);var p=a?gi(s):0;return a&&p>>0,f?(s=Se(s),s&&(typeof a=="string"||a!=null&&!wu(a))&&(a=Dt(a),!a&&mi(s))?ar(rn(s),0,f):s.split(a,f)):[]}var Xx=ki(function(s,a,f){return s+(f?" ":"")+Tu(a)});function Qx(s,a,f){return s=Se(s),f=f==null?0:Fr(se(f),0,s.length),a=Dt(a),s.slice(f,f+a.length)==a}function Zx(s,a,f){var p=b.templateSettings;f&&ft(s,a,f)&&(a=t),s=Se(s),a=Jo({},a,p,Gd);var g=Jo({},a.imports,p.imports,Gd),S=We(g),w=Pa(g,S),k,M,R=0,L=a.interpolate||so,P="__p += '",$=Fa((a.escape||so).source+"|"+L.source+"|"+(L===io?D0:so).source+"|"+(a.evaluate||so).source+"|$","g"),J="//# sourceURL="+(xe.call(a,"sourceURL")?(a.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ay+"]")+`
+`;s.replace($,function(Z,he,ge,Rt,dt,Lt){return ge||(ge=Rt),P+=s.slice(R,Lt).replace(z0,Ay),he&&(k=!0,P+=`' +
__e(`+he+`) +
'`),dt&&(M=!0,P+=`';
`+dt+`;
__p += '`),ge&&(P+=`' +
((__t = (`+ge+`)) == null ? '' : __t) +
'`),R=Lt+Z.length,Z}),P+=`';
-`;var Q=we.call(a,"variable")&&a.variable;if(!Q)P=`with (obj) {
+`;var Q=xe.call(a,"variable")&&a.variable;if(!Q)P=`with (obj) {
`+P+`
}
-`;else if(A0.test(Q))throw new ee(u);P=(M?P.replace(me,""):P).replace(Ye,"$1").replace(St,"$1;"),P="function("+(Q||"obj")+`) {
+`;else if(_0.test(Q))throw new ee(u);P=(M?P.replace(me,""):P).replace(Ye,"$1").replace(St,"$1;"),P="function("+(Q||"obj")+`) {
`+(Q?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(k?", __e = _.escape":"")+(M?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+P+`return __p
-}`;var le=Uh(function(){return ve(S,J+"return "+P).apply(t,x)});if(le.source=P,wu(le))throw le;return le}function Zw(s){return Se(s).toLowerCase()}function ex(s){return Se(s).toUpperCase()}function tx(s,a,c){if(s=Se(s),s&&(c||a===t))return Xf(s);if(!s||!(a=Dt(a)))return s;var p=rn(s),g=rn(a),S=Qf(p,g),x=Zf(p,g)+1;return ar(p,S,x).join("")}function nx(s,a,c){if(s=Se(s),s&&(c||a===t))return s.slice(0,td(s)+1);if(!s||!(a=Dt(a)))return s;var p=rn(s),g=Zf(p,rn(a))+1;return ar(p,0,g).join("")}function rx(s,a,c){if(s=Se(s),s&&(c||a===t))return s.replace(wa,"");if(!s||!(a=Dt(a)))return s;var p=rn(s),g=Qf(p,rn(a));return ar(p,g).join("")}function ix(s,a){var c=at,p=Ot;if(Ae(a)){var g="separator"in a?a.separator:g;c="length"in a?se(a.length):c,p="omission"in a?Dt(a.omission):p}s=Se(s);var S=s.length;if(mi(s)){var x=rn(s);S=x.length}if(c>=S)return s;var k=c-gi(p);if(k<1)return p;var M=x?ar(x,0,k).join(""):s.slice(0,k);if(g===t)return M+p;if(x&&(k+=M.length-k),xu(g)){if(s.slice(k).search(g)){var R,L=M;for(g.global||(g=Fa(g.source,Se(vf.exec(g))+"g")),g.lastIndex=0;R=g.exec(L);)var P=R.index;M=M.slice(0,P===t?k:P)}}else if(s.indexOf(Dt(g),k)!=k){var $=M.lastIndexOf(g);$>-1&&(M=M.slice(0,$))}return M+p}function sx(s){return s=Se(s),s&&In.test(s)?s.replace(Dn,Ry):s}var ox=ki(function(s,a,c){return s+(c?" ":"")+a.toUpperCase()}),Tu=Wd("toUpperCase");function $h(s,a,c){return s=Se(s),a=c?t:a,a===t?Ay(s)?By(s):Sy(s):s.match(a)||[]}var Uh=fe(function(s,a){try{return _t(s,t,a)}catch(c){return wu(c)?c:new ee(c)}}),lx=Fn(function(s,a){return Ut(a,function(c){c=yn(c),Pn(s,c,vu(s[c],s))}),s});function ax(s){var a=s==null?0:s.length,c=G();return s=a?Oe(s,function(p){if(typeof p[1]!="function")throw new Wt(l);return[c(p[0]),p[1]]}):[],fe(function(p){for(var g=-1;++gke)return[];var c=bt,p=rt(s,bt);a=G(a),s-=bt;for(var g=La(p,a);++c0||a<0)?new pe(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),a!==t&&(a=se(a),c=a<0?c.dropRight(-a):c.take(a-s)),c)},pe.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},pe.prototype.toArray=function(){return this.take(bt)},mn(pe.prototype,function(s,a){var c=/^(?:filter|find|map|reject)|While$/.test(a),p=/^(?:head|last)$/.test(a),g=b[p?"take"+(a=="last"?"Right":""):a],S=p||/^find/.test(a);g&&(b.prototype[a]=function(){var x=this.__wrapped__,k=p?[1]:arguments,M=x instanceof pe,R=k[0],L=M||ne(x),P=function(he){var ge=g.apply(b,nr([he],k));return p&&$?ge[0]:ge};L&&c&&typeof R=="function"&&R.length!=1&&(M=L=!1);var $=this.__chain__,J=!!this.__actions__.length,Q=S&&!$,le=M&&!J;if(!S&&L){x=le?x:new pe(this);var Z=s.apply(x,k);return Z.__actions__.push({func:Ho,args:[P],thisArg:t}),new Vt(Z,$)}return Q&&le?s.apply(this,k):(Z=this.thru(P),Q?p?Z.value()[0]:Z.value():Z)})}),Ut(["pop","push","shift","sort","splice","unshift"],function(s){var a=fo[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",p=/^(?:pop|shift)$/.test(s);b.prototype[s]=function(){var g=arguments;if(p&&!this.__chain__){var S=this.value();return a.apply(ne(S)?S:[],g)}return this[c](function(x){return a.apply(ne(x)?x:[],g)})}}),mn(pe.prototype,function(s,a){var c=b[a];if(c){var p=c.name+"";we.call(Si,p)||(Si[p]=[]),Si[p].push({name:a,func:c})}}),Si[Io(t,_).name]=[{name:"wrapper",func:t}],pe.prototype.clone=s1,pe.prototype.reverse=o1,pe.prototype.value=l1,b.prototype.at=Pv,b.prototype.chain=Bv,b.prototype.commit=Fv,b.prototype.next=zv,b.prototype.plant=$v,b.prototype.reverse=Uv,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Wv,b.prototype.first=b.prototype.head,us&&(b.prototype[us]=Hv),b},yi=Fy();Rr?((Rr.exports=yi)._=yi,Ea._=yi):Xe._=yi}).call(ks)})(ul,ul.exports);var Ms=ul.exports;const qk={emits:["move","cell"],props:{context:{type:Object,default:()=>({})},item:{type:Object,default:()=>({})},columns:Array,cell:{type:Object,default(){return{row:0}}},cellTag:{type:String,default:"td"},orderable:{type:Boolean,default:!1}},computed:{row(){return this.cell&&this.cell.row||0},itemData(){return this.item instanceof ii?this.item.data:this.item},cells(){const n=Qx(this.cell)&&Zx(this.cell)||this.cell||{},e=[];for(var t in this.columns)e.push({...n,col:Number(t)});return e}},methods:{cellEmit(n,e,t){this.$emit("cell",{name:n,cell:e,data:t,item:this.item})},onDragStart(n){const t=`cell:${n.target.dataset.col}`;n.dataTransfer.setData("text/cell",t),n.dataTransfer.dropEffect="move"},onDragOver(n){n.preventDefault(),n.dataTransfer.dropEffect="move"},onDrop(n){const e=n.dataTransfer.getData("text/cell");!e||!e.startsWith("cell:")||(n.preventDefault(),this.$emit("move",{from:Number(e.slice(5)),to:Number(n.target.dataset.col)}))},getCellEl(n){const e=this.$el.querySelectorAll(this.cellTag);for(var t of e)if(n==Number(t.dataset.col))return t;return null},focus(n,e){e&&(n+=e.col);const t=this.getCellEl(n);if(!t)return;const r=t.querySelector('input:not([type="hidden"])')||t.querySelector("button")||t.querySelector("select")||t.querySelector("a");r&&r.focus()}},mounted(){this.$el.__row=this}};function Kk(n,e,t,r,i,o){return Y(),te("tr",null,[ye(n.$slots,"head",{context:t.context,item:t.item,row:o.row}),(Y(!0),te(Pt,null,Mt(t.columns,(l,u)=>(Y(),te(Pt,{key:u},[ye(n.$slots,"cell-before",{context:t.context,item:t.item,cell:o.cells[u],attr:l}),(Y(),Yr(ek(t.cellTag),{class:si(["cell","cell-"+l]),"data-col":u,draggable:t.orderable,onDragstart:o.onDragStart,onDragover:o.onDragOver,onDrop:o.onDrop},{default:Ee(()=>[ye(n.$slots,l,{context:t.context,item:t.item,cell:o.cells[u],data:o.itemData,attr:l,emit:o.cellEmit,value:o.itemData&&o.itemData[l]},()=>[$i(Be(o.itemData&&o.itemData[l]),1)]),ye(n.$slots,"cell",{context:t.context,item:t.item,cell:o.cells[u],data:o.itemData,attr:l,emit:o.cellEmit,value:o.itemData&&o.itemData[l]})]),_:2},1064,["class","data-col","draggable","onDragstart","onDragover","onDrop"])),ye(n.$slots,"cell-after",{context:t.context,item:t.item,col:u,cell:o.cells[u],attr:l})],64))),128)),ye(n.$slots,"tail",{context:t.context,item:t.item,row:o.row})])}const Am=hn(qk,[["render",Kk]]),$c={extends:qh,components:{ARow:Am},emits:["cell","colmove"],props:{...qh.props,context:{type:Object,default:()=>({})},columns:Array,columnsOrderable:Boolean},data(){return{...super.data,columns_:[...this.columns],extraItem:new this.set.model}},computed:{columnNames(){return this.columns_.map(n=>n.name)},columnLabels(){return this.columns_.reduce((n,e)=>({...n,[e.name]:e.label}),{})},rowSlots(){return Object.keys(this.$slots).filter(n=>n.startsWith("row-")).map(n=>[n,n.slice(4)])}},methods:{sortColumns(n){const e=n.map(r=>this.columns_.find(i=>i.name==r)).filter(r=>!!r),t=this.columns_.filter(r=>n.indexOf(r.name)==-1);this.columns_=[...e,...t],this.$emit("colmove")},moveColumn(n){const{from:e,to:t}=n,r=this.columns_[e];this.columns_.splice(e,1),this.columns_.splice(t,0,r),this.$emit("colmove",n)},onCellEvent(n,e){e.name=="focus"&&this.focus(e.data,e.cell),this.$emit("cell",{...e,row:n,set:this.set})},getRow(n){const e=this.$el.querySelectorAll("tr");for(var t of e)if(t.__row&&n==Number(t.dataset.row))return t.__row},focus(n,e,t=null){t&&(n+=t.row),n=this.getRow(n),n&&n.focus(e,t)}}};$c.props.itemTag.default="tr";$c.props.listTag.default="tbody";const Jk=$c,jk={class:"table is-stripped is-fullwidth"},Gk=["title"],Yk=I("i",{class:"fa fa-circle-question"},null,-1),Xk=[Yk];function Qk(n,e,t,r,i,o){const l=Ft("a-row");return Y(),te("table",jk,[I("thead",null,[Sr(l,{context:n.context,columns:n.columnNames,orderable:n.columnsOrderable,cellTag:"th",onMove:n.moveColumn},Fs({_:2},[n.$slots["header-head"]?{name:"head",fn:Ee(u=>[ye(n.$slots,"header-head",Cn(Kr(u)))]),key:"0"}:void 0,n.$slots["header-tail"]?{name:"tail",fn:Ee(u=>[ye(n.$slots,"header-tail",Cn(Kr(u)))]),key:"1"}:void 0,Mt(n.columns,u=>({name:u.name,fn:Ee(f=>[ye(n.$slots,"header-"+u.name,Cn(Kr(f)),()=>[$i(Be(u.label)+" ",1),u.help?(Y(),te("span",{key:0,class:"icon small",title:u.help},Xk,8,Gk)):qe("",!0)])])}))]),1032,["context","columns","orderable","onMove"])]),I("tbody",null,[ye(n.$slots,"head"),(Y(!0),te(Pt,null,Mt(n.items,(u,f)=>(Y(),Yr(l,{key:f,context:n.context,item:u,cell:{row:f},columns:n.columnNames,"data-index":f,"data-row":f,draggable:n.orderable,onDragstart:n.onDragStart,onDragover:n.onDragOver,onDrop:n.onDrop,onCell:d=>n.onCellEvent(f,d)},Fs({_:2},[Mt(n.rowSlots,([d,h])=>({name:h,fn:Ee(m=>[ye(n.$slots,d,Cn(Kr(m)))])}))]),1032,["context","item","cell","columns","data-index","data-row","draggable","onDragstart","onDragover","onDrop","onCell"]))),128)),ye(n.$slots,"tail")])])}const Zk=hn(Jk,[["render",Qk]]),eC={emit:["cell","move","colmove","load"],components:{ARows:Zk},props:{labels:Object,actionAdd:Function,columnsOrderable:Boolean,orderBy:String,formData:Object,model:{type:Function,default:ii}},data(){return{set:new Cm(ii)}},computed:{_prefix(){return this.formData.prefix?this.formData.prefix+"-":""},fields(){return this.formData.fields},orderField(){return this.orderBy&&this.fields.find(n=>n.name==this.orderBy)},orderable(){return!!this.orderField},hiddenFields(){return this.fields.filter(n=>n.hidden&&!(this.orderable&&n==this.orderField))},visibleFields(){return this.fields.filter(n=>!n.hidden)},fieldSlots(){return this.visibleFields.reduce((n,e)=>({...n,["row-"+e.name]:e}),{})},items(){return this.set.items},rows(){return this.$refs.rows}},methods:{onCellEvent(n){this.$emit("cell",n)},onColumnMove(n){this.$emit("colmove",n)},onActionAdd(){if(this.actionAdd)return this.actionAdd(this);this.set.push()},moveItem(n){const{from:e,to:t}=n,r=n.set||this.set;r.move(e,t),this.$emit("move",{...n,seŧ:r})},removeItem(n){this.items[n].id||this.items.splice(n,1)},load(n=[],e=!1){e&&(this.set.items=[]);for(var t of n)this.set.push(Ms.cloneDeep(t));this.$emit("load",n)},reset(){var n;this.load(((n=this.formData)==null?void 0:n.initials)||[],!0)}},mounted(){this.reset()}},tC=["name","value"],nC=["name","value"],rC=["title","aria-label","aria-description"],iC=I("span",{class:"icon"},[I("i",{class:"fa fa-arrow-down-1-9"})],-1),sC=[iC],oC=["name","value"],lC=["name","value"],aC=["name","value"],uC={key:0},cC={class:"field"},fC={class:"control"},dC={class:"align-right pr-0"},hC=["onClick","title","aria-label"],pC=I("span",{class:"icon"},[I("i",{class:"fa fa-trash"})],-1),mC=[pC],gC={class:"a-formset-footer flex-row"},yC={class:"flex-grow-1 flex-row"},bC={class:"flex-grow-1 align-right"},vC=["title","aria-label"],SC=I("span",{class:"icon"},[I("i",{class:"fa fa-rotate"})],-1),wC=[SC],xC=["title","aria-label"],kC=I("span",{class:"icon"},[I("i",{class:"fa fa-plus"})],-1),CC=[kC];function TC(n,e,t,r,i,o){const l=Ft("a-rows");return Y(),te("div",null,[I("input",{type:"hidden",name:o._prefix+"TOTAL_FORMS",value:o.items.length||0},null,8,tC),(Y(!0),te(Pt,null,Mt(t.formData.management,(u,f)=>(Y(),te("input",{key:f,type:"hidden",name:o._prefix+f.toUpperCase(),value:u},null,8,nC))),128)),Sr(l,{ref:"rows",set:i.set,context:this,columns:o.visibleFields,columnsOrderable:t.columnsOrderable,orderable:o.orderable,onMove:o.moveItem,onColmove:o.onColumnMove,onCell:e[0]||(e[0]=u=>n.$emit("cell",u))},Fs({"header-head":Ee(()=>[o.orderable?(Y(),te(Pt,{key:0},[I("th",{style:{"max-width":"2em"},title:o.orderField.label,"aria-label":o.orderField.label,"aria-description":o.orderField.help||""},sC,8,rC),ye(n.$slots,"rows-header-head")],64)):qe("",!0)]),"row-head":Ee(u=>[o.orderable?(Y(),te("input",{key:0,type:"hidden",name:o._prefix+u.row+"-"+t.orderBy,value:u.row},null,8,oC)):qe("",!0),I("input",{type:"hidden",name:o._prefix+u.row+"-id",value:u.item?u.item.id:""},null,8,lC),(Y(!0),te(Pt,null,Mt(o.hiddenFields,f=>(Y(),te(Pt,{key:f.name},[f.name in["id",t.orderBy]?qe("",!0):(Y(),te("input",{key:0,type:"hidden",name:o._prefix+u.row+"-"+f.name,value:f.value in[null,void 0]?u.item.data[n.name]:f.value},null,8,aC))],64))),128)),ye(n.$slots,"row-head",Cn(Kr(u)),()=>[o.orderable?(Y(),te("td",uC,Be(u.row+1),1)):qe("",!0)])]),"row-tail":Ee(u=>[n.$slots["row-tail"]?ye(n.$slots,"row-tail",Cn(Pi({key:0},u))):qe("",!0),I("td",dC,[I("button",{type:"button",class:"button square",onClick:tk(f=>o.removeItem(u.row,u.item),["stop"]),title:t.labels.remove_item,"aria-label":t.labels.remove_item},mC,8,hC)])]),_:2},[Mt(o.fieldSlots,(u,f)=>({name:f,fn:Ee(d=>[ye(n.$slots,f,Pi(d,{field:u,inputName:o._prefix+d.cell.row+"-"+u.name}),()=>[I("div",cC,[I("div",fC,[ye(n.$slots,"control-"+u.name,Pi(d,{field:u,inputName:o._prefix+d.cell.row+"-"+u.name}))]),(Y(!0),te(Pt,null,Mt(d.item.error(u.name),([h,m])=>(Y(),te("p",{class:"help is-danger",key:m},Be(h),1))),128))])])])}))]),1032,["set","columns","columnsOrderable","orderable","onMove","onColmove"]),I("div",gC,[I("div",yC,[ye(n.$slots,"footer")]),I("div",bC,[I("button",{type:"button",class:"button square is-warning p-2",onClick:e[1]||(e[1]=u=>o.reset()),title:t.labels.discard_changes,"aria-label":t.labels.discard_changes},wC,8,vC),I("button",{type:"button",class:"button square is-primary p-2",onClick:e[2]||(e[2]=(...u)=>o.onActionAdd&&o.onActionAdd(...u)),title:t.labels.add_item,"aria-label":t.labels.add_item},CC,8,xC)])])])}const Uc=hn(eC,[["render",TC]]),Cs={Text:0,List:1,Settings:2},MC={components:{AActionButton:wm,AFormSet:Uc,ARow:Am,AModal:xm},props:{formData:Object,labels:Object,initData:Object,dataPrefix:String,settingsUrl:String,defaultColumns:{type:Array,default:()=>["artist","title","tags","album","year","timestamp"]}},data(){const n={tracklist_editor_sep:" -- "};return{Page:Cs,page:Cs.Text,extraData:{},settings:n,savedSettings:Ms.cloneDeep(n)}},computed:{rows(){return this.$refs.formset&&this.$refs.formset.rows},columns(){return this.rows&&this.rows.columns_||[]},settingsChanged(){var n=Object.keys(this.savedSettings).findIndex(e=>!Ms.isEqual(this.settings[e],this.savedSettings[e]));return n!=-1},separator:{set(n){this.settings.tracklist_editor_sep=n,this.page==Cs.List&&this.updateInput()},get(){return this.settings.tracklist_editor_sep}},rowsSlots(){return Object.keys(this.$slots).filter(n=>n.startsWith("row-")||n.startsWith("rows-")||n.startsWith("control-")).map(n=>[n,n.startsWith("rows-")?n.slice(5):n])}},methods:{onCellEvent(n){switch(n.name){case"change":this.updateInput();break}},onColumnMove(){this.settings.tracklist_editor_columns=this.$refs.formset.rows.columnNames,this.page==this.Page.List?this.updateInput():this.updateList()},updateList(){const n=this.toList(this.$refs.textarea.value);this.$refs.formset.set.reset(n)},updateInput(){const n=this.toText(this.$refs.formset.items);this.$refs.textarea.value=n},toList(n){const e=this.$refs.formset.rows.columns_;var t=n.split(`
-`),r=[];for(let u of t)if(u=u.trimLeft(),!!u){var i=u.split(this.separator),o={};for(var l in e){if(l>=i.length)break;const f=e[l];o[f.name]=i[l].trim()}o&&r.push(o)}return r},toText(n){const e=this.$refs.formset.rows.columns_,t=` ${this.separator.trim()} `,r=[];for(let l of n)if(l){var i=[];for(var o of e)i.push(l.data[o.name]||"");i=Ms.dropRightWhile(i,u=>!u||!(""+u).trim()),i=i.join(t).trimRight(),r.push(i)}return r.join(`
-`)},_data_key(n){n=n.slice(this.dataPrefix.length);try{var[e,t]=n.split("-",1);return[Number(e),t]}catch{return[null,n]}},settingsSaved(n=null){n!==null&&(this.settings=n),this.$refs.settings&&this.$refs.settings.close(),this.savedSettings=Ms.cloneDeep(this.settings)}},mounted(){const n=this.initData&&this.initData.settings;n&&(this.settingsSaved(n),this.rows.sortColumns(n.tracklist_editor_columns)),this.page=this.initData.items.length?Cs.List:Cs.Text}},EC={class:"a-tracklist-editor"},OC={class:"flex-row"},AC={class:"flex-grow-1"},_C={class:"flex-row align-right"},NC={class:"field has-addons"},DC={class:"control"},IC=I("span",{class:"icon is-small"},[I("i",{class:"fa fa-pencil"})],-1),RC={class:"control"},LC=I("span",{class:"icon is-small"},[I("i",{class:"fa fa-list"})],-1),PC={class:"control ml-3"},BC=["title"],FC=I("span",{class:"icon is-small"},[I("i",{class:"fa fa-cog"})],-1),zC=[FC],HC={class:"panel"},$C={class:"panel"},UC={class:"field"},WC={class:"label",style:{"vertical-align":"middle"}},VC={class:"table is-bordered",style:{"vertical-align":"middle"}},qC={key:0},KC={key:0,style:{cursor:"pointer"}},JC=["onClick"],jC=I("i",{class:"fa fa-left-right"},null,-1),GC=[jC],YC={class:"flex-row"},XC={class:"field is-inline-block is-vcentered flex-grow-1"},QC=I("label",{class:"label is-inline mr-2",style:{"vertical-align":"middle"}}," Séparateur",-1),ZC={class:"control is-inline-block",style:{"vertical-align":"middle"}},eT={class:"flex-row align-right"};function tT(n,e,t,r,i,o){const l=Ft("a-form-set"),u=Ft("a-row"),f=Ft("a-action-button"),d=Ft("a-modal");return Y(),te("div",EC,[I("div",OC,[I("div",AC,[ye(n.$slots,"title")]),I("div",_C,[I("div",NC,[I("p",DC,[I("button",{type:"button",class:si(["button","p-2",i.page==i.Page.Text?"is-primary":"is-light"]),onClick:e[0]||(e[0]=h=>i.page=i.Page.Text)},[IC,I("span",null,Be(t.labels.text),1)],2)]),I("p",RC,[I("button",{type:"button",class:si(["button","p-2",i.page==i.Page.List?"is-primary":"is-light"]),onClick:e[1]||(e[1]=h=>i.page=i.Page.List)},[LC,I("span",null,Be(t.labels.list),1)],2)]),I("p",PC,[I("button",{type:"button",class:"button is-info square",title:t.labels.settings,onClick:e[2]||(e[2]=h=>n.$refs.settings.open())},zC,8,BC)])])])]),Iu(I("section",HC,[I("textarea",{ref:"textarea",class:"is-fullwidth is-size-6",rows:"20",onChange:e[3]||(e[3]=(...h)=>o.updateList&&o.updateList(...h))},null,544)],512),[[Kh,i.page==i.Page.Text]]),Iu(I("section",$C,[Sr(l,{ref:"formset","form-data":t.formData,initials:t.initData.items,columnsOrderable:!0,labels:t.labels,"order-by":"position",onLoad:o.updateInput,onColmove:o.onColumnMove,onMove:o.updateInput,onCell:o.onCellEvent},Fs({_:2},[Mt(o.rowsSlots,([h,m])=>({name:m,fn:Ee(y=>[h!="row-tail"?ye(n.$slots,h,Cn(Pi({key:0},y))):qe("",!0)])}))]),1032,["form-data","initials","labels","onLoad","onColmove","onMove","onCell"])],512),[[Kh,i.page==i.Page.List]]),Sr(d,{ref:"settings",title:t.labels.settings},{default:Ee(()=>[I("div",UC,[I("label",WC,Be(t.labels.columns),1),I("table",VC,[n.$refs.formset?(Y(),te("tr",qC,[Sr(u,{columns:n.$refs.formset.rows.columnNames,item:n.$refs.formset.rows.columnLabels,onMove:n.$refs.formset.rows.moveColumn},{"cell-after":Ee(({cell:h})=>[h.coln.$refs.formset.rows.moveColumn({from:h.col,to:h.col+1})},GC,8,JC)])):qe("",!0)]),_:1},8,["columns","item","onMove"])])):qe("",!0)])]),I("div",YC,[I("div",XC,[QC,I("div",ZC,[Iu(I("input",{type:"text",ref:"sep",class:"input is-inline is-text-centered is-small",style:{"max-width":"5em"},"onUpdate:modelValue":e[4]||(e[4]=h=>o.separator=h),onChange:e[5]||(e[5]=h=>o.updateList())},null,544),[[nk,o.separator]])])])])]),footer:Ee(()=>[I("div",eT,[o.settingsChanged?(Y(),Yr(f,{key:0,icon:"fa fa-floppy-disk",class:"button control p-2 mr-3 is-secondary","run-class":"blink",url:t.settingsUrl,method:"POST",data:i.settings,"aria-label":t.labels.save_settings,onDone:e[6]||(e[6]=h=>o.settingsSaved())},{default:Ee(()=>[$i(Be(t.labels.save_settings),1)]),_:1},8,["url","data","aria-label"])):qe("",!0),I("button",{class:"button",type:"button",onClick:e[7]||(e[7]=h=>n.$refs.settings.close())}," Fermer ")])]),_:1},8,["title"])])}const nT=hn(MC,[["render",tT]]),rT={components:{AFormSet:Uc,ASelectFile:Em},props:{formData:Object,labels:Object,initData:Object,soundListUrl:String,soundUploadUrl:String,soundDeleteUrl:String},computed:{rowsSlots(){return Object.keys(this.$slots).filter(n=>n.startsWith("row-")||n.startsWith("rows-")||n.startsWith("control-")).map(n=>[n,n.startsWith("rows-")?n.slice(5):n])}},methods:{actionAdd(){this.$refs["select-file"].open()},selected(n){const e={sound:n.id,name:n.name,url:n.url,broadcast:n.broadcast};this.$refs.formset.set.push(e)}}},iT={class:"a-playlist-editor"},sT=["src"],oT={class:"label small flex-grow-1"},lT=I("br",null,null,-1),aT=["src"],uT=["name","value"];function cT(n,e,t,r,i,o){const l=Ft("a-select-file"),u=Ft("a-form-set");return Y(),te("div",iT,[Sr(l,{ref:"select-file",title:t.labels&&t.labels.add_sound,labels:t.labels,"list-url":t.soundListUrl,deleteUrl:t.soundDeleteUrl,uploadUrl:t.soundUploadUrl,uploadLabel:t.labels.select_file,onSelect:o.selected},{"upload-preview":Ee(({upload:f})=>[ye(n.$slots,"upload-preview",{upload:f})]),"upload-form":Ee(()=>[ye(n.$slots,"upload-form")]),default:Ee(({item:f})=>[I("audio",{controls:"",src:f.url},null,8,sT),I("label",oT,Be(f.name),1)]),_:3},8,["title","labels","list-url","deleteUrl","uploadUrl","uploadLabel","onSelect"]),Sr(u,{ref:"formset","form-data":t.formData,labels:t.labels,initials:t.initData.items,"order-by":"position","action-add":o.actionAdd},Fs({"row-sound":Ee(({item:f,inputName:d})=>[I("label",null,Be(f.data.name),1),lT,I("audio",{controls:"",src:f.data.url},null,8,aT),I("input",{type:"hidden",name:d,value:f.data.sound},null,8,uT)]),_:2},[Mt(o.rowsSlots,([f,d])=>({name:d,fn:Ee(h=>[f!="row-tail"?ye(n.$slots,f,Cn(Pi({key:0},h))):qe("",!0)])}))]),1032,["form-data","labels","initials","action-add"])])}const fT=hn(rT,[["render",cT]]);function Ze(n){this.content=n}Ze.prototype={constructor:Ze,find:function(n){for(var e=0;e>1}};Ze.from=function(n){if(n instanceof Ze)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ze(e)};function _m(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let l=0;i.text[l]==o.text[l];l++)t++;return t}if(i.content.size||o.content.size){let l=_m(i.content,o.content,t+1);if(l!=null)return l}t+=i.nodeSize}}function Nm(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let l=n.child(--i),u=e.child(--o),f=l.nodeSize;if(l==u){t-=f,r-=f;continue}if(!l.sameMarkup(u))return{a:t,b:r};if(l.isText&&l.text!=u.text){let d=0,h=Math.min(l.text.length,u.text.length);for(;de&&r(f,i+u,o||null,l)!==!1&&f.content.size){let h=u+1;f.nodesBetween(Math.max(0,e-h),Math.min(f.content.size,t-h),r,i+h)}u=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",l=!0;return this.nodesBetween(e,t,(u,f)=>{let d=u.isText?u.text.slice(Math.max(e,f)-f,t-f):u.isLeaf?i?typeof i=="function"?i(u):i:u.type.spec.leafText?u.type.spec.leafText(u):"":"";u.isBlock&&(u.isLeaf&&d||u.isTextblock)&&r&&(l?l=!1:o+=r),o+=d},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,l=0;le&&((lt)&&(u.isText?u=u.cut(Math.max(0,e-l),Math.min(u.text.length,t-l)):u=u.cut(Math.max(0,e-l-1),Math.min(u.content.size,t-l-1))),r.push(u),i+=u.nodeSize),l=f}return new B(r,i)}cutByIndex(e,t){return e==t?B.empty:e==0&&t==this.content.length?this:new B(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new B(i,o)}addToStart(e){return new B([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new B(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),l=i+o.nodeSize;if(l>=e)return l==e||t>0?jo(r+1,l):jo(r,i);i=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return B.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new B(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return B.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};xe.none=[];class fl extends Error{}class U{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Im(this.content,e+this.openStart,t);return r&&new U(r,this.openStart,this.openEnd)}removeBetween(e,t){return new U(Dm(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return U.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new U(B.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new U(e,r,i)}}U.empty=new U(B.empty,0,0);function Dm(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:l,offset:u}=n.findIndex(t);if(i==e||o.isText){if(u!=t&&!n.child(l).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=l)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Dm(o.content,e-i-1,t-i-1)))}function Im(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),l=n.maybeChild(i);if(o==e||l.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let u=Im(l.content,e-o-1,t);return u&&n.replaceChild(i,l.copy(u))}function dT(n,e,t){if(t.openStart>n.depth)throw new fl("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new fl("Inconsistent open depths");return Rm(n,e,t,0)}function Rm(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function _s(n,e,t,r){let i=(e||n).node(t),o=0,l=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Qr(n.nodeAfter,r),o++));for(let u=o;ui&&fc(n,e,i+1),l=r.depth>i&&fc(t,r,i+1),u=[];return _s(null,n,i,u),o&&l&&e.index(i)==t.index(i)?(Lm(o,l),Qr(Zr(o,Pm(n,e,t,r,i+1)),u)):(o&&Qr(Zr(o,dl(n,e,i+1)),u),_s(e,t,i,u),l&&Qr(Zr(l,dl(t,r,i+1)),u)),_s(r,null,i,u),new B(u)}function dl(n,e,t){let r=[];if(_s(null,n,t,r),n.depth>t){let i=fc(n,e,t+1);Qr(Zr(i,dl(n,e,t+1)),r)}return _s(e,null,t,r),new B(r)}function hT(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(B.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class zs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new hl(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let l=e;;){let{index:u,offset:f}=l.content.findIndex(o),d=o-f;if(r.push(l,u,i+f),!d||(l=l.child(u),l.isText))break;o=d-1,i+=f+1}return new zs(t,r,o)}static resolveCached(e,t){for(let i=0;ie&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Bm(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=B.empty,i=0,o=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,o),u=l&&l.matchFragment(this.content,t);if(!u||!u.validEnd)return!1;for(let f=i;ft.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=B.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};ei.prototype.text=void 0;class pl extends ei{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Bm(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new pl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pl(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Bm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class oi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new gT(e,t);if(r.next==null)return oi.empty;let i=Fm(r);r.next&&r.err("Unexpected trailing text");let o=kT(xT(i));return CT(o,r),o}matchType(e){for(let t=0;td.createAndFill()));for(let d=0;d=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let l=0;l"+e.indexOf(r.next[l].next);return o}).join(`
-`)}}oi.empty=new oi(!0);class gT{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Fm(n){let e=[];do e.push(yT(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function yT(n){let e=[];do e.push(bT(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function bT(n){let e=wT(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=vT(n,e);else break;return e}function Jh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function vT(n,e){let t=Jh(n),r=t;return n.eat(",")&&(n.next!="}"?r=Jh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function ST(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let l=t[o];l.groups.indexOf(e)>-1&&i.push(l)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function wT(n){if(n.eat("(")){let e=Fm(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=ST(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function xT(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(l,u,f){let d={term:f,to:u};return e[l].push(d),d}function i(l,u){l.forEach(f=>f.to=u)}function o(l,u){if(l.type=="choice")return l.exprs.reduce((f,d)=>f.concat(o(d,u)),[]);if(l.type=="seq")for(let f=0;;f++){let d=o(l.exprs[f],u);if(f==l.exprs.length-1)return d;i(d,u=t())}else if(l.type=="star"){let f=t();return r(u,f),i(o(l.expr,f),f),[r(f)]}else if(l.type=="plus"){let f=t();return i(o(l.expr,u),f),i(o(l.expr,f),f),[r(f)]}else{if(l.type=="opt")return[r(u)].concat(o(l.expr,u));if(l.type=="range"){let f=u;for(let d=0;d{n[l].forEach(({term:u,to:f})=>{if(!u)return;let d;for(let h=0;h{d||i.push([u,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let o=e[r.join(",")]=new oi(r.indexOf(n.length-1)>-1);for(let l=0;l-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new Wm(o,t,l));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class TT{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class ta{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Um(i.attrs),this.excluded=null;let o=Hm(this.attrs);this.instance=o?new xe(this,o):null}create(e=null){return!e&&this.instance?this.instance:new xe(this,$m(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,l)=>r[o]=new ta(o,i++,t,l)),r}removeFromSet(e){for(var t=0;t-1}}class MT{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Ze.from(e.nodes),t.marks=Ze.from(e.marks||{}),this.nodes=Gh.compile(this.spec.nodes,this),this.marks=ta.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],l=o.spec.content||"",u=o.spec.marks;o.contentMatch=r[l]||(r[l]=oi.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=u=="_"?null:u?Yh(this,u.split(" ")):u==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:Yh(this,l.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Gh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new pl(r,r.defaultAttrs,e,xe.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ei.fromJSON(this,e)}markFromJSON(e){return xe.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Yh(n,e){let t=[];for(let r=0;r-1)&&t.push(l=f)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ET(n){return n.tag!=null}function OT(n){return n.style!=null}class Ui{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{ET(r)?this.tags.push(r):OT(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Qh(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Qh(this,t,!0);return r.addAll(e,t.from,t.to),U.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(u.charCodeAt(e.length)!=61||u.slice(e.length+1)!=t))){if(l.getAttrs){let f=l.getAttrs(t);if(f===!1)continue;l.attrs=f||void 0}return l}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,l=0;for(;l{r(l=Zh(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(l=>{r(l=Zh(l)),l.node||l.ignore||l.mark||(l.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ui(e,Ui.schemaRules(e)))}}const Vm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},AT={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qm={ol:!0,ul:!0},ml=1,gl=2,Ns=4;function Xh(n,e,t){return e!=null?(e?ml:0)|(e==="full"?gl:0):n&&n.whitespace=="pre"?ml|gl:t&~Ns}class Go{constructor(e,t,r,i,o,l,u){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=u,this.content=[],this.activeMarks=xe.none,this.stashMarks=[],this.match=l||(u&Ns?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(B.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ml)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=B.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(B.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;tthis.addAll(e)),l&&this.sync(u),this.needsBlock=f}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,o.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
-`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=xe.none,r=xe.none;for(let i=0;i{l.clearMark(u)&&(r=u.addToSet(r))}):t=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(t),l.consuming===!1)o=l;else break}return[t,r]}addElementByRule(e,t,r){let i,o,l;t.node?(o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):i=this.enter(o,t.attrs||null,t.preserveWhitespace)):(l=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(l));let u=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(f=>this.insertNode(f));else{let f=e;typeof t.contentElement=="string"?f=e.querySelector(t.contentElement):typeof t.contentElement=="function"?f=t.contentElement(e):t.contentElement&&(f=t.contentElement),this.findAround(e,f,!0),this.addAll(f)}i&&this.sync(u)&&this.open--,l&&this.removePendingMark(l,u)}addAll(e,t,r){let i=t||0;for(let o=t?e.childNodes[t]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],l=o.findWrapping(e);if(l&&(!t||t.length>l.length)&&(t=l,r=o,!l.length)||o.solid)break}if(!t)return!1;this.sync(r);for(let i=0;ithis.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),l=(u,f)=>{for(;u>=0;u--){let d=t[u];if(d==""){if(u==t.length-1||u==0)continue;for(;f>=o;f--)if(l(u-1,f))return!0;return!1}else{let h=f>0||f==0&&i?this.nodes[f].type:r&&f>=o?r.node(f-o).type:null;if(!h||h.name!=d&&h.groups.indexOf(d)==-1)return!1;f--}}return!0};return l(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=RT(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let l=i.popFromStashMark(e);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==t)break}}}function _T(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qm.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function NT(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function DT(n){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,r=[];for(;t=e.exec(n);)r.push(t[1],t[2].trim());return r}function Zh(n){let e={};for(let t in n)e[t]=n[t];return e}function IT(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],l=u=>{o.push(u);for(let f=0;f{if(o.length||l.marks.length){let u=0,f=0;for(;u=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Tn.renderSpec(Bu(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let l,u=r?e.createElementNS(r,i):e.createElement(i),f=t[1],d=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){d=2;for(let h in f)if(f[h]!=null){let m=h.indexOf(" ");m>0?u.setAttributeNS(h.slice(0,m),h.slice(m+1),f[h]):u.setAttribute(h,f[h])}}for(let h=d;hd)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:v}=Tn.renderSpec(e,m,r);if(u.appendChild(y),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:u,contentDOM:l}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Tn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ep(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return ep(e.marks)}}function ep(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Bu(n){return n.document||window.document}const Km=65535,Jm=Math.pow(2,16);function LT(n,e){return n+e*Jm}function tp(n){return n&Km}function PT(n){return(n-(n&Km))/Jm}const jm=1,Gm=2,il=4,Ym=8;class hc{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Ym)>0}get deletedBefore(){return(this.delInfo&(jm|il))>0}get deletedAfter(){return(this.delInfo&(Gm|il))>0}get deletedAcross(){return(this.delInfo&il)>0}}class Bt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Bt.empty)return Bt.empty}recover(e){let t=0,r=tp(e);if(!this.inverted)for(let i=0;ie)break;let d=this.ranges[u+o],h=this.ranges[u+l],m=f+d;if(e<=m){let y=d?e==f?-1:e==m?1:t:t,v=f+i+(y<0?0:h);if(r)return v;let w=e==(t<0?f:m)?null:LT(u/3,e-f),T=e==f?Gm:e==m?jm:il;return(t<0?e!=f:e!=m)&&(T|=Ym),new hc(v,T,w)}i+=h-d}return r?e+i:new hc(e+i,0,null)}touches(e,t){let r=0,i=tp(t),o=this.inverted?2:1,l=this.inverted?1:2;for(let u=0;ue)break;let d=this.ranges[u+o],h=f+d;if(e<=h&&u==i*3)return!0;r+=this.ranges[u+l]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Bi;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&f!l.isAtom||!u.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),t.openStart,t.openEnd);return Fe.fromReplace(e,this.from,this.to,o)}invert(){return new Mn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yr(t.pos,r.pos,this.mark)}merge(e){return e instanceof yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yr(t.from,t.to,e.markFromJSON(t.mark))}}lt.jsonID("addMark",yr);class Mn extends lt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new U(Wc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Fe.fromReplace(e,this.from,this.to,r)}invert(){return new yr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Mn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Mn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Mn(t.from,t.to,e.markFromJSON(t.mark))}}lt.jsonID("removeMark",Mn);class br extends lt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Fe.fromReplace(e,this.pos,this.pos+1,new U(B.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Ke(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ke(t.from,t.to,t.gapFrom,t.gapTo,U.fromJSON(e,t.slice),t.insert,!!t.structure)}}lt.jsonID("replaceAround",Ke);function pc(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function BT(n,e,t,r){let i=[],o=[],l,u;n.doc.nodesBetween(e,t,(f,d,h)=>{if(!f.isInline)return;let m=f.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),v=Math.min(d+f.nodeSize,t),w=r.addToSet(m);for(let T=0;Tn.step(f)),o.forEach(f=>n.step(f))}function FT(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(l,u)=>{if(!l.isInline)return;o++;let f=null;if(r instanceof ta){let d=l.marks,h;for(;h=r.isInSet(d);)(f||(f=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(l.marks)&&(f=[r]):f=l.marks;if(f&&f.length){let d=Math.min(u+l.nodeSize,t);for(let h=0;hn.step(new Mn(l.from,l.to,l.style)))}function zT(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let u=0;u=0;u--)n.step(o[u])}function HT(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Gi(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),l=n.$to.indexAfter(r);if(rt;w--)T||r.index(w)>0?(T=!0,h=B.from(r.node(w).copy(h)),m++):f--;let y=B.empty,v=0;for(let w=o,T=!1;w>t;w--)T||i.after(w+1)=0;l--){if(r.size){let u=t[l].type.contentMatch.matchFragment(r);if(!u||!u.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=B.from(t[l].type.create(t[l].attrs,r))}let i=e.start,o=e.end;n.step(new Ke(i,o,i,o,new U(r,0,0),t.length,!0))}function qT(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(l,u)=>{if(l.isTextblock&&!l.hasMarkup(r,i)&&KT(n.doc,n.mapping.slice(o).map(u),r)){n.clearIncompatible(n.mapping.slice(o).map(u,1),r);let f=n.mapping.slice(o),d=f.map(u,1),h=f.map(u+l.nodeSize,1);return n.step(new Ke(d,h,d+1,h-1,new U(B.from(r.create(i,null,l.marks)),0,0),1,!0)),!1}})}function KT(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function JT(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let l=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,l);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ke(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new U(B.from(l),0,0),1,!0))}function Fi(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,h=t-2;d>o;d--,h--){let m=i.node(d),y=i.index(d);if(m.type.spec.isolating)return!1;let v=m.content.cutByIndex(y,m.childCount),w=r&&r[h+1];w&&(v=v.replaceChild(0,w.type.create(w.attrs)));let T=r&&r[h]||m;if(!m.canReplace(y+1,m.childCount)||!T.type.validContent(v))return!1}let u=i.indexAfter(o),f=r&&r[0];return i.node(o).canReplaceWith(u,u,f?f.type:i.node(o+1).type)}function jT(n,e,t=1,r){let i=n.doc.resolve(e),o=B.empty,l=B.empty;for(let u=i.depth,f=i.depth-t,d=t-1;u>f;u--,d--){o=B.from(i.node(u).copy(o));let h=r&&r[d];l=B.from(h?h.type.create(h.attrs,l):i.node(u).copy(l))}n.step(new Ve(e,e,new U(o.append(l),t,t),!0))}function Tr(n,e){let t=n.resolve(e),r=t.index();return Xm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Xm(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function na(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let o,l,u=r.index(i);if(i==r.depth?(o=r.nodeBefore,l=r.nodeAfter):t>0?(o=r.node(i+1),u++,l=r.node(i).maybeChild(u)):(o=r.node(i).maybeChild(u-1),l=r.node(i+1)),o&&!o.isTextblock&&Xm(o,l)&&r.node(i).canReplace(u,u+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function GT(n,e,t){let r=new Ve(e-t,e+t,U.empty,!0);n.step(r)}function YT(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;l--){let u=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,f=r.index(l)+(u>0?1:0),d=r.node(l),h=!1;if(o==1)h=d.canReplace(f,f,i);else{let m=d.contentMatchAt(f).findWrapping(i.firstChild.type);h=m&&d.canReplaceWith(f,f,m[0])}if(h)return u==0?r.pos:u<0?r.before(l+1):r.after(l+1)}return null}function ra(n,e,t=e,r=U.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Zm(i,o,r)?new Ve(e,t,r):new XT(i,o,r).fit()}function Zm(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class XT{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=B.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=B.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,l=r.depth,u=i.depth;for(;l&&u&&o.childCount==1;)o=o.firstChild.content,l--,u--;let f=new U(o,l,u);return e>-1?new Ke(r.pos,e,this.$to.pos,this.$to.end(),f,t):f.size||r.pos!=this.$to.pos?new Ve(r.pos,i.pos,f):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=zu(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let l=i.firstChild;for(let u=this.depth;u>=0;u--){let{type:f,match:d}=this.frontier[u],h,m=null;if(t==1&&(l?d.matchType(l.type)||(m=d.fillBefore(B.from(l),!1)):o&&f.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:u,parent:o,inject:m};if(t==2&&l&&(h=d.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:u,parent:o,wrap:h};if(o&&d.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=zu(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new U(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=zu(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new U(Es(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new U(Es(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let T=0;T1||f==0||T.content.size)&&(m=E,h.push(eg(T.mark(y.allowedMarks(T.marks)),d==1?f:0,d==u.childCount?v:-1)))}let w=d==u.childCount;w||(v=-1),this.placed=Os(this.placed,t,B.from(h)),this.frontier[t].match=m,w&&v<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let T=0,E=u;T1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;u--){let{match:f,type:d}=this.frontier[u],h=Hu(e,u,d,f,!0);if(!h||h.childCount)continue e}return{depth:t,fit:l,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Os(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Os(this.placed,this.depth,B.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(B.empty,!0);t.childCount&&(this.placed=Os(this.placed,this.frontier.length,t))}}function Es(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Es(n.firstChild.content,e-1,t)))}function Os(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Os(n.lastChild.content,e-1,t)))}function zu(n,e){for(let t=0;t1&&(r=r.replaceChild(0,eg(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(B.empty,!0)))),n.copy(r)}function Hu(n,e,t,r,i){let o=n.node(e),l=i?n.indexAfter(e):n.index(e);if(l==o.childCount&&!t.compatibleContent(o.type))return null;let u=r.fillBefore(o.content,!0,l);return u&&!QT(t,o.content,l)?u:null}function QT(n,e,t){for(let r=t;r0;y--,v--){let w=i.node(y).type.spec;if(w.defining||w.definingAsContext||w.isolating)break;l.indexOf(y)>-1?u=y:i.before(y)==v&&l.splice(1,0,-y)}let f=l.indexOf(u),d=[],h=r.openStart;for(let y=r.content,v=0;;v++){let w=y.firstChild;if(d.push(w),v==r.openStart)break;y=w.content}for(let y=h-1;y>=0;y--){let v=d[y],w=ZT(v.type);if(w&&!v.sameMarkup(i.node(Math.abs(u)-1)))h=y;else if(w||!v.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let v=(y+h+1)%(r.openStart+1),w=d[v];if(w)for(let T=0;T=0&&(n.replace(e,t,r),!(n.steps.length>m));y--){let v=l[y];v<0||(e=i.before(v),t=o.after(v))}}function tg(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),l=o.fillBefore(n).append(n);n=l.append(o.matchFragment(l).fillBefore(B.empty,!0))}return n}function tM(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=YT(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new U(B.from(r),0,0))}function nM(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=ng(r,i);for(let l=0;l0&&(f||r.node(u-1).canReplace(r.index(u-1),i.indexAfter(u-1))))return n.delete(r.before(u),i.after(u))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&t>r.end(l)&&i.end(l)-t!=i.depth-l)return n.delete(r.before(l),t);n.delete(e,t)}function ng(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class zi extends lt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Fe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Fe.fromReplace(e,this.pos,this.pos+1,new U(B.from(i),0,t.isLeaf?0:1))}getMap(){return Bt.empty}invert(e){return new zi(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new zi(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new zi(t.pos,t.attr,t.value)}}lt.jsonID("attr",zi);class Hs extends lt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Fe.ok(r)}getMap(){return Bt.empty}invert(e){return new Hs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Hs(t.attr,t.value)}}lt.jsonID("docAttr",Hs);let Vi=class extends Error{};Vi=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Vi.prototype=Object.create(Error.prototype);Vi.prototype.constructor=Vi;Vi.prototype.name="TransformError";class rg{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Bi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vi(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=U.empty){let i=ra(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new U(B.from(r),0,0))}delete(e,t){return this.replace(e,t,U.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return eM(this,e,t,r),this}replaceRangeWith(e,t,r){return tM(this,e,t,r),this}deleteRange(e,t){return nM(this,e,t),this}lift(e,t){return $T(this,e,t),this}join(e,t=1){return GT(this,e,t),this}wrap(e,t){return VT(this,e,t),this}setBlockType(e,t=e,r,i=null){return qT(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return JT(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new zi(e,t,r)),this}setDocAttribute(e,t){return this.step(new Hs(e,t)),this}addNodeMark(e,t){return this.step(new br(e,t)),this}removeNodeMark(e,t){if(!(t instanceof xe)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Wi(e,t)),this}split(e,t=1,r){return jT(this,e,t,r),this}addMark(e,t,r){return BT(this,e,t,r),this}removeMark(e,t,r){return FT(this,e,t,r),this}clearIncompatible(e,t,r){return zT(this,e,t,r),this}}const $u=Object.create(null);class ce{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new rM(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;o--){let l=t<0?_i(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):_i(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fn(e.node(0))}static atStart(e){return _i(e,e,0,0,1)||new fn(e)}static atEnd(e){return _i(e,e,e.content.size,e.childCount,-1)||new fn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$u[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in $u)throw new RangeError("Duplicate use of selection JSON ID "+e);return $u[e]=t,t.prototype.jsonID=e,t}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}}ce.prototype.visible=!0;class rM{constructor(e,t){this.$from=e,this.$to=t}}let rp=!1;function ip(n){!rp&&!n.parent.inlineContent&&(rp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class re extends ce{constructor(e,t=e){ip(e),ip(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ce.near(r);let i=e.resolve(t.map(this.anchor));return new re(i.parent.inlineContent?i:r,r)}replace(e,t=U.empty){if(super.replace(e,t),t==U.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof re&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ia(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=ce.findFrom(t,r,!0)||ce.findFrom(t,-r,!0);if(o)t=o.$head;else return ce.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ce.findFrom(e,-r,!0)||ce.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?l=0;l+=i){let u=e.child(l);if(u.isAtom){if(!o&&j.isSelectable(u))return j.create(n,t-(i<0?u.nodeSize:0))}else{let f=_i(n,u,t+i,i<0?u.childCount:0,i,o);if(f)return f}t+=u.nodeSize*i}return null}function sp(n,e,t){let r=n.steps.length-1;if(r{l==null&&(l=h)}),n.setSelection(ce.near(n.doc.resolve(l),t))}const op=1,Yo=2,lp=4;class sM extends rg{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Yo,this}ensureMarks(e){return xe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Yo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Yo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||xe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let l=this.doc.resolve(t);o=r==t?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(ce.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=lp,this}get scrolledIntoView(){return(this.updated&lp)>0}}function ap(n,e){return!e||!n?n:n.bind(e)}class As{constructor(e,t,r){this.name=e,this.init=ap(t.init,r),this.apply=ap(t.apply,r)}}const oM=[new As("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new As("selection",{init(n,e){return n.selection||ce.atStart(e.doc)},apply(n){return n.selection}}),new As("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new As("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Uu{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=oM.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new As(r.key,r.spec.state,r))})}}class Ri{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Uu(e.schema,e.plugins),o=new Ri(i);return i.fields.forEach(l=>{if(l.name=="doc")o.doc=ei.fromJSON(e.schema,t.doc);else if(l.name=="selection")o.selection=ce.fromJSON(o.doc,t.selection);else if(l.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let u in r){let f=r[u],d=f.spec.state;if(f.key==l.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,u)){o[l.name]=d.fromJSON.call(f,e,t[u],o);return}}o[l.name]=l.init(e,o)}}),o}}function ig(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ig(i,e,{})),t[r]=i}return t}class nt{constructor(e){this.spec=e,this.props={},e.props&&ig(e.props,this,this.props),this.key=e.key?e.key.key:sg("plugin")}getState(e){return e[this.key]}}const Wu=Object.create(null);function sg(n){return n in Wu?n+"$"+ ++Wu[n]:(Wu[n]=0,n+"$")}class zt{constructor(e="key"){this.key=sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const et=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},$s=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let mc=null;const qn=function(n,e,t){let r=mc||(mc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},lM=function(){mc=null},li=function(n,e,t,r){return t&&(up(n,e,t,r,-1)||up(n,e,t,r,1))},aM=/^(img|br|input|textarea|hr)$/i;function up(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:kn(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Ys(n)||aM.test(n.nodeName)||n.contentEditable=="false")return!1;e=et(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?kn(n):0}else return!1}}function kn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function uM(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=kn(n)}else if(n.parentNode&&!Ys(n))e=et(n),n=n.parentNode;else return null}}function cM(n,e){for(;;){if(n.nodeType==3&&e2),Xt=qi||(En?/Mac/.test(En.platform):!1),mM=En?/Win/.test(En.platform):!1,an=/Android \d/.test(Mr),Xs=!!cp&&"webkitFontSmoothing"in cp.documentElement.style,gM=Xs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yM(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Wn(n,e){return typeof n=="number"?n:n[e]}function bM(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function fp(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let l=t||n.dom;l;l=$s(l)){if(l.nodeType!=1)continue;let u=l,f=u==o.body,d=f?yM(o):bM(u),h=0,m=0;if(e.topd.bottom-Wn(r,"bottom")&&(m=e.bottom-e.top>d.bottom-d.top?e.top+Wn(i,"top")-d.top:e.bottom-d.bottom+Wn(i,"bottom")),e.leftd.right-Wn(r,"right")&&(h=e.right-d.right+Wn(i,"right")),h||m)if(f)o.defaultView.scrollBy(h,m);else{let y=u.scrollLeft,v=u.scrollTop;m&&(u.scrollTop+=m),h&&(u.scrollLeft+=h);let w=u.scrollLeft-y,T=u.scrollTop-v;e={left:e.left-w,top:e.top-T,right:e.right-w,bottom:e.bottom-T}}if(f||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function vM(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,l=t+1;l=t-20){r=u,i=f.top;break}}return{refDOM:r,refTop:i,stack:lg(n.dom)}}function lg(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=$s(r));return e}function SM({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ag(t,r==0?0:r-e)}function ag(n,e){for(let t=0;t=u){l=Math.max(w.bottom,l),u=Math.min(w.top,u);let T=w.left>e.left?w.left-e.left:w.right=(w.left+w.right)/2?1:0));continue}}else w.top>e.top&&!f&&w.left<=e.left&&w.right>=e.left&&(f=h,d={left:Math.max(w.left,Math.min(w.right,e.left)),top:w.top});!t&&(e.left>=w.right&&e.top>=w.top||e.left>=w.left&&e.top>=w.bottom)&&(o=m+1)}}return!t&&f&&(t=f,i=d,r=0),t&&t.nodeType==3?xM(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:ug(t,i)}function xM(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function Kc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function kM(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(l.left+l.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function TM(n,e,t,r){let i=-1;for(let o=e,l=!1;o!=n.dom;){let u=n.docView.nearestDesc(o,!0);if(!u)return null;if(u.dom.nodeType==1&&(u.node.isBlock&&u.parent&&!l||!u.contentDOM)){let f=u.dom.getBoundingClientRect();if(u.node.isBlock&&u.parent&&!l&&(l=!0,f.left>r.left||f.top>r.top?i=u.posBefore:(f.right-1?i:n.docView.posFromDOM(e,t,-1)}function cg(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let d;Xs&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?u=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(u=TM(n,r,i,e))}u==null&&(u=CM(n,l,e));let f=n.docView.nearestDesc(l,!0);return{pos:u,inside:f?f.posAtStart-f.border:-1}}function dp(n){return n.top=0&&i==r.nodeValue.length?(f--,h=1):t<0?f--:d++,Ts(fr(qn(r,f,d),h),h<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==kn(r))){let f=r.childNodes[i-1];if(f.nodeType==1)return Vu(f.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==kn(r))){let f=r.childNodes[i-1],d=f.nodeType==3?qn(f,kn(f)-(l?0:1)):f.nodeType==1&&(f.nodeName!="BR"||!f.nextSibling)?f:null;if(d)return Ts(fr(d,1),!1)}if(o==null&&i=0)}function Ts(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Vu(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function dg(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function OM(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return dg(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let u=n.docView.nearestDesc(o,!0);if(!u)break;if(u.node.isBlock){o=u.contentDOM||u.dom;break}o=u.dom.parentNode}let l=fg(n,i.pos,1);for(let u=o.firstChild;u;u=u.nextSibling){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=qn(u,0,u.nodeValue.length).getClientRects();else continue;for(let d=0;dh.top+1&&(t=="up"?l.top-h.top>(h.bottom-l.top)*2:h.bottom-l.bottom>(l.bottom-h.top)*2))return!1}}return!0})}const AM=/[\u0590-\u08ac]/;function _M(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,l=i==r.parent.content.size,u=n.domSelection();return!AM.test(r.parent.textContent)||!u.modify?t=="left"||t=="backward"?o:l:dg(n,e,()=>{let{focusNode:f,focusOffset:d,anchorNode:h,anchorOffset:m}=n.domSelectionRange(),y=u.caretBidiLevel;u.modify("move",t,"character");let v=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:w,focusOffset:T}=n.domSelectionRange(),E=w&&!v.contains(w.nodeType==1?w:w.parentNode)||f==w&&d==T;try{u.collapse(h,m),f&&(f!=h||d!=m)&&u.extend&&u.extend(f,d)}catch{}return y!=null&&(u.caretBidiLevel=y),E})}let hp=null,pp=null,mp=!1;function NM(n,e,t){return hp==e&&pp==t?mp:(hp=e,pp=t,mp=t=="up"||t=="down"?OM(n,e,t):_M(n,e,t))}const Zt=0,gp=1,Jr=2,On=3;class Qs{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Zt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tet(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),l;if(o&&(!t||o.node))if(r&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||l instanceof pg){i=e-o;break}o=u}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof hg&&o.side>=0;r--);if(t<=0){let o,l=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,l=!1);return o&&t&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?et(o.dom)+1:0}}else{let o,l=!0;for(;o=r=h&&t<=d-f.border&&f.node&&f.contentDOM&&this.contentDOM.contains(f.contentDOM))return f.parseRange(e,t,h);e=l;for(let m=u;m>0;m--){let y=this.children[m-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=et(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(d>t||u==this.children.length-1)){t=d;for(let h=u+1;hv&<){let v=u;u=f,f=v}let y=document.createRange();y.setEnd(f.node,f.offset),y.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let u=r+o.border,f=l-o.border;if(e>=u&&t<=f){this.dirty=e==r||t==l?Jr:gp,e==u&&t==f&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=On:o.markDirty(e-u,t-u);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Jr:On}r=l}this.dirty=Jr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Jr:gp;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(l.nodeType!=1){let u=document.createElement("span");u.appendChild(l),l=u}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Zt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class DM extends Qs{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ai extends Qs{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let o=i.nodeViews[t.type.name],l=o&&o(t,i,r);return(!l||!l.dom)&&(l=Tn.renderSpec(document,t.type.spec.toDOM(t,r))),new ai(e,t,l.dom,l.contentDOM||l.dom)}parseRule(){return this.dirty&On||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=On&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Zt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=wc(o,0,e,r));for(let u=0;u{if(!f)return l;if(f.parent)return f.parent.posBeforeChild(f)},r,i),h=d&&d.dom,m=d&&d.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=Tn.renderSpec(document,t.type.spec.toDOM(t)));!m&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let y=h;return h=yg(h,r,t),d?f=new IM(e,t,r,i,h,m||null,y,d,o,l+1):t.isText?new oa(e,t,r,i,h,y,o):new xr(e,t,r,i,h,m||null,y,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>B.empty)}return e}matchesNode(e,t,r){return this.dirty==Zt&&e.eq(this.node)&&Sc(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,l=o&&o.pos>-1?o:null,u=o&&o.pos<0,f=new LM(this,l&&l.node,e);FM(this.node,this.innerDeco,(d,h,m)=>{d.spec.marks?f.syncToMarks(d.spec.marks,r,e):d.type.side>=0&&!m&&f.syncToMarks(h==this.node.childCount?xe.none:this.node.child(h).marks,r,e),f.placeWidget(d,e,i)},(d,h,m,y)=>{f.syncToMarks(d.marks,r,e);let v;f.findNodeMatch(d,h,m,y)||u&&e.state.selection.from>i&&e.state.selection.to-1&&f.updateNodeAt(d,h,m,v,e)||f.updateNextNode(d,h,m,e,y,i)||f.addNode(d,h,m,e,i),i+=d.nodeSize}),f.syncToMarks([],r,e),this.node.isTextblock&&f.addTextblockHacks(),f.destroyRest(),(f.changed||this.dirty==Jr)&&(l&&this.protectLocalComposition(e,l),mg(this.contentDOM,this.children,e),qi&&zM(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof re)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,u=HM(this.node.content,l,r-t,i-t);return u<0?null:{node:o,pos:u,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new DM(this,o,t,i);e.input.compositionNodes.push(l),this.children=wc(this.children,r,r+i.length,e,l)}update(e,t,r,i){return this.dirty==On||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Zt}updateOuterDeco(e){if(Sc(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=gg(this.dom,this.nodeDOM,vc(this.outerDeco,this.node,t),vc(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function yp(n,e,t,r,i){yg(r,e,n);let o=new xr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class oa extends xr{constructor(e,t,r,i,o,l,u){super(e,t,r,i,o,null,l,u,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==On||this.dirty!=Zt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Zt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Zt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new oa(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=On)}get domAtom(){return!1}isText(e){return this.node.text==e}}class pg extends Qs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Zt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class IM extends xr{constructor(e,t,r,i,o,l,u,f,d,h){super(e,t,r,i,o,l,u,d,h),this.spec=f}update(e,t,r,i){if(this.dirty==On)return!1;if(this.spec.update){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function mg(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,l=Math.min(o,e.length);for(;i-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=ai.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,t,r))o=this.top.children.indexOf(l,this.index);else for(let u=this.index,f=Math.min(this.top.children.length,u+5);u0;){let u;for(;;)if(r){let d=t.children[r-1];if(d instanceof ai)t=d,r=d.children.length;else{u=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let f=u.node;if(f){if(f!=n.child(i-1))break;--i,o.set(u,i),l.push(u)}}return{index:i,matched:o,matches:l.reverse()}}function BM(n,e){return n.type.side-e.type.side}function FM(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let d=0;do;)u.push(i[l++]);let w=o+y.nodeSize;if(y.isText){let E=w;l!E.inline):u.slice();r(y,T,e.forChild(o,y),v),o=w}}function zM(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function HM(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&f.slice(r-e.length-u,r-u)==e)return r-e.length;let d=u=0&&d+e.length+u>=t)return u+d;if(t==r&&f.length>=r+e.length-u&&f.slice(r-u,r-u+e.length)==e)return r}}return-1}function wc(n,e,t,r,i){let o=[];for(let l=0,u=0;l=t||h<=e?o.push(f):(dt&&o.push(f.slice(t-d,f.size,r)))}return o}function Jc(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,l=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(l<0)return null;let u=r.resolve(l),f,d;if(sa(t)){for(f=u;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&j.isSelectable(h)&&i.parent&&!(h.isInline&&fM(t.focusNode,t.focusOffset,i.dom))){let m=i.posBefore;d=new j(l==m?u:r.resolve(m))}}else{let h=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(h<0)return null;f=r.resolve(h)}if(!d){let h=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!bg(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function UM(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setEnd(r.parentNode,et(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&Et&&wr<=11&&(r.disabled=!0,r.disabled=!1)}function vg(n,e){if(e instanceof j){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(xp(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else xp(n)}function xp(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function jc(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||re.between(e,t,r)}function kp(n){return n.editable&&!n.hasFocus()?!1:Sg(n)}function Sg(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function WM(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return li(e.node,e.offset,t.anchorNode,t.anchorOffset)}function xc(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&ce.findFrom(o,e)}function dr(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Cp(n,e,t){let r=n.state.selection;if(r instanceof re)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return dr(n,new re(r.$anchor,l))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=xc(n.state,e);return i&&i instanceof j?dr(n,i):!1}else if(!(Xt&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!o||o.isText)return!1;let u=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(l=n.docView.descAt(u))&&!l.contentDOM?j.isSelectable(o)?dr(n,new j(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Xs?dr(n,new re(n.state.doc.resolve(e<0?u:u+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof j&&r.node.isInline)return dr(n,new re(e>0?r.$to:r.$from));{let i=xc(n.state,e);return i?dr(n,i):!1}}}function yl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Is(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Oi(n,e){return e<0?VM(n):qM(n)}function VM(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,l=!1;for(dn&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let u=t.childNodes[r-1];if(Is(u,-1))i=t,o=--r;else if(u.nodeType==3)t=u,r=t.nodeValue.length;else break}}else{if(wg(t))break;{let u=t.previousSibling;for(;u&&Is(u,-1);)i=t.parentNode,o=et(u),u=u.previousSibling;if(u)t=u,r=yl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}l?kc(n,t,r):i&&kc(n,i,o)}function qM(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=yl(t),o,l;for(;;)if(r{n.state==i&&Jn(n)},50)}function Tp(n,e){let t=n.state.doc.resolve(e);if(!(ht||mM)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l1)return o.lefti.top&&l1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Mp(n,e,t){let r=n.state.selection;if(r instanceof re&&!r.empty||t.indexOf("s")>-1||Xt&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let l=xc(n.state,e);if(l&&l instanceof j)return dr(n,l)}if(!i.parent.inlineContent){let l=e<0?i:o,u=r instanceof fn?ce.near(l,e):ce.findFrom(l,e);return u?dr(n,u):!1}return!1}function Ep(n,e){if(!(n.state.selection instanceof re))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let l=n.state.tr;return e<0?l.delete(t.pos-o.nodeSize,t.pos):l.delete(t.pos,t.pos+o.nodeSize),n.dispatch(l),!0}return!1}function Op(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function jM(n){if(!pt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Op(n,r,"true"),setTimeout(()=>Op(n,r,"false"),20)}return!1}function GM(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function YM(n,e){let t=e.keyCode,r=GM(e);if(t==8||Xt&&t==72&&r=="c")return Ep(n,-1)||Oi(n,-1);if(t==46&&!e.shiftKey||Xt&&t==68&&r=="c")return Ep(n,1)||Oi(n,1);if(t==13||t==27)return!0;if(t==37||Xt&&t==66&&r=="c"){let i=t==37?Tp(n,n.state.selection.from)=="ltr"?-1:1:-1;return Cp(n,i,r)||Oi(n,i)}else if(t==39||Xt&&t==70&&r=="c"){let i=t==39?Tp(n,n.state.selection.from)=="ltr"?1:-1:1;return Cp(n,i,r)||Oi(n,i)}else{if(t==38||Xt&&t==80&&r=="c")return Mp(n,-1,r)||Oi(n,-1);if(t==40||Xt&&t==78&&r=="c")return jM(n)||Mp(n,1,r)||Oi(n,1);if(r==(Xt?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function xg(n,e){n.someProp("transformCopied",v=>{e=v(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let v=r.firstChild;t.push(v.type.name,v.attrs!=v.type.defaultAttrs?v.attrs:null),r=v.content}let l=n.someProp("clipboardSerializer")||Tn.fromSchema(n.state.schema),u=Og(),f=u.createElement("div");f.appendChild(l.serializeFragment(r,{document:u}));let d=f.firstChild,h,m=0;for(;d&&d.nodeType==1&&(h=Eg[d.nodeName.toLowerCase()]);){for(let v=h.length-1;v>=0;v--){let w=u.createElement(h[v]);for(;f.firstChild;)w.appendChild(f.firstChild);f.appendChild(w),m++}d=f.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${i} ${o}${m?` -${m}`:""} ${JSON.stringify(t)}`);let y=n.someProp("clipboardTextSerializer",v=>v(e,n))||e.content.textBetween(0,e.content.size,`
+}`;var le=$h(function(){return ve(S,J+"return "+P).apply(t,w)});if(le.source=P,xu(le))throw le;return le}function ew(s){return Se(s).toLowerCase()}function tw(s){return Se(s).toUpperCase()}function nw(s,a,f){if(s=Se(s),s&&(f||a===t))return Yf(s);if(!s||!(a=Dt(a)))return s;var p=rn(s),g=rn(a),S=Xf(p,g),w=Qf(p,g)+1;return ar(p,S,w).join("")}function rw(s,a,f){if(s=Se(s),s&&(f||a===t))return s.slice(0,ed(s)+1);if(!s||!(a=Dt(a)))return s;var p=rn(s),g=Qf(p,rn(a))+1;return ar(p,0,g).join("")}function iw(s,a,f){if(s=Se(s),s&&(f||a===t))return s.replace(xa,"");if(!s||!(a=Dt(a)))return s;var p=rn(s),g=Xf(p,rn(a));return ar(p,g).join("")}function sw(s,a){var f=at,p=At;if(Oe(a)){var g="separator"in a?a.separator:g;f="length"in a?se(a.length):f,p="omission"in a?Dt(a.omission):p}s=Se(s);var S=s.length;if(mi(s)){var w=rn(s);S=w.length}if(f>=S)return s;var k=f-gi(p);if(k<1)return p;var M=w?ar(w,0,k).join(""):s.slice(0,k);if(g===t)return M+p;if(w&&(k+=M.length-k),wu(g)){if(s.slice(k).search(g)){var R,L=M;for(g.global||(g=Fa(g.source,Se(bf.exec(g))+"g")),g.lastIndex=0;R=g.exec(L);)var P=R.index;M=M.slice(0,P===t?k:P)}}else if(s.indexOf(Dt(g),k)!=k){var $=M.lastIndexOf(g);$>-1&&(M=M.slice(0,$))}return M+p}function ow(s){return s=Se(s),s&&Dn.test(s)?s.replace(Nn,Ly):s}var lw=ki(function(s,a,f){return s+(f?" ":"")+a.toUpperCase()}),Tu=Ud("toUpperCase");function Hh(s,a,f){return s=Se(s),a=f?t:a,a===t?_y(s)?Fy(s):xy(s):s.match(a)||[]}var $h=fe(function(s,a){try{return _t(s,t,a)}catch(f){return xu(f)?f:new ee(f)}}),aw=Bn(function(s,a){return Ut(a,function(f){f=yn(f),Ln(s,f,vu(s[f],s))}),s});function uw(s){var a=s==null?0:s.length,f=G();return s=a?Ae(s,function(p){if(typeof p[1]!="function")throw new Wt(l);return[f(p[0]),p[1]]}):[],fe(function(p){for(var g=-1;++gke)return[];var f=bt,p=rt(s,bt);a=G(a),s-=bt;for(var g=La(p,a);++f0||a<0)?new pe(f):(s<0?f=f.takeRight(-s):s&&(f=f.drop(s)),a!==t&&(a=se(a),f=a<0?f.dropRight(-a):f.take(a-s)),f)},pe.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},pe.prototype.toArray=function(){return this.take(bt)},mn(pe.prototype,function(s,a){var f=/^(?:filter|find|map|reject)|While$/.test(a),p=/^(?:head|last)$/.test(a),g=b[p?"take"+(a=="last"?"Right":""):a],S=p||/^find/.test(a);g&&(b.prototype[a]=function(){var w=this.__wrapped__,k=p?[1]:arguments,M=w instanceof pe,R=k[0],L=M||ne(w),P=function(he){var ge=g.apply(b,nr([he],k));return p&&$?ge[0]:ge};L&&f&&typeof R=="function"&&R.length!=1&&(M=L=!1);var $=this.__chain__,J=!!this.__actions__.length,Q=S&&!$,le=M&&!J;if(!S&&L){w=le?w:new pe(this);var Z=s.apply(w,k);return Z.__actions__.push({func:Ho,args:[P],thisArg:t}),new Vt(Z,$)}return Q&&le?s.apply(this,k):(Z=this.thru(P),Q?p?Z.value()[0]:Z.value():Z)})}),Ut(["pop","push","shift","sort","splice","unshift"],function(s){var a=fo[s],f=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",p=/^(?:pop|shift)$/.test(s);b.prototype[s]=function(){var g=arguments;if(p&&!this.__chain__){var S=this.value();return a.apply(ne(S)?S:[],g)}return this[f](function(w){return a.apply(ne(w)?w:[],g)})}}),mn(pe.prototype,function(s,a){var f=b[a];if(f){var p=f.name+"";xe.call(Si,p)||(Si[p]=[]),Si[p].push({name:a,func:f})}}),Si[Io(t,_).name]=[{name:"wrapper",func:t}],pe.prototype.clone=o1,pe.prototype.reverse=l1,pe.prototype.value=a1,b.prototype.at=Bv,b.prototype.chain=Fv,b.prototype.commit=zv,b.prototype.next=Hv,b.prototype.plant=Uv,b.prototype.reverse=Wv,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Vv,b.prototype.first=b.prototype.head,us&&(b.prototype[us]=$v),b},yi=zy();Rr?((Rr.exports=yi)._=yi,Ea._=yi):Xe._=yi}).call(ks)})(ul,ul.exports);var Ms=ul.exports;const Kk={emits:["move","cell"],props:{context:{type:Object,default:()=>({})},item:{type:Object,default:()=>({})},columns:Array,cell:{type:Object,default(){return{row:0}}},cellTag:{type:String,default:"td"},orderable:{type:Boolean,default:!1}},computed:{row(){return this.cell&&this.cell.row||0},itemData(){return this.item instanceof ii?this.item.data:this.item},cells(){const n=Zw(this.cell)&&ek(this.cell)||this.cell||{},e=[];for(var t in this.columns)e.push({...n,col:Number(t)});return e}},methods:{cellEmit(n,e,t){this.$emit("cell",{name:n,cell:e,data:t,item:this.item})},onDragStart(n){const t=`cell:${n.target.dataset.col}`;n.dataTransfer.setData("text/cell",t),n.dataTransfer.dropEffect="move"},onDragOver(n){n.preventDefault(),n.dataTransfer.dropEffect="move"},onDrop(n){const e=n.dataTransfer.getData("text/cell");!e||!e.startsWith("cell:")||(n.preventDefault(),this.$emit("move",{from:Number(e.slice(5)),to:Number(n.target.dataset.col)}))},getCellEl(n){const e=this.$el.querySelectorAll(this.cellTag);for(var t of e)if(n==Number(t.dataset.col))return t;return null},focus(n,e){e&&(n+=e.col);const t=this.getCellEl(n);if(!t)return;const r=t.querySelector('input:not([type="hidden"])')||t.querySelector("button")||t.querySelector("select")||t.querySelector("a");r&&r.focus()}},mounted(){this.$el.__row=this}};function Jk(n,e,t,r,i,o){return Y(),te("tr",null,[ye(n.$slots,"head",{context:t.context,item:t.item,row:o.row}),(Y(!0),te(Pt,null,Mt(t.columns,(l,u)=>(Y(),te(Pt,{key:u},[ye(n.$slots,"cell-before",{context:t.context,item:t.item,cell:o.cells[u],attr:l}),(Y(),Gr(tk(t.cellTag),{class:si(["cell","cell-"+l]),"data-col":u,draggable:t.orderable,onDragstart:o.onDragStart,onDragover:o.onDragOver,onDrop:o.onDrop},{default:Ee(()=>[ye(n.$slots,l,{context:t.context,item:t.item,cell:o.cells[u],data:o.itemData,attr:l,emit:o.cellEmit,value:o.itemData&&o.itemData[l]},()=>[$i(Be(o.itemData&&o.itemData[l]),1)]),ye(n.$slots,"cell",{context:t.context,item:t.item,cell:o.cells[u],data:o.itemData,attr:l,emit:o.cellEmit,value:o.itemData&&o.itemData[l]})]),_:2},1064,["class","data-col","draggable","onDragstart","onDragover","onDrop"])),ye(n.$slots,"cell-after",{context:t.context,item:t.item,col:u,cell:o.cells[u],attr:l})],64))),128)),ye(n.$slots,"tail",{context:t.context,item:t.item,row:o.row})])}const Am=hn(Kk,[["render",Jk]]),$c={extends:Vh,components:{ARow:Am},emits:["cell","colmove"],props:{...Vh.props,context:{type:Object,default:()=>({})},columns:Array,columnsOrderable:Boolean},data(){return{...super.data,columns_:[...this.columns],extraItem:new this.set.model}},computed:{columnNames(){return this.columns_.map(n=>n.name)},columnLabels(){return this.columns_.reduce((n,e)=>({...n,[e.name]:e.label}),{})},rowSlots(){return Object.keys(this.$slots).filter(n=>n.startsWith("row-")).map(n=>[n,n.slice(4)])}},methods:{sortColumns(n){const e=n.map(r=>this.columns_.find(i=>i.name==r)).filter(r=>!!r),t=this.columns_.filter(r=>n.indexOf(r.name)==-1);this.columns_=[...e,...t],this.$emit("colmove")},moveColumn(n){const{from:e,to:t}=n,r=this.columns_[e];this.columns_.splice(e,1),this.columns_.splice(t,0,r),this.$emit("colmove",n)},onCellEvent(n,e){e.name=="focus"&&this.focus(e.data,e.cell),this.$emit("cell",{...e,row:n,set:this.set})},getRow(n){const e=this.$el.querySelectorAll("tr");for(var t of e)if(t.__row&&n==Number(t.dataset.row))return t.__row},focus(n,e,t=null){t&&(n+=t.row),n=this.getRow(n),n&&n.focus(e,t)}}};$c.props.itemTag.default="tr";$c.props.listTag.default="tbody";const jk=$c,Gk={class:"table is-stripped is-fullwidth"},Yk=["title"],Xk=I("i",{class:"fa fa-circle-question"},null,-1),Qk=[Xk];function Zk(n,e,t,r,i,o){const l=Ft("a-row");return Y(),te("table",Gk,[I("thead",null,[Sr(l,{context:n.context,columns:n.columnNames,orderable:n.columnsOrderable,cellTag:"th",onMove:n.moveColumn},Fs({_:2},[n.$slots["header-head"]?{name:"head",fn:Ee(u=>[ye(n.$slots,"header-head",Kn(Pi(u)))]),key:"0"}:void 0,n.$slots["header-tail"]?{name:"tail",fn:Ee(u=>[ye(n.$slots,"header-tail",Kn(Pi(u)))]),key:"1"}:void 0,Mt(n.columns,u=>({name:u.name,fn:Ee(c=>[ye(n.$slots,"header-"+u.name,Kn(Pi(c)),()=>[$i(Be(u.label)+" ",1),u.help?(Y(),te("span",{key:0,class:"icon small",title:u.help},Qk,8,Yk)):qe("",!0)])])}))]),1032,["context","columns","orderable","onMove"])]),I("tbody",null,[ye(n.$slots,"head"),(Y(!0),te(Pt,null,Mt(n.items,(u,c)=>(Y(),Gr(l,{key:c,context:n.context,item:u,cell:{row:c},columns:n.columnNames,"data-index":c,"data-row":c,draggable:n.orderable,onDragstart:n.onDragStart,onDragover:n.onDragOver,onDrop:n.onDrop,onCell:d=>n.onCellEvent(c,d)},Fs({_:2},[Mt(n.rowSlots,([d,h])=>({name:h,fn:Ee(m=>[ye(n.$slots,d,Yr({ref_for:!0},m))])}))]),1032,["context","item","cell","columns","data-index","data-row","draggable","onDragstart","onDragover","onDrop","onCell"]))),128)),ye(n.$slots,"tail")])])}const eC=hn(jk,[["render",Zk]]),tC={emit:["cell","move","colmove","load"],components:{ARows:eC},props:{labels:Object,actionAdd:Function,columnsOrderable:Boolean,orderBy:String,formData:Object,model:{type:Function,default:ii}},data(){return{set:new km(ii)}},computed:{_prefix(){return this.formData.prefix?this.formData.prefix+"-":""},fields(){return this.formData.fields},orderField(){return this.orderBy&&this.fields.find(n=>n.name==this.orderBy)},orderable(){return!!this.orderField},hiddenFields(){return this.fields.filter(n=>n.hidden&&!(this.orderable&&n==this.orderField))},visibleFields(){return this.fields.filter(n=>!n.hidden)},fieldSlots(){return this.visibleFields.reduce((n,e)=>({...n,["row-"+e.name]:e}),{})},items(){return this.set.items},rows(){return this.$refs.rows}},methods:{onCellEvent(n){this.$emit("cell",n)},onColumnMove(n){this.$emit("colmove",n)},onActionAdd(){if(this.actionAdd)return this.actionAdd(this);this.set.push()},moveItem(n){const{from:e,to:t}=n,r=n.set||this.set;r.move(e,t),this.$emit("move",{...n,seŧ:r})},removeItem(n){this.items[n].id||this.items.splice(n,1)},load(n=[],e=!1){e&&(this.set.items=[]);for(var t of n)this.set.push(Ms.cloneDeep(t));this.$emit("load",n)},reset(){var n;this.load(((n=this.formData)==null?void 0:n.initials)||[],!0)}},mounted(){this.reset()}},nC=["name","value"],rC=["name","value"],iC=["title","aria-label","aria-description"],sC=I("span",{class:"icon"},[I("i",{class:"fa fa-arrow-down-1-9"})],-1),oC=[sC],lC=["name","value"],aC=["name","value"],uC=["name","value"],cC={key:0},fC={class:"field"},dC={class:"control"},hC={class:"align-right pr-0"},pC=["onClick","title","aria-label"],mC=I("span",{class:"icon"},[I("i",{class:"fa fa-trash"})],-1),gC=[mC],yC={class:"a-formset-footer flex-row"},bC={class:"flex-grow-1 flex-row"},vC={class:"flex-grow-1 align-right"},SC=["title","aria-label"],xC=I("span",{class:"icon"},[I("i",{class:"fa fa-rotate"})],-1),wC=[xC],kC=["title","aria-label"],CC=I("span",{class:"icon"},[I("i",{class:"fa fa-plus"})],-1),TC=[CC];function MC(n,e,t,r,i,o){const l=Ft("a-rows");return Y(),te("div",null,[I("input",{type:"hidden",name:o._prefix+"TOTAL_FORMS",value:o.items.length||0},null,8,nC),(Y(!0),te(Pt,null,Mt(t.formData.management,(u,c)=>(Y(),te("input",{key:c,type:"hidden",name:o._prefix+c.toUpperCase(),value:u},null,8,rC))),128)),Sr(l,{ref:"rows",set:i.set,context:this,columns:o.visibleFields,columnsOrderable:t.columnsOrderable,orderable:o.orderable,onMove:o.moveItem,onColmove:o.onColumnMove,onCell:e[0]||(e[0]=u=>n.$emit("cell",u))},Fs({"header-head":Ee(()=>[o.orderable?(Y(),te(Pt,{key:0},[I("th",{style:{"max-width":"2em"},title:o.orderField.label,"aria-label":o.orderField.label,"aria-description":o.orderField.help||""},oC,8,iC),ye(n.$slots,"rows-header-head")],64)):qe("",!0)]),"row-head":Ee(u=>[o.orderable?(Y(),te("input",{key:0,type:"hidden",name:o._prefix+u.row+"-"+t.orderBy,value:u.row},null,8,lC)):qe("",!0),I("input",{type:"hidden",name:o._prefix+u.row+"-id",value:u.item?u.item.id:""},null,8,aC),(Y(!0),te(Pt,null,Mt(o.hiddenFields,c=>(Y(),te(Pt,{key:c.name},[c.name in["id",t.orderBy]?qe("",!0):(Y(),te("input",{key:0,type:"hidden",name:o._prefix+u.row+"-"+c.name,value:c.value in[null,void 0]?u.item.data[n.name]:c.value},null,8,uC))],64))),128)),ye(n.$slots,"row-head",Kn(Pi(u)),()=>[o.orderable?(Y(),te("td",cC,Be(u.row+1),1)):qe("",!0)])]),"row-tail":Ee(u=>[n.$slots["row-tail"]?ye(n.$slots,"row-tail",Kn(Yr({key:0},u))):qe("",!0),I("td",hC,[I("button",{type:"button",class:"button square",onClick:nk(c=>o.removeItem(u.row,u.item),["stop"]),title:t.labels.remove_item,"aria-label":t.labels.remove_item},gC,8,pC)])]),_:2},[Mt(o.fieldSlots,(u,c)=>({name:c,fn:Ee(d=>[ye(n.$slots,c,Yr(d,{field:u,inputName:o._prefix+d.cell.row+"-"+u.name}),()=>[I("div",fC,[I("div",dC,[ye(n.$slots,"control-"+u.name,Yr(d,{field:u,inputName:o._prefix+d.cell.row+"-"+u.name}))]),(Y(!0),te(Pt,null,Mt(d.item.error(u.name),([h,m])=>(Y(),te("p",{class:"help is-danger",key:m},Be(h),1))),128))])])])}))]),1032,["set","columns","columnsOrderable","orderable","onMove","onColmove"]),I("div",yC,[I("div",bC,[ye(n.$slots,"footer")]),I("div",vC,[I("button",{type:"button",class:"button square is-warning p-2",onClick:e[1]||(e[1]=u=>o.reset()),title:t.labels.discard_changes,"aria-label":t.labels.discard_changes},wC,8,SC),I("button",{type:"button",class:"button square is-primary p-2",onClick:e[2]||(e[2]=(...u)=>o.onActionAdd&&o.onActionAdd(...u)),title:t.labels.add_item,"aria-label":t.labels.add_item},TC,8,kC)])])])}const Uc=hn(tC,[["render",MC]]),Cs={Text:0,List:1,Settings:2},EC={components:{AActionButton:Sm,AFormSet:Uc,ARow:Am,AModal:xm},props:{formData:Object,labels:Object,initData:Object,dataPrefix:String,settingsUrl:String,defaultColumns:{type:Array,default:()=>["artist","title","tags","album","year","timestamp"]}},data(){const n={tracklist_editor_sep:" -- "};return{Page:Cs,page:Cs.Text,extraData:{},settings:n,savedSettings:Ms.cloneDeep(n)}},computed:{rows(){return this.$refs.formset&&this.$refs.formset.rows},columns(){return this.rows&&this.rows.columns_||[]},settingsChanged(){var n=Object.keys(this.savedSettings).findIndex(e=>!Ms.isEqual(this.settings[e],this.savedSettings[e]));return n!=-1},separator:{set(n){this.settings.tracklist_editor_sep=n,this.page==Cs.List&&this.updateInput()},get(){return this.settings.tracklist_editor_sep}},rowsSlots(){return Object.keys(this.$slots).filter(n=>n.startsWith("row-")||n.startsWith("rows-")||n.startsWith("control-")).map(n=>[n,n.startsWith("rows-")?n.slice(5):n])}},methods:{onCellEvent(n){switch(n.name){case"change":this.updateInput();break}},onColumnMove(){this.settings.tracklist_editor_columns=this.$refs.formset.rows.columnNames,this.page==this.Page.List?this.updateInput():this.updateList()},updateList(){const n=this.toList(this.$refs.textarea.value);this.$refs.formset.set.reset(n)},updateInput(){const n=this.toText(this.$refs.formset.items);this.$refs.textarea.value=n},toList(n){const e=this.$refs.formset.rows.columns_;var t=n.split(`
+`),r=[];for(let u of t)if(u=u.trimLeft(),!!u){var i=u.split(this.separator),o={};for(var l in e){if(l>=i.length)break;const c=e[l];o[c.name]=i[l].trim()}o&&r.push(o)}return r},toText(n){const e=this.$refs.formset.rows.columns_,t=` ${this.separator.trim()} `,r=[];for(let l of n)if(l){var i=[];for(var o of e)i.push(l.data[o.name]||"");i=Ms.dropRightWhile(i,u=>!u||!(""+u).trim()),i=i.join(t).trimRight(),r.push(i)}return r.join(`
+`)},_data_key(n){n=n.slice(this.dataPrefix.length);try{var[e,t]=n.split("-",1);return[Number(e),t]}catch{return[null,n]}},settingsSaved(n=null){n!==null&&(this.settings=n),this.$refs.settings&&this.$refs.settings.close(),this.savedSettings=Ms.cloneDeep(this.settings)}},mounted(){const n=this.initData&&this.initData.settings;n&&(this.settingsSaved(n),this.rows.sortColumns(n.tracklist_editor_columns)),this.page=this.initData.items.length?Cs.List:Cs.Text}},AC={class:"a-tracklist-editor"},OC={class:"flex-row"},_C={class:"flex-grow-1"},NC={class:"flex-row align-right"},DC={class:"field has-addons"},IC={class:"control"},RC=I("span",{class:"icon is-small"},[I("i",{class:"fa fa-pencil"})],-1),LC={class:"control"},PC=I("span",{class:"icon is-small"},[I("i",{class:"fa fa-list"})],-1),BC={class:"control ml-3"},FC=["title"],zC=I("span",{class:"icon is-small"},[I("i",{class:"fa fa-cog"})],-1),HC=[zC],$C={class:"panel"},UC={class:"panel"},WC={class:"field"},VC={class:"label",style:{"vertical-align":"middle"}},qC={class:"table is-bordered",style:{"vertical-align":"middle"}},KC={key:0},JC={key:0,style:{cursor:"pointer"}},jC=["onClick"],GC=I("i",{class:"fa fa-left-right"},null,-1),YC=[GC],XC={class:"flex-row"},QC={class:"field is-inline-block is-vcentered flex-grow-1"},ZC=I("label",{class:"label is-inline mr-2",style:{"vertical-align":"middle"}}," Séparateur",-1),eT={class:"control is-inline-block",style:{"vertical-align":"middle"}},tT={class:"flex-row align-right"};function nT(n,e,t,r,i,o){const l=Ft("a-form-set"),u=Ft("a-row"),c=Ft("a-action-button"),d=Ft("a-modal");return Y(),te("div",AC,[I("div",OC,[I("div",_C,[ye(n.$slots,"title")]),I("div",NC,[I("div",DC,[I("p",IC,[I("button",{type:"button",class:si(["button","p-2",i.page==i.Page.Text?"is-primary":"is-light"]),onClick:e[0]||(e[0]=h=>i.page=i.Page.Text)},[RC,I("span",null,Be(t.labels.text),1)],2)]),I("p",LC,[I("button",{type:"button",class:si(["button","p-2",i.page==i.Page.List?"is-primary":"is-light"]),onClick:e[1]||(e[1]=h=>i.page=i.Page.List)},[PC,I("span",null,Be(t.labels.list),1)],2)]),I("p",BC,[I("button",{type:"button",class:"button is-info square",title:t.labels.settings,onClick:e[2]||(e[2]=h=>n.$refs.settings.open())},HC,8,FC)])])])]),Iu(I("section",$C,[I("textarea",{ref:"textarea",class:"is-fullwidth is-size-6",rows:"20",onChange:e[3]||(e[3]=(...h)=>o.updateList&&o.updateList(...h))},null,544)],512),[[qh,i.page==i.Page.Text]]),Iu(I("section",UC,[Sr(l,{ref:"formset","form-data":t.formData,initials:t.initData.items,columnsOrderable:!0,labels:t.labels,"order-by":"position",onLoad:o.updateInput,onColmove:o.onColumnMove,onMove:o.updateInput,onCell:o.onCellEvent},Fs({_:2},[Mt(o.rowsSlots,([h,m])=>({name:m,fn:Ee(y=>[h!="row-tail"?ye(n.$slots,h,Kn(Yr({key:0},y))):qe("",!0)])}))]),1032,["form-data","initials","labels","onLoad","onColmove","onMove","onCell"])],512),[[qh,i.page==i.Page.List]]),Sr(d,{ref:"settings",title:t.labels.settings},{default:Ee(()=>[I("div",WC,[I("label",VC,Be(t.labels.columns),1),I("table",qC,[n.$refs.formset?(Y(),te("tr",KC,[Sr(u,{columns:n.$refs.formset.rows.columnNames,item:n.$refs.formset.rows.columnLabels,onMove:n.$refs.formset.rows.moveColumn},{"cell-after":Ee(({cell:h})=>[h.coln.$refs.formset.rows.moveColumn({from:h.col,to:h.col+1})},YC,8,jC)])):qe("",!0)]),_:1},8,["columns","item","onMove"])])):qe("",!0)])]),I("div",XC,[I("div",QC,[ZC,I("div",eT,[Iu(I("input",{type:"text",ref:"sep",class:"input is-inline is-text-centered is-small",style:{"max-width":"5em"},"onUpdate:modelValue":e[4]||(e[4]=h=>o.separator=h),onChange:e[5]||(e[5]=h=>o.updateList())},null,544),[[rk,o.separator]])])])])]),footer:Ee(()=>[I("div",tT,[o.settingsChanged?(Y(),Gr(c,{key:0,icon:"fa fa-floppy-disk",class:"button control p-2 mr-3 is-secondary","run-class":"blink",url:t.settingsUrl,method:"POST",data:i.settings,"aria-label":t.labels.save_settings,onDone:e[6]||(e[6]=h=>o.settingsSaved())},{default:Ee(()=>[$i(Be(t.labels.save_settings),1)]),_:1},8,["url","data","aria-label"])):qe("",!0),I("button",{class:"button",type:"button",onClick:e[7]||(e[7]=h=>n.$refs.settings.close())}," Fermer ")])]),_:1},8,["title"])])}const rT=hn(EC,[["render",nT]]),iT={components:{AFormSet:Uc,ASelectFile:Mm},props:{formData:Object,labels:Object,initData:Object,soundListUrl:String,soundUploadUrl:String,soundDeleteUrl:String},computed:{rowsSlots(){return Object.keys(this.$slots).filter(n=>n.startsWith("row-")||n.startsWith("rows-")||n.startsWith("control-")).map(n=>[n,n.startsWith("rows-")?n.slice(5):n])}},methods:{actionAdd(){this.$refs["select-file"].open()},selected(n){const e={sound:n.id,name:n.name,url:n.url,broadcast:n.broadcast};this.$refs.formset.set.push(e)}}},sT={class:"a-playlist-editor"},oT=["src"],lT={class:"label small flex-grow-1"},aT=I("br",null,null,-1),uT=["src"],cT=["name","value"];function fT(n,e,t,r,i,o){const l=Ft("a-select-file"),u=Ft("a-form-set");return Y(),te("div",sT,[Sr(l,{ref:"select-file",title:t.labels&&t.labels.add_sound,labels:t.labels,"list-url":t.soundListUrl,deleteUrl:t.soundDeleteUrl,uploadUrl:t.soundUploadUrl,uploadLabel:t.labels.select_file,onSelect:o.selected},{"upload-preview":Ee(({upload:c})=>[ye(n.$slots,"upload-preview",{upload:c})]),"upload-form":Ee(()=>[ye(n.$slots,"upload-form")]),default:Ee(({item:c})=>[I("audio",{controls:"",src:c.url},null,8,oT),I("label",lT,Be(c.name),1)]),_:3},8,["title","labels","list-url","deleteUrl","uploadUrl","uploadLabel","onSelect"]),Sr(u,{ref:"formset","form-data":t.formData,labels:t.labels,initials:t.initData.items,"order-by":"position","action-add":o.actionAdd},Fs({"row-sound":Ee(({item:c,inputName:d})=>[I("label",null,Be(c.data.name),1),aT,I("audio",{controls:"",src:c.data.url},null,8,uT),I("input",{type:"hidden",name:d,value:c.data.sound},null,8,cT)]),_:2},[Mt(o.rowsSlots,([c,d])=>({name:d,fn:Ee(h=>[c!="row-tail"?ye(n.$slots,c,Kn(Yr({key:0},h))):qe("",!0)])}))]),1032,["form-data","labels","initials","action-add"])])}const dT=hn(iT,[["render",fT]]);function Ze(n){this.content=n}Ze.prototype={constructor:Ze,find:function(n){for(var e=0;e>1}};Ze.from=function(n){if(n instanceof Ze)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ze(e)};function Om(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let l=0;i.text[l]==o.text[l];l++)t++;return t}if(i.content.size||o.content.size){let l=Om(i.content,o.content,t+1);if(l!=null)return l}t+=i.nodeSize}}function _m(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let l=n.child(--i),u=e.child(--o),c=l.nodeSize;if(l==u){t-=c,r-=c;continue}if(!l.sameMarkup(u))return{a:t,b:r};if(l.isText&&l.text!=u.text){let d=0,h=Math.min(l.text.length,u.text.length);for(;de&&r(c,i+u,o||null,l)!==!1&&c.content.size){let h=u+1;c.nodesBetween(Math.max(0,e-h),Math.min(c.content.size,t-h),r,i+h)}u=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",l=!0;return this.nodesBetween(e,t,(u,c)=>{let d=u.isText?u.text.slice(Math.max(e,c)-c,t-c):u.isLeaf?i?typeof i=="function"?i(u):i:u.type.spec.leafText?u.type.spec.leafText(u):"":"";u.isBlock&&(u.isLeaf&&d||u.isTextblock)&&r&&(l?l=!1:o+=r),o+=d},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,l=0;le&&((lt)&&(u.isText?u=u.cut(Math.max(0,e-l),Math.min(u.text.length,t-l)):u=u.cut(Math.max(0,e-l-1),Math.min(u.content.size,t-l-1))),r.push(u),i+=u.nodeSize),l=c}return new B(r,i)}cutByIndex(e,t){return e==t?B.empty:e==0&&t==this.content.length?this:new B(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new B(i,o)}addToStart(e){return new B([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new B(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),l=i+o.nodeSize;if(l>=e)return l==e||t>0?jo(r+1,l):jo(r,i);i=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return B.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new B(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return B.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};we.none=[];class fl extends Error{}class U{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Dm(this.content,e+this.openStart,t);return r&&new U(r,this.openStart,this.openEnd)}removeBetween(e,t){return new U(Nm(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return U.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new U(B.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new U(e,r,i)}}U.empty=new U(B.empty,0,0);function Nm(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:l,offset:u}=n.findIndex(t);if(i==e||o.isText){if(u!=t&&!n.child(l).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=l)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Nm(o.content,e-i-1,t-i-1)))}function Dm(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),l=n.maybeChild(i);if(o==e||l.isText)return n.cut(0,e).append(t).append(n.cut(e));let u=Dm(l.content,e-o-1,t);return u&&n.replaceChild(i,l.copy(u))}function hT(n,e,t){if(t.openStart>n.depth)throw new fl("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new fl("Inconsistent open depths");return Im(n,e,t,0)}function Im(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function _s(n,e,t,r){let i=(e||n).node(t),o=0,l=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Qr(n.nodeAfter,r),o++));for(let u=o;ui&&fc(n,e,i+1),l=r.depth>i&&fc(t,r,i+1),u=[];return _s(null,n,i,u),o&&l&&e.index(i)==t.index(i)?(Rm(o,l),Qr(Zr(o,Lm(n,e,t,r,i+1)),u)):(o&&Qr(Zr(o,dl(n,e,i+1)),u),_s(e,t,i,u),l&&Qr(Zr(l,dl(t,r,i+1)),u)),_s(r,null,i,u),new B(u)}function dl(n,e,t){let r=[];if(_s(null,n,t,r),n.depth>t){let i=fc(n,e,t+1);Qr(Zr(i,dl(n,e,t+1)),r)}return _s(e,null,t,r),new B(r)}function pT(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(B.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class zs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new hl(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let l=e;;){let{index:u,offset:c}=l.content.findIndex(o),d=o-c;if(r.push(l,u,i+c),!d||(l=l.child(u),l.isText))break;o=d-1,i+=c+1}return new zs(t,r,o)}static resolveCached(e,t){for(let i=0;ie&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Pm(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=B.empty,i=0,o=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,o),u=l&&l.matchFragment(this.content,t);if(!u||!u.validEnd)return!1;for(let c=i;ct.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=B.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};ei.prototype.text=void 0;class pl extends ei{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Pm(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new pl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pl(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Pm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class oi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new yT(e,t);if(r.next==null)return oi.empty;let i=Bm(r);r.next&&r.err("Unexpected trailing text");let o=CT(kT(i));return TT(o,r),o}matchType(e){for(let t=0;td.createAndFill()));for(let d=0;d=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let l=0;l"+e.indexOf(r.next[l].next);return o}).join(`
+`)}}oi.empty=new oi(!0);class yT{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Bm(n){let e=[];do e.push(bT(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function bT(n){let e=[];do e.push(vT(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function vT(n){let e=wT(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ST(n,e);else break;return e}function Kh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ST(n,e){let t=Kh(n),r=t;return n.eat(",")&&(n.next!="}"?r=Kh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function xT(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let l=t[o];l.groups.indexOf(e)>-1&&i.push(l)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function wT(n){if(n.eat("(")){let e=Bm(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=xT(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function kT(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(l,u,c){let d={term:c,to:u};return e[l].push(d),d}function i(l,u){l.forEach(c=>c.to=u)}function o(l,u){if(l.type=="choice")return l.exprs.reduce((c,d)=>c.concat(o(d,u)),[]);if(l.type=="seq")for(let c=0;;c++){let d=o(l.exprs[c],u);if(c==l.exprs.length-1)return d;i(d,u=t())}else if(l.type=="star"){let c=t();return r(u,c),i(o(l.expr,c),c),[r(c)]}else if(l.type=="plus"){let c=t();return i(o(l.expr,u),c),i(o(l.expr,c),c),[r(c)]}else{if(l.type=="opt")return[r(u)].concat(o(l.expr,u));if(l.type=="range"){let c=u;for(let d=0;d{n[l].forEach(({term:u,to:c})=>{if(!u)return;let d;for(let h=0;h{d||i.push([u,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let o=e[r.join(",")]=new oi(r.indexOf(n.length-1)>-1);for(let l=0;l-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new Um(o,t,l));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class MT{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class ta{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=$m(i.attrs),this.excluded=null;let o=zm(this.attrs);this.instance=o?new we(this,o):null}create(e=null){return!e&&this.instance?this.instance:new we(this,Hm(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,l)=>r[o]=new ta(o,i++,t,l)),r}removeFromSet(e){for(var t=0;t-1}}class ET{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Ze.from(e.nodes),t.marks=Ze.from(e.marks||{}),this.nodes=jh.compile(this.spec.nodes,this),this.marks=ta.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],l=o.spec.content||"",u=o.spec.marks;if(o.contentMatch=r[l]||(r[l]=oi.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=u=="_"?null:u?Gh(this,u.split(" ")):u==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:Gh(this,l.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof jh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new pl(r,r.defaultAttrs,e,we.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ei.fromJSON(this,e)}markFromJSON(e){return we.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Gh(n,e){let t=[];for(let r=0;r-1)&&t.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function AT(n){return n.tag!=null}function OT(n){return n.style!=null}class Ui{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{AT(r)?this.tags.push(r):OT(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Xh(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Xh(this,t,!0);return r.addAll(e,t.from,t.to),U.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(u.charCodeAt(e.length)!=61||u.slice(e.length+1)!=t))){if(l.getAttrs){let c=l.getAttrs(t);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,l=0;for(;l{r(l=Qh(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(l=>{r(l=Qh(l)),l.node||l.ignore||l.mark||(l.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ui(e,Ui.schemaRules(e)))}}const Wm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},_T={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Vm={ol:!0,ul:!0},ml=1,gl=2,Ns=4;function Yh(n,e,t){return e!=null?(e?ml:0)|(e==="full"?gl:0):n&&n.whitespace=="pre"?ml|gl:t&~Ns}class Go{constructor(e,t,r,i,o,l,u){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=u,this.content=[],this.activeMarks=we.none,this.stashMarks=[],this.match=l||(u&Ns?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(B.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ml)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=B.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(B.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;tthis.addAll(e)),l&&this.sync(u),this.needsBlock=c}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,o.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
+`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=we.none,r=we.none;for(let i=0;i{l.clearMark(u)&&(r=u.addToSet(r))}):t=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(t),l.consuming===!1)o=l;else break}return[t,r]}addElementByRule(e,t,r){let i,o,l;t.node?(o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):i=this.enter(o,t.attrs||null,t.preserveWhitespace)):(l=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(l));let u=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c)}i&&this.sync(u)&&this.open--,l&&this.removePendingMark(l,u)}addAll(e,t,r){let i=t||0;for(let o=t?e.childNodes[t]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],l=o.findWrapping(e);if(l&&(!t||t.length>l.length)&&(t=l,r=o,!l.length)||o.solid)break}if(!t)return!1;this.sync(r);for(let i=0;ithis.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),l=(u,c)=>{for(;u>=0;u--){let d=t[u];if(d==""){if(u==t.length-1||u==0)continue;for(;c>=o;c--)if(l(u-1,c))return!0;return!1}else{let h=c>0||c==0&&i?this.nodes[c].type:r&&c>=o?r.node(c-o).type:null;if(!h||h.name!=d&&h.groups.indexOf(d)==-1)return!1;c--}}return!0};return l(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=LT(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let l=i.popFromStashMark(e);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==t)break}}}function NT(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Vm.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function DT(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function IT(n){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,r=[];for(;t=e.exec(n);)r.push(t[1],t[2].trim());return r}function Qh(n){let e={};for(let t in n)e[t]=n[t];return e}function RT(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],l=u=>{o.push(u);for(let c=0;c{if(o.length||l.marks.length){let u=0,c=0;for(;u=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Cn.renderSpec(Bu(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let l,u=r?e.createElementNS(r,i):e.createElement(i),c=t[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let h in c)if(c[h]!=null){let m=h.indexOf(" ");m>0?u.setAttributeNS(h.slice(0,m),h.slice(m+1),c[h]):u.setAttribute(h,c[h])}}for(let h=d;hd)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:v}=Cn.renderSpec(e,m,r);if(u.appendChild(y),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:u,contentDOM:l}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Cn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Zh(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Zh(e.marks)}}function Zh(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Bu(n){return n.document||window.document}const qm=65535,Km=Math.pow(2,16);function PT(n,e){return n+e*Km}function ep(n){return n&qm}function BT(n){return(n-(n&qm))/Km}const Jm=1,jm=2,il=4,Gm=8;class hc{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Gm)>0}get deletedBefore(){return(this.delInfo&(Jm|il))>0}get deletedAfter(){return(this.delInfo&(jm|il))>0}get deletedAcross(){return(this.delInfo&il)>0}}class Bt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Bt.empty)return Bt.empty}recover(e){let t=0,r=ep(e);if(!this.inverted)for(let i=0;ie)break;let d=this.ranges[u+o],h=this.ranges[u+l],m=c+d;if(e<=m){let y=d?e==c?-1:e==m?1:t:t,v=c+i+(y<0?0:h);if(r)return v;let x=e==(t<0?c:m)?null:PT(u/3,e-c),T=e==c?jm:e==m?Jm:il;return(t<0?e!=c:e!=m)&&(T|=Gm),new hc(v,T,x)}i+=h-d}return r?e+i:new hc(e+i,0,null)}touches(e,t){let r=0,i=ep(t),o=this.inverted?2:1,l=this.inverted?1:2;for(let u=0;ue)break;let d=this.ranges[u+o],h=c+d;if(e<=h&&u==i*3)return!0;r+=this.ranges[u+l]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Bi;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&c!l.isAtom||!u.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),t.openStart,t.openEnd);return Fe.fromReplace(e,this.from,this.to,o)}invert(){return new Tn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yr(t.pos,r.pos,this.mark)}merge(e){return e instanceof yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yr(t.from,t.to,e.markFromJSON(t.mark))}}lt.jsonID("addMark",yr);class Tn extends lt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new U(Wc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Fe.fromReplace(e,this.from,this.to,r)}invert(){return new yr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Tn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Tn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Tn(t.from,t.to,e.markFromJSON(t.mark))}}lt.jsonID("removeMark",Tn);class br extends lt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Fe.fromReplace(e,this.pos,this.pos+1,new U(B.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Ke(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ke(t.from,t.to,t.gapFrom,t.gapTo,U.fromJSON(e,t.slice),t.insert,!!t.structure)}}lt.jsonID("replaceAround",Ke);function pc(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function FT(n,e,t,r){let i=[],o=[],l,u;n.doc.nodesBetween(e,t,(c,d,h)=>{if(!c.isInline)return;let m=c.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),v=Math.min(d+c.nodeSize,t),x=r.addToSet(m);for(let T=0;Tn.step(c)),o.forEach(c=>n.step(c))}function zT(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(l,u)=>{if(!l.isInline)return;o++;let c=null;if(r instanceof ta){let d=l.marks,h;for(;h=r.isInSet(d);)(c||(c=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(l.marks)&&(c=[r]):c=l.marks;if(c&&c.length){let d=Math.min(u+l.nodeSize,t);for(let h=0;hn.step(new Tn(l.from,l.to,l.style)))}function Ym(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),l=[],u=e+1;for(let c=0;c=0;c--)n.step(l[c])}function HT(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Gi(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),l=n.$to.indexAfter(r);if(rt;x--)T||r.index(x)>0?(T=!0,h=B.from(r.node(x).copy(h)),m++):c--;let y=B.empty,v=0;for(let x=o,T=!1;x>t;x--)T||i.after(x+1)=0;l--){if(r.size){let u=t[l].type.contentMatch.matchFragment(r);if(!u||!u.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=B.from(t[l].type.create(t[l].attrs,r))}let i=e.start,o=e.end;n.step(new Ke(i,o,i,o,new U(r,0,0),t.length,!0))}function qT(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(l,u)=>{if(l.isTextblock&&!l.hasMarkup(r,i)&&jT(n.doc,n.mapping.slice(o).map(u),r)){let c=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!v?c=!1:!y&&v&&(c=!0)}c===!1&&JT(n,l,u,o),Ym(n,n.mapping.slice(o).map(u,1),r,void 0,c===null);let d=n.mapping.slice(o),h=d.map(u,1),m=d.map(u+l.nodeSize,1);return n.step(new Ke(h,m,h+1,m-1,new U(B.from(r.create(i,null,l.marks)),0,0),1,!0)),c===!0&&KT(n,l,u,o),!1}})}function KT(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let l,u=/\r?\n|\r/g;for(;l=u.exec(i.text);){let c=n.mapping.slice(r).map(t+1+o+l.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function JT(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let l=n.mapping.slice(r).map(t+1+o);n.replaceWith(l,l+1,e.type.schema.text(`
+`))}})}function jT(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function GT(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let l=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,l);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ke(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new U(B.from(l),0,0),1,!0))}function Fi(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,h=t-2;d>o;d--,h--){let m=i.node(d),y=i.index(d);if(m.type.spec.isolating)return!1;let v=m.content.cutByIndex(y,m.childCount),x=r&&r[h+1];x&&(v=v.replaceChild(0,x.type.create(x.attrs)));let T=r&&r[h]||m;if(!m.canReplace(y+1,m.childCount)||!T.type.validContent(v))return!1}let u=i.indexAfter(o),c=r&&r[0];return i.node(o).canReplaceWith(u,u,c?c.type:i.node(o+1).type)}function YT(n,e,t=1,r){let i=n.doc.resolve(e),o=B.empty,l=B.empty;for(let u=i.depth,c=i.depth-t,d=t-1;u>c;u--,d--){o=B.from(i.node(u).copy(o));let h=r&&r[d];l=B.from(h?h.type.create(h.attrs,l):i.node(u).copy(l))}n.step(new Ve(e,e,new U(o.append(l),t,t),!0))}function Tr(n,e){let t=n.resolve(e),r=t.index();return Xm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Xm(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function na(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let o,l,u=r.index(i);if(i==r.depth?(o=r.nodeBefore,l=r.nodeAfter):t>0?(o=r.node(i+1),u++,l=r.node(i).maybeChild(u)):(o=r.node(i).maybeChild(u-1),l=r.node(i+1)),o&&!o.isTextblock&&Xm(o,l)&&r.node(i).canReplace(u,u+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function XT(n,e,t){let r=new Ve(e-t,e+t,U.empty,!0);n.step(r)}function QT(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;l--){let u=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,c=r.index(l)+(u>0?1:0),d=r.node(l),h=!1;if(o==1)h=d.canReplace(c,c,i);else{let m=d.contentMatchAt(c).findWrapping(i.firstChild.type);h=m&&d.canReplaceWith(c,c,m[0])}if(h)return u==0?r.pos:u<0?r.before(l+1):r.after(l+1)}return null}function ra(n,e,t=e,r=U.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Zm(i,o,r)?new Ve(e,t,r):new ZT(i,o,r).fit()}function Zm(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ZT{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=B.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=B.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,l=r.depth,u=i.depth;for(;l&&u&&o.childCount==1;)o=o.firstChild.content,l--,u--;let c=new U(o,l,u);return e>-1?new Ke(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new Ve(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=zu(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let l=i.firstChild;for(let u=this.depth;u>=0;u--){let{type:c,match:d}=this.frontier[u],h,m=null;if(t==1&&(l?d.matchType(l.type)||(m=d.fillBefore(B.from(l),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:u,parent:o,inject:m};if(t==2&&l&&(h=d.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:u,parent:o,wrap:h};if(o&&d.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=zu(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new U(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=zu(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new U(Es(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new U(Es(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let T=0;T1||c==0||T.content.size)&&(m=E,h.push(eg(T.mark(y.allowedMarks(T.marks)),d==1?c:0,d==u.childCount?v:-1)))}let x=d==u.childCount;x||(v=-1),this.placed=As(this.placed,t,B.from(h)),this.frontier[t].match=m,x&&v<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let T=0,E=u;T1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;u--){let{match:c,type:d}=this.frontier[u],h=Hu(e,u,d,c,!0);if(!h||h.childCount)continue e}return{depth:t,fit:l,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=As(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=As(this.placed,this.depth,B.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(B.empty,!0);t.childCount&&(this.placed=As(this.placed,this.frontier.length,t))}}function Es(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Es(n.firstChild.content,e-1,t)))}function As(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(As(n.lastChild.content,e-1,t)))}function zu(n,e){for(let t=0;t1&&(r=r.replaceChild(0,eg(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(B.empty,!0)))),n.copy(r)}function Hu(n,e,t,r,i){let o=n.node(e),l=i?n.indexAfter(e):n.index(e);if(l==o.childCount&&!t.compatibleContent(o.type))return null;let u=r.fillBefore(o.content,!0,l);return u&&!eM(t,o.content,l)?u:null}function eM(n,e,t){for(let r=t;r0;y--,v--){let x=i.node(y).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;l.indexOf(y)>-1?u=y:i.before(y)==v&&l.splice(1,0,-y)}let c=l.indexOf(u),d=[],h=r.openStart;for(let y=r.content,v=0;;v++){let x=y.firstChild;if(d.push(x),v==r.openStart)break;y=x.content}for(let y=h-1;y>=0;y--){let v=d[y],x=tM(v.type);if(x&&!v.sameMarkup(i.node(Math.abs(u)-1)))h=y;else if(x||!v.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let v=(y+h+1)%(r.openStart+1),x=d[v];if(x)for(let T=0;T=0&&(n.replace(e,t,r),!(n.steps.length>m));y--){let v=l[y];v<0||(e=i.before(v),t=o.after(v))}}function tg(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),l=o.fillBefore(n).append(n);n=l.append(o.matchFragment(l).fillBefore(B.empty,!0))}return n}function rM(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=QT(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new U(B.from(r),0,0))}function iM(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=ng(r,i);for(let l=0;l0&&(c||r.node(u-1).canReplace(r.index(u-1),i.indexAfter(u-1))))return n.delete(r.before(u),i.after(u))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&t>r.end(l)&&i.end(l)-t!=i.depth-l)return n.delete(r.before(l),t);n.delete(e,t)}function ng(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class zi extends lt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Fe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Fe.fromReplace(e,this.pos,this.pos+1,new U(B.from(i),0,t.isLeaf?0:1))}getMap(){return Bt.empty}invert(e){return new zi(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new zi(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new zi(t.pos,t.attr,t.value)}}lt.jsonID("attr",zi);class Hs extends lt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Fe.ok(r)}getMap(){return Bt.empty}invert(e){return new Hs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Hs(t.attr,t.value)}}lt.jsonID("docAttr",Hs);let Vi=class extends Error{};Vi=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Vi.prototype=Object.create(Error.prototype);Vi.prototype.constructor=Vi;Vi.prototype.name="TransformError";class rg{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Bi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vi(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=U.empty){let i=ra(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new U(B.from(r),0,0))}delete(e,t){return this.replace(e,t,U.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return nM(this,e,t,r),this}replaceRangeWith(e,t,r){return rM(this,e,t,r),this}deleteRange(e,t){return iM(this,e,t),this}lift(e,t){return $T(this,e,t),this}join(e,t=1){return XT(this,e,t),this}wrap(e,t){return VT(this,e,t),this}setBlockType(e,t=e,r,i=null){return qT(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return GT(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new zi(e,t,r)),this}setDocAttribute(e,t){return this.step(new Hs(e,t)),this}addNodeMark(e,t){return this.step(new br(e,t)),this}removeNodeMark(e,t){if(!(t instanceof we)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Wi(e,t)),this}split(e,t=1,r){return YT(this,e,t,r),this}addMark(e,t,r){return FT(this,e,t,r),this}removeMark(e,t,r){return zT(this,e,t,r),this}clearIncompatible(e,t,r){return Ym(this,e,t,r),this}}const $u=Object.create(null);class ce{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new sM(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;o--){let l=t<0?_i(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):_i(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fn(e.node(0))}static atStart(e){return _i(e,e,0,0,1)||new fn(e)}static atEnd(e){return _i(e,e,e.content.size,e.childCount,-1)||new fn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$u[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in $u)throw new RangeError("Duplicate use of selection JSON ID "+e);return $u[e]=t,t.prototype.jsonID=e,t}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}}ce.prototype.visible=!0;class sM{constructor(e,t){this.$from=e,this.$to=t}}let np=!1;function rp(n){!np&&!n.parent.inlineContent&&(np=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class re extends ce{constructor(e,t=e){rp(e),rp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ce.near(r);let i=e.resolve(t.map(this.anchor));return new re(i.parent.inlineContent?i:r,r)}replace(e,t=U.empty){if(super.replace(e,t),t==U.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof re&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ia(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=ce.findFrom(t,r,!0)||ce.findFrom(t,-r,!0);if(o)t=o.$head;else return ce.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ce.findFrom(e,-r,!0)||ce.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?l=0;l+=i){let u=e.child(l);if(u.isAtom){if(!o&&j.isSelectable(u))return j.create(n,t-(i<0?u.nodeSize:0))}else{let c=_i(n,u,t+i,i<0?u.childCount:0,i,o);if(c)return c}t+=u.nodeSize*i}return null}function ip(n,e,t){let r=n.steps.length-1;if(r{l==null&&(l=h)}),n.setSelection(ce.near(n.doc.resolve(l),t))}const sp=1,Yo=2,op=4;class lM extends rg{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Yo,this}ensureMarks(e){return we.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Yo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Yo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||we.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let l=this.doc.resolve(t);o=r==t?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(ce.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=op,this}get scrolledIntoView(){return(this.updated&op)>0}}function lp(n,e){return!e||!n?n:n.bind(e)}class Os{constructor(e,t,r){this.name=e,this.init=lp(t.init,r),this.apply=lp(t.apply,r)}}const aM=[new Os("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Os("selection",{init(n,e){return n.selection||ce.atStart(e.doc)},apply(n){return n.selection}}),new Os("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Os("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Uu{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=aM.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Os(r.key,r.spec.state,r))})}}class Ri{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Uu(e.schema,e.plugins),o=new Ri(i);return i.fields.forEach(l=>{if(l.name=="doc")o.doc=ei.fromJSON(e.schema,t.doc);else if(l.name=="selection")o.selection=ce.fromJSON(o.doc,t.selection);else if(l.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let u in r){let c=r[u],d=c.spec.state;if(c.key==l.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,u)){o[l.name]=d.fromJSON.call(c,e,t[u],o);return}}o[l.name]=l.init(e,o)}}),o}}function ig(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ig(i,e,{})),t[r]=i}return t}class nt{constructor(e){this.spec=e,this.props={},e.props&&ig(e.props,this,this.props),this.key=e.key?e.key.key:sg("plugin")}getState(e){return e[this.key]}}const Wu=Object.create(null);function sg(n){return n in Wu?n+"$"+ ++Wu[n]:(Wu[n]=0,n+"$")}class zt{constructor(e="key"){this.key=sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const et=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},$s=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let mc=null;const Vn=function(n,e,t){let r=mc||(mc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},uM=function(){mc=null},li=function(n,e,t,r){return t&&(ap(n,e,t,r,-1)||ap(n,e,t,r,1))},cM=/^(img|br|input|textarea|hr)$/i;function ap(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:kn(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Ys(n)||cM.test(n.nodeName)||n.contentEditable=="false")return!1;e=et(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?kn(n):0}else return!1}}function kn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function fM(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=kn(n)}else if(n.parentNode&&!Ys(n))e=et(n),n=n.parentNode;else return null}}function dM(n,e){for(;;){if(n.nodeType==3&&e2),Xt=qi||(Mn?/Mac/.test(Mn.platform):!1),yM=Mn?/Win/.test(Mn.platform):!1,an=/Android \d/.test(Mr),Xs=!!up&&"webkitFontSmoothing"in up.documentElement.style,bM=Xs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vM(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Un(n,e){return typeof n=="number"?n:n[e]}function SM(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function cp(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let l=t||n.dom;l;l=$s(l)){if(l.nodeType!=1)continue;let u=l,c=u==o.body,d=c?vM(o):SM(u),h=0,m=0;if(e.topd.bottom-Un(r,"bottom")&&(m=e.bottom-e.top>d.bottom-d.top?e.top+Un(i,"top")-d.top:e.bottom-d.bottom+Un(i,"bottom")),e.leftd.right-Un(r,"right")&&(h=e.right-d.right+Un(i,"right")),h||m)if(c)o.defaultView.scrollBy(h,m);else{let y=u.scrollLeft,v=u.scrollTop;m&&(u.scrollTop+=m),h&&(u.scrollLeft+=h);let x=u.scrollLeft-y,T=u.scrollTop-v;e={left:e.left-x,top:e.top-T,right:e.right-x,bottom:e.bottom-T}}if(c||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function xM(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,l=t+1;l=t-20){r=u,i=c.top;break}}return{refDOM:r,refTop:i,stack:lg(n.dom)}}function lg(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=$s(r));return e}function wM({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ag(t,r==0?0:r-e)}function ag(n,e){for(let t=0;t=u){l=Math.max(x.bottom,l),u=Math.min(x.top,u);let T=x.left>e.left?x.left-e.left:x.right=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=h,d={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!t&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(o=m+1)}}return!t&&c&&(t=c,i=d,r=0),t&&t.nodeType==3?CM(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:ug(t,i)}function CM(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function Kc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function TM(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(l.left+l.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function EM(n,e,t,r){let i=-1;for(let o=e,l=!1;o!=n.dom;){let u=n.docView.nearestDesc(o,!0);if(!u)return null;if(u.dom.nodeType==1&&(u.node.isBlock&&u.parent||!u.contentDOM)){let c=u.dom.getBoundingClientRect();if(u.node.isBlock&&u.parent&&(!l&&c.left>r.left||c.top>r.top?i=u.posBefore:(!l&&c.right-1?i:n.docView.posFromDOM(e,t,-1)}function cg(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let d;Xs&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?u=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(u=EM(n,r,i,e))}u==null&&(u=MM(n,l,e));let c=n.docView.nearestDesc(l,!0);return{pos:u,inside:c?c.posAtStart-c.border:-1}}function fp(n){return n.top=0&&i==r.nodeValue.length?(c--,h=1):t<0?c--:d++,Ts(fr(Vn(r,c,d),h),h<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==kn(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Vu(c.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==kn(r))){let c=r.childNodes[i-1],d=c.nodeType==3?Vn(c,kn(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return Ts(fr(d,1),!1)}if(o==null&&i=0)}function Ts(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Vu(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function dg(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function _M(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return dg(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let u=n.docView.nearestDesc(o,!0);if(!u)break;if(u.node.isBlock){o=u.contentDOM||u.dom;break}o=u.dom.parentNode}let l=fg(n,i.pos,1);for(let u=o.firstChild;u;u=u.nextSibling){let c;if(u.nodeType==1)c=u.getClientRects();else if(u.nodeType==3)c=Vn(u,0,u.nodeValue.length).getClientRects();else continue;for(let d=0;dh.top+1&&(t=="up"?l.top-h.top>(h.bottom-l.top)*2:h.bottom-l.bottom>(l.bottom-h.top)*2))return!1}}return!0})}const NM=/[\u0590-\u08ac]/;function DM(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,l=i==r.parent.content.size,u=n.domSelection();return!NM.test(r.parent.textContent)||!u.modify?t=="left"||t=="backward"?o:l:dg(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:h,anchorOffset:m}=n.domSelectionRange(),y=u.caretBidiLevel;u.modify("move",t,"character");let v=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:x,focusOffset:T}=n.domSelectionRange(),E=x&&!v.contains(x.nodeType==1?x:x.parentNode)||c==x&&d==T;try{u.collapse(h,m),c&&(c!=h||d!=m)&&u.extend&&u.extend(c,d)}catch{}return y!=null&&(u.caretBidiLevel=y),E})}let dp=null,hp=null,pp=!1;function IM(n,e,t){return dp==e&&hp==t?pp:(dp=e,hp=t,pp=t=="up"||t=="down"?_M(n,e,t):DM(n,e,t))}const Zt=0,mp=1,Kr=2,En=3;class Qs{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Zt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tet(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),l;if(o&&(!t||o.node))if(r&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||l instanceof pg){i=e-o;break}o=u}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof hg&&o.side>=0;r--);if(t<=0){let o,l=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,l=!1);return o&&t&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?et(o.dom)+1:0}}else{let o,l=!0;for(;o=r=h&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,h);e=l;for(let m=u;m>0;m--){let y=this.children[m-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=et(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(d>t||u==this.children.length-1)){t=d;for(let h=u+1;hv&<){let v=u;u=c,c=v}let y=document.createRange();y.setEnd(c.node,c.offset),y.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let u=r+o.border,c=l-o.border;if(e>=u&&t<=c){this.dirty=e==r||t==l?Kr:mp,e==u&&t==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=En:o.markDirty(e-u,t-u);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Kr:En}r=l}this.dirty=Kr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Kr:mp;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(l.nodeType!=1){let u=document.createElement("span");u.appendChild(l),l=u}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Zt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class RM extends Qs{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ai extends Qs{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let o=i.nodeViews[t.type.name],l=o&&o(t,i,r);return(!l||!l.dom)&&(l=Cn.renderSpec(document,t.type.spec.toDOM(t,r))),new ai(e,t,l.dom,l.contentDOM||l.dom)}parseRule(){return this.dirty&En||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=En&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Zt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=xc(o,0,e,r));for(let u=0;u{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},r,i),h=d&&d.dom,m=d&&d.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=Cn.renderSpec(document,t.type.spec.toDOM(t)));!m&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let y=h;return h=yg(h,r,t),d?c=new LM(e,t,r,i,h,m||null,y,d,o,l+1):t.isText?new oa(e,t,r,i,h,y,o):new wr(e,t,r,i,h,m||null,y,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>B.empty)}return e}matchesNode(e,t,r){return this.dirty==Zt&&e.eq(this.node)&&Sc(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,l=o&&o.pos>-1?o:null,u=o&&o.pos<0,c=new BM(this,l&&l.node,e);HM(this.node,this.innerDeco,(d,h,m)=>{d.spec.marks?c.syncToMarks(d.spec.marks,r,e):d.type.side>=0&&!m&&c.syncToMarks(h==this.node.childCount?we.none:this.node.child(h).marks,r,e),c.placeWidget(d,e,i)},(d,h,m,y)=>{c.syncToMarks(d.marks,r,e);let v;c.findNodeMatch(d,h,m,y)||u&&e.state.selection.from>i&&e.state.selection.to-1&&c.updateNodeAt(d,h,m,v,e)||c.updateNextNode(d,h,m,e,y,i)||c.addNode(d,h,m,e,i),i+=d.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Kr)&&(l&&this.protectLocalComposition(e,l),mg(this.contentDOM,this.children,e),qi&&$M(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof re)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,u=UM(this.node.content,l,r-t,i-t);return u<0?null:{node:o,pos:u,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new RM(this,o,t,i);e.input.compositionNodes.push(l),this.children=xc(this.children,r,r+i.length,e,l)}update(e,t,r,i){return this.dirty==En||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Zt}updateOuterDeco(e){if(Sc(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=gg(this.dom,this.nodeDOM,vc(this.outerDeco,this.node,t),vc(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function gp(n,e,t,r,i){yg(r,e,n);let o=new wr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class oa extends wr{constructor(e,t,r,i,o,l,u){super(e,t,r,i,o,null,l,u,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==En||this.dirty!=Zt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Zt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Zt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new oa(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=En)}get domAtom(){return!1}isText(e){return this.node.text==e}}class pg extends Qs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Zt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class LM extends wr{constructor(e,t,r,i,o,l,u,c,d,h){super(e,t,r,i,o,l,u,d,h),this.spec=c}update(e,t,r,i){if(this.dirty==En)return!1;if(this.spec.update){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function mg(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,l=Math.min(o,e.length);for(;i-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let c=ai.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,t,r))o=this.top.children.indexOf(l,this.index);else for(let u=this.index,c=Math.min(this.top.children.length,u+5);u0;){let u;for(;;)if(r){let d=t.children[r-1];if(d instanceof ai)t=d,r=d.children.length;else{u=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let c=u.node;if(c){if(c!=n.child(i-1))break;--i,o.set(u,i),l.push(u)}}return{index:i,matched:o,matches:l.reverse()}}function zM(n,e){return n.type.side-e.type.side}function HM(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let d=0;do;)u.push(i[l++]);let x=o+y.nodeSize;if(y.isText){let E=x;l!E.inline):u.slice();r(y,T,e.forChild(o,y),v),o=x}}function $M(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function UM(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&c.slice(r-e.length-u,r-u)==e)return r-e.length;let d=u=0&&d+e.length+u>=t)return u+d;if(t==r&&c.length>=r+e.length-u&&c.slice(r-u,r-u+e.length)==e)return r}}return-1}function xc(n,e,t,r,i){let o=[];for(let l=0,u=0;l=t||h<=e?o.push(c):(dt&&o.push(c.slice(t-d,c.size,r)))}return o}function Jc(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,l=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(l<0)return null;let u=r.resolve(l),c,d;if(sa(t)){for(c=u;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&j.isSelectable(h)&&i.parent&&!(h.isInline&&hM(t.focusNode,t.focusOffset,i.dom))){let m=i.posBefore;d=new j(l==m?u:r.resolve(m))}}else{let h=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(h<0)return null;c=r.resolve(h)}if(!d){let h=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!bg(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function VM(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setEnd(r.parentNode,et(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&Et&&xr<=11&&(r.disabled=!0,r.disabled=!1)}function vg(n,e){if(e instanceof j){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(xp(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else xp(n)}function xp(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function jc(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||re.between(e,t,r)}function wp(n){return n.editable&&!n.hasFocus()?!1:Sg(n)}function Sg(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function qM(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return li(e.node,e.offset,t.anchorNode,t.anchorOffset)}function wc(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&ce.findFrom(o,e)}function dr(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function kp(n,e,t){let r=n.state.selection;if(r instanceof re)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return dr(n,new re(r.$anchor,l))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=wc(n.state,e);return i&&i instanceof j?dr(n,i):!1}else if(!(Xt&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!o||o.isText)return!1;let u=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(l=n.docView.descAt(u))&&!l.contentDOM?j.isSelectable(o)?dr(n,new j(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Xs?dr(n,new re(n.state.doc.resolve(e<0?u:u+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof j&&r.node.isInline)return dr(n,new re(e>0?r.$to:r.$from));{let i=wc(n.state,e);return i?dr(n,i):!1}}}function yl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Is(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ai(n,e){return e<0?KM(n):JM(n)}function KM(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,l=!1;for(dn&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let u=t.childNodes[r-1];if(Is(u,-1))i=t,o=--r;else if(u.nodeType==3)t=u,r=t.nodeValue.length;else break}}else{if(xg(t))break;{let u=t.previousSibling;for(;u&&Is(u,-1);)i=t.parentNode,o=et(u),u=u.previousSibling;if(u)t=u,r=yl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}l?kc(n,t,r):i&&kc(n,i,o)}function JM(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=yl(t),o,l;for(;;)if(r{n.state==i&&Jn(n)},50)}function Cp(n,e){let t=n.state.doc.resolve(e);if(!(ht||yM)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l1)return o.lefti.top&&l1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Tp(n,e,t){let r=n.state.selection;if(r instanceof re&&!r.empty||t.indexOf("s")>-1||Xt&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let l=wc(n.state,e);if(l&&l instanceof j)return dr(n,l)}if(!i.parent.inlineContent){let l=e<0?i:o,u=r instanceof fn?ce.near(l,e):ce.findFrom(l,e);return u?dr(n,u):!1}return!1}function Mp(n,e){if(!(n.state.selection instanceof re))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let l=n.state.tr;return e<0?l.delete(t.pos-o.nodeSize,t.pos):l.delete(t.pos,t.pos+o.nodeSize),n.dispatch(l),!0}return!1}function Ep(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function YM(n){if(!pt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ep(n,r,"true"),setTimeout(()=>Ep(n,r,"false"),20)}return!1}function XM(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function QM(n,e){let t=e.keyCode,r=XM(e);if(t==8||Xt&&t==72&&r=="c")return Mp(n,-1)||Ai(n,-1);if(t==46&&!e.shiftKey||Xt&&t==68&&r=="c")return Mp(n,1)||Ai(n,1);if(t==13||t==27)return!0;if(t==37||Xt&&t==66&&r=="c"){let i=t==37?Cp(n,n.state.selection.from)=="ltr"?-1:1:-1;return kp(n,i,r)||Ai(n,i)}else if(t==39||Xt&&t==70&&r=="c"){let i=t==39?Cp(n,n.state.selection.from)=="ltr"?1:-1:1;return kp(n,i,r)||Ai(n,i)}else{if(t==38||Xt&&t==80&&r=="c")return Tp(n,-1,r)||Ai(n,-1);if(t==40||Xt&&t==78&&r=="c")return YM(n)||Tp(n,1,r)||Ai(n,1);if(r==(Xt?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function wg(n,e){n.someProp("transformCopied",v=>{e=v(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let v=r.firstChild;t.push(v.type.name,v.attrs!=v.type.defaultAttrs?v.attrs:null),r=v.content}let l=n.someProp("clipboardSerializer")||Cn.fromSchema(n.state.schema),u=Ag(),c=u.createElement("div");c.appendChild(l.serializeFragment(r,{document:u}));let d=c.firstChild,h,m=0;for(;d&&d.nodeType==1&&(h=Eg[d.nodeName.toLowerCase()]);){for(let v=h.length-1;v>=0;v--){let x=u.createElement(h[v]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),m++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${i} ${o}${m?` -${m}`:""} ${JSON.stringify(t)}`);let y=n.someProp("clipboardTextSerializer",v=>v(e,n))||e.content.textBetween(0,e.content.size,`
-`);return{dom:f,text:y,slice:e}}function kg(n,e,t,r,i){let o=i.parent.type.spec.code,l,u;if(!t&&!e)return null;let f=e&&(r||o||!t);if(f){if(n.someProp("transformPastedText",y=>{e=y(e,o||r,n)}),o)return e?new U(B.from(n.state.schema.text(e.replace(/\r\n?/g,`
-`))),0,0):U.empty;let m=n.someProp("clipboardTextParser",y=>y(e,i,r,n));if(m)u=m;else{let y=i.marks(),{schema:v}=n.state,w=Tn.fromSchema(v);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(T=>{let E=l.appendChild(document.createElement("p"));T&&E.appendChild(w.serializeNode(v.text(T,y)))})}}else n.someProp("transformPastedHTML",m=>{t=m(t,n)}),l=ZM(t),Xs&&eE(l);let d=l&&l.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(u||(u=(n.someProp("clipboardParser")||n.someProp("domParser")||Ui.fromSchema(n.state.schema)).parseSlice(l,{preserveWhitespace:!!(f||h),context:i,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!XM.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)u=tE(Ap(u,+h[1],+h[2]),h[4]);else if(u=U.maxOpen(QM(u.content,i),!0),u.openStart||u.openEnd){let m=0,y=0;for(let v=u.content.firstChild;m