uEdition-Editor 2.0.0b9__py3-none-any.whl → 2.0.0b10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of uEdition-Editor might be problematic. Click here for more details.

@@ -1,192 +0,0 @@
1
- import{T as He,U as tu,V as ea,W as nu,X as Je,Y as lt,Z as Ds,_ as Vt,$ as vi,a0 as St,a1 as Di,a2 as Sr,a3 as ts,a4 as ru,a5 as iu,a6 as su,a7 as wn,a8 as ou,a9 as lu,aa as Cr,ab as un,ac as G,ad as xs,ae as oi,af as mr,ag as au,ah as Is,ai as cu,aj as uu,ak as ta,al as na,am as ra,an as Ps,ao as Nn,ap as fu,aq as du,ar as hu,as as pu,at as mu,au as gu,av as bu,aw as In,ax as yu,ay as ku,az as _u,aA as xi,aB as gr,aC as Su,aD as Cu,aE as Rs,aF as Mu,aG as ns,aH as rs,aI as zr,aJ as is,aK as Ht,aL as wu,S as je,i as We,s as Ne,aM as me,aN as ge,aO as be,aP as ye,k as _,h as C,m as le,J as de,c as N,g as ne,j as re,l as A,aQ as De,aR as Fr,aS as ie,aT as xt,aU as mt,v as Pe,e as R,aV as se,aW as qe,C as ee,aX as Fe,F as ft,aY as ia,aZ as ss,a_ as sa,a$ as Bs,w as te,t as he,f as xe,b0 as Tu,b1 as fe,b2 as rt,a as K,b as q,d as P,A as F,B as V,E as L,I as Me,b3 as Eu,b4 as Vr,K as ls,b5 as Ou,b6 as Cn,b7 as Qe,b8 as as,b9 as cs,ba as us,bb as Nu,bc as zs,p as Au,bd as Dt,be as Mr,bf as wr,bg as vu,P as Ii,bh as Du,Q as Pi,bi as xu,bj as Iu,bk as Pu,bl as Ru,bm as Bu,bn as zu,L as ir,n as Fs,o as Fu,u as Vu,O as rn,N as Vs,q as Lu,R as ju}from"./index-CS7Yn65-.js";import{k as Wu,b as qu}from"./index-Vcq4gwWv.js";function li(r){return Array.from(r.querySelectorAll('[role="option"]:not([data-disabled])')).filter(e=>He(e))}function Ju(r){return window.getComputedStyle(r).getPropertyValue("direction")}function Ku(r){return e=>{const t=e.target,n=tu(r);if(!n||!ea(t))return!1;const i=n.id;return!!(nu(t)&&i===t.htmlFor||t.closest(`label[for="${i}"]`))}}function $u(){return{elements:{root:Je("label",{action:e=>({destroy:lt(e,"mousedown",n=>{!n.defaultPrevented&&n.detail>1&&n.preventDefault()})})})}}}const Uu=[G.ARROW_LEFT,G.ESCAPE,G.ARROW_RIGHT,G.SHIFT,G.CAPS_LOCK,G.CONTROL,G.ALT,G.META,G.ENTER,G.F1,G.F2,G.F3,G.F4,G.F5,G.F6,G.F7,G.F8,G.F9,G.F10,G.F11,G.F12],Hu={positioning:{placement:"bottom",sameWidth:!0},scrollAlignment:"nearest",loop:!0,defaultOpen:!1,closeOnOutsideClick:!0,preventScroll:!0,closeOnEscape:!0,forceVisible:!1,portal:void 0,builder:"listbox",disabled:!1,required:!1,name:void 0,typeahead:!0,highlightOnHover:!0,onOutsideClick:void 0},Gu=["trigger","menu","label"];function Yu(r){const e={...Hu,...r},t=Ds(Vt(null)),n=Ds(Vt(null)),i=e.selected??Vt(e.defaultSelected),s=vi(i,e==null?void 0:e.onSelectedChange),o=St(n,x=>x?Y(x):void 0),a=e.open??Vt(e.defaultOpen),l=vi(a,e==null?void 0:e.onOpenChange),c=Di({...Sr(e,"open","defaultOpen","builder","ids"),multiple:e.multiple??!1}),{scrollAlignment:u,loop:f,closeOnOutsideClick:d,closeOnEscape:h,preventScroll:p,portal:m,forceVisible:g,positioning:b,multiple:y,arrowSize:M,disabled:T,required:S,typeahead:E,name:W,highlightOnHover:D,onOutsideClick:v}=c,{name:k,selector:w}=ts(e.builder),J=Di({...ru(Gu),...e.ids}),{handleTypeaheadSearch:H}=iu({onMatch:x=>{n.set(x),x.scrollIntoView({block:u.get()})},getCurrentItem(){return n.get()}});function Y(x){const $=x.getAttribute("data-value"),oe=x.getAttribute("data-label"),Ue=x.hasAttribute("data-disabled");return{value:$&&JSON.parse($),label:oe??x.textContent??void 0,disabled:!!Ue}}const ae=x=>{s.update($=>{if(y.get()){const Ue=Array.isArray($)?[...$]:[];return Su(x,Ue,(nn,ue)=>wn(nn.value,ue.value))}return x})};function I(x){const $=Y(x);ae($)}async function it(){l.set(!0);const x=document.getElementById(J.trigger.get());if(!x)return;x!==t.get()&&t.set(x),await oi();const $=document.getElementById(J.menu.get());if(!He($))return;const oe=$.querySelector("[aria-selected=true]");He(oe)&&n.set(oe)}function $e(){l.set(!1),n.set(null)}const er=su({open:l,forceVisible:g,activeTrigger:t}),tr=St([s],([x])=>$=>Array.isArray(x)?x.some(oe=>wn(oe.value,$)):ou($)?wn(x==null?void 0:x.value,lu($,void 0)):wn(x==null?void 0:x.value,$)),ei=St([o],([x])=>$=>wn(x==null?void 0:x.value,$)),ti=Je(k("trigger"),{stores:[l,n,T,J.menu,J.trigger,J.label],returned:([x,$,oe,Ue,nn,ue])=>({"aria-activedescendant":$==null?void 0:$.id,"aria-autocomplete":"list","aria-controls":Ue,"aria-expanded":x,"aria-labelledby":ue,id:nn,role:"combobox",disabled:Cr(oe),type:e.builder==="select"?"button":void 0}),action:x=>{const $=xi(x),oe=un(lt(x,"click",()=>{x.focus(),l.get()?$e():it()}),lt(x,"keydown",ue=>{if(!l.get()){if(Uu.includes(ue.key)||ue.key===G.TAB||ue.key===G.BACKSPACE&&$&&x.value===""||ue.key===G.SPACE&&xs(x))return;it(),oi().then(()=>{if(s.get())return;const Rt=document.getElementById(J.menu.get());if(!He(Rt))return;const ke=Array.from(Rt.querySelectorAll(`${w("item")}:not([data-disabled]):not([data-hidden])`)).filter(yt=>He(yt));ke.length&&(ue.key===G.ARROW_DOWN?(n.set(ke[0]),ke[0].scrollIntoView({block:u.get()})):ue.key===G.ARROW_UP&&(n.set(mr(ke)),mr(ke).scrollIntoView({block:u.get()})))})}if(ue.key===G.TAB){$e();return}if(ue.key===G.ENTER&&!ue.isComposing||ue.key===G.SPACE&&xs(x)){ue.preventDefault();const Ve=n.get();Ve&&I(Ve),y.get()||$e()}if(ue.key===G.ARROW_UP&&ue.altKey&&$e(),au.includes(ue.key)){ue.preventDefault();const Ve=document.getElementById(J.menu.get());if(!He(Ve))return;const Rt=li(Ve);if(!Rt.length)return;const ke=Rt.filter(vs=>!Is(vs)&&vs.dataset.hidden===void 0),yt=n.get(),Bt=yt?ke.indexOf(yt):-1,rr=f.get(),eu=u.get();let st;switch(ue.key){case G.ARROW_DOWN:st=na(ke,Bt,rr);break;case G.ARROW_UP:st=ta(ke,Bt,rr);break;case G.PAGE_DOWN:st=uu(ke,Bt,10,rr);break;case G.PAGE_UP:st=cu(ke,Bt,10,rr);break;case G.HOME:st=ke[0];break;case G.END:st=mr(ke);break;default:return}n.set(st),st==null||st.scrollIntoView({block:eu})}else if(E.get()){const Ve=document.getElementById(J.menu.get());if(!He(Ve))return;H(ue.key,li(Ve))}}));let Ue=gr;return Ue=ra(x,{handler:$e,enabled:St([l,h],([ue,nr])=>ue&&nr)}).destroy,{destroy(){oe(),Ue()}}}}),ni=Je(k("menu"),{stores:[er,J.menu],returned:([x,$])=>({hidden:x?void 0:!0,id:$,role:"listbox",style:Ps({display:x?void 0:"none"})}),action:x=>{let $=gr;const oe=un(Nn([er,m,d,b,t],([Ue,nn,ue,nr,Ve])=>{$(),!(!Ue||!Ve)&&oi().then(()=>{$();const Rt=Ku(J.trigger.get());$=fu(x,{anchorElement:Ve,open:l,options:{floating:nr,focusTrap:null,modal:{closeOnInteractOutside:ue,onClose:$e,open:Ue,shouldCloseOnInteractOutside:ke=>{var Bt;if((Bt=v.get())==null||Bt(ke),ke.defaultPrevented)return!1;const yt=ke.target;return!(!ea(yt)||yt===Ve||Ve.contains(yt)||Rt(ke))}},escapeKeydown:null,portal:du(x,nn)}}).destroy})}));return{destroy:()=>{oe(),$()}}}}),{elements:{root:ri}}=$u(),{action:ii}=hu(ri),si=Je(k("label"),{stores:[J.label,J.trigger],returned:([x,$])=>({id:x,for:$}),action:ii}),z=Je(k("option"),{stores:[tr],returned:([x])=>$=>{const oe=x($.value);return{"data-value":JSON.stringify($.value),"data-label":$.label,"data-disabled":Cr($.disabled),"aria-disabled":$.disabled?!0:void 0,"aria-selected":oe,"data-selected":oe?"":void 0,id:pu(),role:"option"}},action:x=>({destroy:un(lt(x,"click",oe=>{if(Is(x)){oe.preventDefault();return}I(x),y.get()||$e()}),Nn(D,oe=>oe?un(lt(x,"mouseover",()=>{n.set(x)}),lt(x,"mouseleave",()=>{n.set(null)})):void 0))})}),Yc=Je(k("group"),{returned:()=>x=>({role:"group","aria-labelledby":x})}),Xc=Je(k("group-label"),{returned:()=>x=>({id:x})}),Zc=mu({value:St([s],([x])=>{const $=Array.isArray(x)?x.map(oe=>oe.value):x==null?void 0:x.value;return typeof $=="string"?$:JSON.stringify($)}),name:gu(W),required:S,prefix:e.builder}),Qc=Je(k("arrow"),{stores:M,returned:x=>({"data-arrow":!0,style:Ps({position:"absolute",width:`var(--arrow-size, ${x}px)`,height:`var(--arrow-size, ${x}px)`})})});return bu(()=>{if(!In)return;const x=document.getElementById(J.menu.get()),$=document.getElementById(J.trigger.get());if($&&t.set($),!x)return;const oe=x.querySelector("[data-selected]");He(oe)}),Nn([n],([x])=>{if(!In)return;const $=document.getElementById(J.menu.get());He($)&&li($).forEach(oe=>{oe===x?yu(oe):ku(oe)})}),Nn([l],([x])=>{if(!In)return;let $=gr;return p.get()&&x&&($=_u()),()=>{$()}}),{ids:J,elements:{trigger:ti,group:Yc,option:z,menu:ni,groupLabel:Xc,label:si,hiddenInput:Zc,arrow:Qc},states:{open:l,selected:s,highlighted:o,highlightedItem:n},helpers:{isSelected:tr,isHighlighted:ei,closeMenu:$e},options:c}}const{name:Xu}=ts("combobox");function Zu(r){const e=Yu({...r,builder:"combobox",typeahead:!1}),t=Vt(""),n=Vt(!1),i=Je(Xu("input"),{stores:[e.elements.trigger,t],returned:([s,o])=>({...Sr(s,"action"),role:"combobox",value:o,autocomplete:"off"}),action:s=>{const o=un(lt(s,"input",u=>{!xi(u.target)&&!Rs(u.target)||n.set(!0)}),Cu(s,"input",u=>{xi(u.target)&&t.set(u.target.value),Rs(u.target)&&t.set(u.target.innerText)}));let a=gr;a=ra(s,{handler:()=>{e.helpers.closeMenu()}}).destroy;const{destroy:c}=e.elements.trigger(s);return{destroy(){c==null||c(),o(),a()}}}});return Nn(e.states.open,s=>{s||n.set(!1)}),{...e,elements:{...Sr(e.elements,"trigger"),input:i},states:{...e.states,touchedInput:n,inputValue:t}}}const Qu={orientation:"horizontal",activateOnFocus:!0,loop:!0,autoSet:!0},{name:sr,selector:ef}=ts("tabs");function tf(r){const e={...Qu,...r},t=Di(Sr(e,"defaultValue","value","onValueChange","autoSet")),{orientation:n,activateOnFocus:i,loop:s}=t,o=e.value??Vt(e.defaultValue),a=vi(o,e==null?void 0:e.onValueChange);let l=e.defaultValue??a.get();const c=Je(sr(),{stores:n,returned:p=>({"data-orientation":p})}),u=Je(sr("list"),{stores:n,returned:p=>({role:"tablist","aria-orientation":p,"data-orientation":p})}),f=p=>typeof p=="string"?{value:p}:p,d=Je(sr("trigger"),{stores:[a,n],returned:([p,m])=>g=>{const{value:b,disabled:y}=f(g);!p&&!l&&e.autoSet&&(l=b,p=b,a.set(b));const T=(In?p:l)===b;return{type:"button",role:"tab","data-state":T?"active":"inactive",tabindex:T?0:-1,"data-value":b,"data-orientation":m,"data-disabled":Cr(y),disabled:Cr(y)}},action:p=>({destroy:un(lt(p,"focus",()=>{const g=p.dataset.disabled==="true",b=p.dataset.value;i.get()&&!g&&b!==void 0&&a.set(b)}),lt(p,"click",g=>{if(p.focus(),g.preventDefault(),p.dataset.disabled==="true")return;const y=p.dataset.value;p.focus(),y!==void 0&&a.set(y)}),lt(p,"keydown",g=>{const b=p.dataset.value;if(!b)return;const y=g.currentTarget;if(!He(y))return;const M=y.closest(ef());if(!He(M))return;const T=s.get(),E=Array.from(M.querySelectorAll('[role="tab"]')).filter(w=>He(w)).filter(w=>!w.hasAttribute("data-disabled")),W=E.findIndex(w=>w===g.target),D=Ju(M),{nextKey:v,prevKey:k}=Mu(D,n.get());g.key===v?(g.preventDefault(),na(E,W,T).focus()):g.key===k?(g.preventDefault(),ta(E,W,T).focus()):g.key===G.ENTER||g.key===G.SPACE?(g.preventDefault(),a.set(b)):g.key===G.HOME?(g.preventDefault(),E[0].focus()):g.key===G.END&&(g.preventDefault(),mr(E).focus())}))})}),h=Je(sr("content"),{stores:a,returned:p=>m=>({role:"tabpanel","aria-labelledby":m,hidden:In?p===m?void 0:!0:l===m?void 0:!0,tabindex:0})});return{elements:{root:c,list:u,trigger:d,content:h},states:{value:a},options:t}}function nf(r,e){return r.length!==e.length?!1:r.every((t,n)=>t===e[n])}function fs(){return{NAME:"combobox",GROUP_NAME:"combobox-group",ITEM_NAME:"combobox-item",PARTS:["content","menu","input","item","label","group","group-label","arrow","hidden-input","indicator"]}}function Lr(){const{NAME:r}=fs();return Ht(r)}function rf(r){const{NAME:e,PARTS:t}=fs(),n=ns(e,t),i={...Zu({...rs(r),forceVisible:!0}),getAttrs:n};return zr(e,i),{...i,updateOption:is(i.options)}}function sf(r){const{ITEM_NAME:e}=fs(),t=Lr();return zr(e,r),t}function of(r){const t={...{side:"bottom",align:"center",sameWidth:!0},...r},{options:{positioning:n}}=Lr();wu(n)(t)}const lf=r=>({ids:r&1}),Ls=r=>({ids:r[0]});function af(r){let e;const t=r[24].default,n=me(t,r,r[23],Ls);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,[s]){n&&n.p&&(!e||s&8388609)&&ge(n,t,i,i[23],e?ye(t,i[23],s,lf):be(i[23]),Ls)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function cf(r,e,t){let n,i,s,{$$slots:o={},$$scope:a}=e,{required:l=void 0}=e,{disabled:c=void 0}=e,{preventScroll:u=void 0}=e,{loop:f=void 0}=e,{closeOnEscape:d=void 0}=e,{closeOnOutsideClick:h=void 0}=e,{portal:p=void 0}=e,{name:m=void 0}=e,{multiple:g=!1}=e,{selected:b=void 0}=e,{onSelectedChange:y=void 0}=e,{open:M=void 0}=e,{onOpenChange:T=void 0}=e,{items:S=[]}=e,{onOutsideClick:E=void 0}=e,{inputValue:W=""}=e,{touchedInput:D=!1}=e;const{states:{open:v,selected:k,inputValue:w,touchedInput:J},updateOption:H,ids:Y}=rf({required:l,disabled:c,preventScroll:u,loop:f,closeOnEscape:d,closeOnOutsideClick:h,portal:p,name:m,onOutsideClick:E,multiple:g,forceVisible:!0,defaultSelected:Array.isArray(b)?[...b]:b,defaultOpen:M,onSelectedChange:({next:I})=>Array.isArray(I)?((!Array.isArray(b)||!nf(b,I))&&(y==null||y(I),t(4,b=I)),I):(b!==I&&(y==null||y(I),t(4,b=I)),t(6,W=(I==null?void 0:I.label)??(typeof(I==null?void 0:I.value)=="string"?I==null?void 0:I.value:"")),w.set(W),I),onOpenChange:({next:I})=>(M!==I&&(T==null||T(I),t(5,M=I)),I),items:S});le(r,w,I=>t(21,n=I)),le(r,J,I=>t(22,i=I));const ae=St([Y.menu,Y.trigger,Y.label],([I,it,$e])=>({menu:I,trigger:it,label:$e}));return le(r,ae,I=>t(0,s=I)),r.$$set=I=>{"required"in I&&t(8,l=I.required),"disabled"in I&&t(9,c=I.disabled),"preventScroll"in I&&t(10,u=I.preventScroll),"loop"in I&&t(11,f=I.loop),"closeOnEscape"in I&&t(12,d=I.closeOnEscape),"closeOnOutsideClick"in I&&t(13,h=I.closeOnOutsideClick),"portal"in I&&t(14,p=I.portal),"name"in I&&t(15,m=I.name),"multiple"in I&&t(16,g=I.multiple),"selected"in I&&t(4,b=I.selected),"onSelectedChange"in I&&t(17,y=I.onSelectedChange),"open"in I&&t(5,M=I.open),"onOpenChange"in I&&t(18,T=I.onOpenChange),"items"in I&&t(19,S=I.items),"onOutsideClick"in I&&t(20,E=I.onOutsideClick),"inputValue"in I&&t(6,W=I.inputValue),"touchedInput"in I&&t(7,D=I.touchedInput),"$$scope"in I&&t(23,a=I.$$scope)},r.$$.update=()=>{r.$$.dirty&4194304&&t(7,D=i),r.$$.dirty&6291456&&i&&t(6,W=n),r.$$.dirty&64&&W!==void 0&&w.set(W),r.$$.dirty&32&&M!==void 0&&v.set(M),r.$$.dirty&16&&b!==void 0&&k.set(Array.isArray(b)?[...b]:b),r.$$.dirty&256&&H("required",l),r.$$.dirty&512&&H("disabled",c),r.$$.dirty&1024&&H("preventScroll",u),r.$$.dirty&2048&&H("loop",f),r.$$.dirty&4096&&H("closeOnEscape",d),r.$$.dirty&8192&&H("closeOnOutsideClick",h),r.$$.dirty&16384&&H("portal",p),r.$$.dirty&32768&&H("name",m),r.$$.dirty&65536&&H("multiple",g),r.$$.dirty&1048576&&H("onOutsideClick",E)},[s,w,J,ae,b,M,W,D,l,c,u,f,d,h,p,m,g,y,T,S,E,n,i,a,o]}class oa extends je{constructor(e){super(),We(this,e,cf,af,Ne,{required:8,disabled:9,preventScroll:10,loop:11,closeOnEscape:12,closeOnOutsideClick:13,portal:14,name:15,multiple:16,selected:4,onSelectedChange:17,open:5,onOpenChange:18,items:19,onOutsideClick:20,inputValue:6,touchedInput:7})}}const uf=r=>({builder:r[0]&256}),js=r=>({builder:r[8]}),ff=r=>({builder:r[0]&256}),Ws=r=>({builder:r[8]}),df=r=>({builder:r[0]&256}),qs=r=>({builder:r[8]}),hf=r=>({builder:r[0]&256}),Js=r=>({builder:r[8]}),pf=r=>({builder:r[0]&256}),Ks=r=>({builder:r[8]}),mf=r=>({builder:r[0]&256}),$s=r=>({builder:r[8]});function gf(r){let e,t,n,i;const s=r[26].default,o=me(s,r,r[25],js);let a=[r[8],r[13]],l={};for(let c=0;c<a.length;c+=1)l=ie(l,a[c]);return{c(){e=R("div"),o&&o.c(),se(e,l)},m(c,u){N(c,e,u),o&&o.m(e,null),r[35](e),t=!0,n||(i=[qe(r[8].action(e)),ee(e,"m-pointerleave",r[12]),ee(e,"keydown",r[31])],n=!0)},p(c,u){o&&o.p&&(!t||u[0]&33554688)&&ge(o,s,c,c[25],t?ye(s,c[25],u,uf):be(c[25]),js),se(e,l=Fe(a,[u[0]&256&&c[8],u[0]&8192&&c[13]]))},i(c){t||(_(o,c),t=!0)},o(c){C(o,c),t=!1},d(c){c&&A(e),o&&o.d(c),r[35](null),n=!1,ft(i)}}}function bf(r){let e,t,n,i,s;const o=r[26].default,a=me(o,r,r[25],Ws);let l=[r[8],r[13]],c={};for(let u=0;u<l.length;u+=1)c=ie(c,l[u]);return{c(){e=R("div"),a&&a.c(),se(e,c)},m(u,f){N(u,e,f),a&&a.m(e,null),r[34](e),n=!0,i||(s=[qe(r[8].action(e)),ee(e,"m-pointerleave",r[12]),ee(e,"keydown",r[30])],i=!0)},p(u,f){r=u,a&&a.p&&(!n||f[0]&33554688)&&ge(a,o,r,r[25],n?ye(o,r[25],f,ff):be(r[25]),Ws),se(e,c=Fe(l,[f[0]&256&&r[8],f[0]&8192&&r[13]]))},i(u){n||(_(a,u),t&&t.end(1),n=!0)},o(u){C(a,u),u&&(t=ia(e,r[5],r[6])),n=!1},d(u){u&&A(e),a&&a.d(u),r[34](null),u&&t&&t.end(),i=!1,ft(s)}}}function yf(r){let e,t,n,i,s;const o=r[26].default,a=me(o,r,r[25],qs);let l=[r[8],r[13]],c={};for(let u=0;u<l.length;u+=1)c=ie(c,l[u]);return{c(){e=R("div"),a&&a.c(),se(e,c)},m(u,f){N(u,e,f),a&&a.m(e,null),n=!0,i||(s=[qe(r[8].action(e)),ee(e,"m-pointerleave",r[12]),ee(e,"keydown",r[29])],i=!0)},p(u,f){r=u,a&&a.p&&(!n||f[0]&33554688)&&ge(a,o,r,r[25],n?ye(o,r[25],f,df):be(r[25]),qs),se(e,c=Fe(l,[f[0]&256&&r[8],f[0]&8192&&r[13]]))},i(u){n||(_(a,u),u&&(t||ss(()=>{t=sa(e,r[3],r[4]),t.start()})),n=!0)},o(u){C(a,u),n=!1},d(u){u&&A(e),a&&a.d(u),i=!1,ft(s)}}}function kf(r){let e,t,n,i,s,o;const a=r[26].default,l=me(a,r,r[25],Js);let c=[r[8],r[13]],u={};for(let f=0;f<c.length;f+=1)u=ie(u,c[f]);return{c(){e=R("div"),l&&l.c(),se(e,u)},m(f,d){N(f,e,d),l&&l.m(e,null),r[33](e),i=!0,s||(o=[qe(r[8].action(e)),ee(e,"m-pointerleave",r[12]),ee(e,"keydown",r[28])],s=!0)},p(f,d){r=f,l&&l.p&&(!i||d[0]&33554688)&&ge(l,a,r,r[25],i?ye(a,r[25],d,hf):be(r[25]),Js),se(e,u=Fe(c,[d[0]&256&&r[8],d[0]&8192&&r[13]]))},i(f){i||(_(l,f),f&&ss(()=>{i&&(n&&n.end(1),t=sa(e,r[3],r[4]),t.start())}),i=!0)},o(f){C(l,f),t&&t.invalidate(),f&&(n=ia(e,r[5],r[6])),i=!1},d(f){f&&A(e),l&&l.d(f),r[33](null),f&&n&&n.end(),s=!1,ft(o)}}}function _f(r){let e,t,n,i,s;const o=r[26].default,a=me(o,r,r[25],Ks);let l=[r[8],r[13]],c={};for(let u=0;u<l.length;u+=1)c=ie(c,l[u]);return{c(){e=R("div"),a&&a.c(),se(e,c)},m(u,f){N(u,e,f),a&&a.m(e,null),r[32](e),n=!0,i||(s=[qe(r[8].action(e)),ee(e,"m-pointerleave",r[12]),ee(e,"keydown",r[27])],i=!0)},p(u,f){r=u,a&&a.p&&(!n||f[0]&33554688)&&ge(a,o,r,r[25],n?ye(o,r[25],f,pf):be(r[25]),Ks),se(e,c=Fe(l,[f[0]&256&&r[8],f[0]&8192&&r[13]]))},i(u){n||(_(a,u),u&&ss(()=>{n&&(t||(t=Bs(e,r[1],r[2],!0)),t.run(1))}),n=!0)},o(u){C(a,u),u&&(t||(t=Bs(e,r[1],r[2],!1)),t.run(0)),n=!1},d(u){u&&A(e),a&&a.d(u),r[32](null),u&&t&&t.end(),i=!1,ft(s)}}}function Sf(r){let e;const t=r[26].default,n=me(t,r,r[25],$s);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s[0]&33554688)&&ge(n,t,i,i[25],e?ye(t,i[25],s,mf):be(i[25]),$s)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function Cf(r){let e,t,n,i;const s=[Sf,_f,kf,yf,bf,gf],o=[];function a(l,c){return l[7]&&l[9]?0:l[1]&&l[9]?1:l[3]&&l[5]&&l[9]?2:l[3]&&l[9]?3:l[5]&&l[9]?4:l[9]?5:-1}return~(e=a(r))&&(t=o[e]=s[e](r)),{c(){t&&t.c(),n=de()},m(l,c){~e&&o[e].m(l,c),N(l,n,c),i=!0},p(l,c){let u=e;e=a(l),e===u?~e&&o[e].p(l,c):(t&&(ne(),C(o[u],1,1,()=>{o[u]=null}),re()),~e?(t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n)):t=null)},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),~e&&o[e].d(l)}}}function Mf(r,e,t){let n;const i=["transition","transitionConfig","inTransition","inTransitionConfig","outTransition","outTransitionConfig","asChild","id","side","align","sideOffset","alignOffset","collisionPadding","avoidCollisions","collisionBoundary","sameWidth","fitViewport","el"];let s=De(e,i),o,a,{$$slots:l={},$$scope:c}=e,{transition:u=void 0}=e,{transitionConfig:f=void 0}=e,{inTransition:d=void 0}=e,{inTransitionConfig:h=void 0}=e,{outTransition:p=void 0}=e,{outTransitionConfig:m=void 0}=e,{asChild:g=!1}=e,{id:b=void 0}=e,{side:y="bottom"}=e,{align:M="center"}=e,{sideOffset:T=0}=e,{alignOffset:S=0}=e,{collisionPadding:E=8}=e,{avoidCollisions:W=!0}=e,{collisionBoundary:D=void 0}=e,{sameWidth:v=!0}=e,{fitViewport:k=!1}=e,{el:w=void 0}=e;const{elements:{menu:J},states:{open:H},ids:Y,getAttrs:ae}=Lr();le(r,J,z=>t(24,a=z)),le(r,H,z=>t(9,o=z));const I=Fr(),it=ae("content");function $e(z){mt.call(this,r,z)}function er(z){mt.call(this,r,z)}function tr(z){mt.call(this,r,z)}function ei(z){mt.call(this,r,z)}function ti(z){mt.call(this,r,z)}function ni(z){Pe[z?"unshift":"push"](()=>{w=z,t(0,w)})}function ri(z){Pe[z?"unshift":"push"](()=>{w=z,t(0,w)})}function ii(z){Pe[z?"unshift":"push"](()=>{w=z,t(0,w)})}function si(z){Pe[z?"unshift":"push"](()=>{w=z,t(0,w)})}return r.$$set=z=>{e=ie(ie({},e),xt(z)),t(13,s=De(e,i)),"transition"in z&&t(1,u=z.transition),"transitionConfig"in z&&t(2,f=z.transitionConfig),"inTransition"in z&&t(3,d=z.inTransition),"inTransitionConfig"in z&&t(4,h=z.inTransitionConfig),"outTransition"in z&&t(5,p=z.outTransition),"outTransitionConfig"in z&&t(6,m=z.outTransitionConfig),"asChild"in z&&t(7,g=z.asChild),"id"in z&&t(14,b=z.id),"side"in z&&t(15,y=z.side),"align"in z&&t(16,M=z.align),"sideOffset"in z&&t(17,T=z.sideOffset),"alignOffset"in z&&t(18,S=z.alignOffset),"collisionPadding"in z&&t(19,E=z.collisionPadding),"avoidCollisions"in z&&t(20,W=z.avoidCollisions),"collisionBoundary"in z&&t(21,D=z.collisionBoundary),"sameWidth"in z&&t(22,v=z.sameWidth),"fitViewport"in z&&t(23,k=z.fitViewport),"el"in z&&t(0,w=z.el),"$$scope"in z&&t(25,c=z.$$scope)},r.$$.update=()=>{r.$$.dirty[0]&16384&&b&&Y.menu.set(b),r.$$.dirty[0]&16777216&&t(8,n=a),r.$$.dirty[0]&256&&Object.assign(n,it),r.$$.dirty[0]&16744960&&o&&of({side:y,align:M,sideOffset:T,alignOffset:S,collisionPadding:E,avoidCollisions:W,collisionBoundary:D,sameWidth:v,fitViewport:k})},[w,u,f,d,h,p,m,g,n,o,J,H,I,s,b,y,M,T,S,E,W,D,v,k,a,c,l,$e,er,tr,ei,ti,ni,ri,ii,si]}class la extends je{constructor(e){super(),We(this,e,Mf,Cf,Ne,{transition:1,transitionConfig:2,inTransition:3,inTransitionConfig:4,outTransition:5,outTransitionConfig:6,asChild:7,id:14,side:15,align:16,sideOffset:17,alignOffset:18,collisionPadding:19,avoidCollisions:20,collisionBoundary:21,sameWidth:22,fitViewport:23,el:0},null,[-1,-1])}}const wf=r=>({builder:r&8,placeholder:r&4}),Us=r=>({builder:r[3],placeholder:r[2]});function Tf(r){let e,t,n,i=[r[3],r[6],{placeholder:r[2]}],s={};for(let o=0;o<i.length;o+=1)s=ie(s,i[o]);return{c(){e=R("input"),se(e,s)},m(o,a){N(o,e,a),e.autofocus&&e.focus(),r[11](e),t||(n=[qe(r[3].action(e)),ee(e,"m-click",r[5]),ee(e,"m-keydown",r[5]),ee(e,"m-input",r[5])],t=!0)},p(o,a){se(e,s=Fe(i,[a&8&&o[3],a&64&&o[6],a&4&&{placeholder:o[2]}]))},i:te,o:te,d(o){o&&A(e),r[11](null),t=!1,ft(n)}}}function Ef(r){let e;const t=r[10].default,n=me(t,r,r[9],Us);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&524)&&ge(n,t,i,i[9],e?ye(t,i[9],s,wf):be(i[9]),Us)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function Of(r){let e,t,n,i;const s=[Ef,Tf],o=[];function a(l,c){return l[1]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function Nf(r,e,t){let n;const i=["asChild","placeholder","el","id"];let s=De(e,i),o,{$$slots:a={},$$scope:l}=e,{asChild:c=!1}=e,{placeholder:u=void 0}=e,{el:f=void 0}=e,{id:d=void 0}=e;const{elements:{input:h},ids:p,getAttrs:m}=Lr();le(r,h,M=>t(8,o=M));const g=Fr(),b=m("input");function y(M){Pe[M?"unshift":"push"](()=>{f=M,t(0,f)})}return r.$$set=M=>{e=ie(ie({},e),xt(M)),t(6,s=De(e,i)),"asChild"in M&&t(1,c=M.asChild),"placeholder"in M&&t(2,u=M.placeholder),"el"in M&&t(0,f=M.el),"id"in M&&t(7,d=M.id),"$$scope"in M&&t(9,l=M.$$scope)},r.$$.update=()=>{r.$$.dirty&128&&d&&p.trigger.set(d),r.$$.dirty&256&&t(3,n=o),r.$$.dirty&8&&Object.assign(n,b)},[f,c,u,n,h,g,s,d,o,l,a,y]}class aa extends je{constructor(e){super(),We(this,e,Nf,Of,Ne,{asChild:1,placeholder:2,el:0,id:7})}}const Af=r=>({builder:r&16,isSelected:r&32}),Hs=r=>({builder:r[4],isSelected:r[5]}),vf=r=>({builder:r&16,isSelected:r&32}),Gs=r=>({builder:r[4],isSelected:r[5]});function Df(r){let e,t,n,i;const s=r[14].default,o=me(s,r,r[13],Hs),a=o||If(r);let l=[r[4],r[9]],c={};for(let u=0;u<l.length;u+=1)c=ie(c,l[u]);return{c(){e=R("div"),a.c(),se(e,c)},m(u,f){N(u,e,f),a.m(e,null),r[19](e),t=!0,n||(i=[qe(r[4].action(e)),ee(e,"m-click",r[8]),ee(e,"m-pointermove",r[8]),ee(e,"focusin",r[15]),ee(e,"keydown",r[16]),ee(e,"focusout",r[17]),ee(e,"pointerleave",r[18])],n=!0)},p(u,f){o?o.p&&(!t||f&8240)&&ge(o,s,u,u[13],t?ye(s,u[13],f,Af):be(u[13]),Hs):a.p&&(!t||f&5)&&a.p(u,t?f:-1),se(e,c=Fe(l,[f&16&&u[4],f&512&&u[9]]))},i(u){t||(_(a,u),t=!0)},o(u){C(a,u),t=!1},d(u){u&&A(e),a.d(u),r[19](null),n=!1,ft(i)}}}function xf(r){let e;const t=r[14].default,n=me(t,r,r[13],Gs);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&8240)&&ge(n,t,i,i[13],e?ye(t,i[13],s,vf):be(i[13]),Gs)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function If(r){let e=(r[0]||r[2])+"",t;return{c(){t=he(e)},m(n,i){N(n,t,i)},p(n,i){i&5&&e!==(e=(n[0]||n[2])+"")&&xe(t,e)},d(n){n&&A(t)}}}function Pf(r){let e,t,n,i;const s=[xf,Df],o=[];function a(l,c){return l[3]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function Rf(r,e,t){let n,i;const s=["value","disabled","label","asChild","el"];let o=De(e,s),a,l,{$$slots:c={},$$scope:u}=e,{value:f}=e,{disabled:d=void 0}=e,{label:h=void 0}=e,{asChild:p=!1}=e,{el:m=void 0}=e;const{elements:{option:g},helpers:{isSelected:b},getAttrs:y}=sf(f);le(r,g,k=>t(12,l=k)),le(r,b,k=>t(11,a=k));const M=Fr(),T=y("item");function S(k){mt.call(this,r,k)}function E(k){mt.call(this,r,k)}function W(k){mt.call(this,r,k)}function D(k){mt.call(this,r,k)}function v(k){Pe[k?"unshift":"push"](()=>{m=k,t(1,m)})}return r.$$set=k=>{e=ie(ie({},e),xt(k)),t(9,o=De(e,s)),"value"in k&&t(2,f=k.value),"disabled"in k&&t(10,d=k.disabled),"label"in k&&t(0,h=k.label),"asChild"in k&&t(3,p=k.asChild),"el"in k&&t(1,m=k.el),"$$scope"in k&&t(13,u=k.$$scope)},r.$$.update=()=>{r.$$.dirty&5&&!h&&typeof f=="string"&&t(0,h=f),r.$$.dirty&5125&&t(4,n=l({value:f,disabled:d,label:h})),r.$$.dirty&16&&Object.assign(n,T),r.$$.dirty&2052&&t(5,i=a(f))},[h,m,f,p,n,i,g,b,M,o,d,a,l,u,c,S,E,W,D,v]}class ca extends je{constructor(e){super(),We(this,e,Rf,Pf,Ne,{value:2,disabled:10,label:0,asChild:3,el:1})}}function Bf(){return{NAME:"separator",PARTS:["root"]}}function zf(r){const{NAME:e,PARTS:t}=Bf(),n=ns(e,t),i={...Tu(rs(r)),getAttrs:n};return{...i,updateOption:is(i.options)}}const Ff=r=>({builder:r&4}),Ys=r=>({builder:r[2]});function Vf(r){let e,t,n,i=[r[2],r[4]],s={};for(let o=0;o<i.length;o+=1)s=ie(s,i[o]);return{c(){e=R("div"),se(e,s)},m(o,a){N(o,e,a),r[10](e),t||(n=qe(r[2].action(e)),t=!0)},p(o,a){se(e,s=Fe(i,[a&4&&o[2],a&16&&o[4]]))},i:te,o:te,d(o){o&&A(e),r[10](null),t=!1,n()}}}function Lf(r){let e;const t=r[9].default,n=me(t,r,r[8],Ys);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&260)&&ge(n,t,i,i[8],e?ye(t,i[8],s,Ff):be(i[8]),Ys)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function jf(r){let e,t,n,i;const s=[Lf,Vf],o=[];function a(l,c){return l[1]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function Wf(r,e,t){let n;const i=["orientation","decorative","asChild","el"];let s=De(e,i),o,{$$slots:a={},$$scope:l}=e,{orientation:c="horizontal"}=e,{decorative:u=!0}=e,{asChild:f=!1}=e,{el:d=void 0}=e;const{elements:{root:h},updateOption:p,getAttrs:m}=zf({orientation:c,decorative:u});le(r,h,y=>t(7,o=y));const g=m("root");function b(y){Pe[y?"unshift":"push"](()=>{d=y,t(0,d)})}return r.$$set=y=>{e=ie(ie({},e),xt(y)),t(4,s=De(e,i)),"orientation"in y&&t(5,c=y.orientation),"decorative"in y&&t(6,u=y.decorative),"asChild"in y&&t(1,f=y.asChild),"el"in y&&t(0,d=y.el),"$$scope"in y&&t(8,l=y.$$scope)},r.$$.update=()=>{r.$$.dirty&32&&p("orientation",c),r.$$.dirty&64&&p("decorative",u),r.$$.dirty&128&&t(2,n=o),r.$$.dirty&4&&Object.assign(n,g)},[d,f,n,h,s,c,u,o,l,a,b]}class ua extends je{constructor(e){super(),We(this,e,Wf,jf,Ne,{orientation:5,decorative:6,asChild:1,el:0})}}function fa(){return{NAME:"tabs",PARTS:["root","content","list","trigger"]}}function qf(r){const{NAME:e,PARTS:t}=fa(),n=ns(e,t),i={...tf(rs(r)),getAttrs:n};return zr(e,i),{...i,updateOption:is(i.options)}}function ds(){const{NAME:r}=fa();return Ht(r)}const Jf=r=>({builder:r&4,value:r&8}),Xs=r=>({builder:r[2],value:r[3]}),Kf=r=>({builder:r&4,value:r&8}),Zs=r=>({builder:r[2],value:r[3]});function $f(r){let e,t,n,i;const s=r[15].default,o=me(s,r,r[14],Xs);let a=[r[2],r[6]],l={};for(let c=0;c<a.length;c+=1)l=ie(l,a[c]);return{c(){e=R("div"),o&&o.c(),se(e,l)},m(c,u){N(c,e,u),o&&o.m(e,null),r[16](e),t=!0,n||(i=qe(r[2].action(e)),n=!0)},p(c,u){o&&o.p&&(!t||u&16396)&&ge(o,s,c,c[14],t?ye(s,c[14],u,Jf):be(c[14]),Xs),se(e,l=Fe(a,[u&4&&c[2],u&64&&c[6]]))},i(c){t||(_(o,c),t=!0)},o(c){C(o,c),t=!1},d(c){c&&A(e),o&&o.d(c),r[16](null),n=!1,i()}}}function Uf(r){let e;const t=r[15].default,n=me(t,r,r[14],Zs);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&16396)&&ge(n,t,i,i[14],e?ye(t,i[14],s,Kf):be(i[14]),Zs)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function Hf(r){let e,t,n,i;const s=[Uf,$f],o=[];function a(l,c){return l[1]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function Gf(r,e,t){let n;const i=["orientation","activateOnFocus","loop","autoSet","value","onValueChange","asChild","el"];let s=De(e,i),o,a,{$$slots:l={},$$scope:c}=e,{orientation:u=void 0}=e,{activateOnFocus:f=void 0}=e,{loop:d=void 0}=e,{autoSet:h=void 0}=e,{value:p=void 0}=e,{onValueChange:m=void 0}=e,{asChild:g=!1}=e,{el:b=void 0}=e;const{elements:{root:y},states:{value:M},updateOption:T,getAttrs:S}=qf({orientation:u,activateOnFocus:f,loop:d,autoSet:h,defaultValue:p,onValueChange:({next:D})=>(p!==D&&(m==null||m(D),t(7,p=D)),D)});le(r,y,D=>t(13,o=D)),le(r,M,D=>t(3,a=D));const E=S("root");function W(D){Pe[D?"unshift":"push"](()=>{b=D,t(0,b)})}return r.$$set=D=>{e=ie(ie({},e),xt(D)),t(6,s=De(e,i)),"orientation"in D&&t(8,u=D.orientation),"activateOnFocus"in D&&t(9,f=D.activateOnFocus),"loop"in D&&t(10,d=D.loop),"autoSet"in D&&t(11,h=D.autoSet),"value"in D&&t(7,p=D.value),"onValueChange"in D&&t(12,m=D.onValueChange),"asChild"in D&&t(1,g=D.asChild),"el"in D&&t(0,b=D.el),"$$scope"in D&&t(14,c=D.$$scope)},r.$$.update=()=>{r.$$.dirty&128&&p!==void 0&&M.set(p),r.$$.dirty&256&&T("orientation",u),r.$$.dirty&512&&T("activateOnFocus",f),r.$$.dirty&1024&&T("loop",d),r.$$.dirty&2048&&T("autoSet",h),r.$$.dirty&8192&&t(2,n=o),r.$$.dirty&4&&Object.assign(n,E)},[b,g,n,a,y,M,s,p,u,f,d,h,m,o,c,l,W]}class Yf extends je{constructor(e){super(),We(this,e,Gf,Hf,Ne,{orientation:8,activateOnFocus:9,loop:10,autoSet:11,value:7,onValueChange:12,asChild:1,el:0})}}const Xf=r=>({builder:r&4}),Qs=r=>({builder:r[2]}),Zf=r=>({builder:r&4}),eo=r=>({builder:r[2]});function Qf(r){let e,t,n,i;const s=r[8].default,o=me(s,r,r[7],Qs);let a=[r[2],r[4]],l={};for(let c=0;c<a.length;c+=1)l=ie(l,a[c]);return{c(){e=R("div"),o&&o.c(),se(e,l)},m(c,u){N(c,e,u),o&&o.m(e,null),r[9](e),t=!0,n||(i=qe(r[2].action(e)),n=!0)},p(c,u){o&&o.p&&(!t||u&132)&&ge(o,s,c,c[7],t?ye(s,c[7],u,Xf):be(c[7]),Qs),se(e,l=Fe(a,[u&4&&c[2],u&16&&c[4]]))},i(c){t||(_(o,c),t=!0)},o(c){C(o,c),t=!1},d(c){c&&A(e),o&&o.d(c),r[9](null),n=!1,i()}}}function ed(r){let e;const t=r[8].default,n=me(t,r,r[7],eo);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&132)&&ge(n,t,i,i[7],e?ye(t,i[7],s,Zf):be(i[7]),eo)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function td(r){let e,t,n,i;const s=[ed,Qf],o=[];function a(l,c){return l[1]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function nd(r,e,t){let n;const i=["value","asChild","el"];let s=De(e,i),o,{$$slots:a={},$$scope:l}=e,{value:c}=e,{asChild:u=!1}=e,{el:f=void 0}=e;const{elements:{content:d},getAttrs:h}=ds();le(r,d,g=>t(6,o=g));const p=h("content");function m(g){Pe[g?"unshift":"push"](()=>{f=g,t(0,f)})}return r.$$set=g=>{e=ie(ie({},e),xt(g)),t(4,s=De(e,i)),"value"in g&&t(5,c=g.value),"asChild"in g&&t(1,u=g.asChild),"el"in g&&t(0,f=g.el),"$$scope"in g&&t(7,l=g.$$scope)},r.$$.update=()=>{r.$$.dirty&96&&t(2,n=o(c)),r.$$.dirty&4&&Object.assign(n,p)},[f,u,n,d,s,c,o,l,a,m]}class rd extends je{constructor(e){super(),We(this,e,nd,td,Ne,{value:5,asChild:1,el:0})}}const id=r=>({builder:r&4}),to=r=>({builder:r[2]}),sd=r=>({builder:r&4}),no=r=>({builder:r[2]});function od(r){let e,t,n,i;const s=r[7].default,o=me(s,r,r[6],to);let a=[r[2],r[4]],l={};for(let c=0;c<a.length;c+=1)l=ie(l,a[c]);return{c(){e=R("div"),o&&o.c(),se(e,l)},m(c,u){N(c,e,u),o&&o.m(e,null),r[8](e),t=!0,n||(i=qe(r[2].action(e)),n=!0)},p(c,u){o&&o.p&&(!t||u&68)&&ge(o,s,c,c[6],t?ye(s,c[6],u,id):be(c[6]),to),se(e,l=Fe(a,[u&4&&c[2],u&16&&c[4]]))},i(c){t||(_(o,c),t=!0)},o(c){C(o,c),t=!1},d(c){c&&A(e),o&&o.d(c),r[8](null),n=!1,i()}}}function ld(r){let e;const t=r[7].default,n=me(t,r,r[6],no);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&68)&&ge(n,t,i,i[6],e?ye(t,i[6],s,sd):be(i[6]),no)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function ad(r){let e,t,n,i;const s=[ld,od],o=[];function a(l,c){return l[1]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function cd(r,e,t){let n;const i=["asChild","el"];let s=De(e,i),o,{$$slots:a={},$$scope:l}=e,{asChild:c=!1}=e,{el:u=void 0}=e;const{elements:{list:f},getAttrs:d}=ds();le(r,f,m=>t(5,o=m));const h=d("list");function p(m){Pe[m?"unshift":"push"](()=>{u=m,t(0,u)})}return r.$$set=m=>{e=ie(ie({},e),xt(m)),t(4,s=De(e,i)),"asChild"in m&&t(1,c=m.asChild),"el"in m&&t(0,u=m.el),"$$scope"in m&&t(6,l=m.$$scope)},r.$$.update=()=>{r.$$.dirty&32&&t(2,n=o),r.$$.dirty&4&&Object.assign(n,h)},[u,c,n,f,s,o,l,a,p]}class ud extends je{constructor(e){super(),We(this,e,cd,ad,Ne,{asChild:1,el:0})}}const fd=r=>({builder:r&4}),ro=r=>({builder:r[2]}),dd=r=>({builder:r&4}),io=r=>({builder:r[2]});function hd(r){let e,t,n,i;const s=r[10].default,o=me(s,r,r[9],ro);let a=[r[2],{type:"button"},r[5]],l={};for(let c=0;c<a.length;c+=1)l=ie(l,a[c]);return{c(){e=R("button"),o&&o.c(),se(e,l)},m(c,u){N(c,e,u),o&&o.m(e,null),e.autofocus&&e.focus(),r[11](e),t=!0,n||(i=[qe(r[2].action(e)),ee(e,"m-click",r[4]),ee(e,"m-focus",r[4]),ee(e,"m-keydown",r[4])],n=!0)},p(c,u){o&&o.p&&(!t||u&516)&&ge(o,s,c,c[9],t?ye(s,c[9],u,fd):be(c[9]),ro),se(e,l=Fe(a,[u&4&&c[2],{type:"button"},u&32&&c[5]]))},i(c){t||(_(o,c),t=!0)},o(c){C(o,c),t=!1},d(c){c&&A(e),o&&o.d(c),r[11](null),n=!1,ft(i)}}}function pd(r){let e;const t=r[10].default,n=me(t,r,r[9],io);return{c(){n&&n.c()},m(i,s){n&&n.m(i,s),e=!0},p(i,s){n&&n.p&&(!e||s&516)&&ge(n,t,i,i[9],e?ye(t,i[9],s,dd):be(i[9]),io)},i(i){e||(_(n,i),e=!0)},o(i){C(n,i),e=!1},d(i){n&&n.d(i)}}}function md(r){let e,t,n,i;const s=[pd,hd],o=[];function a(l,c){return l[1]?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=de()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,[c]){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function gd(r,e,t){let n;const i=["value","disabled","asChild","el"];let s=De(e,i),o,{$$slots:a={},$$scope:l}=e,{value:c}=e,{disabled:u=void 0}=e,{asChild:f=!1}=e,{el:d=void 0}=e;const{elements:{trigger:h},getAttrs:p}=ds();le(r,h,y=>t(8,o=y));const m=Fr(),g=p("trigger");function b(y){Pe[y?"unshift":"push"](()=>{d=y,t(0,d)})}return r.$$set=y=>{e=ie(ie({},e),xt(y)),t(5,s=De(e,i)),"value"in y&&t(6,c=y.value),"disabled"in y&&t(7,u=y.disabled),"asChild"in y&&t(1,f=y.asChild),"el"in y&&t(0,d=y.el),"$$scope"in y&&t(9,l=y.$$scope)},r.$$.update=()=>{r.$$.dirty&448&&t(2,n=o({value:c,disabled:u})),r.$$.dirty&4&&Object.assign(n,g)},[d,f,n,h,m,s,c,u,o,l,a,b]}class bd extends je{constructor(e){super(),We(this,e,gd,md,Ne,{value:6,disabled:7,asChild:1,el:0})}}/*!
2
- * deep-eql
3
- * Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
4
- * MIT Licensed
5
- */function so(r){if(typeof r>"u")return"undefined";if(r===null)return"null";const e=r[Symbol.toStringTag];return typeof e=="string"?e:Object.prototype.toString.call(r).slice(8,-1)}function da(){this._key="chai/deep-eql__"+Math.random()+Date.now()}da.prototype={get:function(e){return e[this._key]},set:function(e,t){Object.isExtensible(e)&&Object.defineProperty(e,this._key,{value:t,configurable:!0})}};var ha=typeof WeakMap=="function"?WeakMap:da;/*!
6
- * Check to see if the MemoizeMap has recorded a result of the two operands
7
- *
8
- * @param {Mixed} leftHandOperand
9
- * @param {Mixed} rightHandOperand
10
- * @param {MemoizeMap} memoizeMap
11
- * @returns {Boolean|null} result
12
- */function oo(r,e,t){if(!t||gn(r)||gn(e))return null;var n=t.get(r);if(n){var i=n.get(e);if(typeof i=="boolean")return i}return null}/*!
13
- * Set the result of the equality into the MemoizeMap
14
- *
15
- * @param {Mixed} leftHandOperand
16
- * @param {Mixed} rightHandOperand
17
- * @param {MemoizeMap} memoizeMap
18
- * @param {Boolean} result
19
- */function or(r,e,t,n){if(!(!t||gn(r)||gn(e))){var i=t.get(r);i?i.set(e,n):(i=new ha,i.set(e,n),t.set(r,i))}}function jr(r,e,t){if(t&&t.comparator)return lo(r,e,t);var n=pa(r,e);return n!==null?n:lo(r,e,t)}function pa(r,e){return r===e?r!==0||1/r===1/e:r!==r&&e!==e?!0:gn(r)||gn(e)?!1:null}/*!
20
- * The main logic of the `deepEqual` function.
21
- *
22
- * @param {Mixed} leftHandOperand
23
- * @param {Mixed} rightHandOperand
24
- * @param {Object} [options] (optional) Additional options
25
- * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
26
- * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
27
- complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
28
- references to blow the stack.
29
- * @return {Boolean} equal match
30
- */function lo(r,e,t){t=t||{},t.memoize=t.memoize===!1?!1:t.memoize||new ha;var n=t&&t.comparator,i=oo(r,e,t.memoize);if(i!==null)return i;var s=oo(e,r,t.memoize);if(s!==null)return s;if(n){var o=n(r,e);if(o===!1||o===!0)return or(r,e,t.memoize,o),o;var a=pa(r,e);if(a!==null)return a}var l=so(r);if(l!==so(e))return or(r,e,t.memoize,!1),!1;or(r,e,t.memoize,!0);var c=yd(r,e,l,t);return or(r,e,t.memoize,c),c}function yd(r,e,t,n){switch(t){case"String":case"Number":case"Boolean":case"Date":return jr(r.valueOf(),e.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return r===e;case"Error":return ma(r,e,["name","message","code"],n);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return qt(r,e,n);case"RegExp":return kd(r,e);case"Generator":return _d(r,e,n);case"DataView":return qt(new Uint8Array(r.buffer),new Uint8Array(e.buffer),n);case"ArrayBuffer":return qt(new Uint8Array(r),new Uint8Array(e),n);case"Set":return ao(r,e,n);case"Map":return ao(r,e,n);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return r.equals(e);case"Temporal.Duration":return r.total("nanoseconds")===e.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return r.toString()===e.toString();default:return Cd(r,e,n)}}/*!
31
- * Compare two Regular Expressions for equality.
32
- *
33
- * @param {RegExp} leftHandOperand
34
- * @param {RegExp} rightHandOperand
35
- * @return {Boolean} result
36
- */function kd(r,e){return r.toString()===e.toString()}/*!
37
- * Compare two Sets/Maps for equality. Faster than other equality functions.
38
- *
39
- * @param {Set} leftHandOperand
40
- * @param {Set} rightHandOperand
41
- * @param {Object} [options] (Optional)
42
- * @return {Boolean} result
43
- */function ao(r,e,t){try{if(r.size!==e.size)return!1;if(r.size===0)return!0}catch{return!1}var n=[],i=[];return r.forEach(function(o,a){n.push([o,a])}),e.forEach(function(o,a){i.push([o,a])}),qt(n.sort(),i.sort(),t)}/*!
44
- * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
45
- *
46
- * @param {Iterable} leftHandOperand
47
- * @param {Iterable} rightHandOperand
48
- * @param {Object} [options] (Optional)
49
- * @return {Boolean} result
50
- */function qt(r,e,t){var n=r.length;if(n!==e.length)return!1;if(n===0)return!0;for(var i=-1;++i<n;)if(jr(r[i],e[i],t)===!1)return!1;return!0}/*!
51
- * Simple equality for generator objects such as those returned by generator functions.
52
- *
53
- * @param {Iterable} leftHandOperand
54
- * @param {Iterable} rightHandOperand
55
- * @param {Object} [options] (Optional)
56
- * @return {Boolean} result
57
- */function _d(r,e,t){return qt(Ri(r),Ri(e),t)}/*!
58
- * Determine if the given object has an @@iterator function.
59
- *
60
- * @param {Object} target
61
- * @return {Boolean} `true` if the object has an @@iterator function.
62
- */function Sd(r){return typeof Symbol<"u"&&typeof r=="object"&&typeof Symbol.iterator<"u"&&typeof r[Symbol.iterator]=="function"}/*!
63
- * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
64
- * This will consume the iterator - which could have side effects depending on the @@iterator implementation.
65
- *
66
- * @param {Object} target
67
- * @returns {Array} an array of entries from the @@iterator function
68
- */function co(r){if(Sd(r))try{return Ri(r[Symbol.iterator]())}catch{return[]}return[]}/*!
69
- * Gets all entries from a Generator. This will consume the generator - which could have side effects.
70
- *
71
- * @param {Generator} target
72
- * @returns {Array} an array of entries from the Generator.
73
- */function Ri(r){for(var e=r.next(),t=[e.value];e.done===!1;)e=r.next(),t.push(e.value);return t}/*!
74
- * Gets all own and inherited enumerable keys from a target.
75
- *
76
- * @param {Object} target
77
- * @returns {Array} an array of own and inherited enumerable keys from the target.
78
- */function uo(r){var e=[];for(var t in r)e.push(t);return e}function fo(r){for(var e=[],t=Object.getOwnPropertySymbols(r),n=0;n<t.length;n+=1){var i=t[n];Object.getOwnPropertyDescriptor(r,i).enumerable&&e.push(i)}return e}/*!
79
- * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
80
- * each key. If any value of the given key is not equal, the function will return false (early).
81
- *
82
- * @param {Mixed} leftHandOperand
83
- * @param {Mixed} rightHandOperand
84
- * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
85
- * @param {Object} [options] (Optional)
86
- * @return {Boolean} result
87
- */function ma(r,e,t,n){var i=t.length;if(i===0)return!0;for(var s=0;s<i;s+=1)if(jr(r[t[s]],e[t[s]],n)===!1)return!1;return!0}/*!
88
- * Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
89
- * for each enumerable key in the object.
90
- *
91
- * @param {Mixed} leftHandOperand
92
- * @param {Mixed} rightHandOperand
93
- * @param {Object} [options] (Optional)
94
- * @return {Boolean} result
95
- */function Cd(r,e,t){var n=uo(r),i=uo(e),s=fo(r),o=fo(e);if(n=n.concat(s),i=i.concat(o),n.length&&n.length===i.length)return qt(ho(n).sort(),ho(i).sort())===!1?!1:ma(r,e,n,t);var a=co(r),l=co(e);return a.length&&a.length===l.length?(a.sort(),l.sort(),qt(a,l,t)):n.length===0&&a.length===0&&i.length===0&&l.length===0}/*!
96
- * Returns true if the argument is a primitive.
97
- *
98
- * This intentionally returns true for all objects that can be compared by reference,
99
- * including functions and symbols.
100
- *
101
- * @param {Mixed} value
102
- * @return {Boolean} result
103
- */function gn(r){return r===null||typeof r!="object"}function ho(r){return r.map(function(t){return typeof t=="symbol"?t.toString():t})}function po(r,e,t){var l;const n=r.slice();n[9]=e[t].type,n[10]=e[t].content,n[16]=t;const i=`${n[1]}-${n[16]}`;n[11]=i;const s=!!((l=n[10])!=null&&l.length);n[12]=s;const o=n[2]({id:n[11]});n[13]=o;const a=n[3]({id:n[11],hasChildren:n[12]});return n[14]=a,n}function Md(r){let e,t;return e=new Me({}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function wd(r){let e,t;return e=new Me({props:{path:Eu}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function Td(r){let e,t;return e=new Me({props:{path:Vr}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function mo(r){let e,t,n,i,s;t=new ga({props:{treeItems:r[10],parent:r[11]}});let o=[r[13]],a={};for(let l=0;l<o.length;l+=1)a=ie(a,o[l]);return{c(){e=R("ol"),F(t.$$.fragment),se(e,a)},m(l,c){N(l,e,c),V(t,e,null),n=!0,i||(s=qe(r[13].action(e)),i=!0)},p(l,c){const u={};c&1&&(u.treeItems=l[10]),c&2&&(u.parent=l[11]),t.$set(u),se(e,a=Fe(o,[c&6&&l[13]]))},i(l){n||(_(t.$$.fragment,l),n=!0)},o(l){C(t.$$.fragment,l),n=!1},d(l){l&&A(e),L(t),i=!1,s()}}}function go(r){let e,t,n,i,s,o,a,l=r[9]+"",c,u,f,d,h,p;const m=[Td,wd,Md],g=[];function b(S,E){return E&19&&(n=null),n==null&&(n=!!(S[12]&&S[4](S[11]))),n?0:S[12]?1:2}i=b(r,-1),s=g[i]=m[i](r);let y=[{class:"flex items-center gap-1 p-1"},r[14]],M={};for(let S=0;S<y.length;S+=1)M=ie(M,y[S]);let T=r[10]&&mo(r);return{c(){e=R("li"),t=R("button"),s.c(),o=K(),a=R("span"),c=he(l),u=K(),T&&T.c(),f=K(),q(a,"class","select-none"),se(t,M),q(e,"role","none")},m(S,E){N(S,e,E),P(e,t),g[i].m(t,null),P(t,o),P(t,a),P(a,c),t.autofocus&&t.focus(),P(e,u),T&&T.m(e,null),P(e,f),d=!0,h||(p=qe(r[14].action(t)),h=!0)},p(S,E){let W=i;i=b(S,E),i!==W&&(ne(),C(g[W],1,1,()=>{g[W]=null}),re(),s=g[i],s||(s=g[i]=m[i](S),s.c()),_(s,1),s.m(t,o)),(!d||E&1)&&l!==(l=S[9]+"")&&xe(c,l),se(t,M=Fe(y,[{class:"flex items-center gap-1 p-1"},E&11&&S[14]])),S[10]?T?(T.p(S,E),E&1&&_(T,1)):(T=mo(S),T.c(),_(T,1),T.m(e,f)):T&&(ne(),C(T,1,1,()=>{T=null}),re())},i(S){d||(_(s),_(T),d=!0)},o(S){C(s),C(T),d=!1},d(S){S&&A(e),g[i].d(),T&&T.d(),h=!1,p()}}}function Ed(r){let e,t,n=fe(r[0]),i=[];for(let o=0;o<n.length;o+=1)i[o]=go(po(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o<i.length;o+=1)i[o].c();e=de()},m(o,a){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(o,a);N(o,e,a),t=!0},p(o,[a]){if(a&31){n=fe(o[0]);let l;for(l=0;l<n.length;l+=1){const c=po(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=go(c),i[l].c(),_(i[l],1),i[l].m(e.parentNode,e))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function Od(r,e,t){let n,i,s,{treeItems:o}=e,{parent:a="metadata-tree"}=e;const{elements:{item:l,group:c},helpers:{isExpanded:u,isSelected:f}}=Ht("tree");return le(r,l,d=>t(3,i=d)),le(r,c,d=>t(2,n=d)),le(r,u,d=>t(4,s=d)),r.$$set=d=>{"treeItems"in d&&t(0,o=d.treeItems),"parent"in d&&t(1,a=d.parent)},[o,a,n,i,s,l,c,u]}class ga extends je{constructor(e){super(),We(this,e,Od,Ed,Ne,{treeItems:0,parent:1})}}function bo(r,e,t){const n=r.slice();return n[22]=e[t],n[24]=t,n}function yo(r){let e,t,n,i,s;e=new Cn({props:{class:"border-b border-gray-300",$$slots:{default:[Id]},$$scope:{ctx:r}}}),i=new ga({props:{treeItems:r[0].content}});let o=[r[2]],a={};for(let l=0;l<o.length;l+=1)a=ie(a,o[l]);return{c(){F(e.$$.fragment),t=K(),n=R("ol"),F(i.$$.fragment),se(n,a)},m(l,c){V(e,l,c),N(l,t,c),N(l,n,c),V(i,n,null),s=!0},p(l,c){const u={};c&33554434&&(u.$$scope={dirty:c,ctx:l}),e.$set(u);const f={};c&1&&(f.treeItems=l[0].content),i.$set(f),se(n,a=Fe(o,[c&4&&l[2]]))},i(l){s||(_(e.$$.fragment,l),_(i.$$.fragment,l),s=!0)},o(l){C(e.$$.fragment,l),C(i.$$.fragment,l),s=!1},d(l){l&&(A(t),A(n)),L(e,l),L(i)}}}function Nd(r){let e,t;return e=new Me({props:{path:as}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function Ad(r){let e,t;return e=new Me({props:{path:cs}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function vd(r){let e,t;return e=new Me({props:{path:Vr}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function Dd(r){let e,t;return e=new Me({props:{path:us}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function xd(r){let e,t;return e=new Me({props:{path:Nu}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function Id(r){let e,t,n,i,s,o,a,l,c,u,f,d,h,p;return e=new Qe({props:{title:"Add a metadata node",$$slots:{default:[Nd]},$$scope:{ctx:r}}}),e.$on("click",r[8]),n=new ua({props:{class:"border-r border-gray-300 mx-2"}}),s=new Qe({props:{title:"Move the selected metadata node up","aria-disabled":r[1]!==null?null:"true",$$slots:{default:[Ad]},$$scope:{ctx:r}}}),s.$on("click",r[10]),a=new Qe({props:{title:"Move the selected metadata node down","aria-disabled":r[1]!==null?null:"true",$$slots:{default:[vd]},$$scope:{ctx:r}}}),a.$on("click",r[11]),c=new Qe({props:{title:"Remove the selected metadata node","aria-disabled":r[1]!==null?null:"true",$$slots:{default:[Dd]},$$scope:{ctx:r}}}),c.$on("click",r[9]),h=new Qe({props:{title:"Clear the selection","aria-disabled":r[1]!==null?null:"true",$$slots:{default:[xd]},$$scope:{ctx:r}}}),h.$on("click",r[15]),{c(){F(e.$$.fragment),t=K(),F(n.$$.fragment),i=K(),F(s.$$.fragment),o=K(),F(a.$$.fragment),l=K(),F(c.$$.fragment),u=K(),f=R("div"),d=K(),F(h.$$.fragment),q(f,"class","flex-1")},m(m,g){V(e,m,g),N(m,t,g),V(n,m,g),N(m,i,g),V(s,m,g),N(m,o,g),V(a,m,g),N(m,l,g),V(c,m,g),N(m,u,g),N(m,f,g),N(m,d,g),V(h,m,g),p=!0},p(m,g){const b={};g&33554432&&(b.$$scope={dirty:g,ctx:m}),e.$set(b);const y={};g&2&&(y["aria-disabled"]=m[1]!==null?null:"true"),g&33554432&&(y.$$scope={dirty:g,ctx:m}),s.$set(y);const M={};g&2&&(M["aria-disabled"]=m[1]!==null?null:"true"),g&33554432&&(M.$$scope={dirty:g,ctx:m}),a.$set(M);const T={};g&2&&(T["aria-disabled"]=m[1]!==null?null:"true"),g&33554432&&(T.$$scope={dirty:g,ctx:m}),c.$set(T);const S={};g&2&&(S["aria-disabled"]=m[1]!==null?null:"true"),g&33554432&&(S.$$scope={dirty:g,ctx:m}),h.$set(S)},i(m){p||(_(e.$$.fragment,m),_(n.$$.fragment,m),_(s.$$.fragment,m),_(a.$$.fragment,m),_(c.$$.fragment,m),_(h.$$.fragment,m),p=!0)},o(m){C(e.$$.fragment,m),C(n.$$.fragment,m),C(s.$$.fragment,m),C(a.$$.fragment,m),C(c.$$.fragment,m),C(h.$$.fragment,m),p=!1},d(m){m&&(A(t),A(i),A(o),A(l),A(u),A(f),A(d)),L(e,m),L(n,m),L(s,m),L(a,m),L(c,m),L(h,m)}}}function Pd(r){let e;return{c(){e=R("p"),e.textContent="Please select a metadata node on the left"},m(t,n){N(t,e,n)},p:te,i:te,o:te,d(t){t&&A(e)}}}function Rd(r){let e,t,n,i,s,o,a,l,c,u,f,d,h,p,m,g,b,y=fe(r[1].attrs),M=[];for(let S=0;S<y.length;S+=1)M[S]=ko(bo(r,y,S));const T=S=>C(M[S],1,1,()=>{M[S]=null});return p=new Cn({props:{$$slots:{default:[Vd]},$$scope:{ctx:r}}}),{c(){e=R("label"),t=R("span"),t.textContent="Tag",n=K(),i=R("input"),o=K(),a=R("label"),l=R("span"),l.textContent="Text",c=K(),u=R("input"),d=K();for(let S=0;S<M.length;S+=1)M[S].c();h=K(),F(p.$$.fragment),q(t,"data-form-field-label",""),q(i,"type","text"),i.value=s=r[1].type,q(i,"data-form-field-text",""),q(e,"class","block mb-2"),q(l,"data-form-field-label",""),q(u,"type","text"),u.value=f=r[1].text,q(u,"data-form-field-text",""),q(a,"class","block mb-2")},m(S,E){N(S,e,E),P(e,t),P(e,n),P(e,i),N(S,o,E),N(S,a,E),P(a,l),P(a,c),P(a,u),N(S,d,E);for(let W=0;W<M.length;W+=1)M[W]&&M[W].m(S,E);N(S,h,E),V(p,S,E),m=!0,g||(b=[ee(i,"change",r[6]),ee(u,"change",r[7])],g=!0)},p(S,E){if((!m||E&2&&s!==(s=S[1].type)&&i.value!==s)&&(i.value=s),(!m||E&2&&f!==(f=S[1].text)&&u.value!==f)&&(u.value=f),E&24578){y=fe(S[1].attrs);let D;for(D=0;D<y.length;D+=1){const v=bo(S,y,D);M[D]?(M[D].p(v,E),_(M[D],1)):(M[D]=ko(v),M[D].c(),_(M[D],1),M[D].m(h.parentNode,h))}for(ne(),D=y.length;D<M.length;D+=1)T(D);re()}const W={};E&33554432&&(W.$$scope={dirty:E,ctx:S}),p.$set(W)},i(S){if(!m){for(let E=0;E<y.length;E+=1)_(M[E]);_(p.$$.fragment,S),m=!0}},o(S){M=M.filter(Boolean);for(let E=0;E<M.length;E+=1)C(M[E]);C(p.$$.fragment,S),m=!1},d(S){S&&(A(e),A(o),A(a),A(d),A(h)),rt(M,S),L(p,S),g=!1,ft(b)}}}function Bd(r){let e,t;return e=new Me({props:{path:us}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function zd(r){let e,t;function n(...i){return r[18](r[24],...i)}return e=new Qe({props:{title:"Move the selected metadata node up","aria-disabled":r[1]!==null?null:"true",$$slots:{default:[Bd]},$$scope:{ctx:r}}}),e.$on("click",n),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s&2&&(o["aria-disabled"]=r[1]!==null?null:"true"),s&33554432&&(o.$$scope={dirty:s,ctx:r}),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function ko(r){let e,t,n,i,s,o,a,l,c,u,f,d,h,p,m,g,b;function y(...T){return r[16](r[24],...T)}function M(...T){return r[17](r[24],...T)}return p=new Cn({props:{class:"border-b border-gray-300",$$slots:{default:[zd]},$$scope:{ctx:r}}}),{c(){e=R("div"),t=R("label"),n=R("span"),n.textContent="Name",i=K(),s=R("input"),a=K(),l=R("label"),c=R("span"),c.textContent="Value",u=K(),f=R("input"),h=K(),F(p.$$.fragment),q(n,"data-form-field-label",""),q(s,"type","text"),s.value=o=r[22].type,q(s,"data-form-field-text",""),q(t,"class","flex-1"),q(c,"data-form-field-label",""),q(f,"type","text"),f.value=d=r[22].value,q(f,"data-form-field-text",""),q(l,"class","flex-1"),q(e,"class","flex flex-row mb-2")},m(T,S){N(T,e,S),P(e,t),P(t,n),P(t,i),P(t,s),P(e,a),P(e,l),P(l,c),P(l,u),P(l,f),P(e,h),V(p,e,null),m=!0,g||(b=[ee(s,"change",y),ee(f,"change",M)],g=!0)},p(T,S){r=T,(!m||S&2&&o!==(o=r[22].type)&&s.value!==o)&&(s.value=o),(!m||S&2&&d!==(d=r[22].value)&&f.value!==d)&&(f.value=d);const E={};S&33554434&&(E.$$scope={dirty:S,ctx:r}),p.$set(E)},i(T){m||(_(p.$$.fragment,T),m=!0)},o(T){C(p.$$.fragment,T),m=!1},d(T){T&&A(e),L(p),g=!1,ft(b)}}}function Fd(r){let e,t;return e=new Me({props:{path:as}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function Vd(r){let e,t,n,i;return n=new Qe({props:{title:"Add a metadata node",$$slots:{default:[Fd]},$$scope:{ctx:r}}}),n.$on("click",r[12]),{c(){e=R("div"),t=K(),F(n.$$.fragment),q(e,"class","flex-1")},m(s,o){N(s,e,o),N(s,t,o),V(n,s,o),i=!0},p(s,o){const a={};o&33554432&&(a.$$scope={dirty:o,ctx:s}),n.$set(a)},i(s){i||(_(n.$$.fragment,s),i=!0)},o(s){C(n.$$.fragment,s),i=!1},d(s){s&&(A(e),A(t)),L(n,s)}}}function Ld(r){let e,t,n,i,s,o,a,l=r[0]&&yo(r);const c=[Rd,Pd],u=[];function f(d,h){return d[1]?0:1}return s=f(r),o=u[s]=c[s](r),{c(){e=R("div"),t=R("div"),l&&l.c(),n=K(),i=R("div"),o.c(),q(t,"class","w-1/4 overflow-auto border-r border-gray-300"),q(i,"class","flex-1 px-2 py-1"),q(e,"class","flex flex-row w-full h-full overflow-auto")},m(d,h){N(d,e,h),P(e,t),l&&l.m(t,null),P(e,n),P(e,i),u[s].m(i,null),a=!0},p(d,[h]){d[0]?l?(l.p(d,h),h&1&&_(l,1)):(l=yo(d),l.c(),_(l,1),l.m(t,null)):l&&(ne(),C(l,1,1,()=>{l=null}),re());let p=s;s=f(d),s===p?u[s].p(d,h):(ne(),C(u[p],1,1,()=>{u[p]=null}),re(),o=u[s],o?o.p(d,h):(o=u[s]=c[s](d),o.c()),_(o,1),o.m(i,null))},i(d){a||(_(l),_(o),a=!0)},o(d){C(l),C(o),a=!1},d(d){d&&A(e),l&&l.d(),u[s].d()}}}function ot(r,e){const t=e.substring(14).split("-").map(n=>Number.parseInt(n));for(let n of t)r&&(r=r.content[n]);if(r)return r}function jd(r,e){r.preventDefault()}function Wd(r,e,t){let n,i,s,{section:o=null}=e;const a=ls(),l=Ou({defaultExpanded:["file-tree--1-0"]});zr("tree",l);const{elements:{tree:c},states:{selectedItem:u}}=l;le(r,c,v=>t(2,s=v)),le(r,u,v=>t(19,n=v));const f=St(u,v=>{if(v!==null&&o){const k=v.getAttribute("data-id");if(k){const w=ot(o,k);if(w)return w}}return null});le(r,f,v=>t(1,i=v));function d(v){if(v.preventDefault(),n!==null&&o){const k=n.getAttribute("data-id");if(k){const w=ot(o,k);w&&(w.type=v.target.value,a("update",o),t(0,o))}}}function h(v){if(v.preventDefault(),n!==null&&o){const k=n.getAttribute("data-id");if(k){const w=ot(o,k);w&&(w.text=v.target.value,a("update",o))}}}function p(v){if(v.preventDefault(),o){const k={type:"newNode",text:"",attrs:[],content:[]};if(n){const w=n.getAttribute("data-id");if(w){const J=ot(o,w);J&&J.content.push(k)}}else o.content.push(k);a("update",o),t(0,o)}}function m(v){if(v.preventDefault(),o&&n){const k=n.getAttribute("data-id");if(k){const w=k.split("-"),J=w.slice(0,w.length-1),H=ot(o,J.join("-"));H?(H.content.splice(Number.parseInt(w[w.length-1]),1),a("update",o),t(0,o)):(o.content.splice(Number.parseInt(w[w.length-1]),1),a("update",o),t(0,o))}}}function g(v){if(v.preventDefault(),o&&n){const k=n.getAttribute("data-id");if(k){const w=k.split("-"),J=w.slice(0,w.length-1),H=ot(o,J.join("-")),Y=Number.parseInt(w[w.length-1]);if(H&&Y>0){const ae=H.content.splice(Y,1);H.content.splice(Y-1,0,...ae),u.set(null),a("update",o),t(0,o)}else if(Y>0){const ae=o.content.splice(Y,1);o.content.splice(Y-1,0,...ae),u.set(null),a("update",o),t(0,o)}}}}function b(v){if(v.preventDefault(),o&&n){const k=n.getAttribute("data-id");if(k){const w=k.split("-"),J=w.slice(0,w.length-1),H=ot(o,J.join("-")),Y=Number.parseInt(w[w.length-1]);if(H&&Y<H.content.length-1){const ae=H.content.splice(Y,1);H.content.splice(Y+1,0,...ae),u.set(null),a("update",o),t(0,o)}else if(Y<o.content.length-1){const ae=o.content.splice(Y,1);o.content.splice(Y+1,0,...ae),u.set(null),a("update",o),t(0,o)}}}}function y(v){if(v.preventDefault(),n!==null&&o){const k=n.getAttribute("data-id");if(k){const w=ot(o,k);w&&(w.attrs.push({type:"",value:""}),a("update",o),t(0,o),u.set(n))}}}function M(v,k){if(v.preventDefault(),n!==null&&o){const w=n.getAttribute("data-id");if(w){const J=ot(o,w);J&&k>=0&&k<J.attrs.length&&(J.attrs[k].type=v.target.value,a("update",o),t(0,o),u.set(n))}}}function T(v,k){if(v.preventDefault(),n!==null&&o){const w=n.getAttribute("data-id");if(w){const J=ot(o,w);J&&k>=0&&k<J.attrs.length&&(J.attrs[k].value=v.target.value,a("update",o),t(0,o),u.set(n))}}}const S=()=>{u.set(null)},E=(v,k)=>{M(k,v)},W=(v,k)=>{T(k,v)},D=(v,k)=>{jd(k)};return r.$$set=v=>{"section"in v&&t(0,o=v.section)},[o,i,s,c,u,f,d,h,p,m,g,b,y,M,T,S,E,W,D]}class qd extends je{constructor(e){super(),We(this,e,Wd,Ld,Ne,{section:0})}}var An={},Zt={};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.cloneArrayBuffer=void 0;function Jd(r){var e=new ArrayBuffer(r.byteLength);return new Uint8Array(e).set(new Uint8Array(r)),e}Zt.cloneArrayBuffer=Jd;var Un={};Object.defineProperty(Un,"__esModule",{value:!0});Un.cloneDataView=void 0;var Kd=Zt;function $d(r){var e=(0,Kd.cloneArrayBuffer)(r.buffer);return new DataView(e,r.byteOffset,r.byteLength)}Un.cloneDataView=$d;var Hn={};Object.defineProperty(Hn,"__esModule",{value:!0});Hn.cloneDate=void 0;function Ud(r){return new Date(r.getTime())}Hn.cloneDate=Ud;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});Gn.cloneRegExp=void 0;function Hd(r){var e=new RegExp(r.source,r.flags);return e.lastIndex=r.lastIndex,e}Gn.cloneRegExp=Hd;var Yn={};Object.defineProperty(Yn,"__esModule",{value:!0});Yn.cloneTypedArray=void 0;var Gd=Zt,ai={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray};function Yd(r){try{ai["[object BigInt64Array]"]=BigInt64Array,ai["[object BigUint64Array]"]=BigUint64Array}catch{}var e=(0,Gd.cloneArrayBuffer)(r.buffer);return new ai[Object.prototype.toString.call(r)](e,r.byteOffset,r.length)}Yn.cloneTypedArray=Yd;var Tn={},En={},_o;function Xd(){if(_o)return En;_o=1,Object.defineProperty(En,"__esModule",{value:!0}),En.cloneMap=void 0;var r=ba();function e(t){var n=new Map;return t.forEach(function(i,s){return n.set((0,r.deepCopy)(s),(0,r.deepCopy)(i))}),n}return En.cloneMap=e,En}var So;function ba(){if(So)return Tn;So=1;var r=zs&&zs.__assign||function(){return r=Object.assign||function(c){for(var u,f=1,d=arguments.length;f<d;f++){u=arguments[f];for(var h in u)Object.prototype.hasOwnProperty.call(u,h)&&(c[h]=u[h])}return c},r.apply(this,arguments)};Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.deepCopy=void 0;var e=Zt,t=Un,n=Hn,i=Xd(),s=Gn,o=Yn,a={"[object Date]":n.cloneDate,"[object ArrayBuffer]":e.cloneArrayBuffer,"[object DataView]":t.cloneDataView,"[object Float32Array]":o.cloneTypedArray,"[object Float64Array]":o.cloneTypedArray,"[object Int8Array]":o.cloneTypedArray,"[object Int16Array]":o.cloneTypedArray,"[object Int32Array]":o.cloneTypedArray,"[object Uint8Array]":o.cloneTypedArray,"[object Uint8ClampedArray]":o.cloneTypedArray,"[object Uint16Array]":o.cloneTypedArray,"[object Uint32Array]":o.cloneTypedArray,"[object BigInt64Array]":o.cloneTypedArray,"[object BigUint64Array]":o.cloneTypedArray,"[object RegExp]":s.cloneRegExp,"[object Map]":i.cloneMap};function l(c){var u=Object.prototype.toString.call(c);if(a[u])return a[u](c);if(c===null)return c;if(c instanceof Array){var f=[];return c.forEach(function(h){f.push(h)}),f.map(function(h){return l(h)})}if(typeof c=="object"){var d=r({},c);return Object.keys(d).forEach(function(h){d[h]=l(d[h])}),d}return c}return Tn.deepCopy=l,Tn}(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.deepCopy=r.cloneTypedArray=r.cloneRegExp=r.cloneDate=r.cloneDataView=r.cloneArrayBuffer=void 0;var e=Zt;Object.defineProperty(r,"cloneArrayBuffer",{enumerable:!0,get:function(){return e.cloneArrayBuffer}});var t=Un;Object.defineProperty(r,"cloneDataView",{enumerable:!0,get:function(){return t.cloneDataView}});var n=Hn;Object.defineProperty(r,"cloneDate",{enumerable:!0,get:function(){return n.cloneDate}});var i=Gn;Object.defineProperty(r,"cloneRegExp",{enumerable:!0,get:function(){return i.cloneRegExp}});var s=Yn;Object.defineProperty(r,"cloneTypedArray",{enumerable:!0,get:function(){return s.cloneTypedArray}});var o=ba();Object.defineProperty(r,"deepCopy",{enumerable:!0,get:function(){return o.deepCopy}})})(An);function Ee(r){this.content=r}Ee.prototype={constructor:Ee,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),s=n.content.slice();return i==-1?s.push(t||r,e):(s[i+1]=e,t&&(s[i]=t)),new Ee(s)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ee(t)},addToStart:function(r,e){return new Ee([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new Ee(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),s=n.find(r);return i.splice(s==-1?i.length:s,0,e,t),new Ee(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=Ee.from(r),r.size?new Ee(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=Ee.from(r),r.size?new Ee(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=Ee.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};Ee.from=function(r){if(r instanceof Ee)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new Ee(e)};function ya(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=ya(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function ka(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){t-=l,n-=l;continue}if(!o.sameMarkup(a))return{a:t,b:n};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;c<u&&o.text[o.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(o.content.size||a.content.size){let c=ka(o.content,a.content,t-1,n-1);if(c)return c}t-=l,n-=l}}class O{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,a=0;a<t;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&n(l,i+a,s||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,t-u),n,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(o?o=!1:s+=n),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new O(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),n.push(a),i+=a.nodeSize),o=l}return new O(n,i)}cutByIndex(e,t){return e==t?O.empty:e==0&&t==this.content.length?this:new O(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new O(i,s)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return ya(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ka(this,e,t,n)}findIndex(e,t=-1){if(e==0)return lr(0,e);if(e==this.size)return lr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let s=this.child(n),o=i+s.nodeSize;if(o>=e)return o==e||t>0?lr(n+1,o):lr(n,i);i=o}}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 O.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new O(t||e,n)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const ci={index:0,offset:0};function lr(r,e){return ci.index=r,ci.offset=e,ci}function Tr(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!Tr(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Tr(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}let ce=class Bi{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Tr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Bi.none;if(e instanceof Bi)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};ce.none=[];class Er extends Error{}class B{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Sa(this.content,e+this.openStart,t);return n&&new B(n,this.openStart,this.openEnd)}removeBetween(e,t){return new B(_a(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 B.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new B(O.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new B(e,n,i)}}B.empty=new B(O.empty,0,0);function _a(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:a}=r.findIndex(t);if(i==e||s.isText){if(a!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(_a(s.content,e-i-1,t-i-1)))}function Sa(r,e,t,n){let{index:i,offset:s}=r.findIndex(e),o=r.maybeChild(i);if(s==e||o.isText)return r.cut(0,e).append(t).append(r.cut(e));let a=Sa(o.content,e-s-1,t);return a&&r.replaceChild(i,o.copy(a))}function Zd(r,e,t){if(t.openStart>r.depth)throw new Er("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Er("Inconsistent open depths");return Ca(r,e,t,0)}function Ca(r,e,t,n){let i=r.index(n),s=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let o=Ca(r,e,t,n+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let o=r.parent,a=o.content;return Kt(o,a.cut(0,r.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=Qd(t,r);return Kt(s,wa(r,o,a,e,n))}else return Kt(s,Or(r,e,n))}function Ma(r,e){if(!e.type.compatibleContent(r.type))throw new Er("Cannot join "+e.type.name+" onto "+r.type.name)}function zi(r,e,t){let n=r.node(t);return Ma(n,e.node(t)),n}function Jt(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function Pn(r,e,t,n){let i=(e||r).node(t),s=0,o=e?e.index(t):i.childCount;r&&(s=r.index(t),r.depth>t?s++:r.textOffset&&(Jt(r.nodeAfter,n),s++));for(let a=s;a<o;a++)Jt(i.child(a),n);e&&e.depth==t&&e.textOffset&&Jt(e.nodeBefore,n)}function Kt(r,e){return r.type.checkContent(e),r.copy(e)}function wa(r,e,t,n,i){let s=r.depth>i&&zi(r,e,i+1),o=n.depth>i&&zi(t,n,i+1),a=[];return Pn(null,r,i,a),s&&o&&e.index(i)==t.index(i)?(Ma(s,o),Jt(Kt(s,wa(r,e,t,n,i+1)),a)):(s&&Jt(Kt(s,Or(r,e,i+1)),a),Pn(e,t,i,a),o&&Jt(Kt(o,Or(t,n,i+1)),a)),Pn(n,null,i,a),new O(a)}function Or(r,e,t){let n=[];if(Pn(null,r,t,n),r.depth>t){let i=zi(r,e,t+1);Jt(Kt(i,Or(r,e,t+1)),n)}return Pn(e,null,t,n),new O(n)}function Qd(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(O.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class Fn{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,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 n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):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 n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=n.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ce.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let a=n;n=i,i=a}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!i||!n[s].isInSet(i.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Nr(this,e,n);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<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,s=t;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(n.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new Fn(t,n,s)}static resolveCached(e,t){let n=Co.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else Co.set(e,n=new eh);let i=n.elts[n.i]=Fn.resolve(e,t);return n.i=(n.i+1)%th,i}}class eh{constructor(){this.elts=[],this.i=0}}const th=12,Co=new WeakMap;class Nr{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const nh=Object.create(null);let Et=class Fi{constructor(e,t,n,i=ce.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Tr(this.attrs,t||e.defaultAttrs||nh)&&ce.sameSet(this.marks,n||ce.none)}copy(e=null){return e==this.content?this:new Fi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Fi(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return B.empty;let i=this.resolve(e),s=this.resolve(t),o=n?0:i.sharedDepth(t),a=i.start(o),c=i.node(o).content.cut(i.pos-a,s.pos-a);return new B(c,i.depth-o,s.depth-o)}replace(e,t,n){return Zd(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return Fn.resolveCached(this,e)}resolveNoCache(e){return Fn.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(n.isInSet(s.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()+")"),Ta(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,n=O.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(n.child(l).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ce.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ce.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.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 n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=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,n)}let i=O.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,n);return s.type.checkAttrs(s.attrs),s}};Et.prototype.text=void 0;class Ar extends Et{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ta(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 Ar(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ar(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 Ta(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class Gt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new rh(e,t);if(n.next==null)return Gt.empty;let i=Ea(n);n.next&&n.err("Unexpected trailing text");let s=uh(ch(i));return fh(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let s=t;i&&s<n;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function s(o,a){let l=o.matchFragment(e,n);if(l&&(!t||l.validEnd))return O.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:f}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=s(f,a.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||l.validEnd)&&(n.push({match:a.contentMatch,type:a,via:i}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=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(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let s=i+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
104
- `)}}Gt.empty=new Gt(!0);class rh{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 Ea(r){let e=[];do e.push(ih(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ih(r){let e=[];do e.push(sh(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function sh(r){let e=ah(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=oh(r,e);else break;return e}function Mo(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function oh(r,e){let t=Mo(r),n=t;return r.eat(",")&&(r.next!="}"?n=Mo(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function lh(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function ah(r){if(r.eat("(")){let e=Ea(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=lh(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ch(r){let e=[[]];return i(s(r,0),t()),e;function t(){return e.push([])-1}function n(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=t())}else if(o.type=="star"){let l=t();return n(a,l),i(s(o.expr,l),l),[n(l)]}else if(o.type=="plus"){let l=t();return i(s(o.expr,a),l),i(s(o.expr,l),l),[n(l)]}else{if(o.type=="opt")return[n(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,l),u),l=u}if(o.max==-1)i(s(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let u=t();n(l,u),i(s(o.expr,l),u),l=u}return[n(l)]}else{if(o.type=="name")return[n(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Oa(r,e){return e-r}function wo(r,e){let t=[];return n(e),t.sort(Oa);function n(i){let s=r[i];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:a,to:l}=s[o];!a&&t.indexOf(l)==-1&&n(l)}}}function uh(r){let e=Object.create(null);return t(wo(r,0));function t(n){let i=[];n.forEach(o=>{r[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<i.length;u++)i[u][0]==a&&(c=i[u][1]);wo(r,l).forEach(u=>{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[n.join(",")]=new Gt(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let a=i[o][1].sort(Oa);s.next.push({type:i[o][0],next:e[a.join(",")]||t(a)})}return s}}function fh(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],s=!i.validEnd,o=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];o.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),n.indexOf(c)==-1&&n.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Na(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Aa(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let s=r[n];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function va(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in r){let s=r[i];s.validate&&s.validate(e[i])}}function Da(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new hh(r,n,e[n]);return t}let To=class xa{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Da(e,n.attrs),this.defaultAttrs=Na(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Gt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Aa(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(e),O.from(t),ce.setFrom(n))}createChecked(e=null,t,n){return t=O.from(t),this.checkContent(t),new Et(this,this.computeAttrs(e),t,ce.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=O.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(O.empty,!0);return s?new Et(this,e,t.append(s),ce.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){va(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:ce.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new xa(s,t,o));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function dh(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}class hh{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?dh(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Wr{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Da(e,i.attrs),this.excluded=null;let s=Na(this.attrs);this.instance=s?new ce(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ce(this,Aa(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new Wr(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){va(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ia{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=Ee.from(e.nodes),t.marks=Ee.from(e.marks||{}),this.nodes=To.compile(this.spec.nodes,this),this.marks=Wr.compile(this.spec.marks,this);let n=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 s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=n[o]||(n[o]=Gt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Eo(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Eo(this,o.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,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof To){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,n,i)}text(e,t){let n=this.nodes.text;return new Ar(n,n.defaultAttrs,e,ce.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Et.fromJSON(this,e)}markFromJSON(e){return ce.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Eo(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=r.marks[i],o=s;if(s)t.push(s);else for(let a in r.marks){let l=r.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function ph(r){return r.tag!=null}function mh(r){return r.style!=null}class Ot{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(ph(i))this.tags.push(i);else if(mh(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new No(this,t,!1);return n.addAll(e,ce.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new No(this,t,!0);return n.addAll(e,ce.none,t.from,t.to),B.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(yh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let a=t[o];if((a.priority==null?50:a.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=Ao(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=Ao(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ot(e,Ot.schemaRules(e)))}}const Pa={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},gh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ra={ol:!0,ul:!0},Vn=1,Vi=2,br=4;function Oo(r,e,t){return e!=null?(e?Vn:0)|(e==="full"?Vi:0):r&&r.whitespace=="pre"?Vn|Vi:t&-5}class ar{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=ce.none,this.match=s||(o&br?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(O.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vn)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=O.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Pa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class No{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Oo(null,t.preserveWhitespace,0)|(n?br:0);i?s=new ar(i.type,i.attrs,ce.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new ar(null,null,ce.none,!0,null,o):s=new ar(e.schema.topNodeType,null,ce.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,s=i.options&Vi?"full":this.localPreserveWS||(i.options&Vn)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)s!=="full"?n=n.replace(/\r?\n|\r/g," "):n=n.replace(/\r\n?/g,`
105
- `);else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],a=e.previousSibling;(!o||a&&a.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;Ra.hasOwnProperty(o)&&this.parser.normalizeLists&&bh(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,n));e:if(l?l.ignore:gh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(Pa.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=l&&l.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
106
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(s,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n)||this.leafFallback(e,n);else{let l=this.enter(o,t.attrs||null,n,t.preserveWhitespace);l&&(s=!0,n=l)}else{let l=this.parser.schema.marks[t.mark];n=n.concat(l.create(t.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,n));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,a=i==null?null:e.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t){let n,i;for(let s=this.open;s>=0;s--){let o=this.nodes[s],a=o.findWrapping(e);if(a&&(!n||n.length>a.length)&&(n=a,i=o,!a.length)||o.solid)break}if(!n)return null;this.sync(i);for(let s=0;s<n.length;s++)t=this.enterInner(n[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let n=this.findPlace(e,t);if(n){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=ce.none;for(let o of n.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):vo(o.type,e.type))&&(s=o.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=Oo(e,s,o.options);o.options&br&&o.content.length==0&&(a|=br);let l=ce.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):vo(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new ar(e,t,l,i,null,a)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.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;this.localPreserveWS&&(this.nodes[t].options|=Vn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:n&&l>=s?n.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function bh(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Ra.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function yh(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function Ao(r){let e={};for(let t in r)e[t]=r[t];return e}function vo(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class Qt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=ui(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let a=0,l=0;for(;a<s.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)i=s.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=yr(ui(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&yr(ui(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return yr(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Do(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Do(e.marks)}}function Do(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function ui(r){return r.document||window.document}const xo=new WeakMap;function kh(r){let e=xo.get(r);return e===void 0&&xo.set(r,e=_h(r)),e}function _h(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function yr(r,e,t,n){if(typeof e=="string")return{dom:r.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=kh(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let a,l=t?r.createElementNS(t,i):r.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?l.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):l.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=yr(r,d,t,n);if(l.appendChild(h),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}const Ba=65535,za=Math.pow(2,16);function Sh(r,e){return r+e*za}function Io(r){return r&Ba}function Ch(r){return(r-(r&Ba))/za}const Fa=1,Va=2,kr=4,La=8;class Li{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&La)>0}get deletedBefore(){return(this.delInfo&(Fa|kr))>0}get deletedAfter(){return(this.delInfo&(Va|kr))>0}get deletedAcross(){return(this.delInfo&kr)>0}}class Ke{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ke.empty)return Ke.empty}recover(e){let t=0,n=Io(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Ch(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+s],u=this.ranges[a+o],f=l+c;if(e<=f){let d=c?e==l?-1:e==f?1:t:t,h=l+i+(d<0?0:u);if(n)return h;let p=e==(t<0?l:f)?null:Sh(a/3,e-l),m=e==l?Va:e==f?Fa:kr;return(t<0?e!=l:e!=f)&&(m|=La),new Li(h,m,p)}i+=u-c}return n?e+i:new Li(e+i,0,null)}touches(e,t){let n=0,i=Io(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?n:0);if(l>e)break;let c=this.ranges[a+s],u=l+c;if(e<=u&&a==i*3)return!0;n+=this.ranges[a+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+n];e(a,a+c,l,l+u),s+=u-c}}invert(){return new Ke(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ke.empty:new Ke(e<0?[0,-e,0]:[0,0,e])}}Ke.empty=new Ke([]);class Rn{constructor(e=[],t,n=0,i=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=i}slice(e=0,t=this.maps.length){return new Rn(this.maps,this.mirror,e,t)}copy(){return new Rn(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new Rn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],a=o.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this.maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return n?e:new Li(e,i,null)}}const fi=Object.create(null);class Ie{getMap(){return Ke.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=fi[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in fi)throw new RangeError("Duplicate use of step JSON ID "+e);return fi[e]=t,t.prototype.jsonID=e,t}}class pe{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new pe(e,null)}static fail(e){return new pe(null,e)}static fromReplace(e,t,n,i){try{return pe.ok(e.replace(t,n,i))}catch(s){if(s instanceof Er)return pe.fail(s.message);throw s}}}function hs(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(hs(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return O.fromArray(n)}class Mt extends Ie{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new B(hs(t.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,s)}invert(){return new at(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Mt(t.pos,n.pos,this.mark)}merge(e){return e instanceof Mt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mt(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 Mt(t.from,t.to,e.markFromJSON(t.mark))}}Ie.jsonID("addMark",Mt);class at extends Ie{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new B(hs(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,n)}invert(){return new Mt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new at(t.pos,n.pos,this.mark)}merge(e){return e instanceof at&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new at(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 at(t.from,t.to,e.markFromJSON(t.mark))}}Ie.jsonID("removeMark",at);class wt extends Ie{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new B(O.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new wt(this.pos,t.marks[i]);return new wt(this.pos,this.mark)}}return new bn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new wt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new wt(t.pos,e.markFromJSON(t.mark))}}Ie.jsonID("addNodeMark",wt);class bn extends Ie{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new B(O.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new wt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new bn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new bn(t.pos,e.markFromJSON(t.mark))}}Ie.jsonID("removeNodeMark",bn);class Se extends Ie{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&ji(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ke([this.from,this.to-this.from,this.slice.size])}invert(e){return new Se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Se(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof Se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?B.empty:new B(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?B.empty:new B(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};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")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Se(t.from,t.to,B.fromJSON(e,t.slice),!!t.structure)}}Ie.jsonID("replace",Se);class Ce extends Ie{constructor(e,t,n,i,s,o,a=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(ji(e,this.from,this.gapFrom)||ji(e,this.gapTo,this.to)))return pe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return pe.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?pe.fromReplace(e,this.from,this.to,n):pe.fail("Content does not fit in gap")}getMap(){return new Ke([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ce(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new Ce(t.pos,n.pos,i,s,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 Ce(t.from,t.to,t.gapFrom,t.gapTo,B.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ie.jsonID("replaceAround",Ce);function ji(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Mh(r,e,t,n){let i=[],s=[],o,a;r.doc.nodesBetween(e,t,(l,c,u)=>{if(!l.isInline)return;let f=l.marks;if(!n.isInSet(f)&&u.type.allowsMarkType(n.type)){let d=Math.max(c,e),h=Math.min(c+l.nodeSize,t),p=n.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(o&&o.to==d&&o.mark.eq(f[m])?o.to=h:i.push(o=new at(d,h,f[m])));a&&a.to==d?a.to=h:s.push(a=new Mt(d,h,n))}}),i.forEach(l=>r.step(l)),s.forEach(l=>r.step(l))}function wh(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(n instanceof Wr){let c=o.marks,u;for(;u=n.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(o.marks)&&(l=[n]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,t);for(let u=0;u<l.length;u++){let f=l[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=s):i.push({style:f,from:Math.max(a,e),to:c,step:s})}}}),i.forEach(o=>r.step(new at(o.from,o.to,o.style)))}function ps(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),u=a+c.nodeSize,f=n.matchType(c.type);if(!f)o.push(new Se(a,u,B.empty));else{n=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||r.step(new at(a,u,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new B(O.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Se(a+d.index,a+d.index+d[0].length,p))}}a=u}if(!n.validEnd){let l=n.fillBefore(O.empty,!0);r.replace(a,a,new B(l,0,0))}for(let l=o.length-1;l>=0;l--)r.step(o[l])}function Th(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Mn(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth;;--n){let i=r.$from.node(n),s=r.$from.index(n),o=r.$to.indexAfter(n);if(n<r.depth&&i.canReplace(s,o,t))return n;if(n==0||i.type.spec.isolating||!Th(i,s,o))break}return null}function Eh(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),a=i.after(s+1),l=o,c=a,u=O.empty,f=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,u=O.from(n.node(p).copy(u)),f++):l--;let d=O.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=O.from(i.node(p).copy(d)),h++):c++;r.step(new Ce(l,c,o,a,new B(u.append(d),f,h),u.size-f,!0))}function ja(r,e,t=null,n=r){let i=Oh(r,e),s=i&&Nh(n,e);return s?i.map(Po).concat({type:e,attrs:t}).concat(s.map(Po)):null}function Po(r){return{type:r,attrs:null}}function Oh(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function Nh(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=n;l&&c<i;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:o}function Ah(r,e,t){let n=O.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let a=t[o].type.contentMatch.matchFragment(n);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=O.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new Ce(i,s,i,s,new B(n,0,0),t.length,!0))}function vh(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,l)&&Dh(r.doc,r.mapping.slice(s).map(a),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&qa(r,o,a,s),ps(r,r.mapping.slice(s).map(a,1),n,void 0,c===null);let u=r.mapping.slice(s),f=u.map(a,1),d=u.map(a+o.nodeSize,1);return r.step(new Ce(f,d,f+1,d-1,new B(O.from(n.create(l,null,o.marks)),0,0),1,!0)),c===!0&&Wa(r,o,a,s),!1}})}function Wa(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function qa(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
107
- `))}})}function Dh(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function xh(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new Ce(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new B(O.from(o),0,0),1,!0))}function hn(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=n&&n[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(h))return!1}let a=i.indexAfter(s),l=n&&n[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Ih(r,e,t=1,n){let i=r.doc.resolve(e),s=O.empty,o=O.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){s=O.from(i.node(a).copy(s));let u=n&&n[c];o=O.from(u?u.type.create(u.attrs,o):i.node(a).copy(o))}r.step(new Se(e,e,new B(s.append(o),t,t),!0))}function en(r,e){let t=r.resolve(e),n=t.index();return Ja(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Ph(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Ja(r,e){return!!(r&&e&&!r.isLeaf&&Ph(r,e))}function qr(r,e,t=-1){let n=r.resolve(e);for(let i=n.depth;;i--){let s,o,a=n.index(i);if(i==n.depth?(s=n.nodeBefore,o=n.nodeAfter):t>0?(s=n.node(i+1),a++,o=n.node(i).maybeChild(a)):(s=n.node(i).maybeChild(a-1),o=n.node(i+1)),s&&!s.isTextblock&&Ja(s,o)&&n.node(i).canReplace(a,a+1))return e;if(i==0)break;e=t<0?n.before(i):n.after(i)}}function Rh(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);u&&!f?n=!1:!u&&f&&(n=!0)}let a=r.steps.length;if(n===!1){let u=r.doc.resolve(e+t);qa(r,u.node(),u.before(),a)}o.inlineContent&&ps(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let l=r.mapping.slice(a),c=l.map(e-t);if(r.step(new Se(c,l.map(e+t,-1),B.empty,!0)),n===!0){let u=r.doc.resolve(c);Wa(r,u.node(),u.before(),r.steps.length)}return r}function Bh(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function zh(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let a=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,l=n.index(o)+(a>0?1:0),c=n.node(o),u=!1;if(s==1)u=c.canReplace(l,l,i);else{let f=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(l,l,f[0])}if(u)return a==0?n.pos:a<0?n.before(o+1):n.after(o+1)}return null}function Jr(r,e,t=e,n=B.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return Ka(i,s,n)?new Se(e,t,n):new Fh(i,s,n).fit()}function Ka(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Fh{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=O.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=O.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new B(s,o,a);return e>-1?new Ce(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Se(n.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=di(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,f=null;if(t==1&&(o?c.matchType(o.type)||(f=c.fillBefore(O.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:a,parent:s,inject:f};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=di(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new B(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=di(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new B(vn(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new B(vn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,a=n?n.content:o.content,l=o.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));f=f.matchFragment(i)}let h=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let m=a.child(c),g=f.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(f=g,u.push($a(m.mark(d.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?h:-1)))}let p=c==a.childCount;p||(h=-1),this.placed=Dn(this.placed,t,O.from(u)),this.frontier[t].match=f,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?B.empty:new B(vn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new B(vn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!hi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=hi(e,t,i,n,s);if(o){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=hi(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?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=Dn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Dn(this.placed,this.depth,O.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(O.empty,!0);t.childCount&&(this.placed=Dn(this.placed,this.frontier.length,t))}}function vn(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(vn(r.firstChild.content,e-1,t)))}function Dn(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Dn(r.lastChild.content,e-1,t)))}function di(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function $a(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,$a(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(O.empty,!0)))),r.copy(n)}function hi(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let a=n.fillBefore(s.content,!0,o);return a&&!Vh(t,s.content,o)?a:null}function Vh(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Lh(r){return r.spec.defining||r.spec.definingForContent}function jh(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(Ka(i,s,n))return r.step(new Se(e,t,n));let o=Ha(i,r.doc.resolve(t));o[o.length-1]==0&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?a=d:i.before(d)==h&&o.splice(1,0,-d)}let l=o.indexOf(a),c=[],u=n.openStart;for(let d=n.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==n.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=Lh(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=n.openStart;d>=0;d--){let h=(d+u+1)%(n.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+l)%o.length],b=!0;g<0&&(b=!1,g=-g);let y=i.node(g-1),M=i.index(g-1);if(y.canReplaceWith(M,M,p.type,p.marks))return r.replace(i.before(g),b?s.after(g):t,new B(Ua(n.content,0,n.openStart,h),h,n.openEnd))}}let f=r.steps.length;for(let d=o.length-1;d>=0&&(r.replace(e,t,n),!(r.steps.length>f));d--){let h=o[d];h<0||(e=i.before(h),t=s.after(h))}}function Ua(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(Ua(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(O.empty,!0))}return r}function Wh(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=Bh(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new B(O.from(n),0,0))}function qh(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),s=Ha(n,i);for(let o=0;o<s.length;o++){let a=s[o],l=o==s.length-1;if(l&&a==0||n.node(a).type.contentMatch.validEnd)return r.delete(n.start(a),i.end(a));if(a>0&&(l||n.node(a-1).canReplace(n.index(a-1),i.indexAfter(a-1))))return r.delete(n.before(a),i.after(a))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function Ha(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class pn extends Ie{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return pe.fromReplace(e,this.pos,this.pos+1,new B(O.from(i),0,t.isLeaf?0:1))}getMap(){return Ke.empty}invert(e){return new pn(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 pn(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 pn(t.pos,t.attr,t.value)}}Ie.jsonID("attr",pn);class Ln extends Ie{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 n=e.type.create(t,e.content,e.marks);return pe.ok(n)}getMap(){return Ke.empty}invert(e){return new Ln(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 Ln(t.attr,t.value)}}Ie.jsonID("docAttr",Ln);let yn=class extends Error{};yn=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};yn.prototype=Object.create(Error.prototype);yn.prototype.constructor=yn;yn.prototype.name="TransformError";class Jh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Rn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new yn(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,n=B.empty){let i=Jr(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new B(O.from(n),0,0))}delete(e,t){return this.replace(e,t,B.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return jh(this,e,t,n),this}replaceRangeWith(e,t,n){return Wh(this,e,t,n),this}deleteRange(e,t){return qh(this,e,t),this}lift(e,t){return Eh(this,e,t),this}join(e,t=1){return Rh(this,e,t),this}wrap(e,t){return Ah(this,e,t),this}setBlockType(e,t=e,n,i=null){return vh(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return xh(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new pn(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ln(e,t)),this}addNodeMark(e,t){return this.step(new wt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof ce)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t=t.isInSet(n.marks),!t)return this}return this.step(new bn(e,t)),this}split(e,t=1,n){return Ih(this,e,t,n),this}addMark(e,t,n){return Mh(this,e,t,n),this}removeMark(e,t,n){return wh(this,e,t,n),this}clearIncompatible(e,t,n){return ps(this,e,t,n),this}}const pi=Object.create(null);class Z{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Kh(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<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=B.empty){let n=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],u=e.mapping.slice(s);e.replaceRange(u.map(l.pos),u.map(c.pos),a?B.empty:t),a==0&&zo(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:a}=i[s],l=e.mapping.slice(n),c=l.map(o.pos),u=l.map(a.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),zo(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new X(e):an(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?an(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):an(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Xe(e.node(0))}static atStart(e){return an(e,e,0,0,1)||new Xe(e)}static atEnd(e){return an(e,e,e.content.size,e.childCount,-1)||new Xe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=pi[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pi)throw new RangeError("Duplicate use of selection JSON ID "+e);return pi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return X.between(this.$anchor,this.$head).getBookmark()}}Z.prototype.visible=!0;class Kh{constructor(e,t){this.$from=e,this.$to=t}}let Ro=!1;function Bo(r){!Ro&&!r.parent.inlineContent&&(Ro=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class X extends Z{constructor(e,t=e){Bo(e),Bo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Z.near(n);let i=e.resolve(t.map(this.anchor));return new X(i.parent.inlineContent?i:n,n)}replace(e,t=B.empty){if(super.replace(e,t),t==B.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof X&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Kr(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 X(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=Z.findFrom(t,n,!0)||Z.findFrom(t,-n,!0);if(s)t=s.$head;else return Z.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(Z.findFrom(e,-n,!0)||Z.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new X(e,t)}}Z.jsonID("text",X);class Kr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Kr(e.map(this.anchor),e.map(this.head))}resolve(e){return X.between(e.resolve(this.anchor),e.resolve(this.head))}}class U extends Z{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?Z.near(s):new U(s)}content(){return new B(O.from(this.node),0,0)}eq(e){return e instanceof U&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ms(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new U(e.resolve(t.anchor))}static create(e,t){return new U(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}U.prototype.visible=!1;Z.jsonID("node",U);class ms{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Kr(n,n):new ms(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&U.isSelectable(n)?new U(t):Z.near(t)}}class Xe extends Z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=B.empty){if(t==B.empty){e.delete(0,e.doc.content.size);let n=Z.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Xe(e)}map(e){return new Xe(e)}eq(e){return e instanceof Xe}getBookmark(){return $h}}Z.jsonID("all",Xe);const $h={map(){return this},resolve(r){return new Xe(r)}};function an(r,e,t,n,i,s=!1){if(e.inlineContent)return X.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&U.isSelectable(a))return U.create(r,t-(i<0?a.nodeSize:0))}else{let l=an(r,a,t+i,i<0?a.childCount:0,i,s);if(l)return l}t+=a.nodeSize*i}return null}function zo(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof Se||i instanceof Ce))return;let s=r.mapping.maps[n],o;s.forEach((a,l,c,u)=>{o==null&&(o=u)}),r.setSelection(Z.near(r.doc.resolve(o),t))}const Fo=1,Vo=2,Lo=4;class Uh extends Jh{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Fo)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Fo)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Vo,this}ensureMarks(e){return ce.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&Vo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||ce.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),n=n??t,!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,s)),this.selection.empty||this.setSelection(Z.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|=Lo,this}get scrolledIntoView(){return(this.updated&Lo)>0}}function jo(r,e){return!e||!r?r:r.bind(e)}class xn{constructor(e,t,n){this.name=e,this.init=jo(t.init,n),this.apply=jo(t.apply,n)}}const Hh=[new xn("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new xn("selection",{init(r,e){return r.selection||Z.atStart(e.doc)},apply(r){return r.selection}}),new xn("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new xn("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class mi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Hh.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new xn(n.key,n.spec.state,n))})}}class fn{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 n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=i?i[o].n:0,c=i?i[o].state:this,u=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,n);if(u&&n.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),s=!0}i&&(i[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new fn(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let s=n[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Uh(this)}static create(e){let t=new mi(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new fn(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new mi(this.schema,e.plugins),n=t.fields,i=new fn(t);for(let s=0;s<n.length;s++){let o=n[s].name;i[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],s=i.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new mi(e.schema,e.plugins),s=new fn(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Et.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=Z.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let a in n){let l=n[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){s[o.name]=c.fromJSON.call(l,e,t[a],s);return}}s[o.name]=o.init(e,s)}}),s}}function Ga(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=Ga(i,e,{})),t[n]=i}return t}class dt{constructor(e){this.spec=e,this.props={},e.props&&Ga(e.props,this,this.props),this.key=e.key?e.key.key:Ya("plugin")}getState(e){return e[this.key]}}const gi=Object.create(null);function Ya(r){return r in gi?r+"$"+ ++gi[r]:(gi[r]=0,r+"$")}class tn{constructor(e="key"){this.key=Ya(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Oe=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},jn=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Wi=null;const pt=function(r,e,t){let n=Wi||(Wi=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Gh=function(){Wi=null},Yt=function(r,e,t,n){return t&&(Wo(r,e,t,n,-1)||Wo(r,e,t,n,1))},Yh=/^(img|br|input|textarea|hr)$/i;function Wo(r,e,t,n,i){for(;;){if(r==t&&e==n)return!0;if(e==(i<0?0:Ye(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Xn(r)||Yh.test(r.nodeName)||r.contentEditable=="false")return!1;e=Oe(r)+(i<0?0:1),r=s}else if(r.nodeType==1){if(r=r.childNodes[e+(i<0?-1:0)],r.contentEditable=="false")return!1;e=i<0?Ye(r):0}else return!1}}function Ye(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Xh(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=Ye(r)}else if(r.parentNode&&!Xn(r))e=Oe(r),r=r.parentNode;else return null}}function Zh(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Xn(r))e=Oe(r)+1,r=r.parentNode;else return null}}function Qh(r,e,t){for(let n=e==0,i=e==Ye(r);n||i;){if(r==t)return!0;let s=Oe(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==Ye(r)}}function Xn(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const $r=function(r){return r.focusNode&&Yt(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function zt(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function ep(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function tp(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(Ye(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(Ye(n.startContainer),n.startOffset)}}}const ct=typeof navigator<"u"?navigator:null,qo=typeof document<"u"?document:null,It=ct&&ct.userAgent||"",qi=/Edge\/(\d+)/.exec(It),Xa=/MSIE \d/.exec(It),Ji=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(It),Le=!!(Xa||Ji||qi),Nt=Xa?document.documentMode:Ji?+Ji[1]:qi?+qi[1]:0,tt=!Le&&/gecko\/(\d+)/i.test(It);tt&&+(/Firefox\/(\d+)/.exec(It)||[0,0])[1];const Ki=!Le&&/Chrome\/(\d+)/.exec(It),ve=!!Ki,Za=Ki?+Ki[1]:0,Re=!Le&&!!ct&&/Apple Computer/.test(ct.vendor),kn=Re&&(/Mobile\/\w+/.test(It)||!!ct&&ct.maxTouchPoints>2),Ge=kn||(ct?/Mac/.test(ct.platform):!1),np=ct?/Win/.test(ct.platform):!1,gt=/Android \d/.test(It),Zn=!!qo&&"webkitFontSmoothing"in qo.documentElement.style,rp=Zn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ip(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function ht(r,e){return typeof r=="number"?r:r[e]}function sp(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function Jo(r,e,t){let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,s=r.dom.ownerDocument;for(let o=t||r.dom;o;o=jn(o)){if(o.nodeType!=1)continue;let a=o,l=a==s.body,c=l?ip(s):sp(a),u=0,f=0;if(e.top<c.top+ht(n,"top")?f=-(c.top-e.top+ht(i,"top")):e.bottom>c.bottom-ht(n,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+ht(i,"top")-c.top:e.bottom-c.bottom+ht(i,"bottom")),e.left<c.left+ht(n,"left")?u=-(c.left-e.left+ht(i,"left")):e.right>c.right-ht(n,"right")&&(u=e.right-c.right+ht(i,"right")),u||f)if(l)s.defaultView.scrollBy(u,f);else{let d=a.scrollLeft,h=a.scrollTop;f&&(a.scrollTop+=f),u&&(a.scrollLeft+=u);let p=a.scrollLeft-d,m=a.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function op(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=r.root.elementFromPoint(s,o);if(!a||a==r.dom||!r.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){n=a,i=l.top;break}}return{refDOM:n,refTop:i,stack:Qa(r.dom)}}function Qa(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=jn(n));return e}function lp({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;ec(t,n==0?0:n-e)}function ec(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:s}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}let sn=null;function ap(r){if(r.setActive)return r.setActive();if(sn)return r.focus(sn);let e=Qa(r);r.focus(sn==null?{get preventScroll(){return sn={preventScroll:!0},!0}}:void 0),sn||(sn=!1,ec(e,0))}function tc(r,e){let t,n=2e8,i,s=0,o=e.top,a=e.top,l,c;for(let u=r.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=pt(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=o&&p.bottom>=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<n){t=u,n=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(s=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=f+1)}}return!t&&l&&(t=l,i=c,n=0),t&&t.nodeType==3?cp(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:tc(t,i)}function cp(r,e){let t=r.nodeValue.length,n=document.createRange();for(let i=0;i<t;i++){n.setEnd(r,i+1),n.setStart(r,i);let s=kt(n,1);if(s.top!=s.bottom&&gs(e,s))return{node:r,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:r,offset:0}}function gs(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function up(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function fp(r,e,t){let{node:n,offset:i}=tc(e,t),s=-1;if(n.nodeType==1&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return r.docView.posFromDOM(n,i,s)}function dp(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let a=r.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&(!o&&l.left>n.left||l.top>n.top?i=a.posBefore:(!o&&l.right<n.left||l.bottom<n.top)&&(i=a.posAfter),o=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?n.top<(l.top+l.bottom)/2:n.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;s=a.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function nc(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=r.childNodes[s];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(gs(e,c))return nc(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function hp(r,e){let t=r.dom.ownerDocument,n,i=0,s=tp(t,e.left,e.top);s&&({node:n,offset:i}=s);let o=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),a;if(!o||!r.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=r.dom.getBoundingClientRect();if(!gs(e,c)||(o=nc(r.dom,e,c),!o))return null}if(Re)for(let c=o;n&&c;c=jn(c))c.draggable&&(n=void 0);if(o=up(o,e),n){if(tt&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let u=n.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Zn&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?a=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(a=dp(r,n,i,e))}a==null&&(a=fp(r,o,e));let l=r.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Ko(r){return r.top<r.bottom||r.left<r.right}function kt(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Ko(n))return n}return Array.prototype.find.call(t,Ko)||r.getBoundingClientRect()}const pp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function rc(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=Zn||tt;if(n.nodeType==3)if(o&&(pp.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let l=kt(pt(n,i,i),t);if(tt&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=kt(pt(n,i-1,i-1),-1);if(c.top==l.top){let u=kt(pt(n,i,i+1),-1);if(u.top!=l.top)return On(u,u.left<c.left)}}return l}else{let l=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==n.nodeValue.length?(l--,u=1):t<0?l--:c++,On(kt(pt(n,l,c),u),u<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Ye(n))){let l=n.childNodes[i-1];if(l.nodeType==1)return bi(l.getBoundingClientRect(),!1)}if(s==null&&i<Ye(n)){let l=n.childNodes[i];if(l.nodeType==1)return bi(l.getBoundingClientRect(),!0)}return bi(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Ye(n))){let l=n.childNodes[i-1],c=l.nodeType==3?pt(l,Ye(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return On(kt(c,1),!1)}if(s==null&&i<Ye(n)){let l=n.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?pt(l,0,o?0:1):l.nodeType==1?l:null:null;if(c)return On(kt(c,-1),!0)}return On(kt(n.nodeType==3?pt(n):n,-t),t>=0)}function On(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function bi(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function ic(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function mp(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return ic(r,e,()=>{let{node:s}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=r.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=rc(r,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=pt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const gp=/[\u0590-\u08ac]/;function bp(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,s=!i,o=i==n.parent.content.size,a=r.domSelection();return a?!gp.test(n.parent.textContent)||!a.modify?t=="left"||t=="backward"?s:o:ic(r,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:f}=r.domSelectionRange(),d=a.caretBidiLevel;a.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:m}=r.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(u,f),l&&(l!=u||c!=f)&&a.extend&&a.extend(l,c)}catch{}return d!=null&&(a.caretBidiLevel=d),g}):n.pos==n.start()||n.pos==n.end()}let $o=null,Uo=null,Ho=!1;function yp(r,e,t){return $o==e&&Uo==t?Ho:($o=e,Uo=t,Ho=t=="up"||t=="down"?mp(r,e,t):bp(r,e,t))}const Ze=0,Go=1,Lt=2,ut=3;class Qn{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=Ze,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Oe(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 s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],s=n+i.size;if(n==e&&s!=n){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<s)return i.descAt(e-n-i.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],a=s+o.size;if(a>e||o instanceof oc){i=e-s;break}s=a}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof sc&&s.side>=0;n--);if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Oe(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Oe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=n,a=0;;a++){let l=this.children[a],c=o+l.size;if(i==-1&&e<=c){let u=o+l.border;if(e>=u&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=o;for(let f=a;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=Oe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let u=a+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Oe(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,n,i);p=g}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),f=!1;if((tt||Re)&&e==t){let{node:h,offset:p}=a;if(h.nodeType==3){if(f=!!(p&&h.nodeValue[p-1]==`
108
- `),f&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:Oe(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(tt&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&Re)&&Yt(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Yt(l.node,l.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),d=!0}catch{}}if(!d){if(e>t){let p=a;a=l,l=p}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}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 n=0,i=0;i<this.children.length;i++){let s=this.children[i],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let a=n+s.border,l=o-s.border;if(e>=a&&t<=l){this.dirty=e==n||t==o?Lt:Go,e==a&&t==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ut:s.markDirty(e-a,t-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Lt:ut}n=o}this.dirty=Lt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Lt:Go;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class sc extends Qn{constructor(e,t,n,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ze&&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 kp extends Qn{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,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 Xt extends Qn{constructor(e,t,n,i,s){super(e,[],n,i),this.mark=t,this.spec=s}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=Qt.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Xt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ut||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ut&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ze){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Ze}}slice(e,t,n){let i=Xt.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=Ui(s,t,o,n)),e>0&&(s=Ui(s,0,e,n));for(let a=0;a<s.length;a++)s[a].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class At extends Qn{constructor(e,t,n,i,s,o,a,l,c){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=a}static create(e,t,n,i,s,o){let a=s.nodeViews[t.type.name],l,c=a&&a(t,s,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},n,i),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=Qt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=cc(u,n,t),c?l=new _p(e,t,n,i,u,f||null,d,c,s,o+1):t.isText?new Ur(e,t,n,i,u,d,s):new At(e,t,n,i,u,f||null,d,s,o+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 n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,t,n){return this.dirty==Ze&&e.eq(this.node)&&vr(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new Cp(this,o&&o.node,e);Tp(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!f&&l.syncToMarks(u==this.node.childCount?ce.none:this.node.child(u).marks,n,e),l.placeWidget(c,e,i)},(c,u,f,d)=>{l.syncToMarks(c.marks,n,e);let h;l.findNodeMatch(c,u,f,d)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,u,f,h,e)||l.updateNextNode(c,u,f,e,d,i)||l.addNode(c,u,f,e,i),i+=c.nodeSize}),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Lt)&&(o&&this.protectLocalComposition(e,o),lc(this.contentDOM,this.children,e),kn&&Ep(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof X)||n<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=Op(this.node.content,o,n-t,i-t);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new kp(this,s,t,i);e.input.compositionNodes.push(o),this.children=Ui(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==ut||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ze}updateOuterDeco(e){if(vr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=ac(this.dom,this.nodeDOM,$i(this.outerDeco,this.node,t),$i(e,this.node,t)),this.dom!=n&&(n.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 Yo(r,e,t,n,i){cc(n,e,r);let s=new At(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Ur extends At{constructor(e,t,n,i,s,o,a){super(e,t,n,i,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==ut||this.dirty!=Ze&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ze||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=Ze,!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,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new Ur(this.parent,i,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ut)}get domAtom(){return!1}isText(e){return this.node.text==e}}class oc extends Qn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ze&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class _p extends At{constructor(e,t,n,i,s,o,a,l,c,u){super(e,t,n,i,s,o,a,c,u),this.spec=l}update(e,t,n,i){if(this.dirty==ut)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,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 lc(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=o.dom;if(a.parentNode==r){for(;a!=n;)n=Xo(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(a,n);if(o instanceof Xt){let l=n?n.previousSibling:r.lastChild;lc(o.contentDOM,o.children,t),n=l?l.nextSibling:r.firstChild}}for(;n;)n=Xo(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const Bn=function(r){r&&(this.nodeName=r)};Bn.prototype=Object.create(null);const jt=[new Bn];function $i(r,e,t){if(r.length==0)return jt;let n=t?jt[0]:new Bn,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new Bn(o.nodeName));for(let a in o){let l=o[a];l!=null&&(t&&i.length==1&&i.push(n=new Bn(e.isInline?"span":"div")),a=="class"?n.class=(n.class?n.class+" ":"")+l:a=="style"?n.style=(n.style?n.style+";":"")+l:a!="nodeName"&&(n[a]=l))}}}return i}function ac(r,e,t,n){if(t==jt&&n==jt)return e;let i=e;for(let s=0;s<n.length;s++){let o=n[s],a=t[s];if(s){let l;a&&a.nodeName==o.nodeName&&i!=r&&(l=i.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=jt[0]),i=l}Sp(i,a||jt[0],o)}return i}function Sp(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)i.indexOf(n[s])==-1&&r.classList.remove(n[s]);for(let s=0;s<i.length;s++)n.indexOf(i[s])==-1&&r.classList.add(i[s]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function cc(r,e,t){return ac(r,r,jt,$i(e,t,r.nodeType!=1))}function vr(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Xo(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class Cp{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Mp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Ze,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){a=l;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=Xt.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){s=a;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,i,s){let o=this.top.children[i];return o.dirty==ut&&o.dom==o.contentDOM&&(o.dirty=Lt),o.update(e,t,n,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,s,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof At){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let u=l.dom,f,d=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ut&&vr(t,l.outerDeco));if(!d&&l.update(e,t,n,i))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(l,e,t,n,i,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Lt,f.updateChildren(i,o+1),f.dirty=Ze),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!vr(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=At.create(this.top,t,n,i,s,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,n,i,s){let o=At.create(this.top,e,t,n,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new sc(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Xt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ur)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Re||ve)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new oc(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Mp(r,e){let t=e,n=t.children.length,i=r.childCount,s=new Map,o=[];e:for(;i>0;){let a;for(;;)if(n){let c=t.children[n-1];if(c instanceof Xt)t=c,n=c.children.length;else{a=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=r.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function wp(r,e){return r.type.side-e.type.side}function Tp(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let u,f;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(wp);for(let g=0;g<f.length;g++)t(f[g],c,!!l)}else t(u,c,!!l);let d,h;if(l)h=-1,d=l,l=null;else if(c<r.childCount)h=c,d=r.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=s&&a.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let p=s+d.nodeSize;if(d.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let b=0;b<a.length;b++)a[b].to<g&&(g=a[b].to);g<p&&(l=d.cut(g-s),d=d.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=d.isInline&&!d.isLeaf?a.filter(g=>!g.inline):a.slice();n(d,m,e.forChild(s,d),h),s=p}}function Ep(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function Op(r,e,t,n){for(let i=0,s=0;i<r.childCount&&s<=n;){let o=r.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<r.childCount;){let c=r.child(i++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=t){if(s>=n&&l.slice(n-e.length-a,n-a)==e)return n-e.length;let c=a<n?l.lastIndexOf(e,n-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==n&&l.length>=n+e.length-a&&l.slice(n-a,n-a+e.length)==e)return n}}return-1}function Ui(r,e,t,n,i){let s=[];for(let o=0,a=0;o<r.length;o++){let l=r[o],c=a,u=a+=l.size;c>=t||u<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,n)),i&&(s.push(i),i=void 0),u>t&&s.push(l.slice(t-c,l.size,n)))}return s}function bs(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let a=n.resolve(o),l,c;if($r(t)){for(l=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&U.isSelectable(f)&&i.parent&&!(f.isInline&&Qh(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new U(o==d?a:n.resolve(d))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=o,d=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[l,o]=d==r.state.selection.anchor?[d,f]:[f,d],a=n.resolve(o)}else l=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let u=n.resolve(l);if(!c){let f=e=="pointer"||r.state.selection.head<a.pos&&!s?1:-1;c=ys(r,u,a,f)}return c}function uc(r){return r.editable?r.hasFocus():dc(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function bt(r,e=!1){let t=r.state.selection;if(fc(r,t),!!uc(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&ve){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&Yt(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Ap(r);else{let{anchor:n,head:i}=t,s,o;Zo&&!(t instanceof X)&&(t.$from.parent.inlineContent||(s=Qo(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Qo(r,t.to))),r.docView.setSelection(n,i,r,e),Zo&&(s&&el(s),o&&el(o)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Np(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Zo=Re||ve&&Za<63;function Qo(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if(Re&&i&&i.contentEditable=="false")return yi(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return yi(i);if(s)return yi(s)}}function yi(r){return r.contentEditable="true",Re&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function el(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function Np(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!uc(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ap(r){let e=r.domSelection(),t=document.createRange();if(!e)return;let n=r.cursorWrapper.dom,i=n.nodeName=="IMG";i?t.setStart(n.parentNode,Oe(n)+1):t.setStart(n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!r.state.selection.visible&&Le&&Nt<=11&&(n.disabled=!0,n.disabled=!1)}function fc(r,e){if(e instanceof U){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(tl(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else tl(r)}function tl(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function ys(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||X.between(e,t,n)}function nl(r){return r.editable&&!r.hasFocus()?!1:dc(r)}function dc(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function vp(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return Yt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Hi(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Z.findFrom(s,e)}function _t(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function rl(r,e,t){let n=r.state.selection;if(n instanceof X)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return _t(r,new X(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Hi(r.state,e);return i&&i instanceof U?_t(r,i):!1}else if(!(Ge&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(a))&&!o.contentDOM?U.isSelectable(s)?_t(r,new U(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):Zn?_t(r,new X(r.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(n instanceof U&&n.node.isInline)return _t(r,new X(e>0?n.$to:n.$from));{let i=Hi(r.state,e);return i?_t(r,i):!1}}}function Dr(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function zn(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function on(r,e){return e<0?Dp(r):xp(r)}function Dp(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(tt&&t.nodeType==1&&n<Dr(t)&&zn(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let a=t.childNodes[n-1];if(zn(a,-1))i=t,s=--n;else if(a.nodeType==3)t=a,n=t.nodeValue.length;else break}}else{if(hc(t))break;{let a=t.previousSibling;for(;a&&zn(a,-1);)i=t.parentNode,s=Oe(a),a=a.previousSibling;if(a)t=a,n=Dr(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?Gi(r,t,n):i&&Gi(r,i,s)}function xp(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=Dr(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let a=t.childNodes[n];if(zn(a,1))s=t,o=++n;else break}else{if(hc(t))break;{let a=t.nextSibling;for(;a&&zn(a,1);)s=a.parentNode,o=Oe(a)+1,a=a.nextSibling;if(a)t=a,n=0,i=Dr(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&Gi(r,s,o)}function hc(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ip(r,e){for(;r&&e==r.childNodes.length&&!Xn(r);)e=Oe(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function Pp(r,e){for(;r&&!e&&!Xn(r);)e=Oe(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Gi(r,e,t){if(e.nodeType!=3){let s,o;(o=Ip(e,t))?(e=o,t=0):(s=Pp(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection();if(!n)return;if($r(n)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),n.removeAllRanges(),n.addRange(s)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&bt(r)},50)}function il(r,e){let t=r.state.doc.resolve(e);if(!(ve||np)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function sl(r,e,t){let n=r.state.selection;if(n instanceof X&&!n.empty||t.indexOf("s")>-1||Ge&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=Hi(r.state,e);if(o&&o instanceof U)return _t(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=n instanceof Xe?Z.near(o,e):Z.findFrom(o,e);return a?_t(r,a):!1}return!1}function ol(r,e){if(!(r.state.selection instanceof X))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function ll(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function Rp(r){if(!Re||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;ll(r,n,"true"),setTimeout(()=>ll(r,n,"false"),20)}return!1}function Bp(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function zp(r,e){let t=e.keyCode,n=Bp(e);if(t==8||Ge&&t==72&&n=="c")return ol(r,-1)||on(r,-1);if(t==46&&!e.shiftKey||Ge&&t==68&&n=="c")return ol(r,1)||on(r,1);if(t==13||t==27)return!0;if(t==37||Ge&&t==66&&n=="c"){let i=t==37?il(r,r.state.selection.from)=="ltr"?-1:1:-1;return rl(r,i,n)||on(r,i)}else if(t==39||Ge&&t==70&&n=="c"){let i=t==39?il(r,r.state.selection.from)=="ltr"?1:-1:1;return rl(r,i,n)||on(r,i)}else{if(t==38||Ge&&t==80&&n=="c")return sl(r,-1,n)||on(r,-1);if(t==40||Ge&&t==78&&n=="c")return Rp(r)||sl(r,1,n)||on(r,1);if(n==(Ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function pc(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let o=r.someProp("clipboardSerializer")||Qt.fromSchema(r.state.schema),a=_c(),l=a.createElement("div");l.appendChild(o.serializeFragment(n,{document:a}));let c=l.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=kc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=a.createElement(u[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
109
-
110
- `);return{dom:l,text:d,slice:e}}function mc(r,e,t,n,i){let s=i.parent.type.spec.code,o,a;if(!t&&!e)return null;let l=e&&(n||s||!t);if(l){if(r.someProp("transformPastedText",d=>{e=d(e,s||n,r)}),s)return e?new B(O.from(r.state.schema.text(e.replace(/\r\n?/g,`
111
- `))),0,0):B.empty;let f=r.someProp("clipboardTextParser",d=>d(e,i,n,r));if(f)a=f;else{let d=i.marks(),{schema:h}=r.state,p=Qt.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,d)))})}}else r.someProp("transformPastedHTML",f=>{t=f(t,r)}),o=jp(t),Zn&&Wp(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(a||(a=(r.someProp("clipboardParser")||r.someProp("domParser")||Ot.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Fp.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)a=qp(al(a,+u[1],+u[2]),u[4]);else if(a=B.maxOpen(Vp(a.content,i),!0),a.openStart||a.openEnd){let f=0,d=0;for(let h=a.content.firstChild;f<a.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=a.content.lastChild;d<a.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);a=al(a,f,d)}return r.someProp("transformPasted",f=>{a=f(a,r)}),a}const Fp=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Vp(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&s.length&&bc(l,s,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=yc(o[o.length-1],s.length));let u=gc(a,l);o.push(u),i=i.matchType(u.type),s=l}}),o)return O.from(o)}return r}function gc(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,O.from(r));return r}function bc(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=bc(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(O.from(gc(t,r,i+1))))}}function yc(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,yc(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(O.empty,!0);return r.copy(t.append(n))}function Yi(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,a=o.content;return r.childCount>1&&(s=0),i<n-1&&(a=Yi(a,e,t,n,i+1,s)),i>=t&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(O.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(a))}function al(r,e,t){return e<r.openStart&&(r=new B(Yi(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new B(Yi(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const kc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let cl=null;function _c(){return cl||(cl=document.implementation.createHTMLDocument("title"))}let ki=null;function Lp(r){let e=window.trustedTypes;return e?(ki||(ki=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ki.createHTML(r)):r}function jp(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=_c().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&kc[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Lp(r),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Wp(r){let e=r.querySelectorAll(ve?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function qp(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let a=n.length-2;a>=0;a-=2){let l=t.nodes[n[a]];if(!l||l.hasRequiredAttrs())break;i=O.from(l.create(n[a+1],i)),s++,o++}return new B(i,s,o)}const Be={},ze={},Jp={touchstart:!0,touchmove:!0};class Kp{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function $p(r){for(let e in Be){let t=Be[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Hp(r,n)&&!ks(r,n)&&(r.editable||!(n.type in ze))&&t(r,n)},Jp[e]?{passive:!0}:void 0)}Re&&r.dom.addEventListener("input",()=>null),Xi(r)}function Tt(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Up(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Xi(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>ks(r,n))})}function ks(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Hp(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Gp(r,e){!ks(r,e)&&Be[e.type]&&(r.editable||!(e.type in ze))&&Be[e.type](r,e)}ze.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Cc(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(gt&&ve&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),kn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,zt(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||zp(r,t)?t.preventDefault():Tt(r,"key")};ze.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};ze.keypress=(r,e)=>{let t=e;if(Cc(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ge&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof X)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i))&&r.dispatch(r.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function Hr(r){return{left:r.clientX,top:r.clientY}}function Yp(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function _s(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,a=>o>s.depth?a(r,t,s.nodeAfter,s.before(o),i,!0):a(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function mn(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Xp(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&U.isSelectable(n)?(mn(r,new U(t)),!0):!1}function Zp(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof U&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(U.isSelectable(a)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(mn(r,U.create(r.state.doc,i)),!0):!1}function Qp(r,e,t,n,i){return _s(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?Zp(r,t):Xp(r,t))}function em(r,e,t,n){return _s(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function tm(r,e,t,n){return _s(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||nm(r,t,n)}function nm(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(mn(r,X.create(n,0,n.content.size)),!0):!1;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)mn(r,X.create(n,a+1,a+1+o.content.size));else if(U.isSelectable(o))mn(r,U.create(n,a));else continue;return!0}}function Ss(r){return xr(r)}const Sc=Ge?"metaKey":"ctrlKey";Be.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Ss(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&Yp(t,r.input.lastClick)&&!t[Sc]&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=r.posAtCoords(Hr(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new rm(r,o,t,!!n)):(s=="doubleClick"?em:tm)(r,o.pos,o.inside,t)?t.preventDefault():Tt(r,"pointer"))};class rm{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Sc],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}const a=i?null:n.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.dom.nodeType==1?l.dom:null;let{selection:c}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof U&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&tt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Tt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>bt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Hr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Tt(this.view,"pointer"):Qp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Re&&this.mightDrag&&!this.mightDrag.node.isAtom||ve&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(mn(this.view,Z.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Tt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Tt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Be.touchstart=r=>{r.input.lastTouch=Date.now(),Ss(r),Tt(r,"pointer")};Be.touchmove=r=>{r.input.lastTouch=Date.now(),Tt(r,"pointer")};Be.contextmenu=r=>Ss(r);function Cc(r,e){return r.composing?!0:Re&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const im=gt?5e3:-1;ze.compositionstart=ze.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof X&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),xr(r,!0),r.markCursor=null;else if(xr(r,!e.selection.empty),tt&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let a=r.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}Mc(r,im)};ze.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Mc(r,20))};function Mc(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>xr(r),e))}function wc(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=om());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function sm(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Xh(e.focusNode,e.focusOffset),n=Zh(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function om(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function xr(r,e=!1){if(!(gt&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),wc(r),e||r.docView&&r.docView.dirty){let t=bs(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!r.state.selection.empty?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function lm(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const Wn=Le&&Nt<15||kn&&rp<604;Be.copy=ze.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=Wn?null:t.clipboardData,o=n.content(),{dom:a,text:l}=pc(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):lm(r,a),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function am(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function cm(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?qn(r,n.value,null,i,e):qn(r,n.textContent,n.innerHTML,i,e)},50)}function qn(r,e,t,n,i){let s=mc(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",l=>l(r,i,s||B.empty)))return!0;if(!s)return!1;let o=am(s),a=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Tc(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ze.paste=(r,e)=>{let t=e;if(r.composing&&!gt)return;let n=Wn?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&qn(r,Tc(n),n.getData("text/html"),i,t)?t.preventDefault():cm(r,t)};class Ec{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Oc=Ge?"altKey":"ctrlKey";Be.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(Hr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof U?i.to-1:i.to))){if(n&&n.mightDrag)o=U.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=r.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=r.docView&&(o=U.create(r.state.doc,f.posBefore))}}let a=(o||r.state.selection).content(),{dom:l,text:c,slice:u}=pc(r,a);(!t.dataTransfer.files.length||!ve||Za>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Wn?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",Wn||t.dataTransfer.setData("text/plain",c),r.dragging=new Ec(u,!t[Oc],o)};Be.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};ze.dragover=ze.dragenter=(r,e)=>e.preventDefault();ze.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(Hr(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",p=>{o=p(o,r)}):o=mc(r,Tc(t.dataTransfer),Wn?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&!t[Oc]);if(r.someProp("handleDrop",p=>p(r,t,o||B.empty,a))){t.preventDefault();return}if(!o)return;t.preventDefault();let l=o?zh(r.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let c=r.state.tr;if(a){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(l),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&U.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new U(h));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,y)=>p=y),c.setSelection(ys(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))};Be.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&bt(r)},20))};Be.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};Be.beforeinput=(r,e)=>{if(ve&&gt&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,zt(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in ze)Be[r]=ze[r];function Jn(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class Ir{constructor(e,t){this.toDOM=e,this.spec=t||$t,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new et(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Ir&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Jn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vt{constructor(e,t){this.attrs=e,this.spec=t||$t}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new et(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vt&&Jn(this.attrs,e.attrs)&&Jn(this.spec,e.spec)}static is(e){return e.type instanceof vt}destroy(){}}class Cs{constructor(e,t){this.attrs=e,this.spec=t||$t}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new et(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Cs&&Jn(this.attrs,e.attrs)&&Jn(this.spec,e.spec)}destroy(){}}class et{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new et(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new et(e,e,new Ir(t,n))}static inline(e,t,n,i){return new et(e,t,new vt(n,i))}static node(e,t,n,i){return new et(e,t,new Cs(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof vt}get widget(){return this.type instanceof Ir}}const cn=[],$t={};class _e{constructor(e,t){this.local=e.length?e:cn,this.children=t.length?t:cn}static create(e,t){return t.length?Pr(t,e,0,$t):Ae}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=t&&a.to>=e&&(!s||s(a.spec))&&n.push(a.copy(a.from+i,a.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,t-a,n,i+a,s)}}map(e,t,n){return this==Ae||e.maps.length==0?this:this.mapInner(e,t,0,0,n||$t)}mapInner(e,t,n,i,s){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,i);l&&l.type.valid(t,l)?(o||(o=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?um(this.children,o||[],e,t,n,i,s):o?new _e(o.sort(Ut),cn):Ae}add(e,t){return t.length?this==Ae?_e.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((a,l)=>{let c=l+n,u;if(u=Ac(t,a,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(a,u,c+1):i.splice(s,0,l,l+a.nodeSize,Pr(u,a,c+1,$t)),s+=3}});let o=Nc(s?vc(t):t,-n);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new _e(o.length?this.local.concat(o).sort(Ut):this.local,i||this.children)}remove(e){return e.length==0||this==Ae?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,a=n[s]+t,l=n[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>a&&f.to<l&&(e[u]=null,(o||(o=[])).push(f));if(!o)continue;n==this.children&&(n=this.children.slice());let c=n[s+2].removeInner(o,a+1);c!=Ae?n[s+2]=c:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let a=0;a<i.length;a++)i[a].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new _e(i,n):Ae}forChild(e,t){if(this==Ae)return this;if(t.isLeaf)return _e.empty;let n,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(n=this.children[a+2]);break}let s=e+1,o=s+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>s&&l.type instanceof vt){let c=Math.max(s,l.from)-s,u=Math.min(o,l.to)-s;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let a=new _e(i.sort(Ut),cn);return n?new Ct([a,n]):a}return n||Ae}eq(e){if(this==e)return!0;if(!(e instanceof _e)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ms(this.localsInner(e))}localsInner(e){if(this==Ae)return cn;if(e.inlineContent||!this.local.some(vt.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof vt||t.push(this.local[n]);return t}forEachSet(e){e(this)}}_e.empty=new _e([],[]);_e.removeOverlap=Ms;const Ae=_e.empty;class Ct{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,$t));return Ct.from(n)}forChild(e,t){if(t.isLeaf)return _e.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=Ae&&(s instanceof Ct?n=n.concat(s.members):n.push(s))}return Ct.from(n)}eq(e){if(!(e instanceof Ct)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ms(n?t:t.sort(Ut)):cn}static from(e){switch(e.length){case 0:return Ae;case 1:return e[0];default:return new Ct(e.every(t=>t instanceof _e)?e:e.reduce((t,n)=>t.concat(n instanceof _e?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function um(r,e,t,n,i,s,o){let a=r.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,m)=>{let g=m-p-(h-d);for(let b=0;b<a.length;b+=3){let y=a[b+1];if(y<0||d>y+u-f)continue;let M=a[b]+u-f;h>=M?a[b+1]=d<=M?-2:-1:d>=u&&g&&(a[b]+=g,a[b+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=t.map(r[c]+s),f=u-i;if(f<0||f>=n.content.size){l=!0;continue}let d=t.map(r[c+1]+s,-1),h=d-i,{index:p,offset:m}=n.content.findIndex(f),g=n.maybeChild(p);if(g&&m==f&&m+g.nodeSize==h){let b=a[c+2].mapInner(t,g,u+1,r[c]+s+1,o);b!=Ae?(a[c]=f,a[c+1]=h,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=fm(a,r,e,t,i,s,o),u=Pr(c,n,0,o);e=u.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<a.length&&a[d]<h;)d+=3;a.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new _e(e.sort(Ut),a)}function Nc(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new et(i.from+e,i.to+e,i.type))}return t}function fm(r,e,t,n,i,s,o){function a(l,c){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(n,i,c);f?t.push(f):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<r.length;l+=3)r[l+1]==-1&&a(r[l+2],e[l]+s+1);return t}function Ac(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function vc(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Pr(r,e,t,n){let i=[],s=!1;e.forEach((a,l)=>{let c=Ac(r,a,l+t);if(c){s=!0;let u=Pr(c,a,t+l+1,n);u!=Ae&&i.push(l,l+a.nodeSize,u)}});let o=Nc(s?vc(r):r,-t).sort(Ut);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(n.onRemove&&n.onRemove(o[a].spec),o.splice(a--,1));return o.length||i.length?new _e(o,i):Ae}function Ut(r,e){return r.from-e.from||r.to-e.to}function Ms(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),ul(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),ul(e,i,n.copy(s.from,n.to)));break}}}return e}function ul(r,e,t){for(;e<r.length&&Ut(t,r[e])>0;)e++;r.splice(e,0,t)}function _i(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=Ae&&e.push(n)}),r.cursorWrapper&&e.push(_e.create(r.state.doc,[r.cursorWrapper.deco])),Ct.from(e)}const dm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hm=Le&&Nt<=11;class pm{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class mm{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pm,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);Le&&Nt<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),hm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,dm)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(nl(this.view)){if(this.suppressingSelectionUpdates)return bt(this.view);if(Le&&Nt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Yt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=jn(s))t.add(s);for(let s=e.anchorNode;s;s=jn(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&nl(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],l);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(a=!0))}if(tt&&l.length){let u=l.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||ym(e,f)!=h)&&d.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&$r(n)&&(c=bs(e))&&c.eq(Z.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,bt(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),gm(e)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||bt(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Le&&Nt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let o=i&&i.parentNode==e.target?Oe(i)+1:0,a=n.localPosFromDOM(e.target,o,-1),l=s&&s.parentNode==e.target?Oe(s):e.target.childNodes.length,c=n.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let fl=new WeakMap,dl=!1;function gm(r){if(!fl.has(r)&&(fl.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=tt,dl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),dl=!0}}function hl(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return Yt(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function bm(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return hl(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?hl(r,t):null}function ym(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function km(r,e,t){let{node:n,fromOffset:i,toOffset:s,from:o,to:a}=r.docView.parseRange(e,t),l=r.domSelectionRange(),c,u=l.anchorNode;if(u&&r.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],$r(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ve&&r.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=n.childNodes[g-1],y=b.pmViewDesc;if(b.nodeName=="BR"&&!y){s=g;break}if(!y||y.size)break}let f=r.state.doc,d=r.someProp("domParser")||Ot.fromSchema(r.state.schema),h=f.resolve(o),p=null,m=d.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:_m,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:a}}function _m(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(Re&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||Re&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Sm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Cm(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let v=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,k=bs(r,v);if(k&&!r.state.selection.eq(k)){if(ve&&gt&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",J=>J(r,zt(13,"Enter"))))return;let w=r.state.tr.setSelection(k);v=="pointer"?w.setMeta("pointer",!0):v=="key"&&w.scrollIntoView(),s&&w.setMeta("composition",s),r.dispatch(w)}return}let o=r.state.doc.resolve(e),a=o.sharedDepth(t);e=o.before(a+1),t=r.state.doc.resolve(t).after(a+1);let l=r.state.selection,c=km(r,e,t),u=r.state.doc,f=u.slice(c.from,c.to),d,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(d=r.state.selection.to,h="end"):(d=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=Tm(f.content,c.doc.content,c.from,d,h);if(p&&r.input.domChangeCount++,(kn&&r.input.lastIOSEnter>Date.now()-225||gt)&&i.some(v=>v.nodeType==1&&!Sm.test(v.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",v=>v(r,zt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&l instanceof X&&!l.empty&&l.$head.sameParent(l.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let v=pl(r,r.state.doc,c.sel);if(v&&!v.eq(r.state.selection)){let k=r.state.tr.setSelection(v);s&&k.setMeta("composition",s),r.dispatch(k)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof X&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),Le&&Nt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),y=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,M;if((kn&&r.input.lastIOSEnter>Date.now()-225&&(!y||i.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!y&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(M=Z.findFrom(c.doc.resolve(m.pos+1),1,!0))&&M.head==g.pos)&&r.someProp("handleKeyDown",v=>v(r,zt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&wm(u,p.start,p.endA,m,g)&&r.someProp("handleKeyDown",v=>v(r,zt(8,"Backspace")))){gt&&ve&&r.domObserver.suppressSelectionUpdates();return}ve&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),gt&&!y&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(v){return v(r,zt(13,"Enter"))})},20));let T=p.start,S=p.endA,E,W,D;if(y){if(m.pos==g.pos)Le&&Nt<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>bt(r),20)),E=r.state.tr.delete(T,S),W=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(D=Mm(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))E=r.state.tr,D.type=="add"?E.addMark(T,S,D.mark):E.removeMark(T,S,D.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,g.parentOffset);if(r.someProp("handleTextInput",k=>k(r,T,S,v)))return;E=r.state.tr.insertText(v,T,S)}}if(E||(E=r.state.tr.replace(T,S,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let v=pl(r,E.doc,c.sel);v&&!(ve&&r.composing&&v.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(v.head==T||v.head==E.mapping.map(S)-1)||Le&&v.empty&&v.head==T)&&E.setSelection(v)}W&&E.ensureMarks(W),s&&E.setMeta("composition",s),r.dispatch(E.scrollIntoView())}function pl(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ys(r,e.resolve(t.anchor),e.resolve(t.head))}function Mm(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,a,l;for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(i.length==1&&s.length==0)a=i[0],o="add",l=u=>u.mark(a.addToSet(u.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(O.from(c).eq(r))return{mark:a,type:o}}function wm(r,e,t,n,i){if(t-e<=i.pos-n.pos||Si(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let a=s.nodeAfter;return a!=null&&t==e+a.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(Si(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Si(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function Si(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Tm(r,e,t,n,i){let s=r.findDiffStart(e,t);if(s==null)return null;let{a:o,b:a}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(o,a));n-=o+l-s}if(o<s&&r.size<e.size){let l=n<=s&&n>=o?s-n:0;s-=l,s&&s<e.size&&ml(e.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-o),o=s}else if(a<s){let l=n<=s&&n>=a?s-n:0;s-=l,s&&s<r.size&&ml(r.textBetween(s-1,s+1))&&(s+=l?1:-1),o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}function ml(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Em{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Kp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_l),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=yl(this),bl(this),this.nodeViews=kl(this),this.docView=Yo(this.state.doc,gl(this),_i(this),this.dom,this),this.domObserver=new mm(this,(n,i,s,o)=>Cm(this,n,i,s,o)),this.domObserver.start(),$p(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Xi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_l),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(wc(this),o=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=kl(this);Nm(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xi(this),this.editable=yl(this),bl(this);let l=_i(this),c=gl(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,c,l);(f||!e.selection.eq(i.selection))&&(o=!0);let d=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&op(this);if(o){this.domObserver.stop();let h=f&&(Le||ve)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Om(i.selection,e.selection);if(f){let p=ve?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=sm(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Yo(e.doc,c,l,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&vp(this))?bt(this,h):(fc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&lp(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof U){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Jo(this,t.getBoundingClientRect(),e)}else Jo(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new Ec(e.slice,e.move,i<0?void 0:U.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(i=t?t(a):a))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let a=s[o].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(Le){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ap(this.dom),bt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return hp(this,e)}coordsAtPos(e,t=1){return rc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return yp(this,t||this.state,e)}pasteHTML(e,t){return qn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return qn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Up(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_i(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Gp(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Re&&this.root.nodeType===11&&ep(this.dom.ownerDocument)==this.dom&&bm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function gl(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[et.node(0,r.state.doc.content.size,e)]}function bl(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:et.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function yl(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Om(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function kl(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Nm(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function _l(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Am=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function vm(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Am?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Dm(r){let e=Object.create(null);for(let t in r)e[vm(t)]=r[t];return e}function Ci(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function xm(r){return new dt({props:{handleKeyDown:Im(r)}})}function Im(r){let e=Dm(r);return function(t,n){let i=Wu(n),s,o=e[Ci(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let a=e[Ci(i,n,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(s=qu[n.keyCode])&&s!=i){let a=e[Ci(s,n)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const Pm=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Dc(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Rm=(r,e,t)=>{let n=Dc(r,t);if(!n)return!1;let i=ws(n);if(!i){let o=n.blockRange(),a=o&&Mn(o);return a==null?!1:(e&&e(r.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(Rc(r,i,e,-1))return!0;if(n.parent.content.size==0&&(_n(s,"end")||U.isSelectable(s)))for(let o=n.depth;;o--){let a=Jr(r.doc,n.before(o),n.after(o),B.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=r.tr.step(a);l.setSelection(_n(s,"end")?Z.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):U.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Bm=(r,e,t)=>{let n=Dc(r,t);if(!n)return!1;let i=ws(n);return i?xc(r,i,e):!1},zm=(r,e,t)=>{let n=Ic(r,t);if(!n)return!1;let i=Ts(n);return i?xc(r,i,e):!1};function xc(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Jr(r.doc,s,l,B.empty);if(!c||c.from!=s||c instanceof Se&&c.slice.size>=l-s)return!1;if(t){let u=r.tr.step(c);u.setSelection(X.create(u.doc,s)),t(u.scrollIntoView())}return!0}function _n(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const Fm=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=ws(n)}let o=s&&s.nodeBefore;return!o||!U.isSelectable(o)?!1:(e&&e(r.tr.setSelection(U.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ws(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Ic(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Vm=(r,e,t)=>{let n=Ic(r,t);if(!n)return!1;let i=Ts(n);if(!i)return!1;let s=i.nodeAfter;if(Rc(r,i,e,1))return!0;if(n.parent.content.size==0&&(_n(s,"start")||U.isSelectable(s))){let o=Jr(r.doc,n.before(),n.after(),B.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=r.tr.step(o);a.setSelection(_n(s,"start")?Z.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):U.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Lm=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=Ts(n)}let o=s&&s.nodeAfter;return!o||!U.isSelectable(o)?!1:(e&&e(r.tr.setSelection(U.create(r.doc,s.pos)).scrollIntoView()),!0)};function Ts(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const jm=(r,e)=>{let t=r.selection,n=t instanceof U,i;if(n){if(t.node.isTextblock||!en(r.doc,t.from))return!1;i=t.from}else if(i=qr(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(U.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Wm=(r,e)=>{let t=r.selection,n;if(t instanceof U){if(t.node.isTextblock||!en(r.doc,t.to))return!1;n=t.to}else if(n=qr(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},qm=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&Mn(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Jm=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
112
- `).scrollIntoView()),!0)};function Pc(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Km=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Pc(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let a=t.after(),l=r.tr.replaceWith(a,a,o.createAndFill());l.setSelection(Z.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},$m=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof Xe||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=Pc(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,a=r.tr.insert(o,s.createAndFill());a.setSelection(X.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},Um=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(hn(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Mn(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)},Hm=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(U.create(r.doc,i))),!0)};function Gm(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||en(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function Rc(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,a,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&Gm(r,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&a.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=O.empty;for(let b=o.length-1;b>=0;b--)p=O.from(o[b].create(null,p));p=O.from(i.copy(p));let m=r.tr.step(new Ce(e.pos-1,h,e.pos,h,new B(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&en(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||n>0&&l?null:Z.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&Mn(f);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(f,d).scrollIntoView()),!0;if(c&&_n(s,"start",!0)&&_n(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=O.empty;for(let M=p.length-1;M>=0;M--)b=O.from(p[M].copy(b));let y=r.tr.step(new Ce(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new B(b,p.length,0),0,!0));t(y.scrollIntoView())}return!0}}return!1}function Bc(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(X.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Ym=Bc(-1),Xm=Bc(1);function Zm(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),a=o&&ja(o,r,e);return a?(n&&n(t.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Sl(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:a}}=t.selection.ranges[s];t.doc.nodesBetween(o,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(r,e)))if(l.type==r)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[o];s.setBlockType(a,l,r,e)}n(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Qm(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let a=n?t.tr:null;return eg(a,o,r,e)?(n&&n(a.scrollIntoView()),!0):!1}}function eg(r,e,t,n=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);s=new Nr(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Nr(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=ja(s,t,n,e);return a?(r&&tg(r,e,a,i,t),!0):!1}function tg(r,e,t,n,i){let s=O.empty;for(let u=t.length-1;u>=0;u--)s=O.from(t[u].type.create(t[u].attrs,s));r.step(new Ce(e.start-(n?2:0),e.end,e.start,e.end,new B(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let a=t.length-o,l=e.start+t.length-(n?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&hn(r.doc,l,a)&&(r.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return r}function ng(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?rg(e,t,r,s):ig(e,t,s):!0:!1}}function rg(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new Ce(s-1,o,s,o,new B(O.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Nr(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const a=Mn(n);if(a==null)return!1;i.lift(n,a);let l=i.mapping.map(s,-1)-1;return en(i.doc,l)&&i.join(l),e(i.scrollIntoView()),!0}function ig(r,e,t){let n=r.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,n.delete(h-1,h+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(a?0:1),u+1,o.content.append(l?O.empty:O.from(i))))return!1;let f=s.pos,d=f+o.nodeSize;return n.step(new Ce(f-(a?1:0),d+(l?1:0),f+1,d-1,new B((a?O.empty:O.from(i.copy(O.empty))).append(l?O.empty:O.from(i.copy(O.empty))),a?0:1,l?0:1),a?0:1)),e(n.scrollIntoView()),!0}function sg(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=r)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,u=O.from(c?r.create():null),f=new B(O.from(r.create(null,O.from(a.type.create(null,u)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new Ce(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function Gr(r){const{state:e,transaction:t}=r;let{selection:n}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){return n=t.selection,i=t.doc,s=t.storedMarks,t}}}class Yr{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{const f=l(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i,a=[],l=!!e,c=e||s.tr,u=()=>(!l&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),a.every(d=>d===!0)),f={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...m)=>{const g=this.buildProps(c,t),b=h(...m)(g);return a.push(b),f}])),run:u};return f}createCan(e){const{rawCommands:t,state:n}=this,i=!1,s=e||n.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i,a={tr:e,editor:i,view:o,state:Gr({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}class og{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(i=>i.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const n=(...i)=>{this.off(e,n),t.apply(this,i)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}}function j(r,e,t){return r.config[e]===void 0&&r.parent?j(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?j(r.parent,e,t):null}):r.config[e]}function Xr(r){const e=r.filter(i=>i.type==="extension"),t=r.filter(i=>i.type==="node"),n=r.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:n}}function zc(r){const e=[],{nodeExtensions:t,markExtensions:n}=Xr(r),i=[...t,...n],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return r.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage,extensions:i},l=j(o,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(f=>{Object.entries(u.attributes).forEach(([d,h])=>{e.push({type:f,name:d,attribute:{...s,...h}})})})})}),i.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=j(o,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,f])=>{const d={...s,...f};typeof(d==null?void 0:d.default)=="function"&&(d.default=d.default()),d!=null&&d.isRequired&&(d==null?void 0:d.default)===void 0&&delete d.default,e.push({type:o.name,name:u,attribute:d})})}),e}function we(r,e){if(typeof r=="string"){if(!e.nodes[r])throw Error(`There is no node type named '${r}'. Maybe you forgot to add the extension?`);return e.nodes[r]}return r}function lg(...r){return r.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([i,s])=>{if(!n[i]){n[i]=s;return}if(i==="class"){const a=s?s.split(" "):[],l=n[i]?n[i].split(" "):[],c=a.filter(u=>!l.includes(u));n[i]=[...l,...c].join(" ")}else if(i==="style"){const a=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],l=n[i]?n[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[f,d]=u.split(":").map(h=>h.trim());c.set(f,d)}),a.forEach(u=>{const[f,d]=u.split(":").map(h=>h.trim());c.set(f,d)}),n[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else n[i]=s}),n},{})}function Zi(r,e){return e.filter(t=>t.type===r.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>lg(t,n),{})}function Fc(r){return typeof r=="function"}function Q(r,e=void 0,...t){return Fc(r)?e?r.bind(e)(...t):r(...t):r}function ag(r={}){return Object.keys(r).length===0&&r.constructor===Object}function cg(r){return typeof r!="string"?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):r==="true"?!0:r==="false"?!1:r}function Cl(r,e){return"style"in r?r:{...r,getAttrs:t=>{const n=r.getAttrs?r.getAttrs(t):r.attrs;if(n===!1)return!1;const i=e.reduce((s,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(t):cg(t.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...n,...i}}}}function Ml(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>e==="attrs"&&ag(t)?!1:t!=null))}function ug(r,e){var t;const n=zc(r),{nodeExtensions:i,markExtensions:s}=Xr(r),o=(t=i.find(c=>j(c,"topNode")))===null||t===void 0?void 0:t.name,a=Object.fromEntries(i.map(c=>{const u=n.filter(b=>b.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},d=r.reduce((b,y)=>{const M=j(y,"extendNodeSchema",f);return{...b,...M?M(c):{}}},{}),h=Ml({...d,content:Q(j(c,"content",f)),marks:Q(j(c,"marks",f)),group:Q(j(c,"group",f)),inline:Q(j(c,"inline",f)),atom:Q(j(c,"atom",f)),selectable:Q(j(c,"selectable",f)),draggable:Q(j(c,"draggable",f)),code:Q(j(c,"code",f)),whitespace:Q(j(c,"whitespace",f)),linebreakReplacement:Q(j(c,"linebreakReplacement",f)),defining:Q(j(c,"defining",f)),isolating:Q(j(c,"isolating",f)),attrs:Object.fromEntries(u.map(b=>{var y;return[b.name,{default:(y=b==null?void 0:b.attribute)===null||y===void 0?void 0:y.default}]}))}),p=Q(j(c,"parseHTML",f));p&&(h.parseDOM=p.map(b=>Cl(b,u)));const m=j(c,"renderHTML",f);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:Zi(b,u)}));const g=j(c,"renderText",f);return g&&(h.toText=g),[c.name,h]})),l=Object.fromEntries(s.map(c=>{const u=n.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},d=r.reduce((g,b)=>{const y=j(b,"extendMarkSchema",f);return{...g,...y?y(c):{}}},{}),h=Ml({...d,inclusive:Q(j(c,"inclusive",f)),excludes:Q(j(c,"excludes",f)),group:Q(j(c,"group",f)),spanning:Q(j(c,"spanning",f)),code:Q(j(c,"code",f)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),p=Q(j(c,"parseHTML",f));p&&(h.parseDOM=p.map(g=>Cl(g,u)));const m=j(c,"renderHTML",f);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Zi(g,u)})),[c.name,h]}));return new Ia({topNode:o,nodes:a,marks:l})}function Mi(r,e){return e.nodes[r]||e.marks[r]||null}function wl(r,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===r.name):e}function Es(r,e){const t=Qt.fromSchema(e).serializeFragment(r),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const fg=(r,e=500)=>{let t="";const n=r.parentOffset;return r.parent.nodesBetween(Math.max(0,n-e),n,(i,s,o,a)=>{var l,c;const u=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,n-s))}),t};function Os(r){return Object.prototype.toString.call(r)==="[object RegExp]"}const dg=(r,e)=>{if(Os(e))return e.exec(r);const t=e(r);if(!t)return null;const n=[t.text];return n.index=t.index,n.input=r,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(t.replaceWith)),n};function cr(r){var e;const{editor:t,from:n,to:i,text:s,rules:o,plugin:a}=r,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(n);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(d=>d.type.spec.code))return!1;let u=!1;const f=fg(c)+s;return o.forEach(d=>{if(u)return;const h=dg(f,d.find);if(!h)return;const p=l.state.tr,m=Gr({state:l.state,transaction:p}),g={from:n-(h[0].length-s.length),to:i},{commands:b,chain:y,can:M}=new Yr({editor:t,state:m});d.handler({state:m,range:g,match:h,commands:b,chain:y,can:M})===null||!p.steps.length||(p.setMeta(a,{transform:p,from:n,to:i,text:s}),l.dispatch(p),u=!0)}),u}function hg(r){const{editor:e,rules:t}=r,n=new dt({state:{init(){return null},apply(i,s,o){const a=i.getMeta(n);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Es(O.from(u),o.schema);const{from:f}=l,d=f+u.length;cr({editor:e,from:f,to:d,text:u,rules:t,plugin:n})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return cr({editor:e,from:s,to:o,text:a,rules:t,plugin:n})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&cr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:n})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?cr({editor:e,from:o.pos,to:o.pos,text:`
113
- `,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function pg(r){return Object.prototype.toString.call(r).slice(8,-1)}function ur(r){return pg(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function Zr(r,e){const t={...r};return ur(r)&&ur(e)&&Object.keys(e).forEach(n=>{ur(e[n])&&ur(r[n])?t[n]=Zr(r[n],e[n]):t[n]=e[n]}),t}class Kn{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Q(j(this,"addOptions",{name:this.name}))),this.storage=Q(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Kn(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zr(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Kn(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Q(j(t,"addOptions",{name:t.name})),t.storage=Q(j(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const l=o.find(c=>(c==null?void 0:c.type.name)===t.name);return l&&n.removeStoredMark(l),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}function mg(r){return typeof r=="number"}const gg=(r,e,t)=>{if(Os(e))return[...r.matchAll(e)];const n=e(r,t);return n?n.map(i=>{const s=[i.text];return s.index=i.index,s.input=r,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function bg(r){const{editor:e,state:t,from:n,to:i,rule:s,pasteEvent:o,dropEvent:a}=r,{commands:l,chain:c,can:u}=new Yr({editor:e,state:t}),f=[];return t.doc.nodesBetween(n,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(n,p),g=Math.min(i,p+h.content.size),b=h.textBetween(m-p,g-p,void 0,"");gg(b,s.find,o).forEach(M=>{if(M.index===void 0)return;const T=m+M.index+1,S=T+M[0].length,E={from:t.tr.mapping.map(T),to:t.tr.mapping.map(S)},W=s.handler({state:t,range:E,match:M,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});f.push(W)})}),f.every(h=>h!==null)}let fr=null;const yg=r=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",r),t};function kg(r){const{editor:e,rules:t}=r;let n=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:u,from:f,to:d,rule:h,pasteEvt:p})=>{const m=u.tr,g=Gr({state:u,transaction:m});if(!(!bg({editor:e,state:g,from:Math.max(f-1,0),to:d.b-1,rule:h,pasteEvent:p,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(u=>new dt({view(f){const d=p=>{var m;n=!((m=f.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?f.dom.parentElement:null,n&&(fr=e)},h=()=>{fr&&(fr=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(f,d)=>{if(s=n===f.dom.parentElement,a=d,!s){const h=fr;h&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(f,d)=>{var h;const p=(h=d.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=d,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(f,d,h)=>{const p=f[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,b=p.getMeta("applyPasteRules"),y=!!b;if(!m&&!g&&!y)return;if(y){let{text:S}=b;typeof S=="string"?S=S:S=Es(O.from(S),h.schema);const{from:E}=b,W=E+S.length,D=yg(S);return l({rule:u,state:h,from:E,to:{b:W},pasteEvt:D})}const M=d.doc.content.findDiffStart(h.doc.content),T=d.doc.content.findDiffEnd(h.doc.content);if(!(!mg(M)||!T||M===T.b))return l({rule:u,state:h,from:M,to:T,pasteEvt:o})}}))}function _g(r){const e=r.filter((t,n)=>r.indexOf(t)!==n);return Array.from(new Set(e))}class dn{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=dn.resolve(e),this.schema=ug(this.extensions,t),this.setupExtensions()}static resolve(e){const t=dn.sort(dn.flatten(e)),n=_g(t.map(i=>i.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const n={name:t.name,options:t.options,storage:t.storage},i=j(t,"addExtensions",n);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((n,i)=>{const s=j(n,"priority")||100,o=j(i,"priority")||100;return s>o?-1:s<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Mi(t.name,this.schema)},i=j(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=dn.sort([...this.extensions].reverse()),n=[],i=[],s=t.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:e,type:Mi(o.name,this.schema)},l=[],c=j(o,"addKeyboardShortcuts",a);let u={};if(o.type==="mark"&&j(o,"exitable",a)&&(u.ArrowRight=()=>Kn.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));u={...u,...m}}const f=xm(u);l.push(f);const d=j(o,"addInputRules",a);wl(o,e.options.enableInputRules)&&d&&n.push(...d());const h=j(o,"addPasteRules",a);wl(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=j(o,"addProseMirrorPlugins",a);if(p){const m=p();l.push(...m)}return l}).flat();return[hg({editor:e,rules:n}),...kg({editor:e,rules:i}),...s]}get attributes(){return zc(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Xr(this.extensions);return Object.fromEntries(t.filter(n=>!!j(n,"addNodeView")).map(n=>{const i=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:e,type:we(n.name,this.schema)},o=j(n,"addNodeView",s);if(!o)return[];const a=(l,c,u,f,d)=>{const h=Zi(l,i);return o()({node:l,view:c,getPos:u,decorations:f,innerDecorations:d,editor:e,extension:n,HTMLAttributes:h})};return[n.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Mi(e.name,this.schema)};e.type==="mark"&&(!((t=Q(j(e,"keepOnSplit",n)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=j(e,"onBeforeCreate",n),s=j(e,"onCreate",n),o=j(e,"onUpdate",n),a=j(e,"onSelectionUpdate",n),l=j(e,"onTransaction",n),c=j(e,"onFocus",n),u=j(e,"onBlur",n),f=j(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}}class nt{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Q(j(this,"addOptions",{name:this.name}))),this.storage=Q(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new nt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zr(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new nt({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Q(j(t,"addOptions",{name:t.name})),t.storage=Q(j(t,"addStorage",{name:t.name,options:t.options})),t}}function Vc(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
114
-
115
- `,textSerializers:o={}}=t||{};let a="";return r.nodesBetween(n,i,(l,c,u,f)=>{var d;l.isBlock&&c>n&&(a+=s);const h=o==null?void 0:o[l.type.name];if(h)return u&&(a+=h({node:l,pos:c,parent:u,index:f,range:e})),!1;l.isText&&(a+=(d=l==null?void 0:l.text)===null||d===void 0?void 0:d.slice(Math.max(n,c)-c,i-c))}),a}function Lc(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Sg=nt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new dt({key:new tn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),l=Lc(t);return Vc(n,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Cg=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Mg=(r=!1)=>({commands:e})=>e.setContent("",r),wg=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,f=c.resolve(u.map(l)),d=c.resolve(u.map(l+a.nodeSize)),h=f.blockRange(d);if(!h)return;const p=Mn(h);if(a.type.isTextblock){const{defaultType:m}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Tg=r=>e=>r(e),Eg=()=>({state:r,dispatch:e})=>$m(r,e),Og=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new X(n.doc.resolve(o-1))),!0},Ng=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const a=i.before(s),l=i.after(s);r.delete(a,l).scrollIntoView()}return!0}return!1},Ag=r=>({tr:e,state:t,dispatch:n})=>{const i=we(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const l=s.before(o),c=s.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},vg=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},Dg=()=>({state:r,dispatch:e})=>Pm(r,e),xg=()=>({commands:r})=>r.keyboardShortcut("Enter"),Ig=()=>({state:r,dispatch:e})=>Km(r,e);function Rr(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:Os(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function jc(r,e,t={}){return r.find(n=>n.type===e&&Rr(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function Tl(r,e,t={}){return!!jc(r,e,t)}function Wc(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((n=i.node.marks[0])===null||n===void 0?void 0:n.attrs),!jc([...i.node.marks],e,t)))return;let o=i.index,a=r.start()+i.offset,l=o+1,c=a+i.node.nodeSize;for(;o>0&&Tl([...r.parent.child(o-1).marks],e,t);)o-=1,a-=r.parent.child(o).nodeSize;for(;l<r.parent.childCount&&Tl([...r.parent.child(l).marks],e,t);)c+=r.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Pt(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}const Pg=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Pt(r,n.schema),{doc:o,selection:a}=t,{$from:l,from:c,to:u}=a;if(i){const f=Wc(l,s,e);if(f&&f.from<=c&&f.to>=u){const d=X.create(o,f.from,f.to);t.setSelection(d)}}return!0},Rg=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function qc(r){return r instanceof X}function Wt(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function Jc(r,e=null){if(!e)return null;const t=Z.atStart(r),n=Z.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?X.create(r,Wt(0,i,s),Wt(r.content.size,i,s)):X.create(r,Wt(e,i,s),Wt(e,i,s))}const Bg=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!qc(t.state.selection))return o(),!0;const a=Jc(i.doc,r)||t.state.selection,l=t.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},zg=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),Fg=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),Kc=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&Kc(n)}return r};function dr(r){const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Kc(t)}function Br(r,e,t){if(r instanceof Et||r instanceof O)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return O.fromArray(r.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),Br("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,a="";const l=new Ia({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ot.fromSchema(l).parseSlice(dr(r),t.parseOptions):Ot.fromSchema(l).parse(dr(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=Ot.fromSchema(e);return t.slice?s.parseSlice(dr(r),t.parseOptions).content:s.parse(dr(r),t.parseOptions)}return Br("",e,t)}function Vg(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof Se||i instanceof Ce))return;const s=r.mapping.maps[n];let o=0;s.forEach((a,l,c,u)=>{o===0&&(o=u)}),r.setSelection(Z.near(r.doc.resolve(o),t))}const Lg=r=>!("type"in r),jg=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;try{a=Br(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(p){return s.emit("contentError",{editor:s,error:p,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:l,to:c}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},u=!0,f=!0;if((Lg(a)?a:[a]).forEach(p=>{p.check(),u=u?p.isText&&p.marks.length===0:!1,f=f?p.isBlock:!1}),l===c&&f){const{parent:p}=n.doc.resolve(l);p.isTextblock&&!p.type.spec.code&&!p.childCount&&(l-=1,c+=1)}let h;if(u){if(Array.isArray(e))h=e.map(p=>p.text||"").join("");else if(e instanceof O){let p="";e.forEach(m=>{m.text&&(p+=m.text)}),h=p}else typeof e=="object"&&e&&e.text?h=e.text:h=e;n.insertText(h,l,c)}else h=a,n.replaceWith(l,c,h);t.updateSelection&&Vg(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:l,text:h}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:l,text:h})}return!0},Wg=()=>({state:r,dispatch:e})=>jm(r,e),qg=()=>({state:r,dispatch:e})=>Wm(r,e),Jg=()=>({state:r,dispatch:e})=>Rm(r,e),Kg=()=>({state:r,dispatch:e})=>Vm(r,e),$g=()=>({state:r,dispatch:e,tr:t})=>{try{const n=qr(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ug=()=>({state:r,dispatch:e,tr:t})=>{try{const n=qr(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Hg=()=>({state:r,dispatch:e})=>Bm(r,e),Gg=()=>({state:r,dispatch:e})=>zm(r,e);function $c(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Uc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Yg(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))$c()||Uc()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const Xg=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Yg(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l==null||l.steps.forEach(c=>{const u=c.map(n.mapping);u&&i&&n.maybeStep(u)}),!0};function $n(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?we(e,r.schema):null,a=[];r.doc.nodesBetween(n,i,(f,d)=>{if(f.isText)return;const h=Math.max(n,d),p=Math.min(i,d+f.nodeSize);a.push({node:f,from:h,to:p})});const l=i-n,c=a.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>Rr(f.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((f,d)=>f+d.to-d.from,0)>=l}const Zg=(r,e={})=>({state:t,dispatch:n})=>{const i=we(r,t.schema);return $n(t,i,e)?qm(t,n):!1},Qg=()=>({state:r,dispatch:e})=>Um(r,e),eb=r=>({state:e,dispatch:t})=>{const n=we(r,e.schema);return ng(n)(e,t)},tb=()=>({state:r,dispatch:e})=>Jm(r,e);function Qr(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function El(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}const nb=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const a=Qr(typeof r=="string"?r:r.name,n.schema);return a?(a==="node"&&(s=we(r,n.schema)),a==="mark"&&(o=Pt(r,n.schema)),i&&t.selection.ranges.forEach(l=>{n.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,El(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(f=>{o===f.type&&t.addMark(u,u+c.nodeSize,o.create(El(f.attrs,e)))})})}),!0):!1},rb=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),ib=()=>({tr:r,dispatch:e})=>{if(e){const t=new Xe(r.doc);r.setSelection(t)}return!0},sb=()=>({state:r,dispatch:e})=>Fm(r,e),ob=()=>({state:r,dispatch:e})=>Lm(r,e),lb=()=>({state:r,dispatch:e})=>Hm(r,e),ab=()=>({state:r,dispatch:e})=>Xm(r,e),cb=()=>({state:r,dispatch:e})=>Ym(r,e);function Qi(r,e,t={},n={}){return Br(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}const ub=(r,e=!1,t={},n={})=>({editor:i,tr:s,dispatch:o,commands:a})=>{var l,c;const{doc:u}=s;if(t.preserveWhitespace!=="full"){const f=Qi(r,i.schema,t,{errorOnInvalidContent:(l=n.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return o&&s.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:u.content.size},r,{parseOptions:t,errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function Hc(r,e){const t=Pt(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function fb(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function db(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function Ns(r){return e=>db(e.$from,r)}function hb(r,e){const t={from:0,to:r.content.size};return Vc(r,t,e)}function pb(r,e){const t=we(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,a=>{s.push(a)});const o=s.reverse().find(a=>a.type.name===t.name);return o?{...o.attrs}:{}}function mb(r,e){const t=Qr(typeof e=="string"?e:e.name,r.schema);return t==="node"?pb(r,e):t==="mark"?Hc(r,e):{}}function _r(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function es(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Pt(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>Rr(f.attrs,t,{strict:!1}));let o=0;const a=[];if(i.forEach(({$from:f,$to:d})=>{const h=f.pos,p=d.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),y=Math.min(p,g+m.nodeSize),M=y-b;o+=M,a.push(...m.marks.map(T=>({mark:T,from:b,to:y})))})}),o===0)return!1;const l=a.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>Rr(f.mark.attrs,t,{strict:!1})).reduce((f,d)=>f+d.to-d.from,0),c=a.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,d)=>f+d.to-d.from,0);return(l>0?l+c:l)>=o}function gb(r,e,t={}){if(!e)return $n(r,null,t)||es(r,null,t);const n=Qr(e,r.schema);return n==="node"?$n(r,e,t):n==="mark"?es(r,e,t):!1}function Ol(r,e){const{nodeExtensions:t}=Xr(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=Q(j(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function As(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return/^\s*$/m.test((n=r.text)!==null&&n!==void 0?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(As(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function bb(r,e,t){var n;const{selection:i}=e;let s=null;if(qc(i)&&(s=i.$cursor),s){const a=(n=r.storedMarks)!==null&&n!==void 0?n:s.marks();return!!t.isInSet(a)||!a.some(l=>l.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(a.pos,l.pos,(u,f,d)=>{if(c)return!1;if(u.isInline){const h=!d||d.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const yb=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:a}=s,l=Pt(r,n.schema);if(i)if(o){const c=Hc(n,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;n.doc.nodesBetween(u,f,(d,h)=>{const p=Math.max(h,u),m=Math.min(h+d.nodeSize,f);d.marks.find(b=>b.type===l)?d.marks.forEach(b=>{l===b.type&&t.addMark(p,m,l.create({...b.attrs,...e}))}):t.addMark(p,m,l.create(e))})});return bb(n,t,l)},kb=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),_b=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=we(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:a})=>Sl(s,{...o,...e})(t)?!0:a.clearNodes()).command(({state:a})=>Sl(s,{...o,...e})(a,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Sb=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=Wt(r,0,n.content.size),s=U.create(n,i);e.setSelection(s)}return!0},Cb=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=X.atStart(n).from,a=X.atEnd(n).to,l=Wt(i,o,a),c=Wt(s,o,a),u=X.create(n,l,c);e.setSelection(u)}return!0},Mb=r=>({state:e,dispatch:t})=>{const n=we(r,e.schema);return sg(n)(e,t)};function Nl(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}const wb=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=i.extensionManager.attributes,u=_r(c,a.node().type.name,a.node().attrs);if(s instanceof U&&s.node.isBlock)return!a.parentOffset||!hn(o,a.pos)?!1:(n&&(r&&Nl(t,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,d=a.depth===0?void 0:fb(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=f&&d?[{type:d,attrs:u}]:void 0,p=hn(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&hn(e.doc,e.mapping.map(a.pos),1,d?[{type:d}]:void 0)&&(p=!0,h=d?[{type:d,attrs:u}]:void 0),n){if(p&&(s instanceof X&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),d&&!f&&!a.parentOffset&&a.parent.type!==d)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(a.before()),d)}r&&Nl(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Tb=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const a=we(r,n.schema),{$from:l,$to:c}=n.selection,u=n.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.type!==a)return!1;const d=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=O.empty;const y=l.index(-1)?1:l.index(-2)?2:3;for(let D=l.depth-y;D>=l.depth-3;D-=1)b=O.from(l.node(D).copy(b));const M=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={..._r(d,l.node().type.name,l.node().attrs),...e},S=((o=a.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(T))||void 0;b=b.append(O.from(a.createAndFill(null,S)||void 0));const E=l.before(l.depth-(y-1));t.replace(E,l.after(-M),new B(b,4-y,0));let W=-1;t.doc.nodesBetween(E,t.doc.content.size,(D,v)=>{if(W>-1)return!1;D.isTextblock&&D.content.size===0&&(W=v+1)}),W>-1&&t.setSelection(X.near(t.doc.resolve(W))),t.scrollIntoView()}return!0}const h=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,p={..._r(d,f.type.name,f.attrs),...e},m={..._r(d,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const g=h?[{type:a,attrs:p},{type:h,attrs:m}]:[{type:a,attrs:p}];if(!hn(t.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:y}=n,{splittableMarks:M}=s.extensionManager,T=y||b.$to.parentOffset&&b.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!T||!i)return!0;const S=T.filter(E=>M.includes(E.type.name));t.ensureMarks(S)}return!0},wi=(r,e)=>{const t=Ns(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&en(r.doc,t.pos)&&r.join(t.pos),!0},Ti=(r,e)=>{const t=Ns(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&en(r.doc,n)&&r.join(n),!0},Eb=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:f,splittableMarks:d}=i.extensionManager,h=we(r,o.schema),p=we(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:y}=m,M=b.blockRange(y),T=g||m.$to.parentOffset&&m.$from.marks();if(!M)return!1;const S=Ns(E=>Ol(E.type.name,f))(m);if(M.depth>=1&&S&&M.depth-S.depth<=1){if(S.node.type===h)return c.liftListItem(p);if(Ol(S.node.type.name,f)&&h.validContent(S.node.content)&&a)return l().command(()=>(s.setNodeMarkup(S.pos,h),!0)).command(()=>wi(s,h)).command(()=>Ti(s,h)).run()}return!t||!T||!a?l().command(()=>u().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>wi(s,h)).command(()=>Ti(s,h)).run():l().command(()=>{const E=u().wrapInList(h,n),W=T.filter(D=>d.includes(D.type.name));return s.ensureMarks(W),E?!0:c.clearNodes()}).wrapInList(h,n).command(()=>wi(s,h)).command(()=>Ti(s,h)).run()},Ob=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Pt(r,n.schema);return es(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Nb=(r,e,t={})=>({state:n,commands:i})=>{const s=we(r,n.schema),o=we(e,n.schema),a=$n(n,s,t);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),a?i.setNode(o,l):i.setNode(s,{...l,...t})},Ab=(r,e={})=>({state:t,commands:n})=>{const i=we(r,t.schema);return $n(t,i,e)?n.lift(i):n.wrapIn(i,e)},vb=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,a=s.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},Db=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},xb=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=t,l=Pt(r,n.schema),{$from:c,empty:u,ranges:f}=a;if(!i)return!0;if(u&&o){let{from:d,to:h}=a;const p=(s=c.marks().find(g=>g.type===l))===null||s===void 0?void 0:s.attrs,m=Wc(c,l,p);m&&(d=m.from,h=m.to),t.removeMark(d,h,l)}else f.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,l)});return t.removeStoredMark(l),!0},Ib=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const a=Qr(typeof r=="string"?r:r.name,n.schema);return a?(a==="node"&&(s=we(r,n.schema)),a==="mark"&&(o=Pt(r,n.schema)),i&&t.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;let f,d,h,p;t.selection.empty?n.doc.nodesBetween(c,u,(m,g)=>{s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,u),f=g,d=m)}):n.doc.nodesBetween(c,u,(m,g)=>{g<c&&s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,u),f=g,d=m),g>=c&&g<=u&&(s&&s===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(b=>{if(o===b.type){const y=Math.max(g,c),M=Math.min(g+m.nodeSize,u);t.addMark(y,M,o.create({...b.attrs,...e}))}}))}),d&&(f!==void 0&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},Pb=(r,e={})=>({state:t,dispatch:n})=>{const i=we(r,t.schema);return Zm(i,e)(t,n)},Rb=(r,e={})=>({state:t,dispatch:n})=>{const i=we(r,t.schema);return Qm(i,e)(t,n)};var Bb=Object.freeze({__proto__:null,blur:Cg,clearContent:Mg,clearNodes:wg,command:Tg,createParagraphNear:Eg,cut:Og,deleteCurrentNode:Ng,deleteNode:Ag,deleteRange:vg,deleteSelection:Dg,enter:xg,exitCode:Ig,extendMarkRange:Pg,first:Rg,focus:Bg,forEach:zg,insertContent:Fg,insertContentAt:jg,joinBackward:Jg,joinDown:qg,joinForward:Kg,joinItemBackward:$g,joinItemForward:Ug,joinTextblockBackward:Hg,joinTextblockForward:Gg,joinUp:Wg,keyboardShortcut:Xg,lift:Zg,liftEmptyBlock:Qg,liftListItem:eb,newlineInCode:tb,resetAttributes:nb,scrollIntoView:rb,selectAll:ib,selectNodeBackward:sb,selectNodeForward:ob,selectParentNode:lb,selectTextblockEnd:ab,selectTextblockStart:cb,setContent:ub,setMark:yb,setMeta:kb,setNode:_b,setNodeSelection:Sb,setTextSelection:Cb,sinkListItem:Mb,splitBlock:wb,splitListItem:Tb,toggleList:Eb,toggleMark:Ob,toggleNode:Nb,toggleWrap:Ab,undoInputRule:vb,unsetAllMarks:Db,unsetMark:xb,updateAttributes:Ib,wrapIn:Pb,wrapInList:Rb});const zb=nt.create({name:"commands",addCommands(){return{...Bb}}}),Fb=nt.create({name:"drop",addProseMirrorPlugins(){return[new dt({key:new tn("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),Vb=nt.create({name:"editable",addProseMirrorPlugins(){return[new dt({key:new tn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Lb=nt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new dt({key:new tn("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),jb=nt.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:f}=l,{pos:d,parent:h}=f,p=f.parent.isTextblock&&d>0?a.doc.resolve(d-1):f,m=p.parent.type.spec.isolating,g=f.pos-f.parentOffset,b=m&&p.parent.childCount===1?g===f.pos:Z.atStart(c).from===d;return!u||!h.type.isTextblock||h.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return $c()||Uc()?s:i},addProseMirrorPlugins(){return[new dt({key:new tn("clearDocument"),appendTransaction:(r,e,t)=>{const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:a}=e.selection,l=Z.atStart(e.doc).from,c=Z.atEnd(e.doc).to;if(s||!(o===l&&a===c)||!As(t.doc))return;const d=t.tr,h=Gr({state:t,transaction:d}),{commands:p}=new Yr({editor:this.editor,state:h});if(p.clearNodes(),!!d.steps.length)return d}})]}}),Wb=nt.create({name:"paste",addProseMirrorPlugins(){return[new dt({key:new tn("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),qb=nt.create({name:"tabindex",addProseMirrorPlugins(){return[new dt({key:new tn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Ft{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Ft(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ft(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ft(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,n)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+n+(s?0:1),a=this.resolvedPos.doc.resolve(o);if(!i&&a.depth<=this.depth)return;const l=new Ft(a,this.editor,i,i?t:null);i&&(l.actualDepth=this.depth+1),e.push(new Ft(a,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let a=0;a<o.length;a+=1){const l=o[a];if(s[l]!==t[l])break}}else n=i;i=i.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{n&&i.length>0||(o.node.type.name===e&&s.every(l=>t[l]===o.node.attrs[l])&&i.push(o),!(n&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,n))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const Jb=`.ProseMirror {
116
- position: relative;
117
- }
118
-
119
- .ProseMirror {
120
- word-wrap: break-word;
121
- white-space: pre-wrap;
122
- white-space: break-spaces;
123
- -webkit-font-variant-ligatures: none;
124
- font-variant-ligatures: none;
125
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
126
- }
127
-
128
- .ProseMirror [contenteditable="false"] {
129
- white-space: normal;
130
- }
131
-
132
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
133
- white-space: pre-wrap;
134
- }
135
-
136
- .ProseMirror pre {
137
- white-space: pre-wrap;
138
- }
139
-
140
- img.ProseMirror-separator {
141
- display: inline !important;
142
- border: none !important;
143
- margin: 0 !important;
144
- width: 0 !important;
145
- height: 0 !important;
146
- }
147
-
148
- .ProseMirror-gapcursor {
149
- display: none;
150
- pointer-events: none;
151
- position: absolute;
152
- margin: 0;
153
- }
154
-
155
- .ProseMirror-gapcursor:after {
156
- content: "";
157
- display: block;
158
- position: absolute;
159
- top: -2px;
160
- width: 20px;
161
- border-top: 1px solid black;
162
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
163
- }
164
-
165
- @keyframes ProseMirror-cursor-blink {
166
- to {
167
- visibility: hidden;
168
- }
169
- }
170
-
171
- .ProseMirror-hideselection *::selection {
172
- background: transparent;
173
- }
174
-
175
- .ProseMirror-hideselection *::-moz-selection {
176
- background: transparent;
177
- }
178
-
179
- .ProseMirror-hideselection * {
180
- caret-color: transparent;
181
- }
182
-
183
- .ProseMirror-focused .ProseMirror-gapcursor {
184
- display: block;
185
- }
186
-
187
- .tippy-box[data-animation=fade][data-state=hidden] {
188
- opacity: 0
189
- }`;function Kb(r,e,t){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=r,document.getElementsByTagName("head")[0].appendChild(i),i}class $b extends og{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:n,moved:i})=>this.options.onDrop(t,n,i)),this.on("paste",({event:t,slice:n})=>this.options.onPaste(t,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Kb(Jb,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Fc(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let n=t;if([].concat(e).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;n=t.filter(a=>!a.key.startsWith(o))}),t.length===n.length)return;const i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[Vb,Sg.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),zb,Lb,jb,qb,Fb,Wb].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new dn(i,this)}createCommandManager(){this.commandManager=new Yr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Qi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),t=Qi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=Jc(t,this.options.autofocus);this.view=new Em(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:fn.create({doc:t,selection:n||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return mb(this.state,e)}isActive(e,t){const n=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return gb(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Es(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
190
-
191
- `,textSerializers:n={}}=e||{};return hb(this.state.doc,{blockSeparator:t,textSerializers:{...Lc(this.schema),...n}})}get isEmpty(){return As(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Ft(t,this)}get $doc(){return this.$pos(0)}}class Sn{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Q(j(this,"addOptions",{name:this.name}))),this.storage=Q(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Sn(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zr(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Sn(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Q(j(t,"addOptions",{name:t.name})),t.storage=Q(j(t,"addStorage",{name:t.name,options:t.options})),t}}const Ub=Sn.create({name:"doc",topNode:!0,content:"block+"}),Hb=Sn.create({name:"text",group:"inline"});function Al(r,e,t){const n=r.slice();return n[23]=e[t],n}function vl(r,e,t){const n=r.slice();return n[26]=e[t],n}function Dl(r,e,t){const n=r.slice();return n[31]=e[t],n[33]=t,n}function xl(r,e,t){const n=r.slice();return n[34]=e[t],n}function Il(r,e,t){const n=r.slice();return n[31]=e[t],n[33]=t,n}function Pl(r,e,t){const n=r.slice();return n[26]=e[t],n}function Rl(r){let e,t,n=fe(r[1].type.sidebar),i=[];for(let o=0;o<n.length;o+=1)i[o]=$l(Al(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o<i.length;o+=1)i[o].c();e=de()},m(o,a){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(o,a);N(o,e,a),t=!0},p(o,a){if(a[0]&407){n=fe(o[1].type.sidebar);let l;for(l=0;l<n.length;l+=1){const c=Al(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=$l(c),i[l].c(),_(i[l],1),i[l].m(e.parentNode,e))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function Bl(r){let e,t,n=r[23].title+"",i,s,o,a,l,c;const u=[Yb,Gb],f=[];function d(h,p){return h[23].type==="toolbar"?0:h[23].type==="form"?1:-1}return~(o=d(r))&&(a=f[o]=u[o](r)),{c(){e=R("section"),t=R("h2"),i=he(n),s=K(),a&&a.c(),l=K(),q(t,"class","font-bold mb-2"),q(e,"class","mb-4")},m(h,p){N(h,e,p),P(e,t),P(t,i),P(e,s),~o&&f[o].m(e,null),P(e,l),c=!0},p(h,p){(!c||p[0]&2)&&n!==(n=h[23].title+"")&&xe(i,n);let m=o;o=d(h),o===m?~o&&f[o].p(h,p):(a&&(ne(),C(f[m],1,1,()=>{f[m]=null}),re()),~o?(a=f[o],a?a.p(h,p):(a=f[o]=u[o](h),a.c()),_(a,1),a.m(e,l)):a=null)},i(h){c||(_(a),c=!0)},o(h){C(a),c=!1},d(h){h&&A(e),~o&&f[o].d()}}}function Gb(r){let e,t,n=fe(r[23].items),i=[];for(let o=0;o<n.length;o+=1)i[o]=Jl(vl(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){e=R("div");for(let o=0;o<i.length;o+=1)i[o].c();q(e,"class","flex flex-row flex-wrap")},m(o,a){N(o,e,a);for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(e,null);t=!0},p(o,a){if(a[0]&407){n=fe(o[23].items);let l;for(l=0;l<n.length;l+=1){const c=vl(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=Jl(c),i[l].c(),_(i[l],1),i[l].m(e,null))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function Yb(r){let e,t;return e=new Cn({props:{class:"flex-wrap",$$slots:{default:[d1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i[0]&18|i[1]&128&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function Xb(r){let e=r[4],t,n=Fl(r);return{c(){n.c(),t=de()},m(i,s){n.m(i,s),N(i,t,s)},p(i,s){s[0]&16&&Ne(e,e=i[4])?(n.d(1),n=Fl(i),n.c(),n.m(t.parentNode,t)):n.p(i,s)},i:te,o:te,d(i){i&&A(t),n.d(i)}}}function Zb(r){let e,t,n=r[26].title+"",i,s,o,a,l,c,u;function f(...d){return r[16](r[26],...d)}return{c(){e=R("label"),t=R("span"),i=he(n),s=K(),o=R("input"),l=K(),q(t,"data-form-field-label",""),q(o,"type","text"),o.value=a=r[4].getAttributes(r[26].mark)[r[26].name],q(o,"data-form-field-text","")},m(d,h){N(d,e,h),P(e,t),P(t,i),P(e,s),P(e,o),P(e,l),c||(u=ee(o,"change",f),c=!0)},p(d,h){r=d,h[0]&2&&n!==(n=r[26].title+"")&&xe(i,n),h[0]&18&&a!==(a=r[4].getAttributes(r[26].mark)[r[26].name])&&o.value!==a&&(o.value=a)},i:te,o:te,d(d){d&&A(e),c=!1,u()}}}function Qb(r){let e,t=r[4],n,i,s,o,a=jl(r);return i=new Cn({props:{class:"flex-wrap",$$slots:{default:[o1]},$$scope:{ctx:r}}}),{c(){e=R("div"),a.c(),n=K(),F(i.$$.fragment),s=K(),q(e,"class","flex flex-row flex-wrap")},m(l,c){N(l,e,c),a.m(e,null),P(e,n),V(i,e,null),P(e,s),o=!0},p(l,c){c[0]&16&&Ne(t,t=l[4])?(ne(),C(a,1,1,te),re(),a=jl(l),a.c(),_(a,1),a.m(e,n)):a.p(l,c);const u={};c[0]&22|c[1]&128&&(u.$$scope={dirty:c,ctx:l}),i.$set(u)},i(l){o||(_(a),_(i.$$.fragment,l),o=!0)},o(l){C(a),C(i.$$.fragment,l),o=!1},d(l){l&&A(e),a.d(l),L(i)}}}function e1(r){let e,t,n=r[26].title+"",i,s,o,a,l,c,u;function f(...d){return r[13](r[26],...d)}return{c(){e=R("label"),t=R("span"),i=he(n),s=K(),o=R("input"),l=K(),q(t,"data-form-field-label",""),q(o,"type","text"),o.value=a=r[4].getAttributes(r[26].block)[r[26].name],q(o,"data-form-field-text","")},m(d,h){N(d,e,h),P(e,t),P(t,i),P(e,s),P(e,o),P(e,l),c||(u=ee(o,"change",f),c=!0)},p(d,h){r=d,h[0]&2&&n!==(n=r[26].title+"")&&xe(i,n),h[0]&18&&a!==(a=r[4].getAttributes(r[26].block)[r[26].name])&&o.value!==a&&(o.value=a)},i:te,o:te,d(d){d&&A(e),c=!1,u()}}}function t1(r){let e=r[4],t,n=ql(r);return{c(){n.c(),t=de()},m(i,s){n.m(i,s),N(i,t,s)},p(i,s){s[0]&16&&Ne(e,e=i[4])?(n.d(1),n=ql(i),n.c(),n.m(t.parentNode,t)):n.p(i,s)},i:te,o:te,d(i){i&&A(t),n.d(i)}}}function zl(r){let e,t=r[31].title+"",n,i;return{c(){e=R("option"),n=he(t),e.__value=i=r[31].value,wr(e,e.__value)},m(s,o){N(s,e,o),P(e,n)},p(s,o){o[0]&2&&t!==(t=s[31].title+"")&&xe(n,t),o[0]&2&&i!==(i=s[31].value)&&(e.__value=i,wr(e,e.__value))},d(s){s&&A(e)}}}function Fl(r){let e,t,n=r[26].title+"",i,s,o,a,l,c,u,f=fe(r[26].values),d=[];for(let p=0;p<f.length;p+=1)d[p]=zl(Dl(r,f,p));function h(...p){return r[17](r[26],...p)}return{c(){e=R("label"),t=R("span"),i=he(n),s=K(),o=R("select");for(let p=0;p<d.length;p+=1)d[p].c();l=K(),q(t,"class","sr-only"),q(o,"data-combobox-input",""),q(o,"class","bg-white")},m(p,m){N(p,e,m),P(e,t),P(t,i),P(e,s),P(e,o);for(let g=0;g<d.length;g+=1)d[g]&&d[g].m(o,null);Mr(o,r[4].getAttributes(r[26].mark)[r[26].name]),P(e,l),c||(u=ee(o,"change",h),c=!0)},p(p,m){if(r=p,m[0]&2&&n!==(n=r[26].title+"")&&xe(i,n),m[0]&2){f=fe(r[26].values);let g;for(g=0;g<f.length;g+=1){const b=Dl(r,f,g);d[g]?d[g].p(b,m):(d[g]=zl(b),d[g].c(),d[g].m(o,null))}for(;g<d.length;g+=1)d[g].d(1);d.length=f.length}m[0]&18&&a!==(a=r[4].getAttributes(r[26].mark)[r[26].name])&&Mr(o,r[4].getAttributes(r[26].mark)[r[26].name])},d(p){p&&A(e),rt(d,p),c=!1,u()}}}function Vl(r){let e,t,n=fe(r[7](r[26])),i=[];for(let o=0;o<n.length;o+=1)i[o]=Ll(xl(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o<i.length;o+=1)i[o].c();e=de()},m(o,a){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(o,a);N(o,e,a),t=!0},p(o,a){if(a[0]&130){n=fe(o[7](o[26]));let l;for(l=0;l<n.length;l+=1){const c=xl(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=Ll(c),i[l].c(),_(i[l],1),i[l].m(e.parentNode,e))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function n1(r){let e=r[34].label+"",t;return{c(){t=he(e)},m(n,i){N(n,t,i)},p(n,i){i[0]&2&&e!==(e=n[34].label+"")&&xe(t,e)},d(n){n&&A(t)}}}function Ll(r){let e,t;return e=new ca({props:{value:r[34].value,label:r[34].label,$$slots:{default:[n1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i[0]&2&&(s.value=n[34].value),i[0]&2&&(s.label=n[34].label),i[0]&2|i[1]&128&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function r1(r){let e,t,n=r[0][r[26].section].type.type==="textlist"&&Vl(r);return{c(){n&&n.c(),e=de()},m(i,s){n&&n.m(i,s),N(i,e,s),t=!0},p(i,s){i[0][i[26].section].type.type==="textlist"?n?(n.p(i,s),s[0]&3&&_(n,1)):(n=Vl(i),n.c(),_(n,1),n.m(e.parentNode,e)):n&&(ne(),C(n,1,1,()=>{n=null}),re())},i(i){t||(_(n),t=!0)},o(i){C(n),t=!1},d(i){i&&A(e),n&&n.d(i)}}}function i1(r){let e,t,n,i,s,o,a,l,c,u;return t=new aa({props:{placeholder:"Select the text to edit","aria-label":"Select the text to edit",class:"relative pr-6 z-10 bg-transparent"}}),s=new Me({props:{path:Vr,class:"w-6 h-6 combobox-expand"}}),a=new Me({props:{path:cs,class:"w-6 h-6 combobox-collapse"}}),c=new la({props:{$$slots:{default:[r1]},$$scope:{ctx:r}}}),{c(){e=R("div"),F(t.$$.fragment),n=K(),i=R("div"),F(s.$$.fragment),o=K(),F(a.$$.fragment),l=K(),F(c.$$.fragment),q(i,"class","absolute top-1/2 right-0 -translate-y-1/2"),q(e,"class","relative")},m(f,d){N(f,e,d),V(t,e,null),P(e,n),P(e,i),V(s,i,null),P(i,o),V(a,i,null),N(f,l,d),V(c,f,d),u=!0},p(f,d){const h={};d[0]&3|d[1]&128&&(h.$$scope={dirty:d,ctx:f}),c.$set(h)},i(f){u||(_(t.$$.fragment,f),_(s.$$.fragment,f),_(a.$$.fragment,f),_(c.$$.fragment,f),u=!0)},o(f){C(t.$$.fragment,f),C(s.$$.fragment,f),C(a.$$.fragment,f),C(c.$$.fragment,f),u=!1},d(f){f&&(A(e),A(l)),L(t),L(s),L(a),L(c,f)}}}function jl(r){let e,t;function n(...i){return r[14](r[26],...i)}return e=new oa({props:{selected:r[8](r[26]),items:r[7](r[26]),onSelectedChange:n,$$slots:{default:[i1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s[0]&2&&(o.selected=r[8](r[26])),s[0]&2&&(o.items=r[7](r[26])),s[0]&18&&(o.onSelectedChange=n),s[0]&3|s[1]&128&&(o.$$scope={dirty:s,ctx:r}),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function s1(r){let e,t;return e=new Me({props:{path:vu,label:"Edit the selected entry"}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function o1(r){let e,t;function n(){return r[15](r[26])}return e=new Qe({props:{title:"Edit the selected entry",$$slots:{default:[s1]},$$scope:{ctx:r}}}),e.$on("click",n),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s[1]&128&&(o.$$scope={dirty:s,ctx:r}),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function Wl(r){let e,t=r[31].title+"",n,i;return{c(){e=R("option"),n=he(t),e.__value=i=r[31].value,wr(e,e.__value)},m(s,o){N(s,e,o),P(e,n)},p(s,o){o[0]&2&&t!==(t=s[31].title+"")&&xe(n,t),o[0]&2&&i!==(i=s[31].value)&&(e.__value=i,wr(e,e.__value))},d(s){s&&A(e)}}}function ql(r){let e,t,n=r[26].title+"",i,s,o,a,l,c,u,f=fe(r[26].values),d=[];for(let p=0;p<f.length;p+=1)d[p]=Wl(Il(r,f,p));function h(...p){return r[12](r[26],...p)}return{c(){e=R("label"),t=R("span"),i=he(n),s=K(),o=R("select");for(let p=0;p<d.length;p+=1)d[p].c();l=K(),q(t,"class","sr-only"),q(o,"data-combobox-input",""),q(o,"class","bg-white")},m(p,m){N(p,e,m),P(e,t),P(t,i),P(e,s),P(e,o);for(let g=0;g<d.length;g+=1)d[g]&&d[g].m(o,null);Mr(o,r[4].getAttributes(r[26].block)[r[26].name]),P(e,l),c||(u=ee(o,"change",h),c=!0)},p(p,m){if(r=p,m[0]&2&&n!==(n=r[26].title+"")&&xe(i,n),m[0]&2){f=fe(r[26].values);let g;for(g=0;g<f.length;g+=1){const b=Il(r,f,g);d[g]?d[g].p(b,m):(d[g]=Wl(b),d[g].c(),d[g].m(o,null))}for(;g<d.length;g+=1)d[g].d(1);d.length=f.length}m[0]&18&&a!==(a=r[4].getAttributes(r[26].block)[r[26].name])&&Mr(o,r[4].getAttributes(r[26].block)[r[26].name])},d(p){p&&A(e),rt(d,p),c=!1,u()}}}function Jl(r){let e,t,n,i;const s=[t1,e1,Qb,Zb,Xb],o=[];function a(l,c){return l[26].type==="select-block-attribute"?0:l[26].type==="input-block-attribute"?1:l[26].type==="select-cross-reference-attribute"?2:l[26].type==="input-mark-attribute"?3:l[26].type==="select-mark-attribute"?4:-1}return~(e=a(r))&&(t=o[e]=s[e](r)),{c(){t&&t.c(),n=de()},m(l,c){~e&&o[e].m(l,c),N(l,n,c),i=!0},p(l,c){let u=e;e=a(l),e===u?~e&&o[e].p(l,c):(t&&(ne(),C(o[u],1,1,()=>{o[u]=null}),re()),~e?(t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n)):t=null)},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),~e&&o[e].d(l)}}}function l1(r){let e,t;return e=new ua({props:{class:"mx-2 border-r border-gray-300"}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function a1(r){let e,t;function n(...i){return r[11](r[26],...i)}return e=new Qe({props:{"aria-pressed":(r[26].type==="set-block"||r[26].type==="toggle-wrap-block")&&r[4].isActive(r[26].block)||r[26].type==="set-block-attribute"&&r[4].isActive(r[26].block,{[r[26].name]:r[26].value})||r[26].type==="toggle-mark"&&r[4].isActive(r[26].mark),title:r[26].title,$$slots:{default:[f1]},$$scope:{ctx:r}}}),e.$on("click",n),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s[0]&18&&(o["aria-pressed"]=(r[26].type==="set-block"||r[26].type==="toggle-wrap-block")&&r[4].isActive(r[26].block)||r[26].type==="set-block-attribute"&&r[4].isActive(r[26].block,{[r[26].name]:r[26].value})||r[26].type==="toggle-mark"&&r[4].isActive(r[26].mark)),s[0]&2&&(o.title=r[26].title),s[0]&2|s[1]&128&&(o.$$scope={dirty:s,ctx:r}),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function c1(r){let e=r[26].title+"",t;return{c(){t=he(e)},m(n,i){N(n,t,i)},p(n,i){i[0]&2&&e!==(e=n[26].title+"")&&xe(t,e)},i:te,o:te,d(n){n&&A(t)}}}function u1(r){let e,t,n,i=r[26].title+"",s,o;return e=new Me({props:{path:r[26].icon}}),{c(){F(e.$$.fragment),t=K(),n=R("span"),s=he(i),q(n,"class","sr-only")},m(a,l){V(e,a,l),N(a,t,l),N(a,n,l),P(n,s),o=!0},p(a,l){const c={};l[0]&2&&(c.path=a[26].icon),e.$set(c),(!o||l[0]&2)&&i!==(i=a[26].title+"")&&xe(s,i)},i(a){o||(_(e.$$.fragment,a),o=!0)},o(a){C(e.$$.fragment,a),o=!1},d(a){a&&(A(t),A(n)),L(e,a)}}}function f1(r){let e,t,n,i;const s=[u1,c1],o=[];function a(l,c){return l[26].icon?0:1}return e=a(r),t=o[e]=s[e](r),{c(){t.c(),n=K()},m(l,c){o[e].m(l,c),N(l,n,c),i=!0},p(l,c){let u=e;e=a(l),e===u?o[e].p(l,c):(ne(),C(o[u],1,1,()=>{o[u]=null}),re(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n))},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),o[e].d(l)}}}function Kl(r){let e,t,n,i;const s=[a1,l1],o=[];function a(l,c){return l[26].type==="set-block"||l[26].type==="toggle-wrap-block"||l[26].type==="set-block-attribute"||l[26].type==="toggle-mark"?0:l[26].type==="separator"?1:-1}return~(e=a(r))&&(t=o[e]=s[e](r)),{c(){t&&t.c(),n=de()},m(l,c){~e&&o[e].m(l,c),N(l,n,c),i=!0},p(l,c){let u=e;e=a(l),e===u?~e&&o[e].p(l,c):(t&&(ne(),C(o[u],1,1,()=>{o[u]=null}),re()),~e?(t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n)):t=null)},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),~e&&o[e].d(l)}}}function d1(r){let e,t,n=fe(r[23].items),i=[];for(let o=0;o<n.length;o+=1)i[o]=Kl(Pl(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o<i.length;o+=1)i[o].c();e=de()},m(o,a){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(o,a);N(o,e,a),t=!0},p(o,a){if(a[0]&18){n=fe(o[23].items);let l;for(l=0;l<n.length;l+=1){const c=Pl(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=Kl(c),i[l].c(),_(i[l],1),i[l].m(e.parentNode,e))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function $l(r){let e=!r[23].condition||r[4].isActive(r[23].condition.node),t,n,i=e&&Bl(r);return{c(){i&&i.c(),t=de()},m(s,o){i&&i.m(s,o),N(s,t,o),n=!0},p(s,o){o[0]&18&&(e=!s[23].condition||s[4].isActive(s[23].condition.node)),e?i?(i.p(s,o),o[0]&18&&_(i,1)):(i=Bl(s),i.c(),_(i,1),i.m(t.parentNode,t)):i&&(ne(),C(i,1,1,()=>{i=null}),re())},i(s){n||(_(i),n=!0)},o(s){C(i),n=!1},d(s){s&&A(t),i&&i.d(s)}}}function h1(r){let e,t,n,i,s,o=r[1]&&r[1].type.sidebar&&r[4]&&Rl(r);return{c(){e=R("div"),t=R("div"),n=K(),i=R("div"),o&&o.c(),q(t,"class","flex-1 overflow-auto px-3 py-2"),q(i,"class","w-3/12 px-3 py-2 border-l border-gray-300 overflow-auto"),q(e,"class","flex flex-row w-full h-full overflow-hidden")},m(a,l){N(a,e,l),P(e,t),r[10](t),P(e,n),P(e,i),o&&o.m(i,null),s=!0},p(a,l){a[1]&&a[1].type.sidebar&&a[4]?o?(o.p(a,l),l[0]&18&&_(o,1)):(o=Rl(a),o.c(),_(o,1),o.m(i,null)):o&&(ne(),C(o,1,1,()=>{o=null}),re())},i(a){s||(_(o),s=!0)},o(a){C(o),s=!1},d(a){a&&A(e),r[10](null),o&&o.d()}}}function ln(r,e,t){r&&(e.type==="set-block"?r.chain().focus().setNode(e.block).run():e.type==="toggle-wrap-block"?r.chain().focus().toggleWrap(e.block).run():e.type==="set-block-attribute"?r.chain().focus().updateAttributes(e.block,{[e.name]:e.value}).run():e.type==="toggle-mark"?r.chain().focus().toggleMark(e.mark).run():e.type==="select-block-attribute"||e.type==="input-block-attribute"?r.chain().focus().updateAttributes(e.block,{[e.name]:t.target.value}).run():e.type==="select-cross-reference-attribute"?r.chain().focus().extendMarkRange(e.mark).updateAttributes(e.mark,{[e.name]:t.value}).run():(e.type==="input-mark-attribute"||e.type==="select-mark-attribute")&&r.chain().focus().extendMarkRange(e.mark).updateAttributes(e.mark,{[e.name]:t.target.value}).run())}function p1(r,e,t){let n,i,{section:s=null}=e,{sections:o}=e,{sectionsDict:a={}}=e,{editTextListEntry:l}=e;const c=ls(),u=Ht("uEditorConfig");le(r,u,k=>t(20,i=k));const f=Ht("uEditionConfig");le(r,f,k=>t(19,n=k));let d=null,h=null,p=-1;Au(()=>{if(d!==null&&i.isSuccess&&n.isSuccess){const k=[Ub,Hb];let w=An.deepCopy(i.data.tei.blocks);n.data.sphinx_config&&n.data.sphinx_config.tei&&n.data.sphinx_config.tei.blocks&&(w=w.concat(An.deepCopy(n.data.sphinx_config.tei.blocks)));for(let H of w)k.push(Sn.create({name:H.name,group:"block",content:H.content?H.content:"inline*",addAttributes(){return Object.fromEntries(H.attributes.map(Y=>[Y.name,{default:Y.default,renderHTML(ae){return{["data-tei-attribute-"+Y.name]:ae[Y.name]}}}]))},renderHTML({node:Y,HTMLAttributes:ae}){return ae["data-tei-block-"+Y.type.name]="",[H.tag||"div",ae,0]}}));let J=An.deepCopy(i.data.tei.marks);n.data.sphinx_config&&n.data.sphinx_config.tei&&n.data.sphinx_config.tei.marks&&(J=J.concat(An.deepCopy(n.data.sphinx_config.tei.marks)));for(let H of J)k.push(Kn.create({name:H.name,addAttributes(){return Object.fromEntries(H.attributes.map(Y=>[Y.name,{default:Y.default,renderHTML(ae){return{["data-tei-attribute-"+Y.name]:ae[Y.name]}}}]))},renderHTML({mark:Y,HTMLAttributes:ae}){return ae["data-tei-mark-"+Y.type.name]="",[H.tag||"span",ae,0]}}));t(4,h=new $b({element:d,extensions:k,content:s==null?void 0:s.content,onTransaction:({transaction:H})=>{t(4,h),H.docChanged&&(window.clearTimeout(p),p=window.setTimeout(()=>{h&&c("update",h.getJSON())},100))}}))}});function m(){s!==null&&h!==null&&h.commands.setContent(s.content)}function g(k){return a[k.section].type.type==="textlist"?a[k.section].content.map(w=>({value:w.attrs.id,label:Dt(w.content)})):[]}function b(k){if(a[k.section].type.type==="textlist"&&h){const w=a[k.section].content.filter(J=>J.attrs.id===(h==null?void 0:h.getAttributes(k.mark)[k.name])||J.attrs.id===(h==null?void 0:h.getAttributes(k.mark)[k.name].substring(1)));if(w.length===1)return{value:h.getAttributes(k.mark)[k.name],label:Dt(w[0].content)}}}function y(k){Pe[k?"unshift":"push"](()=>{d=k,t(3,d)})}const M=(k,w)=>{ln(h,k,w)},T=(k,w)=>{ln(h,k,w)},S=(k,w)=>{ln(h,k,w)},E=(k,w)=>{ln(h,k,w)},W=k=>{l(k.section,h==null?void 0:h.getAttributes(k.mark)[k.name])},D=(k,w)=>{ln(h,k,w)},v=(k,w)=>{ln(h,k,w)};return r.$$set=k=>{"section"in k&&t(1,s=k.section),"sections"in k&&t(9,o=k.sections),"sectionsDict"in k&&t(0,a=k.sectionsDict),"editTextListEntry"in k&&t(2,l=k.editTextListEntry)},r.$$.update=()=>{r.$$.dirty[0]&2&&s&&m(),r.$$.dirty[0]&512&&o&&t(0,a=Object.fromEntries(o.map(k=>[k.name,k])))},[a,s,l,d,h,u,f,g,b,o,y,M,T,S,E,W,D,v]}class Gc extends je{constructor(e){super(),We(this,e,p1,h1,Ne,{section:1,sections:9,sectionsDict:0,editTextListEntry:2},null,[-1,-1])}}var Te=[];for(var Ei=0;Ei<256;++Ei)Te.push((Ei+256).toString(16).slice(1));function m1(r,e=0){return(Te[r[e+0]]+Te[r[e+1]]+Te[r[e+2]]+Te[r[e+3]]+"-"+Te[r[e+4]]+Te[r[e+5]]+"-"+Te[r[e+6]]+Te[r[e+7]]+"-"+Te[r[e+8]]+Te[r[e+9]]+"-"+Te[r[e+10]]+Te[r[e+11]]+Te[r[e+12]]+Te[r[e+13]]+Te[r[e+14]]+Te[r[e+15]]).toLowerCase()}var hr,g1=new Uint8Array(16);function b1(){if(!hr&&(hr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!hr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hr(g1)}var Oi,pr,Ni=0,Ai=0;function y1(r,e,t){var n=0,i=e||new Array(16);r=r||{};var s=r.node,o=r.clockseq;if(r._v6||(s||(s=Oi),o==null&&(o=pr)),s==null||o==null){var a=r.random||(r.rng||b1)();s==null&&(s=[a[0],a[1],a[2],a[3],a[4],a[5]],!Oi&&!r._v6&&(s[0]|=1,Oi=s)),o==null&&(o=(a[6]<<8|a[7])&16383,pr===void 0&&!r._v6&&(pr=o))}var l=r.msecs!==void 0?r.msecs:Date.now(),c=r.nsecs!==void 0?r.nsecs:Ai+1,u=l-Ni+(c-Ai)/1e4;if(u<0&&r.clockseq===void 0&&(o=o+1&16383),(u<0||l>Ni)&&r.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ni=l,Ai=c,pr=o,l+=122192928e5;var f=((l&268435455)*1e4+c)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=f&255;var d=l/4294967296*1e4&268435455;i[n++]=d>>>8&255,i[n++]=d&255,i[n++]=d>>>24&15|16,i[n++]=d>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var h=0;h<6;++h)i[n+h]=s[h];return e||m1(i)}function Ul(r,e,t){const n=r.slice();return n[18]=e[t],n}function k1(r){let e=Dt(r[18].content)+"",t;return{c(){t=he(e)},m(n,i){N(n,t,i)},p(n,i){i&8&&e!==(e=Dt(n[18].content)+"")&&xe(t,e)},d(n){n&&A(t)}}}function Hl(r){let e,t;return e=new ca({props:{value:r[18].attrs.id,label:Dt(r[18].content),$$slots:{default:[k1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i&8&&(s.value=n[18].attrs.id),i&8&&(s.label=Dt(n[18].content)),i&2097160&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function _1(r){let e,t,n=fe(r[3]),i=[];for(let o=0;o<n.length;o+=1)i[o]=Hl(Ul(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o<i.length;o+=1)i[o].c();e=de()},m(o,a){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(o,a);N(o,e,a),t=!0},p(o,a){if(a&8){n=fe(o[3]);let l;for(l=0;l<n.length;l+=1){const c=Ul(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=Hl(c),i[l].c(),_(i[l],1),i[l].m(e.parentNode,e))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function S1(r){let e,t,n,i,s,o,a,l,c,u;return t=new aa({props:{placeholder:"Select the text to edit","aria-label":"Select the text to edit",class:"relative pr-6 z-10 bg-transparent"}}),s=new Me({props:{path:Vr,class:"w-6 h-6 combobox-expand"}}),a=new Me({props:{path:cs,class:"w-6 h-6 combobox-collapse"}}),c=new la({props:{$$slots:{default:[_1]},$$scope:{ctx:r}}}),{c(){e=R("div"),F(t.$$.fragment),n=K(),i=R("div"),F(s.$$.fragment),o=K(),F(a.$$.fragment),l=K(),F(c.$$.fragment),q(i,"class","absolute top-1/2 right-0 -translate-y-1/2"),q(e,"class","relative")},m(f,d){N(f,e,d),V(t,e,null),P(e,n),P(e,i),V(s,i,null),P(i,o),V(a,i,null),N(f,l,d),V(c,f,d),u=!0},p(f,d){const h={};d&2097160&&(h.$$scope={dirty:d,ctx:f}),c.$set(h)},i(f){u||(_(t.$$.fragment,f),_(s.$$.fragment,f),_(a.$$.fragment,f),_(c.$$.fragment,f),u=!0)},o(f){C(t.$$.fragment,f),C(s.$$.fragment,f),C(a.$$.fragment,f),C(c.$$.fragment,f),u=!1},d(f){f&&(A(e),A(l)),L(t),L(s),L(a),L(c,f)}}}function C1(r){let e,t;return e=new Me({props:{path:as}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function M1(r){let e,t;return e=new Me({props:{path:us}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p:te,i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function w1(r){let e,t,n,i;return e=new Qe({props:{"aria-label":"Add a text",title:"Add a text",$$slots:{default:[C1]},$$scope:{ctx:r}}}),e.$on("click",r[8]),n=new Qe({props:{"aria-label":"Delete the current text",title:"Delete the current text","aria-disabled":r[2].value===null?"true":null,$$slots:{default:[M1]},$$scope:{ctx:r}}}),n.$on("click",r[14]),{c(){F(e.$$.fragment),t=K(),F(n.$$.fragment)},m(s,o){V(e,s,o),N(s,t,o),V(n,s,o),i=!0},p(s,o){const a={};o&2097152&&(a.$$scope={dirty:o,ctx:s}),e.$set(a);const l={};o&4&&(l["aria-disabled"]=s[2].value===null?"true":null),o&2097152&&(l.$$scope={dirty:o,ctx:s}),n.$set(l)},i(s){i||(_(e.$$.fragment,s),_(n.$$.fragment,s),i=!0)},o(s){C(e.$$.fragment,s),C(n.$$.fragment,s),i=!1},d(s){s&&A(t),L(e,s),L(n,s)}}}function Gl(r){let e,t;return e=new Gc({props:{section:r[4],sections:r[0],editTextListEntry:r[1]}}),e.$on("update",r[7]),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i&16&&(s.section=n[4]),i&1&&(s.sections=n[0]),i&2&&(s.editTextListEntry=n[1]),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function T1(r){let e;return{c(){e=he("Delete Text")},m(t,n){N(t,e,n)},d(t){t&&A(e)}}}function E1(r){let e;return{c(){e=he("Don't delete")},m(t,n){N(t,e,n)},d(t){t&&A(e)}}}function O1(r){let e,t,n,i,s,o=r[2].label+"",a,l,c,u,f,d,h,p,m,g;return e=new Bu({props:{$$slots:{default:[T1]},$$scope:{ctx:r}}}),f=new zu({props:{"data-button":!0,$$slots:{default:[E1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment),t=K(),n=R("form"),i=R("p"),s=he("Please confirm that you wish to delete the text "),a=he(o),l=he("."),c=K(),u=R("div"),F(f.$$.fragment),d=K(),h=R("button"),h.textContent="Delete",q(h,"type","submit"),q(h,"data-button",""),q(u,"data-dialog-buttons",""),q(n,"data-dialog-content-area","")},m(b,y){V(e,b,y),N(b,t,y),N(b,n,y),P(n,i),P(i,s),P(i,a),P(i,l),P(n,c),P(n,u),V(f,u,null),P(u,d),P(u,h),p=!0,m||(g=ee(n,"submit",r[9]),m=!0)},p(b,y){const M={};y&2097152&&(M.$$scope={dirty:y,ctx:b}),e.$set(M),(!p||y&4)&&o!==(o=b[2].label+"")&&xe(a,o);const T={};y&2097152&&(T.$$scope={dirty:y,ctx:b}),f.$set(T)},i(b){p||(_(e.$$.fragment,b),_(f.$$.fragment,b),p=!0)},o(b){C(e.$$.fragment,b),C(f.$$.fragment,b),p=!1},d(b){b&&(A(t),A(n)),L(e,b),L(f),m=!1,g()}}}function N1(r){let e,t,n,i;return e=new Pu({}),n=new Ru({props:{$$slots:{default:[O1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment),t=K(),F(n.$$.fragment)},m(s,o){V(e,s,o),N(s,t,o),V(n,s,o),i=!0},p(s,o){const a={};o&2097156&&(a.$$scope={dirty:o,ctx:s}),n.$set(a)},i(s){i||(_(e.$$.fragment,s),_(n.$$.fragment,s),i=!0)},o(s){C(e.$$.fragment,s),C(n.$$.fragment,s),i=!1},d(s){s&&A(t),L(e,s),L(n,s)}}}function A1(r){let e,t,n,i;return e=new xu({props:{class:"hidden"}}),n=new Iu({props:{$$slots:{default:[N1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment),t=K(),F(n.$$.fragment)},m(s,o){V(e,s,o),N(s,t,o),V(n,s,o),i=!0},p(s,o){const a={};o&2097156&&(a.$$scope={dirty:o,ctx:s}),n.$set(a)},i(s){i||(_(e.$$.fragment,s),_(n.$$.fragment,s),i=!0)},o(s){C(e.$$.fragment,s),C(n.$$.fragment,s),i=!1},d(s){s&&A(t),L(e,s),L(n,s)}}}function v1(r){let e,t,n,i,s,o,a,l,c,u,f,d;function h(y){r[13](y)}let p={items:r[3].map(r[12]),$$slots:{default:[S1]},$$scope:{ctx:r}};r[2]!==void 0&&(p.selected=r[2]),n=new oa({props:p}),Pe.push(()=>Ii(n,"selected",h)),o=new Cn({props:{$$slots:{default:[w1]},$$scope:{ctx:r}}});let m=r[4]!==null&&Gl(r);function g(y){r[15](y)}let b={$$slots:{default:[A1]},$$scope:{ctx:r}};return r[5]!==void 0&&(b.open=r[5]),u=new Du({props:b}),Pe.push(()=>Ii(u,"open",g)),{c(){e=R("div"),t=R("div"),F(n.$$.fragment),s=K(),F(o.$$.fragment),a=K(),l=R("div"),m&&m.c(),c=K(),F(u.$$.fragment),q(t,"class","flex flex-row items-center space-x-4 border-b border-gray-300 px-2 py-1"),q(l,"class","flex-1 overflow-hidden"),q(e,"class","flex flex-col w-full h-full overflow-hidden")},m(y,M){N(y,e,M),P(e,t),V(n,t,null),P(t,s),V(o,t,null),P(e,a),P(e,l),m&&m.m(l,null),N(y,c,M),V(u,y,M),d=!0},p(y,[M]){const T={};M&8&&(T.items=y[3].map(y[12])),M&2097160&&(T.$$scope={dirty:M,ctx:y}),!i&&M&4&&(i=!0,T.selected=y[2],Pi(()=>i=!1)),n.$set(T);const S={};M&2097188&&(S.$$scope={dirty:M,ctx:y}),o.$set(S),y[4]!==null?m?(m.p(y,M),M&16&&_(m,1)):(m=Gl(y),m.c(),_(m,1),m.m(l,null)):m&&(ne(),C(m,1,1,()=>{m=null}),re());const E={};M&2097156&&(E.$$scope={dirty:M,ctx:y}),!f&&M&32&&(f=!0,E.open=y[5],Pi(()=>f=!1)),u.$set(E)},i(y){d||(_(n.$$.fragment,y),_(o.$$.fragment,y),_(m),_(u.$$.fragment,y),d=!0)},o(y){C(n.$$.fragment,y),C(o.$$.fragment,y),C(m),C(u.$$.fragment,y),d=!1},d(y){y&&(A(e),A(c)),L(n),L(o),m&&m.d(),L(u,y)}}}function D1(r,e,t){let n,{section:i=null}=e,{sections:s}=e,{selectedEntryId:o}=e,{editTextListEntry:a}=e;const l=ls(),c=Ht("uEditorConfig");le(r,c,S=>t(16,n=S));let u={value:null},f=[],d=null,h=!1;function p(S){if(u.value!==null&&i&&i.content){const E=f.filter(W=>W.attrs.id===u.value);E.length===1&&(E[0].content=S.detail),l("update",f)}}function m(){var S;n.isSuccess&&((S=n.data)==null?void 0:S.tei.blocks.length)>0&&(f.push({attrs:{id:(i==null?void 0:i.name)+"-"+y1()},content:{type:"doc",content:[{type:n.data.tei.blocks[0].name,attrs:{},content:[{type:"text",marks:[],text:"New"}]}]}}),l("update",f))}function g(S){S.preventDefault(),t(5,h=!1);let E=-1;for(let W=0;W<f.length;W++)if(u.value==f[W].attrs.id){E=W;break}E>=0&&(f.splice(E,1),t(2,u={value:null}),t(4,d=null),l("update",f))}const b=S=>({value:S.attrs.id,label:Dt(S.content)});function y(S){u=S,t(2,u),t(10,o),t(11,i),t(3,f)}const M=()=>{t(5,h=!0)};function T(S){h=S,t(5,h)}return r.$$set=S=>{"section"in S&&t(11,i=S.section),"sections"in S&&t(0,s=S.sections),"selectedEntryId"in S&&t(10,o=S.selectedEntryId),"editTextListEntry"in S&&t(1,a=S.editTextListEntry)},r.$$.update=()=>{if(r.$$.dirty&2048&&(i!==null&&i.content?t(3,f=i.content):t(3,f=[])),r.$$.dirty&3080&&o&&i){const S=f.filter(E=>E.attrs.id===o||E.attrs.id===o.substring(1));S.length===1&&t(2,u={value:S[0].attrs.id,label:Dt(S[0].content)}),t(10,o=null)}if(r.$$.dirty&2060)if(u.value!==null&&i&&i.content){const S=f.filter(E=>E.attrs.id===u.value);S.length===1?t(4,d={name:"",title:"",type:{name:"",title:"",type:"text",selector:"",sidebar:i.type.sidebar},content:S[0].content}):t(4,d=null)}else t(4,d=null)},[s,a,u,f,d,h,c,p,m,g,o,i,b,y,M,T]}class x1 extends je{constructor(e){super(),We(this,e,D1,v1,Ne,{section:11,sections:0,selectedEntryId:10,editTextListEntry:1})}}function Yl(r,e,t){const n=r.slice();return n[23]=e[t],n[25]=t,n}function Xl(r,e,t){const n=r.slice();return n[23]=e[t],n}function I1(r){let e,t;return e=new ju({props:{$$slots:{default:[B1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i&268435456&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function P1(r){let e;return{c(){e=R("p"),e.textContent=`There was an error loading this TEI file. The most likely cause is a TEI tag
192
- that is not configured. Please check your server logs for details.`,q(e,"class","px-4 py-2 text-red-800")},m(t,n){N(t,e,n)},p:te,i:te,o:te,d(t){t&&A(e)}}}function R1(r){let e,t,n,i,s,o;function a(c){r[14](c)}let l={class:"flex-1 flex flex-col",$$slots:{default:[q1]},$$scope:{ctx:r}};return r[1]!==void 0&&(l.value=r[1]),t=new Yf({props:l}),Pe.push(()=>Ii(t,"value",a)),{c(){e=R("div"),F(t.$$.fragment),q(e,"class","flex-1 flex overflow-hidden")},m(c,u){N(c,e,u),V(t,e,null),i=!0,s||(o=ee(e,"keydown",r[9]),s=!0)},p(c,u){const f={};u&268435476&&(f.$$scope={dirty:u,ctx:c}),!n&&u&2&&(n=!0,f.value=c[1],Pi(()=>n=!1)),t.$set(f)},i(c){i||(_(t.$$.fragment,c),i=!0)},o(c){C(t.$$.fragment,c),i=!1},d(c){c&&A(e),L(t),s=!1,o()}}}function B1(r){let e;return{c(){e=he("Loading the TEI file. Please wait...")},m(t,n){N(t,e,n)},d(t){t&&A(e)}}}function z1(r){let e=r[23].type.title+"",t;return{c(){t=he(e)},m(n,i){N(n,t,i)},p(n,i){i&16&&e!==(e=n[23].type.title+"")&&xe(t,e)},d(n){n&&A(t)}}}function Zl(r){let e,t;return e=new bd({props:{value:r[23].type.name,$$slots:{default:[z1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i&16&&(s.value=n[23].type.name),i&268435472&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function F1(r){let e,t,n=fe(r[4]),i=[];for(let o=0;o<n.length;o+=1)i[o]=Zl(Xl(r,n,o));const s=o=>C(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o<i.length;o+=1)i[o].c();e=de()},m(o,a){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(o,a);N(o,e,a),t=!0},p(o,a){if(a&16){n=fe(o[4]);let l;for(l=0;l<n.length;l+=1){const c=Xl(o,n,l);i[l]?(i[l].p(c,a),_(i[l],1)):(i[l]=Zl(c),i[l].c(),_(i[l],1),i[l].m(e.parentNode,e))}for(ne(),l=n.length;l<i.length;l+=1)s(l);re()}},i(o){if(!t){for(let a=0;a<n.length;a+=1)_(i[a]);t=!0}},o(o){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)C(i[a]);t=!1},d(o){o&&A(e),rt(i,o)}}}function V1(r){let e,t;function n(...i){return r[13](r[25],...i)}return e=new x1({props:{section:r[23],sections:r[4],editTextListEntry:r[10],selectedEntryId:r[2][r[23].name]}}),e.$on("update",n),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s&16&&(o.section=r[23]),s&16&&(o.sections=r[4]),s&20&&(o.selectedEntryId=r[2][r[23].name]),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function L1(r){let e,t;function n(...i){return r[12](r[25],...i)}return e=new Gc({props:{section:r[23],sections:r[4],editTextListEntry:r[10]}}),e.$on("update",n),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s&16&&(o.section=r[23]),s&16&&(o.sections=r[4]),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function j1(r){let e,t;function n(...i){return r[11](r[25],...i)}return e=new qd({props:{section:r[23]}}),e.$on("update",n),{c(){F(e.$$.fragment)},m(i,s){V(e,i,s),t=!0},p(i,s){r=i;const o={};s&16&&(o.section=r[23]),e.$set(o)},i(i){t||(_(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){L(e,i)}}}function W1(r){let e,t,n,i;const s=[j1,L1,V1],o=[];function a(l,c){return l[23].type.type==="metadata"?0:l[23].type.type==="text"?1:l[23].type.type==="textlist"?2:-1}return~(e=a(r))&&(t=o[e]=s[e](r)),{c(){t&&t.c(),n=K()},m(l,c){~e&&o[e].m(l,c),N(l,n,c),i=!0},p(l,c){let u=e;e=a(l),e===u?~e&&o[e].p(l,c):(t&&(ne(),C(o[u],1,1,()=>{o[u]=null}),re()),~e?(t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),_(t,1),t.m(n.parentNode,n)):t=null)},i(l){i||(_(t),i=!0)},o(l){C(t),i=!1},d(l){l&&A(n),~e&&o[e].d(l)}}}function Ql(r){let e,t;return e=new rd({props:{value:r[23].type.name,class:"flex-1 overflow-hidden",$$slots:{default:[W1]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(n,i){V(e,n,i),t=!0},p(n,i){const s={};i&16&&(s.value=n[23].type.name),i&268435476&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(_(e.$$.fragment,n),t=!0)},o(n){C(e.$$.fragment,n),t=!1},d(n){L(e,n)}}}function q1(r){let e,t,n,i;e=new ud({props:{$$slots:{default:[F1]},$$scope:{ctx:r}}});let s=fe(r[4]),o=[];for(let l=0;l<s.length;l+=1)o[l]=Ql(Yl(r,s,l));const a=l=>C(o[l],1,1,()=>{o[l]=null});return{c(){F(e.$$.fragment),t=K();for(let l=0;l<o.length;l+=1)o[l].c();n=de()},m(l,c){V(e,l,c),N(l,t,c);for(let u=0;u<o.length;u+=1)o[u]&&o[u].m(l,c);N(l,n,c),i=!0},p(l,c){const u={};if(c&268435472&&(u.$$scope={dirty:c,ctx:l}),e.$set(u),c&1300){s=fe(l[4]);let f;for(f=0;f<s.length;f+=1){const d=Yl(l,s,f);o[f]?(o[f].p(d,c),_(o[f],1)):(o[f]=Ql(d),o[f].c(),_(o[f],1),o[f].m(n.parentNode,n))}for(ne(),f=s.length;f<o.length;f+=1)a(f);re()}},i(l){if(!i){_(e.$$.fragment,l);for(let c=0;c<s.length;c+=1)_(o[c]);i=!0}},o(l){C(e.$$.fragment,l),o=o.filter(Boolean);for(let c=0;c<o.length;c+=1)C(o[c]);i=!1},d(l){l&&(A(t),A(n)),L(e,l),rt(o,l)}}}function J1(r){var d;let e,t=((d=r[3])==null?void 0:d.name)+"",n,i,s,o,a,l;const c=[R1,P1,I1],u=[];function f(h,p){return h[4]?0:h[0]?1:2}return s=f(r),o=u[s]=c[s](r),{c(){e=R("h1"),n=he(t),i=K(),o.c(),a=de(),q(e,"class","sr-only")},m(h,p){N(h,e,p),P(e,n),N(h,i,p),u[s].m(h,p),N(h,a,p),l=!0},p(h,[p]){var g;(!l||p&8)&&t!==(t=((g=h[3])==null?void 0:g.name)+"")&&xe(n,t);let m=s;s=f(h),s===m?u[s].p(h,p):(ne(),C(u[m],1,1,()=>{u[m]=null}),re(),o=u[s],o?o.p(h,p):(o=u[s]=c[s](h),o.c()),_(o,1),o.m(a.parentNode,a))},i(h){l||(_(o),l=!0)},o(h){C(o),l=!1},d(h){h&&(A(e),A(i),A(a)),u[s].d(h)}}}function K1(r,e,t){let n,i,s,o,a;le(r,ir,k=>t(18,n=k)),le(r,Fs,k=>t(3,i=k));let l=[],c=-1,u=[],f=!1,d="",h={};const p=Ht("uEditorConfig"),m=Fu();le(r,m,k=>t(19,s=k));const g=Vu();le(r,g,k=>t(20,o=k));const b=St([p,Fs],([k,w],J)=>{k.isSuccess&&w&&w.name.endsWith(".tei")&&(t(0,f=!1),u=[],l=[],J(null),ir.set(null),rn.set(!1),Vs({action:"LoadTextFile",branch:s,filename:w.fullpath,callback:H=>{try{l=JSON.parse(H),u=JSON.parse(H),ir.set(H),rn.set(!1);const Y=JSON.parse(H),ae=[];for(let I of k.data.tei.sections)for(let it of Y)if(I.name===it.name){it.type=I,ae.push(it);break}J(ae),t(1,d="")}catch{t(0,f=!0),J(null)}}}))},null);le(r,b,k=>t(4,a=k));const y=rn.subscribe(k=>{if(!k&&n)try{u=JSON.parse(n)}catch{}});function M(k,w){l[k].type==="text"||l[k].type==="textlist"?l[k].content=w.detail:l[k].type==="metadata"&&(l[k].content=w.detail.content),window.clearTimeout(c),c=window.setTimeout(()=>{jr(l,u)?rn.set(!1):(ir.set(JSON.stringify(l)),rn.set(!0))},100)}function T(k){var w,J;i!==null&&n!==null&&k.key==="s"&&(k.ctrlKey||k.metaKey)&&(k.preventDefault(),(!((w=o.data)!=null&&w.git.protect_default_branch)||((J=o.data)==null?void 0:J.git.default_branch)!==(s==null?void 0:s.id))&&Vs({action:"SaveCurrentFile",branch:s,filename:i.fullpath,data:n,callback(){rn.set(!1)}}))}function S(k,w){t(1,d=k),t(2,h[k]=w,h),t(2,h)}Lu(y);const E=(k,w)=>{M(k,w)},W=(k,w)=>{M(k,w)},D=(k,w)=>{M(k,w)};function v(k){d=k,t(1,d)}return[f,d,h,i,a,m,g,b,M,T,S,E,W,D,v]}class H1 extends je{constructor(e){super(),We(this,e,K1,J1,Ne,{})}}export{H1 as default};