@monkeyplus/flow 6.0.97 → 6.0.99
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.
- package/package.json +1 -1
- package/src/runtime/components/MkImage.d.ts +1 -1
- package/src/runtime/components/MkImage.mjs +2 -12
- package/src/runtime/components/MkPicture.mjs +2 -19
- package/cms/dist/assets/AuthForm-Dyry4sjr.js +0 -1
- package/cms/dist/assets/Button-DqA6yHmE.js +0 -3
- package/cms/dist/assets/Checkbox-B9TQzWoR.js +0 -1
- package/cms/dist/assets/Cms-DBVYneZ6.js +0 -1
- package/cms/dist/assets/Cms-RiSl7itt.js +0 -1
- package/cms/dist/assets/Cms.vue_vue_type_script_setup_true_lang-BE4gcjtK.js +0 -1
- package/cms/dist/assets/Collection-BKCtzrFp.js +0 -1
- package/cms/dist/assets/Collection-DnqXcyIX.js +0 -1
- package/cms/dist/assets/Collection.vue_vue_type_script_setup_true_lang-D00wuxPQ.js +0 -4
- package/cms/dist/assets/DropdownMenu-BQssBxgT.js +0 -1
- package/cms/dist/assets/Entry-CGSN0PAz.js +0 -1
- package/cms/dist/assets/Entry-CaHgQH1Y.js +0 -1
- package/cms/dist/assets/Entry-Dm44tSiN.js +0 -1
- package/cms/dist/assets/Entry-Dmqp93hD.js +0 -1
- package/cms/dist/assets/Entry.vue_vue_type_script_setup_true_lang-BfyEnUL0.js +0 -1
- package/cms/dist/assets/Entry.vue_vue_type_script_setup_true_lang-CxjPxxzL.js +0 -1
- package/cms/dist/assets/Fields-Bi4LYuMU.js +0 -210
- package/cms/dist/assets/FormField-C34EWjac.js +0 -1
- package/cms/dist/assets/Input-mdAflUvn.js +0 -1
- package/cms/dist/assets/Main-CXgqjq7s.js +0 -1
- package/cms/dist/assets/Media-Zai8Eyjm.js +0 -64
- package/cms/dist/assets/Modal-CGsB-OTj.js +0 -1
- package/cms/dist/assets/Page-XI1TMPvl.js +0 -1
- package/cms/dist/assets/PageSideForm-DLg59PHV.js +0 -1
- package/cms/dist/assets/PageSideForm-a3VRcJON.js +0 -1
- package/cms/dist/assets/Pages-CKJpfmGL.js +0 -1
- package/cms/dist/assets/Pages-xAbJV9U3.js +0 -1
- package/cms/dist/assets/Preview-OR4KfKz3.js +0 -1
- package/cms/dist/assets/RovingFocusGroup-BcsqcJ5O.js +0 -1
- package/cms/dist/assets/RovingFocusItem-9F18dqW5.js +0 -1
- package/cms/dist/assets/SelectMenu-tO51XXJu.js +0 -1
- package/cms/dist/assets/Settings-BEdVFG1w.js +0 -1
- package/cms/dist/assets/Sidebar-CEo-y76h.js +0 -1
- package/cms/dist/assets/TooltipProvider-DSEdSlGC.js +0 -1
- package/cms/dist/assets/app-CaD5gbmy.js +0 -1
- package/cms/dist/assets/app-CskbKD_s.js +0 -1
- package/cms/dist/assets/app.vue_vue_type_script_setup_true_lang-CcJRfxNS.js +0 -13
- package/cms/dist/assets/auth-DCjN847G.js +0 -3
- package/cms/dist/assets/cms-CPHw4cSK.js +0 -1
- package/cms/dist/assets/dist-DT4goRM8.js +0 -1
- package/cms/dist/assets/index.spa-92WvmWuv.js +0 -18
- package/cms/dist/assets/index.vue_vue_type_script_setup_true_lang-rpB9rqn_.js +0 -1
- package/cms/dist/assets/not-found-DHHFlsrQ.js +0 -1
- package/cms/dist/assets/not-found-D_-ir4iz.js +0 -1
- package/cms/dist/assets/pages-B40UGtkq.js +0 -1
- package/cms/dist/assets/pages-Ckuyy9Ug.js +0 -1
- package/cms/dist/assets/preview-DNlc8BJR.js +0 -1
- package/cms/dist/assets/useCmsBreadcrumb-Td17D_qt.js +0 -1
- package/cms/dist/assets/useOverlay-BfXmCZ3K.js +0 -1
- package/cms/dist/assets/usePortal-CQWjJqTo.js +0 -1
- package/cms/dist/assets/useToast-CXoHGY9X.js +0 -1
- package/cms/dist/assets/utils-CjR9cj4u.js +0 -1
- package/monkeyplus-flow-6.0.96.tgz +0 -0
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import{$ as e,$t as t,An as n,At as r,B as i,Bt as a,Cn as o,D as s,Dn as c,Dt as l,Fn as u,Gt as d,H as f,Ht as p,I as m,In as h,It as g,Jt as _,Kt as v,L as y,Ln as b,Lt as x,Mt as S,N as C,Nn as w,Nt as T,On as ee,Ot as E,Pt as D,Qt as O,Rn as k,Rt as A,Sn as te,St as j,T as ne,Tt as re,Vt as ie,W as ae,Wt as oe,Xt as se,Yt as ce,_ as le,_n as ue,_t as de,a as fe,an as pe,bn as me,bt as he,cn as ge,d as _e,dn as M,en as ve,et as ye,f as be,h as xe,in as Se,j as Ce,jn as N,jt as P,kn as we,l as Te,ln as Ee,lt as De,m as Oe,mn as F,o as ke,ot as Ae,rn as je,sn as Me,tn as I,u as Ne,un as Pe,ut as Fe,v as Ie,wn as L,wt as Le,y as Re,yn as ze,yt as Be,zt as Ve}from"./index.spa-92WvmWuv.js";import{A as He,B as Ue,C as We,D as R,E as Ge,G as Ke,H as qe,M as Je,N as Ye,O as Xe,R as Ze,S as Qe,T as $e,V as et,W as tt,b as nt,j as rt,k as it,n as at,t as ot,w as st,z as ct}from"./Input-mdAflUvn.js";import{C as lt,D as ut,E as dt,N as ft,O as pt,P as mt,S as ht,_ as gt,b as _t,g as vt,k as yt,m as bt,p as xt,t as St,v as Ct,w as wt,x as Tt,y as Et}from"./Button-DqA6yHmE.js";import{a as Dt,c as Ot,d as kt,f as At,i as jt,n as Mt,p as Nt,r as Pt,u as Ft}from"./usePortal-CQWjJqTo.js";import{l as It,s as Lt}from"./RovingFocusGroup-BcsqcJ5O.js";import{a as Rt,c as zt,i as Bt,n as Vt,o as Ht,r as Ut,s as Wt,t as Gt}from"./DropdownMenu-BQssBxgT.js";import{n as Kt,t as qt}from"./Modal-CGsB-OTj.js";import{s as Jt}from"./utils-CjR9cj4u.js";import{i as Yt,n as Xt,r as Zt,t as Qt}from"./SelectMenu-tO51XXJu.js";import{n as $t}from"./TooltipProvider-DSEdSlGC.js";import{t as en}from"./useOverlay-BfXmCZ3K.js";import{t as tn}from"./logger-DSeL-og4.js";import{t as nn}from"./cms-CPHw4cSK.js";import{t as rn}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{i as an,t as on}from"./Media-Zai8Eyjm.js";function sn(e,t=-1/0,n=1/0){return Math.min(n,Math.max(t,e))}var cn=[` `,`Enter`,`ArrowUp`,`ArrowDown`],ln=[` `,`Enter`];function un(e,t,n){return e===void 0?!1:Array.isArray(e)?e.some(e=>dn(e,t,n)):dn(e,t,n)}function dn(e,t,n){return e===void 0||t===void 0?!1:typeof e==`string`?e===t:typeof n==`function`?n(e,t):typeof n==`string`?e?.[n]===t?.[n]:ne(e,t)}function fn(e){return e==null||e===``||Array.isArray(e)&&e.length===0}var pn={key:0,value:``},[mn,hn]=mt(`SelectRoot`),gn=A({inheritAttrs:!1,__name:`SelectRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},by:{type:[String,Function],required:!1},dir:{type:String,required:!1},multiple:{type:Boolean,required:!1},autocomplete:{type:String,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`,`update:open`],setup(e,{emit:t}){let i=e,a=t,{required:o,disabled:s,multiple:c,dir:u}=n(i),f=ye(i,`modelValue`,a,{defaultValue:i.defaultValue??(c.value?[]:void 0),passive:i.modelValue===void 0,deep:!0}),p=ye(i,`open`,a,{defaultValue:i.defaultOpen,passive:i.open===void 0}),m=L(),h=L(),g=L({x:0,y:0}),_=r(()=>c.value&&Array.isArray(f.value)?f.value?.length===0:At(f.value));Lt({isProvider:!0});let v=It(u),y=et(m),b=L(new Set),x=r(()=>Array.from(b.value).map(e=>e.value).join(`;`));function C(e){if(c.value){let t=Array.isArray(f.value)?[...f.value]:[],n=t.findIndex(t=>dn(t,e,i.by));n===-1?t.push(e):t.splice(n,1),f.value=[...t]}else f.value=e}function ee(e){return Array.from(b.value).find(t=>un(e,t.value,i.by))}return hn({triggerElement:m,onTriggerChange:e=>{m.value=e},valueElement:h,onValueElementChange:e=>{h.value=e},contentId:``,modelValue:f,onValueChange:C,by:i.by,open:p,multiple:c,required:o,onOpenChange:e=>{p.value=e},dir:v,triggerPointerDownPosRef:g,disabled:s,isEmptyModelValue:_,optionsSet:b,onOptionAdd:e=>{let t=ee(e.value);t&&b.value.delete(t),b.value.add(e)},onOptionRemove:e=>{let t=ee(e.value);t&&b.value.delete(t)}}),(e,t)=>(O(),S(w(Ye),null,{default:F(()=>[I(e.$slots,`default`,{modelValue:w(f),open:w(p)}),w(y)&&e.name?(O(),S(_n,{key:x.value,"aria-hidden":`true`,tabindex:`-1`,multiple:w(c),required:w(o),name:e.name,autocomplete:e.autocomplete,disabled:w(s),value:w(f)},{default:F(()=>[w(At)(w(f))?(O(),D(`option`,pn)):T(`v-if`,!0),(O(!0),D(l,null,ve(Array.from(b.value),e=>(O(),D(`option`,d({key:e.value??``},{ref_for:!0},e),null,16))),128))]),_:1},8,[`multiple`,`required`,`name`,`autocomplete`,`disabled`,`value`])):T(`v-if`,!0)]),_:3}))}}),_n=A({__name:`BubbleSelect`,props:{autocomplete:{type:String,required:!1},autofocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},form:{type:String,required:!1},multiple:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},size:{type:Number,required:!1},value:{type:null,required:!1}},setup(e){let t=e,n=L(),r=mn();Pe(()=>t.value,(e,t)=>{let r=window.HTMLSelectElement.prototype,i=Object.getOwnPropertyDescriptor(r,`value`).set;if(e!==t&&i&&n.value){let t=new Event(`change`,{bubbles:!0});i.call(n.value,e),n.value.dispatchEvent(t)}});function i(e){r.onValueChange(e.target.value)}return(e,r)=>(O(),S(w(Pt),{"as-child":``},{default:F(()=>[P(`select`,d({ref_key:`selectElement`,ref:n},t,{onInput:i}),[I(e.$slots,`default`)],16)]),_:3}))}}),vn=A({__name:`SelectPopperPosition`,props:{side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1,default:`start`},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1,default:10},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=pt(e);return(e,n)=>(O(),S(w(Qe),d(w(t),{style:{boxSizing:`border-box`,"--reka-select-content-transform-origin":`var(--reka-popper-transform-origin)`,"--reka-select-content-available-width":`var(--reka-popper-available-width)`,"--reka-select-content-available-height":`var(--reka-popper-available-height)`,"--reka-select-trigger-width":`var(--reka-popper-anchor-width)`,"--reka-select-trigger-height":`var(--reka-popper-anchor-height)`}}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))}}),yn={onViewportChange:()=>{},itemTextRefCallback:()=>{},itemRefCallback:()=>{}},[bn,xn]=mt(`SelectContent`),Sn=A({__name:`SelectContentImpl`,props:{position:{type:String,required:!1,default:`item-aligned`},bodyLock:{type:Boolean,required:!1,default:!0},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1,default:`start`},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1,default:!0}},emits:[`closeAutoFocus`,`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,i=t,a=mn();qe(),kt(n.bodyLock);let{CollectionSlot:o,getItems:s}=Lt(),c=L();Ft(c);let{search:l,handleTypeaheadSearch:u}=ct(),f=L(),p=L(),h=L(),g=L(!1),_=L(!1),v=L(!1);function y(){p.value&&c.value&&Jt([p.value,c.value])}Pe(g,()=>{y()});let{onOpenChange:b,triggerPointerDownPosRef:C}=a;M(e=>{if(!c.value)return;let t={x:0,y:0},n=e=>{t={x:Math.abs(Math.round(e.pageX)-(C.value?.x??0)),y:Math.abs(Math.round(e.pageY)-(C.value?.y??0))}},r=e=>{e.pointerType!==`touch`&&(t.x<=10&&t.y<=10?e.preventDefault():c.value?.contains(e.target)||b(!1),document.removeEventListener(`pointermove`,n),C.value=null)};C.value!==null&&(document.addEventListener(`pointermove`,n),document.addEventListener(`pointerup`,r,{capture:!0,once:!0})),e(()=>{document.removeEventListener(`pointermove`,n),document.removeEventListener(`pointerup`,r,{capture:!0})})});function T(e){let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&u(e.key,s()),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=[...s().map(e=>e.ref)];if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>Jt(t)),e.preventDefault()}}let ee=pt(r(()=>n.position===`popper`?n:{}).value);return xn({content:c,viewport:f,onViewportChange:e=>{f.value=e},itemRefCallback:(e,t,n)=>{let r=!_.value&&!n,i=un(a.modelValue.value,t,a.by);if(a.multiple.value){if(v.value)return;(i||r)&&(p.value=e,i&&(v.value=!0))}else (i||r)&&(p.value=e);r&&(_.value=!0)},selectedItem:p,selectedItemText:h,onItemLeave:()=>{c.value?.focus()},itemTextRefCallback:(e,t,n)=>{let r=!_.value&&!n;(un(a.modelValue.value,t,a.by)||r)&&(h.value=e)},focusSelectedItem:y,position:n.position,isPositioned:g,searchRef:l}),(e,t)=>(O(),S(w(o),null,{default:F(()=>[x(w(Dt),{"as-child":``,onMountAutoFocus:t[6]||=re(()=>{},[`prevent`]),onUnmountAutoFocus:t[7]||=e=>{i(`closeAutoFocus`,e),!e.defaultPrevented&&(w(a).triggerElement.value?.focus({preventScroll:!0}),e.preventDefault())}},{default:F(()=>[x(w(Ot),{"as-child":``,"disable-outside-pointer-events":e.disableOutsidePointerEvents,onFocusOutside:t[2]||=re(()=>{},[`prevent`]),onDismiss:t[3]||=e=>w(a).onOpenChange(!1),onEscapeKeyDown:t[4]||=e=>i(`escapeKeyDown`,e),onPointerDownOutside:t[5]||=e=>i(`pointerDownOutside`,e)},{default:F(()=>[(O(),S(je(e.position===`popper`?vn:Tn),d({...e.$attrs,...w(ee)},{id:w(a).contentId,ref:e=>{if(!e)return;let t=w(m)(e);t?.hasAttribute(`data-reka-popper-content-wrapper`)?c.value=t.firstElementChild:c.value=t},role:`listbox`,"data-state":w(a).open.value?`open`:`closed`,dir:w(a).dir.value,style:{display:`flex`,flexDirection:`column`,outline:`none`},onContextmenu:t[0]||=re(()=>{},[`prevent`]),onPlaced:t[1]||=e=>g.value=!0,onKeydown:T}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16,[`id`,`data-state`,`dir`,`onKeydown`]))]),_:3},8,[`disable-outside-pointer-events`])]),_:3})]),_:3}))}}),[Cn,wn]=mt(`SelectItemAlignedPosition`),Tn=A({inheritAttrs:!1,__name:`SelectItemAlignedPosition`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`placed`],setup(t,{emit:n}){let r=t,i=n,{getItems:a}=Lt(),o=mn(),s=bn(),c=L(!1),l=L(!0),u=L(),{forwardRef:f,currentElement:p}=yt(),{viewport:m,selectedItem:h,selectedItemText:g,focusSelectedItem:_}=s;function y(){if(o.triggerElement.value&&o.valueElement.value&&u.value&&p.value&&m?.value&&h?.value&&g?.value){let e=o.triggerElement.value.getBoundingClientRect(),t=p.value.getBoundingClientRect(),n=o.valueElement.value.getBoundingClientRect(),r=g.value.getBoundingClientRect();if(o.dir.value!==`rtl`){let i=r.left-t.left,a=n.left-i,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-10,d=sn(a,10,Math.max(10,l-c));u.value.style.minWidth=`${s}px`,u.value.style.left=`${d}px`}else{let i=t.right-r.right,a=window.innerWidth-n.right-i,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-10,d=sn(a,10,Math.max(10,l-c));u.value.style.minWidth=`${s}px`,u.value.style.right=`${d}px`}let s=a().map(e=>e.ref),l=window.innerHeight-20,d=m.value.scrollHeight,f=window.getComputedStyle(p.value),_=Number.parseInt(f.borderTopWidth,10),v=Number.parseInt(f.paddingTop,10),y=Number.parseInt(f.borderBottomWidth,10),b=Number.parseInt(f.paddingBottom,10),x=_+v+d+b+y,S=Math.min(h.value.offsetHeight*5,x),C=window.getComputedStyle(m.value),w=Number.parseInt(C.paddingTop,10),T=Number.parseInt(C.paddingBottom,10),ee=e.top+e.height/2-10,E=l-ee,D=h.value.offsetHeight/2,O=h.value.offsetTop+D,k=_+v+O,A=x-k;if(k<=ee){let e=h.value===s.at(-1);u.value.style.bottom=`0px`;let t=p.value.clientHeight-m.value.offsetTop-m.value.offsetHeight,n=k+Math.max(E,D+(e?T:0)+t+y);u.value.style.height=`${n}px`}else{let e=h.value===s[0];u.value.style.top=`0px`;let t=Math.max(ee,_+m.value.offsetTop+(e?w:0)+D)+A;u.value.style.height=`${t}px`,m.value.scrollTop=k-ee+m.value.offsetTop}u.value.style.margin=`10px 0`,u.value.style.minHeight=`${S}px`,u.value.style.maxHeight=`${l}px`,i(`placed`),requestAnimationFrame(()=>c.value=!0)}}let S=L(``);ce(async()=>{await v(),y(),p.value&&(S.value=window.getComputedStyle(p.value).zIndex)});function C(e){e&&l.value===!0&&(y(),_?.(),l.value=!1)}return e(o.triggerElement,()=>{y()}),wn({contentWrapper:u,shouldExpandOnScrollRef:c,onScrollButtonChange:C}),(e,t)=>(O(),D(`div`,{ref_key:`contentWrapperElement`,ref:u,style:b({display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S.value})},[x(w(wt),d({ref:w(f),style:{boxSizing:`border-box`,maxHeight:`100%`}},{...e.$attrs,...r}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16)],4))}}),En=A({__name:`SelectArrow`,props:{width:{type:Number,required:!1,default:10},height:{type:Number,required:!1,default:5},rounded:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`svg`}},setup(e){let t=e,n=bn(yn);return(e,r)=>w(n).position===`popper`?(O(),S(w(nt),h(d({key:0},t)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16)):T(`v-if`,!0)}}),Dn=A({inheritAttrs:!1,__name:`SelectProvider`,props:{context:{type:Object,required:!0}},setup(e){return hn(e.context),xn(yn),(e,t)=>I(e.$slots,`default`)}}),On={key:1},kn=A({inheritAttrs:!1,__name:`SelectContent`,props:{forceMount:{type:Boolean,required:!1},position:{type:String,required:!1},bodyLock:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:[`closeAutoFocus`,`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,i=Ue(n,t),o=mn(),s=L();ce(()=>{s.value=new DocumentFragment});let c=L(),l=r(()=>n.forceMount||o.open.value),u=L(l.value),d;function f(){d&&=(clearTimeout(d),void 0)}return Pe(l,(e,t,n)=>{f(),d=setTimeout(()=>{u.value=l.value,d=void 0}),n(f)}),se(f),(e,t)=>l.value||u.value||c.value?.present?(O(),S(w(dt),{key:0,ref_key:`presenceRef`,ref:c,present:l.value},{default:F(()=>[x(Sn,h(a({...w(i),...e.$attrs})),{default:F(()=>[I(e.$slots,`default`)]),_:3},16)]),_:3},8,[`present`])):s.value?(O(),D(`div`,On,[(O(),S(E,{to:s.value},[x(Dn,{context:w(o)},{default:F(()=>[I(e.$slots,`default`)]),_:3},8,[`context`])],8,[`to`]))])):T(`v-if`,!0)}}),[An,jn]=mt(`SelectGroup`),Mn=A({__name:`SelectGroup`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=ut(void 0,`reka-select-group`);return jn({id:n}),(e,r)=>(O(),S(w(wt),d({role:`group`},t,{"aria-labelledby":w(n)}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16,[`aria-labelledby`]))}}),[Nn,Pn]=mt(`SelectItem`),Fn=A({__name:`SelectItem`,props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`select`],setup(e,{emit:t}){let i=e,a=t,{disabled:o}=n(i),s=mn(),c=bn(),{forwardRef:l,currentElement:u}=yt(),{CollectionItem:d}=Lt(),f=r(()=>un(s.modelValue?.value,i.value,s.by)),p=L(!1),m=L(i.textValue??``),h=ut(void 0,`reka-select-item-text`);async function g(e){e.defaultPrevented||Nt(`select.select`,_,{originalEvent:e,value:i.value})}async function _(e){await v(),a(`select`,e),!e.defaultPrevented&&(o.value||(s.onValueChange(i.value),s.multiple.value||s.onOpenChange(!1)))}async function y(e){await v(),!e.defaultPrevented&&(o.value?c.onItemLeave?.():e.currentTarget?.focus({preventScroll:!0}))}async function b(e){await v(),!e.defaultPrevented&&e.currentTarget===ft()&&c.onItemLeave?.()}async function C(e){await v(),!e.defaultPrevented&&(c.searchRef?.value!==``&&e.key===` `||(ln.includes(e.key)&&g(e),e.key===` `&&e.preventDefault()))}if(i.value===``)throw Error(`A <SelectItem /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return ce(()=>{u.value&&c.itemRefCallback(u.value,i.value,i.disabled)}),Pn({value:i.value,disabled:o,textId:h,isSelected:f,onItemTextChange:e=>{m.value=((m.value||e?.textContent)??``).trim()}}),(e,t)=>(O(),S(w(d),{value:{textValue:m.value}},{default:F(()=>[x(w(wt),{ref:w(l),role:`option`,"aria-labelledby":w(h),"data-highlighted":p.value?``:void 0,"aria-selected":f.value,"data-state":f.value?`checked`:`unchecked`,"aria-disabled":w(o)||void 0,"data-disabled":w(o)?``:void 0,tabindex:w(o)?void 0:-1,as:e.as,"as-child":e.asChild,onFocus:t[0]||=e=>p.value=!0,onBlur:t[1]||=e=>p.value=!1,onPointerup:g,onPointerdown:t[2]||=e=>{e.currentTarget.focus({preventScroll:!0})},onTouchend:t[3]||=re(()=>{},[`prevent`,`stop`]),onPointermove:y,onPointerleave:b,onKeydown:C},{default:F(()=>[I(e.$slots,`default`)]),_:3},8,[`aria-labelledby`,`data-highlighted`,`aria-selected`,`data-state`,`aria-disabled`,`data-disabled`,`tabindex`,`as`,`as-child`])]),_:3},8,[`value`]))}}),In=A({__name:`SelectItemIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(e){let t=e,n=Nn();return(e,r)=>w(n).isSelected.value?(O(),S(w(wt),d({key:0,"aria-hidden":`true`},t),{default:F(()=>[I(e.$slots,`default`)]),_:3},16)):T(`v-if`,!0)}}),Ln=A({inheritAttrs:!1,__name:`SelectItemText`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(e){let t=e,n=mn(),i=bn(),a=Nn(),{forwardRef:o,currentElement:s}=yt(),c=r(()=>({value:a.value,disabled:a.disabled.value,textContent:s.value?.textContent??a.value?.toString()??``}));return ce(()=>{s.value&&(a.onItemTextChange(s.value),i.itemTextRefCallback(s.value,a.value,a.disabled.value),n.onOptionAdd(c.value))}),se(()=>{n.onOptionRemove(c.value)}),(e,n)=>(O(),S(w(wt),d({id:w(a).textId,ref:w(o)},{...t,...e.$attrs}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16,[`id`]))}}),Rn=A({__name:`SelectLabel`,props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`div`}},setup(e){let t=e,n=An({id:``});return(e,r)=>(O(),S(w(wt),d(t,{id:w(n).id}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16,[`id`]))}}),zn=A({__name:`SelectPortal`,props:{to:{type:null,required:!1},disabled:{type:Boolean,required:!1},defer:{type:Boolean,required:!1},forceMount:{type:Boolean,required:!1}},setup(e){let t=e;return(e,n)=>(O(),S(w(jt),h(a(t)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))}}),Bn=A({__name:`SelectSeparator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e;return(e,n)=>(O(),S(w(wt),d({"aria-hidden":`true`},t),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))}}),Vn=A({__name:`SelectTrigger`,props:{disabled:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e,n=mn(),{forwardRef:i,currentElement:a}=yt(),o=r(()=>n.disabled?.value||t.disabled);n.contentId||=ut(void 0,`reka-select-content`),ce(()=>{n.onTriggerChange(a.value)});let{getItems:s}=Lt(),{search:c,handleTypeaheadSearch:l,resetTypeahead:u}=ct();function d(){o.value||(n.onOpenChange(!0),u())}function f(e){d(),n.triggerPointerDownPosRef.value={x:Math.round(e.pageX),y:Math.round(e.pageY)}}return(e,t)=>(O(),S(w(Je),{"as-child":``,reference:e.reference},{default:F(()=>[x(w(wt),{ref:w(i),role:`combobox`,type:e.as===`button`?`button`:void 0,"aria-controls":w(n).contentId,"aria-expanded":w(n).open.value||!1,"aria-required":w(n).required?.value,"aria-autocomplete":`none`,disabled:o.value,dir:w(n)?.dir.value,"data-state":w(n)?.open.value?`open`:`closed`,"data-disabled":o.value?``:void 0,"data-placeholder":w(fn)(w(n).modelValue?.value)?``:void 0,"as-child":e.asChild,as:e.as,onClick:t[0]||=e=>{(e?.currentTarget)?.focus()},onPointerdown:t[1]||=e=>{if(e.pointerType===`touch`)return e.preventDefault();let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&(f(e),e.preventDefault())},onPointerup:t[2]||=re(e=>{e.pointerType===`touch`&&f(e)},[`prevent`]),onKeydown:t[3]||=e=>{let t=w(c)!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&t&&e.key===` `||(w(l)(e.key,w(s)()),w(cn).includes(e.key)&&(d(),e.preventDefault()))}},{default:F(()=>[I(e.$slots,`default`)]),_:3},8,[`type`,`aria-controls`,`aria-expanded`,`aria-required`,`disabled`,`dir`,`data-state`,`data-disabled`,`data-placeholder`,`as-child`,`as`])]),_:3},8,[`reference`]))}}),Hn=A({__name:`SelectValue`,props:{placeholder:{type:String,required:!1,default:``},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(e){let t=e,{forwardRef:n,currentElement:i}=yt(),a=mn();ce(()=>{a.valueElement=i});let o=r(()=>{let e=[],t=Array.from(a.optionsSet.value),n=e=>t.find(t=>un(e,t.value,a.by));return e=Array.isArray(a.modelValue.value)?a.modelValue.value.map(e=>n(e)?.textContent??``):[n(a.modelValue.value)?.textContent??``],e.filter(Boolean)}),s=r(()=>o.value.length?o.value.join(`, `):t.placeholder);return(e,r)=>(O(),S(w(wt),{ref:w(n),as:e.as,"as-child":e.asChild,style:{pointerEvents:`none`},"data-placeholder":o.value.length?void 0:t.placeholder},{default:F(()=>[I(e.$slots,`default`,{selectedLabel:o.value,modelValue:w(a).modelValue.value},()=>[g(k(s.value),1)])]),_:3},8,[`as`,`as-child`,`data-placeholder`]))}}),Un=A({__name:`SelectViewport`,props:{nonce:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,{nonce:r}=n(t),i=Wt(r),a=bn(),o=a.position===`item-aligned`?Cn():void 0,{forwardRef:s,currentElement:c}=yt();ce(()=>{a?.onViewportChange(c.value)});let u=L(0);function f(e){let t=e.currentTarget,{shouldExpandOnScrollRef:n,contentWrapper:r}=o??{};if(n?.value&&r?.value){let e=Math.abs(u.value-t.scrollTop);if(e>0){let n=window.innerHeight-20,i=Number.parseFloat(r.value.style.minHeight),a=Number.parseFloat(r.value.style.height),o=Math.max(i,a);if(o<n){let i=o+e,a=Math.min(n,i),s=i-a;r.value.style.height=`${a}px`,r.value.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,r.value.style.justifyContent=`flex-end`)}}}u.value=t.scrollTop}return(e,n)=>(O(),D(l,null,[x(w(wt),d({ref:w(s),"data-reka-select-viewport":``,role:`presentation`},{...e.$attrs,...t},{style:{position:`relative`,flex:1,overflow:`hidden auto`},onScroll:f}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16),x(w(wt),{as:`style`,nonce:w(i)},{default:F(()=>n[0]||=[g(` /* Hide scrollbars cross-browser and enable momentum scroll for touch devices */ [data-reka-select-viewport] { scrollbar-width:none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } [data-reka-select-viewport]::-webkit-scrollbar { display: none; } `)]),_:1,__:[0]},8,[`nonce`])],64))}}),[Wn,Gn]=mt(`TagsInputRoot`),Kn=A({__name:`TagsInputRoot`,props:{modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1,default:()=>[]},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1,default:`,`},dir:{type:String,required:!1},max:{type:Number,required:!1,default:0},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1,default:e=>e.toString()},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`,`invalid`,`addTag`,`removeTag`],setup(e,{emit:t}){let i=e,a=t,{addOnPaste:o,disabled:s,delimiter:c,max:l,id:u,dir:d,addOnBlur:f,addOnTab:p}=n(i),m=It(d),h=ye(i,`modelValue`,a,{defaultValue:i.defaultValue,passive:!0,deep:!0}),{forwardRef:g,currentElement:_}=yt(),{focused:v}=ae(_),y=et(_),{getItems:b,CollectionSlot:C}=Lt({isProvider:!0}),ee=L(),E=L(!1),D=r(()=>Array.isArray(h.value)?[...h.value]:[]);function k(e){if(e!==-1){let t=b().filter(e=>e.ref.dataset.disabled!==``);h.value=h.value.filter((t,n)=>n!==e),a(`removeTag`,t[e].value)}}return Gn({modelValue:h,onAddValue:e=>{let t=[...D.value],n=t.length>0&&typeof t[0]==`object`,r=t.length>0&&typeof i.defaultValue[0]==`object`;if((n||r)&&typeof i.convertValue!=`function`)throw Error("You must provide a `convertValue` function when using objects as values.");let o=i.convertValue?i.convertValue(e):e;if(t.length>=l.value&&l.value)return a(`invalid`,o),!1;if(i.duplicate)return h.value=[...t,o],a(`addTag`,o),!0;if(t.includes(o))E.value=!0;else return h.value=[...t,o],a(`addTag`,o),!0;return a(`invalid`,o),!1},onRemoveValue:k,onInputKeydown:e=>{if(e.isComposing)return;let t=e.target,n=b().map(e=>e.ref).filter(e=>e.dataset.disabled!==``);if(!n.length)return;let r=n.at(-1);switch(e.key){case`Delete`:case`Backspace`:if(t.selectionStart!==0||t.selectionEnd!==0)break;if(ee.value){let t=n.findIndex(e=>e===ee.value);k(t),ee.value=ee.value===r?n.at(t-1):n.at(t+1),e.preventDefault()}else e.key===`Backspace`&&(ee.value=r,e.preventDefault());break;case`Home`:case`End`:case`ArrowRight`:case`ArrowLeft`:{let i=e.key===`ArrowRight`&&m.value===`ltr`||e.key===`ArrowLeft`&&m.value===`rtl`,a=!i;if(t.selectionStart!==0||t.selectionEnd!==0)break;if(a&&!ee.value)ee.value=r,e.preventDefault();else if(i&&r&&ee.value===r)ee.value=void 0,e.preventDefault();else if(ee.value){let t=Ke(e,ee.value,void 0,{itemsArray:n,loop:!1,dir:m.value});t&&(ee.value=t),e.preventDefault()}break}case`ArrowUp`:case`ArrowDown`:ee.value&&e.preventDefault();break;default:ee.value=void 0}},selectedElement:ee,isInvalidInput:E,addOnPaste:o,addOnBlur:f,addOnTab:p,dir:m,disabled:s,delimiter:c,max:l,id:u,displayValue:i.displayValue}),(e,t)=>(O(),S(w(C),null,{default:F(()=>[x(w(wt),{ref:w(g),dir:w(m),as:e.as,"as-child":e.asChild,"data-invalid":E.value?``:void 0,"data-disabled":w(s)?``:void 0,"data-focused":w(v)?``:void 0},{default:F(()=>[I(e.$slots,`default`,{modelValue:w(h)}),w(y)&&e.name?(O(),S(w(Ze),{key:0,name:e.name,value:w(h),required:e.required,disabled:w(s)},null,8,[`name`,`value`,`required`,`disabled`])):T(`v-if`,!0)]),_:3},8,[`dir`,`as`,`as-child`,`data-invalid`,`data-disabled`,`data-focused`])]),_:3}))}}),qn=A({__name:`TagsInputInput`,props:{placeholder:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},maxLength:{type:Number,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`input`}},setup(e){let t=e,n=Wn(),{forwardRef:r,currentElement:i}=yt();function a(e){if(n.selectedElement.value=void 0,!n.addOnBlur.value)return;let t=e.target,r=e.relatedTarget,i=t.getAttribute(`aria-controls`);i&&r?.closest(`#${CSS.escape(i)}`)||t.value&&n.onAddValue(t.value)&&(t.value=``)}function o(e){n.addOnTab.value&&u(e)}let{isComposing:s,handleCompositionStart:c,handleCompositionEnd:l}=tt();async function u(e){if(s.value||(await v(),e.defaultPrevented))return;let t=e.target;t.value&&(n.onAddValue(t.value)&&(t.value=``),e.preventDefault())}function d(e){if(s.value||(n.isInvalidInput.value=!1,e.data===null))return;let t=n.delimiter.value;if(t===e.data||t instanceof RegExp&&t.test(e.data)){let r=e.target;if(r.value=r.value.replace(t,``),r.value.trim()===``){r.value=``;return}n.onAddValue(r.value)&&(r.value=``)}}function f(e){s.value||n.onInputKeydown(e)}function p(e){if(n.addOnPaste.value){e.preventDefault();let t=e.clipboardData;if(!t)return;let r=t.getData(`text`);n.delimiter.value?r.split(n.delimiter.value).forEach(e=>{n.onAddValue(e)}):n.onAddValue(r)}}return ce(()=>{let e=i.value.nodeName===`INPUT`?i.value:i.value.querySelector(`input`);e&&setTimeout(()=>{t.autoFocus&&e?.focus()},1)}),(e,t)=>(O(),S(w(wt),{id:w(n).id?.value,ref:w(r),type:`text`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`,as:e.as,"as-child":e.asChild,maxlength:e.maxLength,placeholder:e.placeholder,disabled:w(n).disabled.value,"data-invalid":w(n).isInvalidInput.value?``:void 0,onInput:d,onKeydown:[Le(u,[`enter`]),Le(o,[`tab`]),f],onBlur:a,onCompositionstart:w(c),onCompositionend:w(l),onPaste:p},{default:F(()=>[I(e.$slots,`default`)]),_:3},8,[`id`,`as`,`as-child`,`maxlength`,`placeholder`,`disabled`,`data-invalid`,`onCompositionstart`,`onCompositionend`]))}}),[Jn,Yn]=mt(`TagsInputItem`),Xn=A({__name:`TagsInputItem`,props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,{value:i}=n(t),a=Wn(),{forwardRef:o,currentElement:s}=yt(),{CollectionItem:c}=Lt(),l=r(()=>a.selectedElement.value===s.value),u=r(()=>t.disabled||a.disabled.value),d=Yn({value:i,isSelected:l,disabled:u,textId:``,displayValue:r(()=>a.displayValue(i.value))});return(e,t)=>(O(),S(w(c),{value:w(i)},{default:F(()=>[x(w(wt),{ref:w(o),as:e.as,"as-child":e.asChild,"aria-labelledby":w(d).textId,"aria-current":l.value,"data-disabled":u.value?``:void 0,"data-state":l.value?`active`:`inactive`},{default:F(()=>[I(e.$slots,`default`)]),_:3},8,[`as`,`as-child`,`aria-labelledby`,`aria-current`,`data-disabled`,`data-state`])]),_:3},8,[`value`]))}}),Zn=A({__name:`TagsInputItemDelete`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;yt();let n=Wn(),i=Jn(),a=r(()=>i.disabled?.value||n.disabled.value);function o(){if(a.value)return;let e=n.modelValue.value.findIndex(e=>ne(e,i.value.value));n.onRemoveValue(e)}return(e,n)=>(O(),S(w(wt),d({tabindex:`-1`},t,{"aria-labelledby":w(i).textId,"aria-current":w(i).isSelected.value,"data-state":w(i).isSelected.value?`active`:`inactive`,"data-disabled":a.value?``:void 0,type:e.as===`button`?`button`:void 0,onClick:o}),{default:F(()=>[I(e.$slots,`default`)]),_:3},16,[`aria-labelledby`,`aria-current`,`data-state`,`data-disabled`,`type`]))}}),Qn=A({__name:`TagsInputItemText`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(e){let t=e,n=Jn();return yt(),n.textId||=ut(void 0,`reka-tags-input-item-text`),(e,r)=>(O(),S(w(wt),d(t,{id:w(n).textId}),{default:F(()=>[I(e.$slots,`default`,{},()=>[g(k(w(n).displayValue.value),1)])]),_:3},16,[`id`]))}}),$n=A({__name:`TooltipArrow`,props:{width:{type:Number,required:!1,default:10},height:{type:Number,required:!1,default:5},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`svg`}},setup(e){let t=e;return yt(),(e,n)=>(O(),S(w(nt),h(a(t)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))}}),er=`tooltip.open`,[tr,nr]=mt(`TooltipRoot`),rr=A({__name:`TooltipRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},delayDuration:{type:Number,required:!1,default:void 0},disableHoverableContent:{type:Boolean,required:!1,default:void 0},disableClosingTrigger:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1,default:void 0},ignoreNonKeyboardFocus:{type:Boolean,required:!1,default:void 0}},emits:[`update:open`],setup(e,{emit:t}){let n=e,i=t;yt();let a=$t(),o=r(()=>n.disableHoverableContent??a.disableHoverableContent.value),s=r(()=>n.disableClosingTrigger??a.disableClosingTrigger.value),c=r(()=>n.disabled??a.disabled.value),l=r(()=>n.delayDuration??a.delayDuration.value),u=r(()=>n.ignoreNonKeyboardFocus??a.ignoreNonKeyboardFocus.value),d=ye(n,`open`,i,{defaultValue:n.defaultOpen,passive:n.open===void 0});Pe(d,e=>{a.onClose&&(e?(a.onOpen(),document.dispatchEvent(new CustomEvent(er))):a.onClose())});let f=L(!1),p=L(),m=r(()=>d.value?f.value?`delayed-open`:`instant-open`:`closed`),{start:h,stop:g}=de(()=>{f.value=!0,d.value=!0},l,{immediate:!1});function _(){g(),f.value=!1,d.value=!0}function v(){g(),d.value=!1}function y(){h()}return nr({contentId:``,open:d,stateAttribute:m,trigger:p,onTriggerChange(e){p.value=e},onTriggerEnter(){a.isOpenDelayed.value?y():_()},onTriggerLeave(){o.value?v():g()},onOpen:_,onClose:v,disableHoverableContent:o,disableClosingTrigger:s,disabled:c,ignoreNonKeyboardFocus:u}),(e,t)=>(O(),S(w(Ye),null,{default:F(()=>[I(e.$slots,`default`,{open:w(d)})]),_:3}))}}),ir=A({__name:`TooltipContentImpl`,props:{ariaLabel:{type:String,required:!1},asChild:{type:Boolean,required:!1,default:void 0},as:{type:null,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},avoidCollisions:{type:Boolean,required:!1,default:void 0},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1,default:void 0},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,i=t,a=tr(),o=$t(),{forwardRef:c,currentElement:l}=yt(),u=r(()=>n.ariaLabel||l.value?.textContent),p=r(()=>{let{ariaLabel:e,...t}=n;return s(t,o.content.value??{},{side:`top`,sideOffset:0,align:`center`,avoidCollisions:!0,collisionBoundary:[],collisionPadding:0,arrowPadding:0,sticky:`partial`,hideWhenDetached:!1})});return ce(()=>{f(window,`scroll`,e=>{e.target?.contains(a.trigger.value)&&a.onClose()},{capture:!0}),f(window,er,a.onClose)}),(e,t)=>(O(),S(w(Ot),{"as-child":``,"disable-outside-pointer-events":!1,onEscapeKeyDown:t[0]||=e=>i(`escapeKeyDown`,e),onPointerDownOutside:t[1]||=e=>{w(a).disableClosingTrigger.value&&w(a).trigger.value?.contains(e.target)&&e.preventDefault(),i(`pointerDownOutside`,e)},onFocusOutside:t[2]||=re(()=>{},[`prevent`]),onDismiss:t[3]||=e=>w(a).onClose()},{default:F(()=>[x(w(Qe),d({ref:w(c),"data-state":w(a).stateAttribute.value},{...e.$attrs,...p.value},{style:{"--reka-tooltip-content-transform-origin":`var(--reka-popper-transform-origin)`,"--reka-tooltip-content-available-width":`var(--reka-popper-available-width)`,"--reka-tooltip-content-available-height":`var(--reka-popper-available-height)`,"--reka-tooltip-trigger-width":`var(--reka-popper-anchor-width)`,"--reka-tooltip-trigger-height":`var(--reka-popper-anchor-height)`}}),{default:F(()=>[I(e.$slots,`default`),x(w(Pt),{id:w(a).contentId,role:`tooltip`},{default:F(()=>[g(k(u.value),1)]),_:1},8,[`id`])]),_:3},16,[`data-state`])]),_:3}))}}),ar=A({__name:`TooltipContentHoverable`,props:{ariaLabel:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1}},setup(e){let t=pt(e),{forwardRef:n,currentElement:r}=yt(),{trigger:i,onClose:a}=tr(),o=$t(),{isPointerInTransit:s,onPointerExit:c}=zt(i,r);return o.isPointerInTransitRef=s,c(()=>{a()}),(e,r)=>(O(),S(ir,d({ref:w(n)},w(t)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))}}),or=A({__name:`TooltipContent`,props:{forceMount:{type:Boolean,required:!1},ariaLabel:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=tr(),a=Ue(n,r),{forwardRef:o}=yt();return(e,t)=>(O(),S(w(dt),{present:e.forceMount||w(i).open.value},{default:F(()=>[(O(),S(je(w(i).disableHoverableContent.value?ir:ar),d({ref:w(o)},w(a)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))]),_:3},8,[`present`]))}}),sr=A({__name:`TooltipPortal`,props:{to:{type:null,required:!1},disabled:{type:Boolean,required:!1},defer:{type:Boolean,required:!1},forceMount:{type:Boolean,required:!1}},setup(e){let t=e;return(e,n)=>(O(),S(w(jt),h(a(t)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16))}}),cr=A({__name:`TooltipTrigger`,props:{reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e,n=tr(),i=$t();n.contentId||=ut(void 0,`reka-tooltip-content`);let{forwardRef:a,currentElement:o}=yt(),s=L(!1),c=L(!1),l=r(()=>n.disabled.value?{}:{click:_,focus:h,pointermove:p,pointerleave:m,pointerdown:f,blur:g});ce(()=>{n.onTriggerChange(o.value)});function u(){setTimeout(()=>{s.value=!1},1)}function f(){n.open&&!n.disableClosingTrigger.value&&n.onClose(),s.value=!0,document.addEventListener(`pointerup`,u,{once:!0})}function p(e){e.pointerType!==`touch`&&!c.value&&!i.isPointerInTransitRef.value&&(n.onTriggerEnter(),c.value=!0)}function m(){n.onTriggerLeave(),c.value=!1}function h(e){s.value||n.ignoreNonKeyboardFocus.value&&!e.target.matches?.(`:focus-visible`)||n.onOpen()}function g(){n.onClose()}function _(){n.disableClosingTrigger.value||n.onClose()}return(e,r)=>(O(),S(w(Je),{"as-child":``,reference:e.reference},{default:F(()=>[x(w(wt),d({ref:w(a),"aria-describedby":w(n).open.value?w(n).contentId:void 0,"data-state":w(n).stateAttribute.value,as:e.as,"as-child":t.asChild,"data-grace-area-trigger":``},Se(l.value)),{default:F(()=>[I(e.$slots,`default`)]),_:3},16,[`aria-describedby`,`data-state`,`as`,`as-child`])]),_:3},8,[`reference`]))}}),lr={slots:{root:`relative flex flex-col items-center justify-center gap-4 rounded-lg p-4 sm:p-6 lg:p-8 min-w-0`,header:`flex flex-col items-center gap-2 max-w-sm text-center`,avatar:`shrink-0 mb-2`,title:`text-highlighted text-pretty font-medium`,description:`text-balance text-center`,body:`flex flex-col items-center gap-4 max-w-sm`,actions:`flex flex-wrap justify-center gap-2 shrink-0`,footer:`flex flex-col items-center gap-2 max-w-sm`},variants:{size:{xs:{avatar:`size-8 text-base`,title:`text-sm`,description:`text-xs`},sm:{avatar:`size-9 text-lg`,title:`text-sm`,description:`text-xs`},md:{avatar:`size-10 text-xl`,title:`text-base`,description:`text-sm`},lg:{avatar:`size-11 text-[22px]`,title:`text-base`,description:`text-sm`},xl:{avatar:`size-12 text-2xl`,title:`text-lg`,description:`text-base`}},variant:{solid:{root:`bg-inverted`,title:`text-inverted`,description:`text-dimmed`},outline:{root:`bg-default ring ring-default`,description:`text-muted`},soft:{root:`bg-elevated/50`,description:`text-toned`},subtle:{root:`bg-elevated/50 ring ring-default`,description:`text-toned`},naked:{description:`text-muted`}}},defaultVariants:{variant:`outline`,size:`md`}},ur={__name:`Empty`,props:{as:{type:null,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},title:{type:String,required:!1},description:{type:String,required:!1},actions:{type:Array,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1}},setup(e){let t=e,n=ge(),i=lt(`empty`,t),a=Ce(),o=r(()=>Tt({extend:Tt(lr),...a.ui?.empty||{}})({variant:i.variant,size:i.size}));return(e,t)=>(O(),S(w(wt),{as:w(i).as,"data-slot":`root`,class:u(o.value.root({class:[w(i).ui?.root,w(i).class]}))},{default:F(()=>[n.header||w(i).icon||w(i).avatar||n.leading||w(i).title||n.title||w(i).description||n.description?(O(),D(`div`,{key:0,"data-slot":`header`,class:u(o.value.header({class:w(i).ui?.header}))},[I(e.$slots,`header`,{},()=>[I(e.$slots,`leading`,{ui:o.value},()=>[w(i).icon||w(i).avatar?(O(),S(Ct,d({key:0,icon:w(i).icon},typeof w(i).avatar==`object`?w(i).avatar:{},{"data-slot":`avatar`,class:o.value.avatar({class:w(i).ui?.avatar})}),null,16,[`icon`,`class`])):T(``,!0)]),w(i).title||n.title?(O(),D(`h2`,{key:0,"data-slot":`title`,class:u(o.value.title({class:w(i).ui?.title}))},[I(e.$slots,`title`,{},()=>[g(k(w(i).title),1)])],2)):T(``,!0),w(i).description||n.description?(O(),D(`div`,{key:1,"data-slot":`description`,class:u(o.value.description({class:w(i).ui?.description}))},[I(e.$slots,`description`,{},()=>[g(k(w(i).description),1)])],2)):T(``,!0)])],2)):T(``,!0),n.body||w(i).actions?.length||n.actions?(O(),D(`div`,{key:1,"data-slot":`body`,class:u(o.value.body({class:w(i).ui?.body}))},[I(e.$slots,`body`,{},()=>[w(i).actions?.length||n.actions?(O(),D(`div`,{key:0,"data-slot":`actions`,class:u(o.value.actions({class:w(i).ui?.actions}))},[I(e.$slots,`actions`,{},()=>[(O(!0),D(l,null,ve(w(i).actions,(e,t)=>(O(),S(St,d({key:t,size:w(i).size},{ref_for:!0},e),null,16,[`size`]))),128))])],2)):T(``,!0)])],2)):T(``,!0),n.footer?(O(),D(`div`,{key:2,"data-slot":`footer`,class:u(o.value.footer({class:w(i).ui?.footer}))},[I(e.$slots,`footer`)],2)):T(``,!0)]),_:3},8,[`as`,`class`]))}};function dr(e){return typeof e==`function`}function fr(e){return e==null}var pr=e=>e!==null&&!!e&&typeof e==`object`&&!Array.isArray(e);function mr(e){return Number(e)>=0}function hr(e){let t=parseFloat(e);return isNaN(t)?e:t}function gr(e){return typeof e==`object`&&!!e}function _r(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function vr(e){if(!gr(e)||_r(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function yr(e,t){return Object.keys(t).forEach(n=>{if(vr(t[n])&&vr(e[n])){e[n]||(e[n]={}),yr(e[n],t[n]);return}e[n]=t[n]}),e}function br(e){let t=e.split(`.`);if(!t.length)return``;let n=String(t[0]);for(let e=1;e<t.length;e++){if(mr(t[e])){n+=`[${t[e]}]`;continue}n+=`.${t[e]}`}return n}var xr={};function Sr(e){return xr[e]}function Cr(e,t,n){typeof n.value==`object`&&(n.value=wr(n.value)),!n.enumerable||n.get||n.set||!n.configurable||!n.writable||t===`__proto__`?Object.defineProperty(e,t,n):e[t]=n.value}function wr(e){if(typeof e!=`object`)return e;var t=0,n,r,i,a=Object.prototype.toString.call(e);if(a===`[object Object]`?i=Object.create(e.__proto__||null):a===`[object Array]`?i=Array(e.length):a===`[object Set]`?(i=new Set,e.forEach(function(e){i.add(wr(e))})):a===`[object Map]`?(i=new Map,e.forEach(function(e,t){i.set(wr(t),wr(e))})):a===`[object Date]`?i=new Date(+e):a===`[object RegExp]`?i=new RegExp(e.source,e.flags):a===`[object DataView]`?i=new e.constructor(wr(e.buffer)):a===`[object ArrayBuffer]`?i=e.slice(0):a.slice(-6)===`Array]`&&(i=new e.constructor(e)),i){for(r=Object.getOwnPropertySymbols(e);t<r.length;t++)Cr(i,r[t],Object.getOwnPropertyDescriptor(e,r[t]));for(t=0,r=Object.getOwnPropertyNames(e);t<r.length;t++)Object.hasOwnProperty.call(i,n=r[t])&&i[n]===e[n]||Cr(i,n,Object.getOwnPropertyDescriptor(e,n))}return i||e}var Tr=Symbol(`vee-validate-form`),Er=Symbol(`vee-validate-form-context`),Dr=Symbol(`vee-validate-field-instance`),Or=Symbol(`Default empty value`),kr=typeof window<`u`;function Ar(e){return dr(e)&&!!e.__locatorRef}function jr(e){return!!e&&dr(e.parse)&&e.__type===`VVTypedSchema`}function Mr(e){return!!e&&dr(e.validate)}function Nr(e){return e===`checkbox`||e===`radio`}function Pr(e){return pr(e)||Array.isArray(e)}function Fr(e){return Array.isArray(e)?e.length===0:pr(e)&&Object.keys(e).length===0}function Ir(e){return/^\[.+\]$/i.test(e)}function Lr(e){return Rr(e)&&e.multiple}function Rr(e){return e.tagName===`SELECT`}function zr(e,t){let n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return e===`select`&&`multiple`in t&&n}function Br(e,t){return!zr(e,t)&&t.type!==`file`&&!Nr(t.type)}function Vr(e){return Hr(e)&&e.target&&`submit`in e.target}function Hr(e){return e?!!(typeof Event<`u`&&dr(Event)&&e instanceof Event||e&&e.srcElement):!1}function Ur(e,t){return t in e&&e[t]!==Or}function Wr(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(e.constructor!==t.constructor)return!1;var n,r,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Wr(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!Wr(r[1],t.get(r[0])))return!1;return!0}if(Kr(e)&&Kr(t))return!(e.size!==t.size||e.name!==t.name||e.lastModified!==t.lastModified||e.type!==t.type);if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(e=Gr(e),t=Gr(t),i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){var a=i[r];if(!Wr(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Gr(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function Kr(e){return kr?e instanceof File:!1}function qr(e){return Ir(e)?e.replace(/\[|\]/gi,``):e}function Jr(e,t,n){return e?Ir(t)?e[qr(t)]:(t||``).split(/\.|\[(\d+)\]/).filter(Boolean).reduce((e,t)=>Pr(e)&&t in e?e[t]:n,e):n}function Yr(e,t,n){if(Ir(t)){e[qr(t)]=n;return}let r=t.split(/\.|\[(\d+)\]/).filter(Boolean),i=e;for(let e=0;e<r.length;e++){if(e===r.length-1){i[r[e]]=n;return}(!(r[e]in i)||fr(i[r[e]]))&&(i[r[e]]=mr(r[e+1])?[]:{}),i=i[r[e]]}}function Xr(e,t){if(Array.isArray(e)&&mr(t)){e.splice(Number(t),1);return}pr(e)&&delete e[t]}function Zr(e,t){if(Ir(t)){delete e[qr(t)];return}let n=t.split(/\.|\[(\d+)\]/).filter(Boolean),r=e;for(let e=0;e<n.length;e++){if(e===n.length-1){Xr(r,n[e]);break}if(!(n[e]in r)||fr(r[n[e]]))break;r=r[n[e]]}let i=n.map((t,r)=>Jr(e,n.slice(0,r).join(`.`)));for(let t=i.length-1;t>=0;t--)if(Fr(i[t])){if(t===0){Xr(e,n[0]);continue}Xr(i[t-1],n[t-1])}}function Qr(e){return Object.keys(e)}function $r(e,t=void 0){return Ve()?.provides[e]||p(e,t)}function ei(e,t,n){if(Array.isArray(e)){let n=[...e],r=n.findIndex(e=>Wr(e,t));return r>=0?n.splice(r,1):n.push(t),n}return Wr(e,t)?n:t}function ti(e,t=0){let n=null,r=[];return function(...i){return n&&clearTimeout(n),n=setTimeout(()=>{let t=e(...i);r.forEach(e=>e(t)),r=[]},t),new Promise(e=>r.push(e))}}function ni(e,t){return pr(t)&&t.number?hr(e):e}function ri(e,t){let n;return async function(...r){let i=e(...r);n=i;let a=await i;return i===n?(n=void 0,t(a,r)):a}}function ii({get:e,set:t}){let n=L(wr(e()));return Pe(e,e=>{Wr(e,n.value)||(n.value=wr(e))},{deep:!0}),Pe(n,n=>{Wr(n,e())||t(wr(n))},{deep:!0}),n}function ai(e){return Array.isArray(e)?e:e?[e]:[]}function oi(e,t){let n={};for(let r in e)t.includes(r)||(n[r]=e[r]);return n}function si(e){let t=null,n=[];return function(...r){let i=v(()=>{if(t!==i)return;let a=e(...r);n.forEach(e=>e(a)),n=[],t=null});return t=i,new Promise(e=>n.push(e))}}function ci(e,t,n){return t.slots.default?typeof e==`string`||!e?t.slots.default(n()):{default:()=>{var e;return(e=t.slots).default?.call(e,n())}}:t.slots.default}function li(e){if(ui(e))return e._value}function ui(e){return`_value`in e}function di(e){return e.type===`number`||e.type===`range`?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}function fi(e){if(!Hr(e))return e;let t=e.target;if(Nr(t.type)&&ui(t))return li(t);if(t.type===`file`&&t.files){let e=Array.from(t.files);return t.multiple?e:e[0]}if(Lr(t))return Array.from(t.options).filter(e=>e.selected&&!e.disabled).map(li);if(Rr(t)){let e=Array.from(t.options).find(e=>e.selected);return e?li(e):t.value}return di(t)}function pi(e){let t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?pr(e)&&e._$$isNormalized?e:pr(e)?Object.keys(e).reduce((t,n)=>{let r=mi(e[n]);return e[n]!==!1&&(t[n]=hi(r)),t},t):typeof e==`string`?e.split(`|`).reduce((e,t)=>{let n=gi(t);return n.name&&(e[n.name]=hi(n.params)),e},t):t:t}function mi(e){return e===!0?[]:Array.isArray(e)||pr(e)?e:[e]}function hi(e){let t=e=>typeof e==`string`&&e[0]===`@`?_i(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce((n,r)=>(n[r]=t(e[r]),n),{})}var gi=e=>{let t=[],n=e.split(`:`)[0];return e.includes(`:`)&&(t=e.split(`:`).slice(1).join(`:`).split(`,`)),{name:n,params:t}};function _i(e){let t=t=>Jr(t,e)??t[e];return t.__locatorRef=e,t}function vi(e){return Array.isArray(e)?e.filter(Ar):Qr(e).filter(t=>Ar(e[t])).map(t=>e[t])}var yi=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0}),bi=()=>yi;async function xi(e,t,n={}){let r=n?.bails,i=await Si({name:n?.name||`{field}`,rules:t,label:n?.label,bails:r??!0,formData:n?.values||{}},e);return Object.assign(Object.assign({},i),{valid:!i.errors.length})}async function Si(e,t){let n=e.rules;if(jr(n)||Mr(n))return Ti(t,Object.assign(Object.assign({},e),{rules:n}));if(dr(n)||Array.isArray(n)){let r={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},i=Array.isArray(n)?n:[n],a=i.length,o=[];for(let n=0;n<a;n++){let a=i[n],s=await a(t,r);if(!(typeof s!=`string`&&!Array.isArray(s)&&s)){if(Array.isArray(s))o.push(...s);else{let e=typeof s==`string`?s:Di(r);o.push(e)}if(e.bails)return{errors:o}}}return{errors:o}}let r=Object.assign(Object.assign({},e),{rules:pi(n)}),i=[],a=Object.keys(r.rules),o=a.length;for(let n=0;n<o;n++){let o=a[n],s=await Ei(r,t,{name:o,params:r.rules[o]});if(s.error&&(i.push(s.error),e.bails))return{errors:i}}return{errors:i}}function Ci(e){return!!e&&e.name===`ValidationError`}function wi(e){return{__type:`VVTypedSchema`,async parse(t,n){try{return{output:await e.validate(t,{abortEarly:!1,context:n?.formData||{}}),errors:[]}}catch(e){if(!Ci(e))throw e;if(!e.inner?.length&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};let t=e.inner.reduce((e,t)=>{let n=t.path||``;return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e},{});return{errors:Object.values(t)}}}}}async function Ti(e,t){let n=await(jr(t.rules)?t.rules:wi(t.rules)).parse(e,{formData:t.formData}),r=[];for(let e of n.errors)e.errors.length&&r.push(...e.errors);return{value:n.value,errors:r}}async function Ei(e,t,n){let r=Sr(n.name);if(!r)throw Error(`No such validator '${n.name}' exists.`);let i=Oi(n.params,e.formData),a={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:i})},o=await r(t,i,a);return typeof o==`string`?{error:o}:{error:o?void 0:Di(a)}}function Di(e){let t=bi().generateMessage;return t?t(e):`Field is invalid`}function Oi(e,t){let n=e=>Ar(e)?e(t):e;return Array.isArray(e)?e.map(n):Object.keys(e).reduce((t,r)=>(t[r]=n(e[r]),t),{})}async function ki(e,t){let n=await(jr(e)?e:wi(e)).parse(wr(t),{formData:wr(t)}),r={},i={};for(let e of n.errors){let t=e.errors,n=(e.path||``).replace(/\["(\d+)"\]/g,(e,t)=>`[${t}]`);r[n]={valid:!t.length,errors:t},t.length&&(i[n]=t[0])}return{valid:!n.errors.length,results:r,errors:i,values:n.value,source:`schema`}}async function Ai(e,t,n){let r=Qr(e).map(async r=>{let i=n?.names?.[r],a=await xi(Jr(t,r),e[r],{name:i?.name||r,label:i?.label,values:t,bails:n?.bailsMap?.[r]??!0});return Object.assign(Object.assign({},a),{path:r})}),i=!0,a=await Promise.all(r),o={},s={};for(let e of a)o[e.path]={valid:e.valid,errors:e.errors},e.valid||(i=!1,s[e.path]=e.errors[0]);return{valid:i,results:o,errors:s,source:`schema`}}var ji=0;function Mi(e,t){let{value:n,initialValue:i,setInitialValue:a}=Ni(e,t.modelValue,t.form);if(!t.form){let{errors:r,setErrors:o}=Ii(),s=ji>=2**53-1?0:++ji,c=Fi(n,i,r,t.schema);function l(e){`value`in e&&(n.value=e.value),`errors`in e&&o(e.errors),`touched`in e&&(c.touched=e.touched??c.touched),`initialValue`in e&&a(e.initialValue)}return{id:s,path:e,value:n,initialValue:i,meta:c,flags:{pendingUnmount:{[s]:!1},pendingReset:!1},errors:r,setState:l}}let o=t.form.createPathState(e,{bails:t.bails,label:t.label,type:t.type,validate:t.validate,schema:t.schema}),s=r(()=>o.errors);function c(r){var i,o;`value`in r&&(n.value=r.value),`errors`in r&&((i=t.form)==null||i.setFieldError(w(e),r.errors)),`touched`in r&&((o=t.form)==null||o.setFieldTouched(w(e),r.touched??!1)),`initialValue`in r&&a(r.initialValue)}return{id:Array.isArray(o.id)?o.id[o.id.length-1]:o.id,path:e,value:n,errors:s,meta:o,initialValue:i,flags:o.__flags,setState:c}}function Ni(e,t,n){let i=L(w(t));function a(){return n?Jr(n.initialValues.value,w(e),w(i)):w(i)}function o(t){if(!n){i.value=t;return}n.setFieldInitialValue(w(e),t,!0)}let s=r(a);if(!n)return{value:L(a()),initialValue:s,setInitialValue:o};let c=Pi(t,n,s,e);return n.stageInitialValue(w(e),c,!0),{value:r({get(){return Jr(n.values,w(e))},set(t){n.setFieldValue(w(e),t,!1)}}),initialValue:s,setInitialValue:o}}function Pi(e,t,n,r){return ze(e)?w(e):e===void 0?Jr(t.values,w(r),w(n)):e}function Fi(e,t,n,i){let a=te({touched:!1,pending:!1,valid:!0,required:r(()=>{var e;return((e=N(i))?.describe)?.call(e).required??!1}),validated:!!w(n).length,initialValue:r(()=>w(t)),dirty:r(()=>!Wr(w(e),w(t)))});return Pe(n,e=>{a.valid=!e.length},{immediate:!0,flush:`sync`}),a}function Ii(){let e=L([]);return{errors:e,setErrors:t=>{e.value=ai(t)}}}function Li(e,t,n){return Nr(n?.type)?Bi(e,t,n):Ri(e,t,n)}function Ri(e,n,i){let{initialValue:a,validateOnMount:o,bails:s,type:c,checkedValue:l,label:u,validateOnValueUpdate:d,uncheckedValue:f,controlled:p,keepValueOnUnmount:m,syncVModel:h,form:g}=zi(i),v=p?$r(Tr):void 0,y=g||v,b=r(()=>br(N(e))),x=r(()=>{if(N(y?.schema))return;let e=w(n);return Mr(e)||jr(e)||dr(e)||Array.isArray(e)?e:pi(e)}),S=!dr(x.value)&&jr(N(n)),{id:C,value:T,initialValue:ee,meta:E,setState:D,errors:O,flags:k}=Mi(b,{modelValue:a,form:y,bails:s,label:u,type:c,validate:x.value?ie:void 0,schema:S?n:void 0}),A=r(()=>O.value[0]);h&&Vi({value:T,prop:h,handleChange:ae,shouldValidate:()=>d&&!k.pendingReset});let te=(e,t=!1)=>{E.touched=!0,t&&ne()};async function j(e){if(y?.validateSchema){let{results:t}=await y.validateSchema(e);return t[N(b)]??{valid:!0,errors:[]}}return x.value?xi(T.value,x.value,{name:N(b),label:N(u),values:y?.values??{},bails:s}):{valid:!0,errors:[]}}let ne=ri(async()=>(E.pending=!0,E.validated=!0,j(`validated-only`)),e=>k.pendingUnmount[fe.id]?e:(D({errors:e.errors}),E.pending=!1,E.valid=e.valid,e)),re=ri(async()=>j(`silent`),e=>(E.valid=e.valid,e));function ie(e){return e?.mode===`silent`?re():ne()}function ae(e,t=!0){ue(fi(e),t)}ce(()=>{if(o)return ne();(!y||!y.validateSchema)&&re()});function oe(e){E.touched=e}function se(e){let t=e&&`value`in e?e.value:ee.value;D({value:wr(t),initialValue:wr(t),touched:e?.touched??!1,errors:e?.errors||[]}),E.pending=!1,E.validated=!1,re()}let le=Ve();function ue(e,t=!0){T.value=le&&h?ni(e,le.props.modelModifiers):e,(t?ne:re)()}function de(e){D({errors:Array.isArray(e)?e:[e]})}let fe={id:C,name:b,label:u,value:r({get(){return T.value},set(e){ue(e,d)}}),meta:E,errors:O,errorMessage:A,type:c,checkedValue:l,uncheckedValue:f,bails:s,keepValueOnUnmount:m,resetField:se,handleReset:()=>se(),validate:ie,handleChange:ae,handleBlur:te,setState:D,setTouched:oe,setErrors:de,setValue:ue};return t(Dr,fe),ze(n)&&typeof w(n)!=`function`&&Pe(n,(e,t)=>{Wr(e,t)||(E.validated?ne():re())},{deep:!0}),y?(Pe(r(()=>{let e=x.value;return!e||dr(e)||Mr(e)||jr(e)||Array.isArray(e)?{}:Object.keys(e).reduce((t,n)=>{let r=vi(e[n]).map(e=>e.__locatorRef).reduce((e,t)=>{let n=Jr(y.values,t)||y.values[t];return n!==void 0&&(e[t]=n),e},{});return Object.assign(t,r),t},{})}),(e,t)=>{Object.keys(e).length&&(Wr(e,t)||(E.validated?ne():re()))}),_(()=>{let e=N(fe.keepValueOnUnmount)??N(y.keepValuesOnUnmount),t=N(b);if(e||!y||k.pendingUnmount[fe.id]){y?.removePathState(t,C);return}k.pendingUnmount[fe.id]=!0;let n=y.getPathState(t);if(Array.isArray(n?.id)&&n?.multiple?n?.id.includes(fe.id):n?.id===fe.id){if(n?.multiple&&Array.isArray(n.value)){let e=n.value.findIndex(e=>Wr(e,N(fe.checkedValue)));if(e>-1){let r=[...n.value];r.splice(e,1),y.setFieldValue(t,r)}Array.isArray(n.id)&&n.id.splice(n.id.indexOf(fe.id),1)}else y.unsetPathValue(N(b));y.removePathState(t,C)}}),fe):fe}function zi(e){let t=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),n=!!e?.syncVModel,r=typeof e?.syncVModel==`string`?e.syncVModel:e?.modelPropName||`modelValue`,i=n&&!(`initialValue`in(e||{}))?Hi(Ve(),r):e?.initialValue;if(!e)return Object.assign(Object.assign({},t()),{initialValue:i});let a=`valueProp`in e?e.valueProp:e.checkedValue,o=`standalone`in e?!e.standalone:e.controlled,s=e?.modelPropName||e?.syncVModel||!1;return Object.assign(Object.assign(Object.assign({},t()),e||{}),{initialValue:i,controlled:o??!0,checkedValue:a,syncVModel:s})}function Bi(e,t,n){let i=n?.standalone?void 0:$r(Tr),a=n?.checkedValue,o=n?.uncheckedValue;function s(t){let s=t.handleChange,c=r(()=>{let e=N(t.value),n=N(a);return Array.isArray(e)?e.findIndex(e=>Wr(e,n))>=0:Wr(n,e)});function l(r,l=!0){if(c.value===r?.target?.checked){l&&t.validate();return}let u=N(e),d=i?.getPathState(u),f=fi(r),p=N(a)??f;i&&d?.multiple&&d.type===`checkbox`?p=ei(Jr(i.values,u)||[],p,void 0):n?.type===`checkbox`&&(p=ei(N(t.value),p,N(o))),s(p,l)}return Object.assign(Object.assign({},t),{checked:c,checkedValue:a,uncheckedValue:o,handleChange:l})}return s(Ri(e,t,n))}function Vi({prop:e,value:t,handleChange:n,shouldValidate:r}){let i=Ve();if(!i||!e)return;let a=typeof e==`string`?e:`modelValue`,o=`update:${a}`;a in i.props&&(Pe(t,e=>{Wr(e,Hi(i,a))||i.emit(o,e)}),Pe(()=>Hi(i,a),e=>{if(e===Or&&t.value===void 0)return;let i=e===Or?void 0:e;Wr(i,t.value)||n(i,r())}))}function Hi(e,t){if(e)return e.props[t]}var Ui=A({name:`Field`,inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>bi().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:Or},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,t){let n=we(e,`rules`),i=we(e,`name`),a=we(e,`label`),o=we(e,`uncheckedValue`),s=we(e,`keepValue`),{errors:c,value:l,errorMessage:u,validate:d,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:_,checked:v,setErrors:y,setValue:b}=Li(i,n,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:t.attrs.type,initialValue:Ki(e,t),checkedValue:t.attrs.value,uncheckedValue:o,label:a,validateOnValueUpdate:e.validateOnModelUpdate,keepValueOnUnmount:s,syncVModel:!0}),x=function(e,t=!0){f(e,t)},S=r(()=>{let{validateOnInput:n,validateOnChange:r,validateOnBlur:i,validateOnModelUpdate:a}=Gi(e);function o(e){p(e,i),dr(t.attrs.onBlur)&&t.attrs.onBlur(e)}function s(e){x(e,n),dr(t.attrs.onInput)&&t.attrs.onInput(e)}function c(e){x(e,r),dr(t.attrs.onChange)&&t.attrs.onChange(e)}let l={name:e.name,onBlur:o,onInput:s,onChange:c};return l[`onUpdate:modelValue`]=e=>x(e,a),l}),C=r(()=>{let n=Object.assign({},S.value);return Nr(t.attrs.type)&&v&&(n.checked=v.value),Br(Wi(e,t),t.attrs)&&(n.value=l.value),n}),w=r(()=>Object.assign(Object.assign({},S.value),{modelValue:l.value}));function T(){return{field:C.value,componentField:w.value,value:l.value,meta:_,errors:c.value,errorMessage:u.value,validate:d,resetField:h,handleChange:x,handleInput:e=>x(e,!1),handleReset:g,handleBlur:S.value.onBlur,setTouched:m,setErrors:y,setValue:b}}return t.expose({value:l,meta:_,errors:c,errorMessage:u,setErrors:y,setTouched:m,setValue:b,reset:h,validate:d,handleChange:f}),()=>{let n=je(Wi(e,t)),r=ci(n,t,T);return n?ie(n,Object.assign(Object.assign({},t.attrs),C.value),r):r}}});function Wi(e,t){let n=e.as||``;return!e.as&&!t.slots.default&&(n=`input`),n}function Gi(e){let{validateOnInput:t,validateOnChange:n,validateOnBlur:r,validateOnModelUpdate:i}=bi();return{validateOnInput:e.validateOnInput??t,validateOnChange:e.validateOnChange??n,validateOnBlur:e.validateOnBlur??r,validateOnModelUpdate:e.validateOnModelUpdate??i}}function Ki(e,t){return Nr(t.attrs.type)?Ur(e,`modelValue`)?e.modelValue:void 0:Ur(e,`modelValue`)?e.modelValue:t.attrs.value}var qi=Ui,Ji=0,Yi=[`bails`,`fieldsCount`,`id`,`multiple`,`type`,`validate`];function Xi(e){let t=e?.initialValues||{},n=Object.assign({},N(t)),r=w(e?.validationSchema);return r&&jr(r)&&dr(r.cast)?wr(r.cast(n)||{}):wr(n)}function Zi(e){let n=Ji++,i=e?.name||`Form`,a=0,s=L(!1),l=L(!1),u=L(0),d=[],f=te(Xi(e)),p=L([]),m=L({}),h=L({}),g=si(()=>{h.value=p.value.reduce((e,t)=>(e[br(N(t.path))]=t,e),{})});function _(e,t){let n=se(e);if(!n){typeof e==`string`&&(m.value[br(e)]=ai(t));return}if(typeof e==`string`){let t=br(e);m.value[t]&&delete m.value[t]}n.errors=ai(t),n.valid=!n.errors.length}function y(e){Qr(e).forEach(t=>{_(t,e[t])})}e?.initialErrors&&y(e.initialErrors);let b=r(()=>{let e=p.value.reduce((e,t)=>(t.errors.length&&(e[N(t.path)]=t.errors),e),{});return Object.assign(Object.assign({},m.value),e)}),x=r(()=>Qr(b.value).reduce((e,t)=>{let n=b.value[t];return n?.length&&(e[t]=n[0]),e},{})),S=r(()=>p.value.reduce((e,t)=>(e[N(t.path)]={name:N(t.path)||``,label:t.label||``},e),{})),C=r(()=>p.value.reduce((e,t)=>(e[N(t.path)]=t.bails??!0,e),{})),T=Object.assign({},e?.initialErrors||{}),ee=e?.keepValuesOnUnmount??!1,{initialValues:E,originalInitialValues:D,setInitialValues:O}=$i(p,f,e),k=Qi(p,f,D,x),A=r(()=>p.value.reduce((e,t)=>{let n=Jr(f,N(t.path));return Yr(e,N(t.path),n),e},{})),j=e?.validationSchema;function ne(e,t){let n=r(()=>Jr(E.value,N(e))),i=h.value[N(e)],o=t?.type===`checkbox`||t?.type===`radio`;if(i&&o){i.multiple=!0;let e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}let s=r(()=>Jr(f,N(e))),l=N(e),u=ue.findIndex(e=>e===l);u!==-1&&ue.splice(u,1);let d=r(()=>{let n=N(j);if(jr(n))return n.describe?.call(n,N(e)).required??!1;let r=N(t?.schema);return jr(r)?r.describe?.call(r).required??!1:!1}),m=a++,_=te({id:m,path:e,touched:!1,pending:!1,valid:!0,validated:!!T[l]?.length,required:d,initialValue:n,errors:c([]),bails:t?.bails??!1,label:t?.label,type:t?.type||`default`,value:s,multiple:!1,__flags:{pendingUnmount:{[m]:!1},pendingReset:!1},fieldsCount:1,validate:t?.validate,dirty:r(()=>!Wr(w(s),w(n)))});return p.value.push(_),h.value[l]=_,g(),x.value[l]&&!T[l]&&v(()=>{Oe(l,{mode:`silent`})}),ze(e)&&Pe(e,e=>{g();let t=wr(s.value);h.value[e]=_,v(()=>{Yr(f,e,t)})}),_}let re=ti(je,5),ie=ti(je,5),ae=ri(async e=>await(e===`silent`?re():ie()),(e,[t])=>{let n=Qr(_e.errorBag.value),r=[...new Set([...Qr(e.results),...p.value.map(e=>e.path),...n])].sort().reduce((n,r)=>{let i=r,a=se(i)||le(i),o=e.results[i]?.errors||[],s=N(a?.path)||i,c=ea({errors:o,valid:!o.length},n.results[s]);return n.results[s]=c,c.valid||(n.errors[s]=c.errors[0]),a&&m.value[s]&&delete m.value[s],a?(a.valid=c.valid,t===`silent`||t===`validated-only`&&!a.validated||_(a,c.errors),n):(_(s,o),n)},{valid:e.valid,results:{},errors:{},source:e.source});return e.values&&(r.values=e.values,r.source=e.source),Qr(r.results).forEach(e=>{let n=se(e);n&&t!==`silent`&&(t===`validated-only`&&!n.validated||_(n,r.results[e]?.errors))}),r});function oe(e){p.value.forEach(e)}function se(e){let t=typeof e==`string`?br(e):e;return typeof t==`string`?h.value[t]:t}function le(e){return p.value.filter(t=>e.startsWith(N(t.path))).reduce((e,t)=>e?t.path.length>e.path.length?t:e:t,void 0)}let ue=[],de;function fe(e){return ue.push(e),de||=v(()=>{[...ue].sort().reverse().forEach(e=>{Zr(f,e)}),ue=[],de=null}),de}function pe(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),oe(e=>e.touched=!0),s.value=!0,u.value++,De().then(i=>{let a=wr(f);if(i.valid&&typeof t==`function`){let n=wr(A.value),o=e?n:a;return i.values&&(o=i.source===`schema`?i.values:Object.assign({},o,i.values)),t(o,{evt:r,controlledValues:n,setErrors:y,setFieldError:_,setTouched:we,setFieldTouched:xe,setValues:ye,setFieldValue:M,resetForm:Ee,resetField:Te})}!i.valid&&typeof n==`function`&&n({values:a,evt:r,errors:i.errors,results:i.results})}).then(e=>(s.value=!1,e),e=>{throw s.value=!1,e})}}}let me=pe(!1);me.withControlled=pe(!0);function he(e,t){let n=p.value.findIndex(n=>n.path===e&&(Array.isArray(n.id)?n.id.includes(t):n.id===t)),r=p.value[n];if(!(n===-1||!r)){if(v(()=>{Oe(e,{mode:`silent`,warn:!1})}),r.multiple&&r.fieldsCount&&r.fieldsCount--,Array.isArray(r.id)){let e=r.id.indexOf(t);e>=0&&r.id.splice(e,1),delete r.__flags.pendingUnmount[t]}(!r.multiple||r.fieldsCount<=0)&&(p.value.splice(n,1),F(e),g(),delete h.value[e])}}function ge(e){Qr(h.value).forEach(t=>{t.startsWith(e)&&delete h.value[t]}),p.value=p.value.filter(t=>!t.path.startsWith(e)),v(()=>{g()})}let _e={name:i,formId:n,values:f,controlledValues:A,errorBag:b,errors:x,schema:j,submitCount:u,meta:k,isSubmitting:s,isValidating:l,fieldArrays:d,keepValuesOnUnmount:ee,validateSchema:w(j)?ae:void 0,validate:De,setFieldError:_,validateField:Oe,setFieldValue:M,setValues:ye,setErrors:y,setFieldTouched:xe,setTouched:we,resetForm:Ee,resetField:Te,handleSubmit:me,useFieldModel:Ne,defineInputBinds:Fe,defineComponentBinds:Ie,defineField:I,stageInitialValue:ke,unsetInitialValue:F,setFieldInitialValue:Ae,createPathState:ne,getPathState:se,unsetPathValue:fe,removePathState:he,initialValues:E,getAllPathStates:()=>p.value,destroyPath:ge,isFieldTouched:Se,isFieldDirty:Ce,isFieldValid:P};function M(e,t,n=!0){let r=wr(t),i=typeof e==`string`?e:e.path;se(i)||ne(i),Yr(f,i,r),n&&Oe(i)}function ve(e,t=!0){Qr(f).forEach(e=>{delete f[e]}),Qr(e).forEach(t=>{M(t,e[t],!1)}),t&&De()}function ye(e,t=!0){yr(f,e),d.forEach(e=>e&&e.reset()),t&&De()}function be(e,t){let n=se(N(e))||ne(e);return r({get(){return n.value},set(n){M(N(e),n,N(t)??!1)}})}function xe(e,t){let n=se(e);n&&(n.touched=t)}function Se(e){let t=se(e);return t?t.touched:p.value.filter(t=>t.path.startsWith(e)).some(e=>e.touched)}function Ce(e){let t=se(e);return t?t.dirty:p.value.filter(t=>t.path.startsWith(e)).some(e=>e.dirty)}function P(e){let t=se(e);return t?t.valid:p.value.filter(t=>t.path.startsWith(e)).every(e=>e.valid)}function we(e){if(typeof e==`boolean`){oe(t=>{t.touched=e});return}Qr(e).forEach(t=>{xe(t,!!e[t])})}function Te(e,t){let n=t&&`value`in t?t.value:Jr(E.value,e),r=se(e);r&&(r.__flags.pendingReset=!0),Ae(e,wr(n),!0),M(e,n,!1),xe(e,t?.touched??!1),_(e,t?.errors||[]),v(()=>{r&&(r.__flags.pendingReset=!1)})}function Ee(e,t){let n=wr(e?.values?e.values:D.value);n=t?.force?n:yr(D.value,n),n=jr(j)&&dr(j.cast)?j.cast(n):n,O(n,{force:t?.force}),oe(t=>{t.__flags.pendingReset=!0,t.validated=!1,t.touched=e?.touched?.[N(t.path)]||!1,M(N(t.path),Jr(n,N(t.path)),!1),_(N(t.path),void 0)}),t?.force?ve(n,!1):ye(n,!1),y(e?.errors||{}),u.value=e?.submitCount||0,v(()=>{De({mode:`silent`}),oe(e=>{e.__flags.pendingReset=!1})})}async function De(e){let t=e?.mode||`force`;if(t===`force`&&oe(e=>e.validated=!0),_e.validateSchema)return _e.validateSchema(t);l.value=!0;let n=await Promise.all(p.value.map(t=>t.validate?t.validate(e).then(e=>({key:N(t.path),valid:e.valid,errors:e.errors,value:e.value})):Promise.resolve({key:N(t.path),valid:!0,errors:[],value:void 0})));l.value=!1;let r={},i={},a={};for(let e of n)r[e.key]={valid:e.valid,errors:e.errors},e.value&&Yr(a,e.key,e.value),e.errors.length&&(i[e.key]=e.errors[0]);return{valid:n.every(e=>e.valid),results:r,errors:i,values:a,source:`fields`}}async function Oe(e,t){let n=se(e);if(n&&t?.mode!==`silent`&&(n.validated=!0),j){let{results:n}=await ae(t?.mode||`validated-only`);return n[e]||{errors:[],valid:!0}}return n?.validate?n.validate(t):(!n&&t?.warn,Promise.resolve({errors:[],valid:!0}))}function F(e){Zr(E.value,e)}function ke(t,n,r=!1){Ae(t,n),Yr(f,t,n),r&&!e?.initialValues&&Yr(D.value,t,wr(n))}function Ae(e,t,n=!1){Yr(E.value,e,wr(t)),n&&Yr(D.value,e,wr(t))}async function je(){let e=w(j);if(!e)return{valid:!0,results:{},errors:{},source:`none`};l.value=!0;let t=Mr(e)||jr(e)?await ki(e,f):await Ai(e,f,{names:S.value,bailsMap:C.value});return l.value=!1,t}let Me=me((e,{evt:t})=>{Vr(t)&&t.target.submit()});ce(()=>{if(e?.initialErrors&&y(e.initialErrors),e?.initialTouched&&we(e.initialTouched),e?.validateOnMount){De();return}_e.validateSchema&&_e.validateSchema(`silent`)}),ze(j)&&Pe(j,()=>{var e;(e=_e.validateSchema)==null||e.call(_e,`validated-only`)}),t(Tr,_e);function I(e,t){let n=dr(t)?void 0:t?.label,i=se(N(e))||ne(e,{label:n}),a=()=>dr(t)?t(oi(i,Yi)):t||{};function o(){i.touched=!0,(a().validateOnBlur??bi().validateOnBlur)&&Oe(N(i.path))}function s(){(a().validateOnInput??bi().validateOnInput)&&v(()=>{Oe(N(i.path))})}function c(){(a().validateOnChange??bi().validateOnChange)&&v(()=>{Oe(N(i.path))})}let l=r(()=>{let e={onChange:c,onInput:s,onBlur:o};return dr(t)?Object.assign(Object.assign({},e),t(oi(i,Yi)).props||{}):t?.props?Object.assign(Object.assign({},e),t.props(oi(i,Yi))):e});return[be(e,()=>a().validateOnModelUpdate??bi()?.validateOnModelUpdate??!0),l]}function Ne(e){return Array.isArray(e)?e.map(e=>be(e,!0)):be(e)}function Fe(e,t){let[n,i]=I(e,t);function a(){i.value.onBlur()}function o(t){let n=fi(t);M(N(e),n,!1),i.value.onInput()}function s(t){let n=fi(t);M(N(e),n,!1),i.value.onChange()}return r(()=>Object.assign(Object.assign({},i.value),{onBlur:a,onInput:o,onChange:s,value:n.value}))}function Ie(e,t){let[n,i]=I(e,t),a=se(N(e));function o(e){n.value=e}return r(()=>{let e=dr(t)?t(oi(a,Yi)):t||{};return Object.assign({[e.model||`modelValue`]:n.value,[`onUpdate:${e.model||`modelValue`}`]:o},i.value)})}let Le=Object.assign(Object.assign({},_e),{values:o(f),handleReset:()=>Ee(),submitForm:Me});return t(Er,Le),Le}function Qi(e,t,n,i){let a={touched:`some`,pending:`some`,valid:`every`},o=r(()=>!Wr(t,w(n)));function s(){let t=e.value;return Qr(a).reduce((e,n)=>(e[n]=t[a[n]](e=>e[n]),e),{})}let c=te(s());return M(()=>{let e=s();c.touched=e.touched,c.valid=e.valid,c.pending=e.pending}),r(()=>Object.assign(Object.assign({initialValues:w(n)},c),{valid:c.valid&&!Qr(i.value).length,dirty:o.value}))}function $i(e,t,n){let r=Xi(n),i=L(r),a=L(wr(r));function o(n,r){r?.force?(i.value=wr(n),a.value=wr(n)):(i.value=yr(wr(i.value)||{},wr(n)),a.value=yr(wr(a.value)||{},wr(n))),r?.updateFields&&e.value.forEach(e=>{if(e.touched)return;let n=Jr(i.value,N(e.path));Yr(t,N(e.path),wr(n))})}return{initialValues:i,originalInitialValues:a,setInitialValues:o}}function ea(e,t){return t?{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}:e}A({name:`Form`,inheritAttrs:!1,props:{as:{type:null,default:`form`},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1},name:{type:String,default:`Form`}},setup(e,t){let n=we(e,`validationSchema`),r=we(e,`keepValues`),{errors:i,errorBag:a,values:o,meta:s,isSubmitting:c,isValidating:l,submitCount:u,controlledValues:d,validate:f,validateField:p,handleReset:m,resetForm:h,handleSubmit:g,setErrors:_,setFieldError:v,setFieldValue:y,setValues:b,setFieldTouched:x,setTouched:S,resetField:C}=Zi({validationSchema:n.value?n:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:r,name:e.name}),w=g((e,{evt:t})=>{Vr(t)&&t.target.submit()},e.onInvalidSubmit),T=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function ee(e){Hr(e)&&e.preventDefault(),m(),typeof t.attrs.onReset==`function`&&t.attrs.onReset()}function E(t,n){return g(typeof t==`function`&&!n?t:n,e.onInvalidSubmit)(t)}function D(){return wr(o)}function O(){return wr(s.value)}function k(){return wr(i.value)}function A(){return{meta:s.value,errors:i.value,errorBag:a.value,values:o,isSubmitting:c.value,isValidating:l.value,submitCount:u.value,controlledValues:d.value,validate:f,validateField:p,handleSubmit:E,handleReset:m,submitForm:w,setErrors:_,setFieldError:v,setFieldValue:y,setValues:b,setFieldTouched:x,setTouched:S,resetForm:h,resetField:C,getValues:D,getMeta:O,getErrors:k}}return t.expose({setFieldError:v,setErrors:_,setFieldValue:y,setValues:b,setFieldTouched:x,setTouched:S,resetForm:h,validate:f,validateField:p,resetField:C,getValues:D,getMeta:O,getErrors:k,values:o,meta:s,errors:i}),function(){let n=e.as===`form`?e.as:e.as?je(e.as):null,r=ci(n,t,A);return n?ie(n,Object.assign(Object.assign(Object.assign({},n===`form`?{novalidate:!0}:{}),t.attrs),{onSubmit:T,onReset:ee}),r):r}}});function ta(e){let t=$r(Tr,void 0),n=L([]),r=()=>{},i={fields:n,remove:r,push:r,swap:r,insert:r,update:r,replace:r,prepend:r,move:r};if(!t||!w(e))return i;let a=t.fieldArrays.find(t=>w(t.path)===w(e));if(a)return a;let o=0;function s(){return Jr(t?.values,N(e),[])||[]}function c(){let e=s();Array.isArray(e)&&(n.value=e.map((e,t)=>u(e,t,n.value)),l())}c();function l(){let e=n.value.length;for(let t=0;t<e;t++){let r=n.value[t];r.isFirst=t===0,r.isLast=t===e-1}}function u(r,i,a){if(a&&!fr(i)&&a[i])return a[i];let s=o++;return{key:s,value:ii({get(){let i=Jr(t?.values,N(e),[])||[],a=n.value.findIndex(e=>e.key===s);return a===-1?r:i[a]},set(e){let t=n.value.findIndex(e=>e.key===s);t!==-1&&v(t,e)}}),isFirst:!1,isLast:!1}}function d(){l(),t?.validate({mode:`silent`})}function f(r){let i=N(e),a=Jr(t?.values,i);if(!a||!Array.isArray(a))return;let o=[...a];o.splice(r,1);let s=i+`[${r}]`;t.destroyPath(s),t.unsetInitialValue(s),Yr(t.values,i,o),n.value.splice(r,1),d()}function p(r){let i=wr(r),a=N(e),o=Jr(t?.values,a),s=fr(o)?[]:o;if(!Array.isArray(s))return;let c=[...s];c.push(i),t.stageInitialValue(a+`[${c.length-1}]`,i),Yr(t.values,a,c),n.value.push(u(i)),d()}function m(r,i){let a=N(e),o=Jr(t?.values,a);if(!Array.isArray(o)||!(r in o)||!(i in o))return;let s=[...o],c=[...n.value],u=s[r];s[r]=s[i],s[i]=u;let d=c[r];c[r]=c[i],c[i]=d,Yr(t.values,a,s),n.value=c,l()}function h(r,i){let a=wr(i),o=N(e),s=Jr(t?.values,o);if(!Array.isArray(s)||s.length<r)return;let c=[...s],l=[...n.value];c.splice(r,0,a),l.splice(r,0,u(a)),Yr(t.values,o,c),n.value=l,d()}function g(n){let r=N(e);t.stageInitialValue(r,n),Yr(t.values,r,n),c(),d()}function v(n,r){let i=N(e),a=Jr(t?.values,i);!Array.isArray(a)||a.length-1<n||(Yr(t.values,`${i}[${n}]`,r),t?.validate({mode:`validated-only`}))}function y(r){let i=wr(r),a=N(e),o=Jr(t?.values,a),s=fr(o)?[]:o;if(!Array.isArray(s))return;let c=[i,...s];Yr(t.values,a,c),t.stageInitialValue(a+`[0]`,i),n.value.unshift(u(i)),d()}function b(r,i){let a=N(e),o=Jr(t?.values,a),s=fr(o)?[]:[...o];if(!Array.isArray(o)||!(r in o)||!(i in o))return;let c=[...n.value],l=c[r];c.splice(r,1),c.splice(i,0,l);let u=s[r];s.splice(r,1),s.splice(i,0,u),Yr(t.values,a,s),n.value=c,d()}let x={fields:n,remove:f,push:p,swap:m,insert:h,update:v,replace:g,prepend:y,move:b};return t.fieldArrays.push(Object.assign({path:e,reset:c},x)),_(()=>{let n=t.fieldArrays.findIndex(t=>N(t.path)===N(e));n>=0&&t.fieldArrays.splice(n,1)}),Pe(s,e=>{Wr(e,n.value.map(e=>e.value))||c()}),x}A({name:`FieldArray`,inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){let{push:n,remove:r,swap:i,insert:a,replace:o,update:s,prepend:c,move:l,fields:u}=ta(()=>e.name);function d(){return{fields:u.value,push:n,remove:r,swap:i,insert:a,update:s,replace:o,prepend:c,move:l}}return t.expose({push:n,remove:r,swap:i,insert:a,update:s,replace:o,prepend:c,move:l}),()=>ci(void 0,t,d)}}),A({name:`ErrorMessage`,props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,t){let n=p(Tr,void 0),i=r(()=>n?.errors.value[e.name]);function a(){return{message:i.value}}return()=>{if(!i.value)return;let n=e.as?je(e.as):e.as,r=ci(n,t,a),o=Object.assign({role:`alert`},t.attrs);return!n&&(Array.isArray(r)||!r)&&r?.length?r:(Array.isArray(r)||!r)&&!r?.length?ie(n||`span`,o,i.value):ie(n,o,r)}}});function na(){let e=$r(Tr);return r(()=>e?.values||{})}var ra={key:0,class:`bg-gray-900/10 pb-3`},ia={class:`font-medium bg-white p-2 flex items-center`},aa={class:`mx-4`},oa={class:`flex-1 text-sm font-medium`},sa={class:`border border-gray-300 m-2 rounded-lg overflow-hidden`},ca={key:0},la=[`onClick`],ua={class:`px-3`},da={key:1,class:`border-l-2 border-white pl-1`},fa={class:`py-2 font-medium bg-white mb-2`},pa={class:`absolute top-2 right-2 z-10`},ma={class:`font-semibold text-sm text-gray-500 mb-2`},ha=A({__name:`List`,props:{field:{},fields:{},base:{},options:{}},setup(e){let t=e,n=ke(),r=fe(),{fields:i,push:a,remove:o}=ta(t.base||t.field.name);function s(e){let i=[typeof r.params.file==`string`?r.params.file:r.params.file[0],...t.base?t.base.split(`.`):[t.field.name],e.toString()];n.push({params:{file:i}})}function c(){t.fields&&t.fields.length>0?a({}):a(``)}return(t,n)=>{let r=_t,a=ur,d=Zt,f=St,p=GL;return O(),D(`div`,null,[e.options?.notNested?(O(),D(`div`,da,[P(`div`,fa,k(e.field.label),1),(O(!0),D(l,null,ve(w(i),(t,n)=>(O(),D(`div`,{key:t.key,class:`mb-4 relative border border-gray-200 p-2 bg-gray-50 rounded`},[P(`div`,pa,[x(r,{name:`i-mdi-trash-can-outline`,class:`size-5 text-red-500 cursor-pointer hover:text-red-700`,onClick:e=>w(o)(n)},null,8,[`onClick`])]),P(`div`,ma,` Item `+k(n+1),1),x(p,{fields:e.fields,base:e.base?`${e.base}.${n}`:`${e.field.name}.${n}`},null,8,[`fields`,`base`])]))),128))])):(O(),D(`div`,ra,[P(`div`,ia,[P(`div`,aa,[x(r,{name:`i-lucide-list`,class:`size-5`})]),P(`div`,oa,k(e.field.label),1)]),P(`div`,sa,[w(i).length===0?(O(),D(`div`,ca,[x(a,{icon:`i-lucide-list`,title:`Lista vacia`,class:`rounded-none`,description:`No hay elementos en la lista. Agrega uno para empezar.`})])):T(``,!0),(O(!0),D(l,null,ve(w(i),(t,n)=>(O(),D(`div`,{key:t.key,class:u([{"border-t border-gray-300":!!n},`flex items-center bg-white hover:bg-gray-50`])},[P(`div`,{class:`flex-1 p-3 cursor-pointer text-sm`,onClick:e=>s(n)},k(t.value?.[e.field?.fields?.[0].name]),9,la),P(`div`,ua,[x(r,{name:`i-mdi-trash-can-outline`,class:`size-5 text-red-500 cursor-pointer hover:text-red-700`,onClick:e=>w(o)(n)},null,8,[`onClick`])])],2))),128)),x(d),x(f,{block:``,variant:`ghost`,class:`bg-white`,square:``,icon:`mdi-add`,size:`lg`,onClick:re(c,[`prevent`])},{default:F(()=>[...n[0]||=[g(` Agregar `,-1)]]),_:1})])]))])}}}),ga={class:`mr-3`},_a={class:`flex-1 text-sm font-medium`},va={key:1,class:`overflow-hidden border-y border-gray-300 bg-gray-900/10`},ya={class:`font-medium bg-white p-2 flex items-center mb-2`},ba={class:`mx-4`},xa={class:`flex-1 text-sm font-medium`},Sa=A({__name:`Object`,props:{field:{},fields:{},base:{}},setup(e){let t=ke(),n=fe();function r(){let r=[typeof n.params.file==`string`?n.params.file:n.params.file[0],...e.base?e.base.split(`.`):[e.field.name]];t.push({params:{file:r}})}return(t,n)=>{let i=_t,a=GL;return O(),D(`div`,null,[e.field.collapsed?(O(),D(`div`,{key:0,class:`px-4 py-3 bg-white border border-gray-300 mx-2 flex items-center cursor-pointer hover:bg-gray-50 rounded-lg`,onClick:n[0]||=e=>r()},[P(`div`,ga,[x(i,{name:`i-uim-object-group`,class:`size-5`})]),P(`div`,_a,k(e.field.label),1),P(`div`,null,[x(i,{name:`i-mdi-chevron-right`,class:`size-5`})])])):(O(),D(`div`,va,[P(`div`,ya,[P(`div`,ba,[x(i,{name:`i-uim-object-group`,class:`size-5`})]),P(`div`,xa,k(e.field.label),1)]),x(a,{fields:e.fields,base:e.base},null,8,[`fields`,`base`])]))])}}}),Ca={class:`mx-2 bg-white px-4 pb-4 pt-3 rounded-lg`},wa={class:`flex items-center gap-2 mb-2`},Ta={class:`font-medium text-sm text-gray-900 pl-1`},Ea=A({__name:`FieldBox`,props:{label:{},icon:{}},setup(e){return(t,n)=>{let r=_t;return O(),D(`div`,Ca,[P(`div`,wa,[x(r,{name:e.icon,size:`24`},null,8,[`name`]),P(`span`,Ta,k(e.label),1)]),I(t.$slots,`default`)])}}}),Da=A({__name:`Relation`,props:{field:{},name:{}},setup(e){let t=nn();function n(){return e.name.includes(`.`)&&e.field.options?.alias?`${e.name.split(`.`).slice(0,-1).join(`.`)}.${e.field.options?.alias}`:e.field.options?.alias||e.name}let{value:i}=Li(n()),a=r(()=>t.dataCollections||{}),o=r(()=>{let n=t.lang;if(!a.value||!a.value[n])return[];let r=e.field.collection;if(!r)return[];if(r===`sitemap`)return a.value[n].sitemap||[];let[i,o]=r.split(`.`);if(i&&o)return a.value[n][i]?.[o]||[];if(i){let e=a.value[n][i];return e?Object.values(e).flat():[]}return[]});return(t,n)=>{let r=Qt,a=Ea;return O(),S(a,{label:e.field.label,icon:`i-lucide-link`},{default:F(()=>[x(r,{modelValue:w(i),"onUpdate:modelValue":n[0]||=e=>ze(i)?i.value=e:null,items:o.value,multiple:e.field.multiple,"value-key":`value`,searchable:``,class:`w-full`},{empty:F(()=>[...n[1]||=[g(` No hay opciones disponibles `,-1)]]),_:1},8,[`modelValue`,`items`,`multiple`])]),_:1},8,[`label`])}}}),Oa={slots:{content:`bg-default shadow-lg rounded-md ring ring-default data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-popover-content-transform-origin) focus:outline-none pointer-events-auto`,arrow:`fill-bg stroke-default`}},ka={__name:`Popover`,props:{mode:{type:null,required:!1,default:`click`},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},reference:{type:null,required:!1},dismissible:{type:Boolean,required:!1,default:!0},class:{type:null,required:!1},ui:{type:null,required:!1},defaultOpen:{type:Boolean,required:!1},open:{type:Boolean,required:!1},modal:{type:Boolean,required:!1},openDelay:{type:Number,required:!1,default:0},closeDelay:{type:Number,required:!1,default:0}},emits:[`close:prevent`,`update:open`],setup(e,{emit:t}){let n=e,i=t,o=ge(),c=lt(`popover`,n),l=Ce(),f=ht(c.mode===`hover`?Fe(c,`defaultOpen`,`open`,`openDelay`,`closeDelay`):Fe(c,`defaultOpen`,`open`,`modal`),i),p=Mt(we(()=>c.portal)),m=we(()=>s(c.content,{side:`bottom`,sideOffset:8,collisionPadding:8})),g=r(()=>c.dismissible?{pointerDownOutside:Kt}:[`interactOutside`,`escapeKeyDown`].reduce((e,t)=>(e[t]=e=>{e.preventDefault(),i(`close:prevent`)},e),{})),_=we(()=>s(c.arrow,{rounded:!0})),v=r(()=>Tt({extend:Tt(Oa),...l.ui?.popover||{}})({side:m.value.side})),y=r(()=>c.mode===`hover`?Rt:Ht);return(e,t)=>(O(),S(w(y).Root,h(a(w(f))),{default:F(({open:t,close:n})=>[o.default?(O(),S(w(y).Trigger,{key:0,"as-child":``,class:u(w(c).class)},{default:F(()=>[I(e.$slots,`default`,{open:t})]),_:2},1032,[`class`])):T(``,!0),`Anchor`in y.value&&o.anchor?(O(),S(w(y).Anchor,{key:1,"as-child":``},{default:F(()=>[I(e.$slots,`anchor`,h(a(n?{close:n}:{})))]),_:2},1024)):T(``,!0),x(w(y).Portal,h(a(w(p))),{default:F(()=>[x(w(bt),null,{default:F(()=>[x(w(y).Content,d(m.value,{reference:w(c).reference??w(c).content?.reference,"data-slot":`content`,class:v.value.content({class:[!o.default&&w(c).class,w(c).ui?.content]})},Se(g.value)),{default:F(()=>[I(e.$slots,`content`,h(a(n?{close:n}:{}))),w(c).arrow?(O(),S(w(y).Arrow,d({key:0},_.value,{"data-slot":`arrow`,class:v.value.arrow({class:w(c).ui?.arrow})}),null,16,[`class`])):T(``,!0)]),_:2},1040,[`reference`,`class`])]),_:2},1024)]),_:2},1040)]),_:3},16))}},z=255,Aa=100,ja=125,Ma=150,B,Na,Pa,Fa;(function(e){e.HEX=`HEX`,e.RGB=`RGB`,e.HWB=`HWB`,e.HSL=`HSL`,e.CIELab=`CIELab`,e.LCH=`LCH`,e.CMYK=`CMYK`})(B||={}),function(e){e.ANALOGOUS=`ANALOGOUS`,e.COMPLEMENTARY=`COMPLEMENTARY`,e.SPLIT_COMPLEMENTARY=`SPLIT_COMPLEMENTARY`,e.TRIADIC=`TRIADIC`,e.TETRADIC=`TETRADIC`,e.SQUARE=`SQUARE`}(Na||={}),function(e){e.ADDITIVE=`ADDITIVE`,e.SUBTRACTIVE=`SUBTRACTIVE`}(Pa||={}),function(e){e.black=`#000000`,e.silver=`#C0C0C0`,e.gray=`#808080`,e.white=`#FFFFFF`,e.maroon=`#800000`,e.red=`#FF0000`,e.purple=`#800080`,e.fuchsia=`#FF00FF`,e.green=`#008000`,e.lime=`#00FF00`,e.olive=`#808000`,e.yellow=`#FFFF00`,e.navy=`#000080`,e.blue=`#0000FF`,e.teal=`#008080`,e.aqua=`#00FFFF`,e.orange=`#FFA500`,e.aliceblue=`#F0F8FF`,e.antiquewhite=`#FAEBD7`,e.aquamarine=`#7FFFD4`,e.azure=`#F0FFFF`,e.beige=`#F5F5DC`,e.bisque=`#FFE4C4`,e.blanchedalmond=`#FFEBCD`,e.blueviolet=`#8A2BE2`,e.brown=`#A52A2A`,e.burlywood=`#DEB887`,e.cadetblue=`#5F9EA0`,e.chartreuse=`#7FFF00`,e.chocolate=`#D2691E`,e.coral=`#FF7F50`,e.cornflowerblue=`#6495ED`,e.cornsilk=`#FFF8DC`,e.crimson=`#DC143C`,e.cyan=`#00FFFF`,e.darkblue=`#00008B`,e.darkcyan=`#008B8B`,e.darkgoldenrod=`#B8860B`,e.darkgray=`#A9A9A9`,e.darkgreen=`#006400`,e.darkgrey=`#A9A9A9`,e.darkkhaki=`#BDB76B`,e.darkmagenta=`#8B008B`,e.darkolivegreen=`#556B2F`,e.darkorange=`#FF8C00`,e.darkorchid=`#9932CC`,e.darkred=`#8B0000`,e.darksalmon=`#E9967A`,e.darkseagreen=`#8FBC8F`,e.darkslateblue=`#483D8B`,e.darkslategray=`#2F4F4F`,e.darkslategrey=`#2F4F4F`,e.darkturquoise=`#00CED1`,e.darkviolet=`#9400D3`,e.deeppink=`#FF1493`,e.deepskyblue=`#00BFFF`,e.dimgray=`#696969`,e.dimgrey=`#696969`,e.dodgerblue=`#1E90FF`,e.firebrick=`#B22222`,e.floralwhite=`#FFFAF0`,e.forestgreen=`#228B22`,e.gainsboro=`#DCDCDC`,e.ghostwhite=`#F8F8FF`,e.gold=`#FFD700`,e.goldenrod=`#DAA520`,e.greenyellow=`#ADFF2F`,e.grey=`#808080`,e.honeydew=`#F0FFF0`,e.hotpink=`#FF69B4`,e.indianred=`#CD5C5C`,e.indigo=`#4B0082`,e.ivory=`#FFFFF0`,e.khaki=`#F0E68C`,e.lavender=`#E6E6FA`,e.lavenderblush=`#FFF0F5`,e.lawngreen=`#7CFC00`,e.lemonchiffon=`#FFFACD`,e.lightblue=`#ADD8E6`,e.lightcoral=`#F08080`,e.lightcyan=`#E0FFFF`,e.lightgoldenrodyellow=`#FAFAD2`,e.lightgray=`#D3D3D3`,e.lightgreen=`#90EE90`,e.lightgrey=`#D3D3D3`,e.lightpink=`#FFB6C1`,e.lightsalmon=`#FFA07A`,e.lightseagreen=`#20B2AA`,e.lightskyblue=`#87CEFA`,e.lightslategray=`#778899`,e.lightslategrey=`#778899`,e.lightsteelblue=`#B0C4DE`,e.lightyellow=`#FFFFE0`,e.limegreen=`#32CD32`,e.linen=`#FAF0E6`,e.magenta=`#FF00FF`,e.mediumaquamarine=`#66CDAA`,e.mediumblue=`#0000CD`,e.mediumorchid=`#BA55D3`,e.mediumpurple=`#9370DB`,e.mediumseagreen=`#3CB371`,e.mediumslateblue=`#7B68EE`,e.mediumspringgreen=`#00FA9A`,e.mediumturquoise=`#48D1CC`,e.mediumvioletred=`#C71585`,e.midnightblue=`#191970`,e.mintcream=`#F5FFFA`,e.mistyrose=`#FFE4E1`,e.moccasin=`#FFE4B5`,e.navajowhite=`#FFDEAD`,e.oldlace=`#FDF5E6`,e.olivedrab=`#6B8E23`,e.orangered=`#FF4500`,e.orchid=`#DA70D6`,e.palegoldenrod=`#EEE8AA`,e.palegreen=`#98FB98`,e.paleturquoise=`#AFEEEE`,e.palevioletred=`#DB7093`,e.papayawhip=`#FFEFD5`,e.peachpuff=`#FFDAB9`,e.peru=`#CD853F`,e.pink=`#FFC0CB`,e.plum=`#DDA0DD`,e.powderblue=`#B0E0E6`,e.rosybrown=`#BC8F8F`,e.royalblue=`#4169E1`,e.saddlebrown=`#8B4513`,e.salmon=`#FA8072`,e.sandybrown=`#F4A460`,e.seagreen=`#2E8B57`,e.seashell=`#FFF5EE`,e.sienna=`#A0522D`,e.skyblue=`#87CEEB`,e.slateblue=`#6A5ACD`,e.slategray=`#708090`,e.slategrey=`#708090`,e.snow=`#FFFAFA`,e.springgreen=`#00FF7F`,e.steelblue=`#4682B4`,e.tan=`#D2B48C`,e.thistle=`#D8BFD8`,e.tomato=`#FF6347`,e.turquoise=`#40E0D0`,e.violet=`#EE82EE`,e.wheat=`#F5DEB3`,e.whitesmoke=`#F5F5F5`,e.yellowgreen=`#9ACD32`,e.rebeccapurple=`#663399`}(Fa||={});var Ia=Object.keys(Fa),La={HEX:[`R`,`G`,`B`,`A`],RGB:[`R`,`G`,`B`,`A`],HSL:[`H`,`S`,`L`,`A`],HWB:[`H`,`W`,`B`,`A`],CIELab:[`L`,`a`,`b`,`A`],LCH:[`L`,`C`,`H`,`A`],CMYK:[`C`,`M`,`Y`,`K`,`A`]},Ra={ABGR:B.RGB,ABHW:B.HWB,ACHL:B.LCH,ACKMY:B.CMYK,AHLS:B.HSL,ALAB:B.CIELab,BGR:B.RGB,BHW:B.HWB,CHL:B.LCH,CKMY:B.CMYK,HLS:B.HSL,LAB:B.CIELab},za;(function(e){e.NUMBER=`number`,e.BOOLEAN=`boolean`})(za||={});var Ba={[B.HEX]:/^#(?:(?<r>[a-f\d])(?<g>[a-f\d])(?<b>[a-f\d])(?<a>[a-f\d])?|(?<rr>[a-f\d]{2})(?<gg>[a-f\d]{2})(?<bb>[a-f\d]{2})(?<aa>[a-f\d]{2})?)$/i,[B.RGB]:/^rgba?\s*\(\s*(?:(?<r_legacy>(?:\d*\.)?\d+%?)\s*,\s*(?<g_legacy>(?:\d*\.)?\d+%?)\s*,\s*(?<b_legacy>(?:\d*\.)?\d+%?)(?:\s*,\s*(?<a_legacy>(?:\d*\.)?\d+))?|(?<r>(?:\d*\.)?\d+%?)\s+(?<g>(?:\d*\.)?\d+%?)\s+(?<b>(?:\d*\.)?\d+%?)(?:\s*\/\s*(?<a>(?:\d*\.)?\d+%?))?|from\s+(?<from>(?:\w+|\w+\(\s*[^())]+\s*\)|\w+\(from\s+\w+\(.*\)\s*\)|#[a-fA-F\d]+))\s+(?<relative_r>(?:[rgb]|(?:\d*\.)?\d+|calc\([rgb()/*\-+\d.\s]+\)))\s+(?<relative_g>(?:[rgb]|(?:\d*\.)?\d+|calc\([rgb()/*\-+\d.\s]+\)))\s+(?<relative_b>(?:[rgb]|(?:\d*\.)?\d+|calc\([rgb()/*\-+\d.\s]+\)))(?:\s*\/\s*(?<relative_a>(?:(?:\d*\.)?\d+%?|calc\([()/*\-+\d.\s\w]*(?:alpha)?[()/*\-+\d.\s\w]*\)|alpha)))?)\s*\)$/,[B.HWB]:/^hwb\s*\(\s*(?:(?<h>(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s+(?<w>(?:\d*\.)?\d+)%\s+(?<b>(?:\d*\.)?\d+)%(?:\s*\/\s*(?<a>(?:\d*\.)?\d+%?))?|from\s+(?<from>(?:\w+|\w+\(\s*[^())]+\s*\)|\w+\(from\s+\w+\(.*\)\s*\)|#[a-fA-F\d]+))\s+(?<relative_h>(?:[hwb]|(?:\d*\.)?\d+|calc\([hwb()/*\-+\d.\s]+\)))\s+(?<relative_w>(?:[hwb]|(?:\d*\.)?\d+|calc\([hwb()/*\-+\d.\s]+\)))%?\s+(?<relative_b>(?:[hwb]|(?:\d*\.)?\d+|calc\([hwb()/*\-+\d.\s]+\)))%?(?:\s*\/\s*(?<relative_a>(?:(?:\d*\.)?\d+%?|calc\([()/*\-+\d.\s\w]*(?:alpha)?[()/*\-+\d.\s\w]*\)|alpha)))?)\s*\)$/,[B.HSL]:/^hsla?\s*\(\s*(?:(?<h_legacy>-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s*,\s*(?<s_legacy>(?:\d*\.)?\d+)%\s*,\s*(?<l_legacy>(?:\d*\.)?\d+)%(?:\s*,\s*(?<a_legacy>(?:\d*\.)?\d+))?|(?<h>-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s+(?<s>(?:\d*\.)?\d+)%?\s+(?<l>(?:\d*\.)?\d+)%?(?:\s*\/\s*(?<a>(?:\d*\.)?\d+%?))?|from\s+(?<from>(?:\w+|\w+\(\s*[^())]+\s*\)|\w+\(from\s+\w+\(.*\)\s*\)|#[a-fA-F\d]+))\s+(?<relative_h>(?:[hsl]|(?:\d*\.)?\d+|calc\([hsl()/*\-+\d.\s]+\)))\s+(?<relative_s>(?:[hsl]|(?:\d*\.)?\d+|calc\([hsl()/*\-+\d.\s]+\)))%?\s+(?<relative_l>(?:[hsl]|(?:\d*\.)?\d+|calc\([hsl()/*\-+\d.\s]+\)))%?(?:\s*\/\s*(?<relative_a>(?:(?:\d*\.)?\d+%?|calc\([()/*\-+\d.\s\w]*(?:alpha)?[()/*\-+\d.\s\w]*\)|alpha)))?)\s*\)$/,[B.CIELab]:/^lab\s*\(\s*(?:(?<L>(?:\d*\.)?\d+%?)\s+(?<a>-?(?:\d*\.)?\d+%?)\s+(?<b>-?(?:\d*\.)?\d+%?)(?:\s*\/\s*(?<A>(?:\d*\.)?\d+%?))?|from\s+(?<from>(?:\w+|\w+\(\s*[^())]+\s*\)|\w+\(from\s+\w+\(.*\)\s*\)|#[a-fA-F\d]+))\s+(?<relative_L>(?:[lab]|(?:\d*\.)?\d+|calc\([lab()/*\-+\d.\s]+\)))\s+(?<relative_a>(?:[lab]|(?:\d*\.)?\d+|calc\([lab()/*\-+\d.\s]+\)))\s+(?<relative_b>(?:[lab]|(?:\d*\.)?\d+|calc\([lab()/*\-+\d.\s]+\)))(?:\s*\/\s*(?<relative_A>(?:(?:\d*\.)?\d+%?|calc\([()/*\-+\d.\s\w]*(?:alpha)?[()/*\-+\d.\s\w]*\)|alpha)))?)\s*\)$/,[B.LCH]:/^lch\s*\(\s*(?:(?<l>(?:\d*\.)?\d+%?)\s+(?<c>-?(?:\d*\.)?\d+%?)\s+(?<h>-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)(?:\s*\/\s*(?<a>(?:\d*\.)?\d+%?))?|from\s+(?<from>(?:\w+|\w+\(\s*[^())]+\s*\)|\w+\(from\s+\w+\(.*\)\s*\)|#[a-fA-F\d]+))\s+(?<relative_l>(?:[lch]|(?:\d*\.)?\d+|calc\([lch()/*\-+\d.\s]+\)))\s+(?<relative_c>(?:[lch]|(?:\d*\.)?\d+|calc\([lch()/*\-+\d.\s]+\)))\s+(?<relative_h>(?:[lch]|(?:\d*\.)?\d+|calc\([lch()/*\-+\d.\s]+\)))(?:\s*\/\s*(?<relative_a>(?:(?:\d*\.)?\d+%?|calc\([()/*\-+\d.\s\w]*(?:alpha)?[()/*\-+\d.\s\w]*\)|alpha)))?)\s*\)$/,[B.CMYK]:/^(?:device-cmyk|cmyk)\s*\(\s*(?:(?<c_legacy>(?:\d*\.)?\d+%?)\s*,\s*(?<m_legacy>(?:\d*\.)?\d+%?)\s*,\s*(?<y_legacy>(?:\d*\.)?\d+%?)\s*,\s*(?<k_legacy>(?:\d*\.)?\d+%?)(?:\s*,\s*(?<a_legacy>(?:\d*\.)?\d+))?|(?<c>(?:\d*\.)?\d+%?)\s+(?<m>(?:\d*\.)?\d+%?)\s+(?<y>(?:\d*\.)?\d+%?)\s+(?<k>(?:\d*\.)?\d+%?)(?:\s*\/\s*(?<a>(?:\d*\.)?\d+%?))?)\s*\)$/},Va={REGEXP:/^calc\(\s*(?<operation>[\d./*+-\w\s]+)\s*\)$/,SCOPED:/\(\s*([^()]+)\s*\)/g,DIVISION:/\s*(?<left>(?:(?:\d*\.)?\d+|\w+))\s*\/\s*(?<right>(?:(?:\d*\.)?\d+|\w+))\s*/,MULTIPLICATION:/\s*(?<left>(?:(?:\d*\.)?\d+|\w+))\s*\*\s*(?<right>(?:(?:\d*\.)?\d+|\w+))\s*/,SUM:/\s*(?<left>(?:(?:\d*\.)?\d+|\w+))\s*\+\s*(?<right>(?:(?:\d*\.)?\d+|\w+))\s*/,REST:/\s*(?<left>(?:(?:\d*\.)?\d+|\w+))\s*-\s*(?<right>(?:(?:\d*\.)?\d+|\w+))\s*/},Ha=/^(?<number>-?(?:\d*\.)?\d+)(?<units>(?:deg|grad|rad|turn)?)$/,Ua=/^(-?\d+(?:\.\d+)?|-?\.\d+)%$/,Wa=/^0x([a-f\d]{1,2})$/i,Ga=/\{(\d+)\}/g,Ka=/,( +|\d+)/g,qa=/ +/,Ja=`The provided string color doesn't have a correct format`,Ya=`The provided color object doesn't have the proper keys or format`,Xa=`is not a valid operation for a relative color`,Za,Qa,$a;(function(e){e.NONE=`none`,e.DEGREES=`deg`,e.GRADIANS=`grad`,e.RADIANS=`rad`,e.TURNS=`turn`})(Za||={}),function(e){e.NONE=`none`,e.PERCENT=`percent`}(Qa||={}),function(e){e.DEVICE_CMYK=`device-cmyk`,e.CMYK=`cmyk`}($a||={});var eo={decimals:6,legacyCSS:!1,spacesAfterCommas:!1,anglesUnit:Za.NONE,rgbUnit:Qa.NONE,labUnit:Qa.NONE,lchUnit:Qa.NONE,cmykUnit:Qa.PERCENT,alphaUnit:Qa.NONE,cmykFunction:$a.DEVICE_CMYK},to=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),no=e=>+`${e}`.replace(Ua,`$1`),ro=e=>Ua.test(`${e}`)?no(e):Math.min(+e,100),io=e=>(e.length===1&&(e+=e),parseInt(e,16)),ao=e=>{let t=V(e,0).toString(16).toUpperCase();return t.length===1?`0x0${t}`:`0x${t}`},oo=(e,t=!1)=>!t&&Ua.test(e)?Math.min(z*no(e)/100,z):Wa.test(e)?(e.length===3&&(e+=e.slice(-1)),t?V(e)/z:V(e)):Math.min(+e,t?1:z),so=e=>Ua.test(e)?H(ja*no(e)/100,-125,ja):H(+e,-125,ja),co=e=>Ua.test(e)?H(Ma*no(e)/100,-150,Ma):H(+e,-150,Ma),lo=e=>Math.min(Ua.test(e)?no(e)/100:+e,1),uo=e=>[...e].sort().join(``).toUpperCase(),V=(e,t=6)=>{let n=10**t;return Math.round(+e*n)/n},H=(e,t,n)=>Math.max(t,Math.min(e,n)),fo=e=>180*e/Math.PI,po=e=>e*Math.PI/180,mo=360,ho=e=>{if(typeof e==`string`){let t=e.match(Ha).groups,n=+t.number;switch(t.units){case Za.RADIANS:e=V(fo(n));break;case Za.TURNS:e=V(n*mo);break;case Za.GRADIANS:e=V(.9*n);break;case Za.DEGREES:default:e=n}}return(e>360||e<0)&&(e-=Math.floor(e/mo)*mo),e},go=e=>(typeof e==`string`&&(e=Ua.test(e)?no(e)/100:+e),isNaN(+e)||e>1?1:V(e)),_o=(e,t)=>{let n;switch(t){case Za.RADIANS:n=V(po(e));break;case Za.TURNS:n=V(e/mo);break;case Za.GRADIANS:n=V(10/9*e);break;case Za.DEGREES:case Za.NONE:default:n=e}return n},vo=e=>`${e}`in Pa,yo=[[.4360747,.3850649,.1430804],[.2225045,.7168786,.0606169],[.0139322,.0971045,.7141733]],bo=[[3.1338561,-1.6168667,-.4906146],[-.9787684,1.9161415,.033454],[.0719453,-.2289914,1.4052427]],xo=yo.map((e=>e.reduce(((e,t)=>e+t),0))),So=(e,t,n)=>(n<0&&(n+=6),n>=6&&(n-=6),V(n<1?((t-e)*n+e)*z:n<3?t*z:n<4?((t-e)*(4-n)+e)*z:e*z)),Co=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,wo=e=>e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055,To=(e,t,n,r)=>{let i=[0,0,0],a=[e,t,n];return r.forEach(((e,t)=>{e.forEach(((e,n)=>{i[t]+=e*a[n]}))})),i},Eo=(e,t,n)=>{t/=100;let r=(n/=100)<=.5?n*(t+1):n+t-n*t,i=2*n-r;return{R:So(i,r,(e/=60)+2),G:So(i,r,e),B:So(i,r,e-2)}},Do=(e,t,n,r=1)=>{e/=z,t/=z,n/=z,r=Math.min(r,1);let i=Math.max(e,t,n),a=Math.min(e,t,n),o=i-a,s=0,c=0,l=(i+a)/2;if(o!==0){switch(i){case e:s=(t-n)/o%6;break;case t:s=(n-e)/o+2;break;case n:s=(e-t)/o+4}s=V(60*s),s<0&&(s+=360),c=o/(1-Math.abs(2*l-1))}return{H:s,S:V(100*c),L:V(100*l),A:r}},Oo=(e,t,n)=>{let r=[e/z,t/z,n/z].map(Co),i=To(r[0],r[1],r[2],yo),a=((e,t,n)=>{let r=e=>e>(6/29)**3?Math.cbrt(e):e/(3*(6/29)**2)+4/29,i=r(e/xo[0]),a=r(t/xo[1]);return[116*a-16,500*(i-a),200*(a-r(n/xo[2]))]})(i[0],i[1],i[2]);return{L:a[0],a:a[1],b:a[2]}},ko=(e,t,n)=>{let r=((e,t,n)=>{let r=e=>e>6/29?e**3:3*(6/29)**2*(e-4/29),i=(e+16)/116,a=t/500,o=n/200;return[xo[0]*r(i+a),xo[1]*r(i),xo[2]*r(i-o)]})(e,t,n),i=To(r[0],r[1],r[2],bo).map(wo);return{R:H(i[0]*z,0,z),G:H(i[1]*z,0,z),B:H(i[2]*z,0,z)}},Ao=(e,t,n)=>({L:e,C:Math.sqrt(t**2+n**2),H:ho(fo(Math.atan2(n,t)))}),jo=(e,t,n)=>{let r=po(n);return{L:e,a:t*Math.cos(r),b:t*Math.sin(r)}},Mo=(e,t,n)=>{let r=Oo(e,t,n);return Ao(r.L,r.a,r.b)},No=(e,t,n)=>{let r=jo(e,t,n);return ko(r.L,r.a,r.b)},Po=(e,t,n,r=1)=>({H:Do(e,t,n,r).H,W:V(Math.min(e,t,n)/z*100),B:V(100*(1-Math.max(e,t,n)/z)),A:r}),Fo=(e,t,n)=>{let r=1-(n/=100)-(t/=100),i=r*(1-Math.abs(e/60%2-1)),a=0,o=0,s=0;return e<60?(a=r,o=i,s=0):e>=60&&e<120?(a=i,o=r,s=0):e>=120&&e<180?(a=0,o=r,s=i):e>=180&&e<240?(a=0,o=i,s=r):e>=240&&e<300?(a=i,o=0,s=r):e>=300&&(a=r,o=0,s=i),a+=t,o+=t,s+=t,{R:H(a*z,0,z),G:H(o*z,0,z),B:H(s*z,0,z)}},Io=(e,t,n,r)=>({R:V(z*(1-e)*(r=1-r)),G:V(z*(1-t)*r),B:V(z*(1-n)*r)}),Lo=(e,t,n)=>{e/=z,t/=z,n/=z;let r=1-Math.max(e,t,n),i=1-r,a=i&&(i-t)/i,o=i&&(i-n)/i;return{C:V(100*(i&&(i-e)/i)),M:V(100*a),Y:V(100*o),K:V(100*r)}},Ro=(e,t)=>{if(e<0&&(e+=360),e>360&&(e-=360),e===360||e===0)return e;let n=[[0,120],[120,180],[180,240],[240,360]],r=[[0,60],[60,120],[120,240],[240,360]],i=t?r:n,a=0,o=0,s=0,c=0;return(t?n:r).find(((t,n)=>e>=t[0]&&e<t[1]&&(a=t[0],o=t[1],s=i[n][0],c=i[n][1],!0))),s+(c-s)/(o-a)*(e-a)},zo=class{get rgb(){return this._rgb}},Bo=class extends zo{constructor(e){super();let t=e.match(Ba.HEX).groups;this._r=t.r??t.rr,this._g=t.g??t.gg,this._b=t.b??t.bb,this._a=t.a??t.aa;let n={R:io(this._r),G:io(this._g),B:io(this._b)};this._a!==void 0&&(n.A=io(this._a)/z),this._rgb=n}},Vo=class{constructor(e,t,n){this._operations=new Map([[Va.DIVISION,this._division],[Va.MULTIPLICATION,this._multiplication],[Va.SUM,this._sum],[Va.REST,this._rest]]),this._colorIndex=e;let r=t,i=0;if(Number.isNaN(+t))if(t in n)this._result=n[t];else if(Va.REGEXP.test(r))Va.REGEXP.lastIndex=0,this._result=this._getCalcValue(r,n);else{for(;Va.SCOPED.test(r)&&i<100;){if(Va.SCOPED.lastIndex=0,r=r.replace(Va.SCOPED,((e,t)=>this._calculate(t,n).toString())),Va.REGEXP.test(r)){Va.REGEXP.lastIndex=0;break}i++}this._result=this._getCalcValue(r,n)}else this._result=+t}_division(e,t){return e/t}_multiplication(e,t){return e*t}_sum(e,t){return e+t}_rest(e,t){return e-t}_getCalcValue(e,t){let n=e.match(Va.REGEXP).groups.operation,r=this._calculate(n,t);if(Number.isNaN(r))throw Error(`Invalid value for ${this._colorIndex}. ${n} ${Xa}`);return r}_calculate(e,t){return this._operations.forEach(((n,r)=>{let i=0;for(;r.test(e)&&i<100;)e=e.replace(r,((e,r,i)=>n(t[r]??+r,t[i]??+i).toString())),i++})),+e}get result(){return this._result}},Ho=class extends zo{get hasPercentageAlpha(){return Ua.test(this._a)}},Uo=class extends Ho{constructor(e,t){super();let{r_legacy:n,g_legacy:r,b_legacy:i,a_legacy:a,r:o,g:s,b:c,a:l,from:u,relative_r:d,relative_g:f,relative_b:p,relative_a:m}=e.match(Ba.RGB).groups;if(u){let e=t(u),n={r:e.R,g:e.G,b:e.B,alpha:e.A??1},r=new Vo(`r`,d,n).result,i=new Vo(`g`,f,n).result,a=new Vo(`b`,p,n).result,o={R:Math.min(r,z),G:Math.min(i,z),B:Math.min(a,z)};if(m){let e=new Vo(`alpha`,m,n).result;o.A=Math.min(e,1)}this._rgb=o}else{this._r=n??o,this._g=r??s,this._b=i??c,this._a=a??l;let e={R:Math.min(oo(this._r),z),G:Math.min(oo(this._g),z),B:Math.min(oo(this._b),z)};this._a!==void 0&&(e.A=go(this._a)),this._rgb=e}}get hasPercentageValues(){return Ua.test(this._r)&&Ua.test(this._g)&&Ua.test(this._b)}static test(e){return Ba.RGB.test(e)}},Wo=class extends Ho{get angleUnit(){if(this._h){let e=this._h.match(Ha).groups.units;return e===``?Za.NONE:e}return Za.NONE}},Go=class extends Wo{constructor(e,t){super();let{h_legacy:n,s_legacy:r,l_legacy:i,a_legacy:a,h:o,s,l:c,a:l,from:u,relative_h:d,relative_s:f,relative_l:p,relative_a:m}=e.match(Ba.HSL).groups;if(u){let e=t(u),n=Do(e.R,e.G,e.B,e.A),r={h:n.H,s:n.S,l:n.L,alpha:n.A},i=new Vo(`h`,d,r).result,a=new Vo(`s`,f,r).result,o=new Vo(`l`,p,r).result,s=Eo(H(i,0,360),H(a,0,Aa),H(o,0,Aa));if(m){let e=new Vo(`alpha`,m,r).result;s.A=H(e,0,1)}this._rgb=s}else{this._h=n??o,this._s=r??s,this._l=i??c,this._a=a??l;let e=Eo(ho(this._h),ro(this._s),ro(this._l));this._a!==void 0&&(e.A=go(this._a)),this._rgb=e}}static test(e){return Ba.HSL.test(e)}},Ko=class extends Wo{constructor(e,t){super();let{h:n,w:r,b:i,a,from:o,relative_h:s,relative_w:c,relative_b:l,relative_a:u}=e.match(Ba.HWB).groups;if(o){let e=t(o),n=Po(e.R,e.G,e.B,e.A),r={h:n.H,w:n.W,b:n.B,alpha:n.A},i=new Vo(`h`,s,r).result,a=new Vo(`w`,c,r).result,d=new Vo(`b`,l,r).result,f=Fo(H(i,0,360),H(a,0,Aa),H(d,0,Aa));if(u){let e=new Vo(`alpha`,u,r).result;f.A=H(e,0,1)}this._rgb=f}else{this._h=n,this._w=r,this._b=i,this._a=a;let e=Fo(ho(this._h),ro(this._w),ro(this._b));this._a!==void 0&&(e.A=go(this._a)),this._rgb=e}}static test(e){return Ba.HWB.test(e)}},qo=class extends Ho{constructor(e,t){super();let{L:n,a:r,b:i,A:a,from:o,relative_L:s,relative_a:c,relative_b:l,relative_A:u}=e.match(Ba.CIELab).groups;if(o){let e=t(o),n=Oo(e.R,e.G,e.B),r={l:n.L,a:n.a,b:n.b,alpha:e.A??1},i=new Vo(`l`,s,r).result,a=new Vo(`a`,c,r).result,d=new Vo(`b`,l,r).result,f=ko(H(i,0,Aa),H(a,-125,ja),H(d,-125,ja));if(u){let e=new Vo(`alpha`,u,r).result;f.A=H(e,0,1)}this._rgb=f}else{this._L=n,this._A=r,this._B=i,this._a=a;let e=ko(ro(this._L),so(this._A),so(this._B));this._a!==void 0&&(e.A=go(this._a)),this._rgb=e}}get hasPercentageValues(){return Ua.test(this._L)&&Ua.test(this._A)&&Ua.test(this._B)}static test(e){return Ba.CIELab.test(e)}},Jo=class extends Wo{constructor(e,t){super();let{l:n,c:r,h:i,a,from:o,relative_l:s,relative_c:c,relative_h:l,relative_a:u}=e.match(Ba.LCH).groups;if(o){let e=t(o),n=Mo(e.R,e.G,e.B),r={l:n.L,c:n.C,h:n.H,alpha:e.A??1},i=new Vo(`l`,s,r).result,a=new Vo(`c`,c,r).result,d=new Vo(`h`,l,r).result,f=No(H(i,0,Aa),H(a,-150,Ma),ho(d));if(u){let e=new Vo(`alpha`,u,r).result;f.A=H(e,0,1)}this._rgb=f}else{this._l=n,this._c=r,this._h=i,this._a=a;let e=No(ro(this._l),co(this._c),ho(this._h));this._a!==void 0&&(e.A=go(this._a)),this._rgb=e}}get hasPercentageValues(){return Ua.test(this._l)&&Ua.test(this._c)}static test(e){return Ba.LCH.test(e)}},Yo=class extends Ho{constructor(e){super();let t=e.match(Ba.CMYK).groups;this._c=t.c_legacy??t.c,this._m=t.m_legacy??t.m,this._y=t.y_legacy??t.y,this._k=t.k_legacy??t.k,this._a=t.a_legacy??t.a;let n=Io(lo(this._c),lo(this._m),lo(this._y),lo(this._k));this._a!==void 0&&(n.A=go(this._a)),this._rgb=n}get hasPercentageValues(){return Ua.test(this._c)&&Ua.test(this._m)&&Ua.test(this._y)&&Ua.test(this._k)}static test(e){return Ba.CMYK.test(e)}},Xo=e=>typeof e==`string`?(e=>{let t;if(Object.keys(B).some((n=>{if(Ba[n].test(e))return t=n,!0})),!t&&~Ia.indexOf(e)&&(t=B.HEX),!t)throw Error(Ja);return t})(e):(e=>{let t,n=!1,r=uo(Object.keys(e));if(Ra[r]&&(t=Ra[r]),t&&t===B.RGB){let r=Object.entries(e).some((e=>!Wa.test(`${e[1]}`))),i=Object.entries(e).some((e=>!(Ua.test(`${e[1]}`)||!Wa.test(`${e[1]}`)&&!isNaN(+e[1])&&+e[1]<=z)));r&&i&&(n=!0),r||(t=B.HEX)}if(!t||n)throw Error(Ya);return t})(e),Zo={[B.HEX](e){return new Bo(~Ia.indexOf(e)?Fa[e]:e).rgb},[B.RGB]:e=>new Uo(e,$o).rgb,[B.HSL]:e=>new Go(e,$o).rgb,[B.HWB]:e=>new Ko(e,$o).rgb,[B.CIELab]:e=>new qo(e,$o).rgb,[B.LCH]:e=>new Jo(e,$o).rgb,[B.CMYK]:e=>new Yo(e).rgb},Qo={[B.HEX](e){let t={R:oo(`${e.R}`),G:oo(`${e.G}`),B:oo(`${e.B}`)};return to(e,`A`)&&(t.A=Math.min(oo(`${e.A}`,!0),1)),t},[B.RGB](e){return this.HEX(e)},[B.HSL](e){let t=ro(`${e.S}`),n=ro(`${e.L}`),r=Eo(ho(e.H),t,n);return to(e,`A`)&&(r.A=go(e.A)),r},[B.HWB](e){let t=ro(`${e.W}`),n=ro(`${e.B}`),r=Fo(ho(e.H),t,n);return to(e,`A`)&&(r.A=go(e.A)),r},[B.CIELab](e){let t=ko(ro(`${e.L}`),so(`${e.a}`),so(`${e.b}`));return to(e,`A`)&&(t.A=go(e.A)),t},[B.LCH](e){let t=No(ro(`${e.L}`),co(`${e.C}`),ho(`${e.H}`));return to(e,`A`)&&(t.A=go(e.A)),t},[B.CMYK](e){let t=Io(lo(`${e.C}`),lo(`${e.M}`),lo(`${e.Y}`),lo(`${e.K}`));return to(e,`A`)&&(t.A=go(e.A)),t}},$o=(e,t=Xo(e))=>typeof e==`string`?Zo[t](e):Qo[t](e),es=(e,...t)=>{let n=[],r=[],i=[],a=[],o=[],s=[],c=[],l=Object.values(Za),u=Object.values(Qa),d=Object.values($a),f={legacyCSS:0,spacesAfterCommas:0,cmykFunction:0};for(let e of t)if(typeof e==`string`){if(n.push(e),e.includes(`,`)){f.legacyCSS++;let t=e.match(Ka);new Set(t).size===1&&qa.test(t[0].slice(1))&&f.spacesAfterCommas++}if(Go.test(e)){let t=new Go(e,$o);r.push(t.angleUnit),c.push(t.hasPercentageAlpha);continue}if(Ko.test(e)){let t=new Ko(e,$o);r.push(t.angleUnit),c.push(t.hasPercentageAlpha);continue}if(Uo.test(e)){let t=new Uo(e,$o);i.push(t.hasPercentageValues),c.push(t.hasPercentageAlpha);continue}if(qo.test(e)){let t=new qo(e,$o);a.push(t.hasPercentageValues),c.push(t.hasPercentageAlpha);continue}if(Jo.test(e)){let t=new Jo(e,$o);r.push(t.angleUnit),o.push(t.hasPercentageValues),c.push(t.hasPercentageAlpha);continue}if(Yo.test(e)){let t=new Yo(e);s.push(t.hasPercentageValues),e.startsWith(`cmyk`)&&f.cmykFunction++,c.push(t.hasPercentageAlpha)}}return{decimals:typeof e.decimals===za.NUMBER?e.decimals:eo.decimals,legacyCSS:typeof e.legacyCSS===za.BOOLEAN?e.legacyCSS:!!(n.length&&f.legacyCSS===n.length)||eo.legacyCSS,spacesAfterCommas:typeof e.spacesAfterCommas===za.BOOLEAN?e.spacesAfterCommas:!!(n.length&&f.spacesAfterCommas===n.length)||eo.spacesAfterCommas,anglesUnit:e.anglesUnit&&l.includes(e.anglesUnit)?e.anglesUnit:new Set(r).size===1?r[0]:eo.anglesUnit,rgbUnit:e.rgbUnit&&u.includes(e.rgbUnit)?e.rgbUnit:new Set(i).size===1&&i[0]?Qa.PERCENT:eo.rgbUnit,labUnit:e.labUnit&&u.includes(e.labUnit)?e.labUnit:new Set(a).size===1&&a[0]?Qa.PERCENT:eo.labUnit,lchUnit:e.lchUnit&&u.includes(e.lchUnit)?e.lchUnit:new Set(o).size===1&&o[0]?Qa.PERCENT:eo.lchUnit,cmykUnit:e.cmykUnit&&u.includes(e.cmykUnit)?e.cmykUnit:new Set(s).size!==1||s[0]?eo.cmykUnit:Qa.NONE,alphaUnit:e.alphaUnit&&u.includes(e.alphaUnit)?e.alphaUnit:new Set(c).size===1&&c[0]?Qa.PERCENT:eo.alphaUnit,cmykFunction:e.cmykFunction&&d.includes(e.cmykFunction)?e.cmykFunction:s.length&&s.length===f.cmykFunction?$a.CMYK:eo.cmykFunction}},ts=(e,t)=>({H:V(e.H,t),S:V(e.S,t),L:V(e.L,t)}),ns=e=>e?`, `:`,`,rs=(e,t)=>La[Ra[uo(Object.keys(e))]].reduce(((n,r,i)=>{let a=e[r];return a!==void 0&&n.push(t(a,i)),n}),[]),is=(e,t)=>e.replace(Ga,((e,n)=>`${t[n-1]}`)),as=(e,t,n=!1)=>{let{alphaUnit:r,legacyCSS:i,decimals:a}=t;return r!==Qa.PERCENT||i&&!n?V(e,a):`${V(100*e,a)}%`},ss=e=>{let{anglesUnit:t,decimals:n}=e;return(r,i)=>i===0&&t!==Za.NONE?`${V(_o(r,t),n)}${t}`:i===3?as(r,e):V(r,n)},U={[B.HEX]:e=>{let t=rs(e,(e=>(e=>{let t=V(e,0).toString(16).toUpperCase();return t.length===1&&(t=`0${t}`),t})(V(e))));return is(t.length===4?`#{1}{2}{3}{4}`:`#{1}{2}{3}`,t)},[B.RGB]:(e,t)=>{let{decimals:n,legacyCSS:r,spacesAfterCommas:i,rgbUnit:a}=t,o=ns(i),s=rs(e,((e,r)=>a===Qa.PERCENT&&r<3?`${((e,t)=>V(e/z*100,t))(e,n)}%`:r===3?as(e,t):V(e,n)));return is(r?s.length===4?`rgba({1}${o}{2}${o}{3}${o}{4})`:`rgb({1}${o}{2}${o}{3})`:s.length===4?`rgb({1} {2} {3} / {4})`:`rgb({1} {2} {3})`,s)},[B.HSL]:(e,t)=>{let{legacyCSS:n,spacesAfterCommas:r}=t,i=ns(r),a=rs(e,ss(t));return is(n?a.length===4?`hsla({1}${i}{2}%${i}{3}%${i}{4})`:`hsl({1}${i}{2}%${i}{3}%)`:a.length===4?`hsl({1} {2}% {3}% / {4})`:`hsl({1} {2}% {3}%)`,a)},[B.HWB]:(e,t)=>{let n=rs(e,ss(t));return is(n.length===4?`hwb({1} {2}% {3}% / {4})`:`hwb({1} {2}% {3}%)`,n)},[B.CIELab]:(e,t)=>{let{decimals:n,labUnit:r}=t,i=rs(e,((e,i)=>{if(i===0){let t=V(ro(e),n);return r===Qa.PERCENT?`${t}%`:`${t}`}return i<3?r===Qa.PERCENT?`${((e,t)=>V(e/ja*100,t))(e,n)}%`:V(e,n):as(e,t,!0)}));return is(i.length===4?`lab({1} {2} {3} / {4})`:`lab({1} {2} {3})`,i)},[B.LCH]:(e,t)=>{let{decimals:n,lchUnit:r,anglesUnit:i}=t,a=rs(e,((e,a)=>{if(a===0){let t=V(ro(e),n);return r===Qa.PERCENT?`${t}%`:`${t}`}return a===1?r===Qa.PERCENT?`${((e,t)=>V(e/Ma*100,t))(e,n)}%`:V(e,n):a===2?i===Za.NONE?V(e,n):`${V(_o(e,i),n)}${i}`:as(e,t,!0)}));return is(a.length===4?`lch({1} {2} {3} / {4})`:`lch({1} {2} {3})`,a)},[B.CMYK]:(e,t)=>{let{decimals:n,legacyCSS:r,spacesAfterCommas:i,cmykUnit:a,cmykFunction:o}=t,s=ns(i),c=rs(e,((e,r)=>a===Qa.PERCENT&&r<4?`${V(e,n)}%`:r===4?as(e,t):V(e/100,n)));return is(r?c.length===5?`${o}({1}${s}{2}${s}{3}${s}{4}${s}{5})`:`${o}({1}${s}{2}${s}{3}${s}{4})`:c.length===5?`${o}({1} {2} {3} {4} / {5})`:`${o}({1} {2} {3} {4})`,c)}},cs=(e,t,n)=>t.reduce(((t,r)=>[...t,{...e,H:n===Pa.ADDITIVE?ho(e.H+r):ho(Ro(Ro(e.H,!1)+r,!0))}]),[{...e}]),ls=(e,t)=>cs(e,[30,-30],t),us=(e,t)=>cs(e,[180],t),ds=(e,t)=>cs(e,[150,-150],t),fs=(e,t)=>cs(e,[120,-120],t),ps=(e,t)=>cs(e,[60,-120,180],t),ms=(e,t)=>cs(e,[90,-90,180],t),W={[B.HEX]:e=>({R:ao(e.R),G:ao(e.G),B:ao(e.B)}),HEXA(e){let t=W.HEX(e);return t.A=to(e,`A`)?ao(e.A*z):`0xFF`,t},[B.RGB](e,t){let n=vs(e,t);return to(n,`A`)&&delete n.A,n},RGBA(e,t){let n=W.RGB(e,t);return n.A=to(e,`A`)?V(e.A):1,n},[B.HSL](e,t){let n=Do(e.R,e.G,e.B);return delete n.A,ts(n,t)},HSLA(e,t){let n=W.HSL(e,t);return n.A=to(e,`A`)?V(e.A,t):1,n},[B.HWB](e,t){let n=Po(e.R,e.G,e.B);return delete n.A,((e,t)=>({H:V(e.H,t),W:V(e.W,t),B:V(e.B,t)}))(n,t)},HWBA(e,t){let n=W.HWB(e,t);return n.A=to(e,`A`)?V(e.A,t):1,n},[B.CIELab]:(e,t)=>((e,t)=>({L:V(e.L,t),a:V(e.a,t),b:V(e.b,t)}))(Oo(e.R,e.G,e.B),t),CIELabA(e,t){let n=W.CIELab(e,t);return n.A=to(e,`A`)?V(e.A,t):1,n},[B.LCH]:(e,t)=>((e,t)=>({L:V(e.L,t),C:V(e.C,t),H:V(e.H,t)}))(Mo(e.R,e.G,e.B),t),LCHA(e,t){let n=W.LCH(e,t);return n.A=to(e,`A`)?V(e.A,t):1,n},[B.CMYK]:(e,t)=>((e,t)=>({C:V(e.C,t),M:V(e.M,t),Y:V(e.Y,t),K:V(e.K,t)}))(Lo(e.R,e.G,e.B),t),CMYKA(e,t){let n=W.CMYK(e,t);return n.A=to(e,`A`)?V(e.A,t):1,n}},hs=(e,t,n,r)=>{let i=Xo(e),a=typeof e==`string`,o=$o(e,i),s=typeof e==`string`&&to(o,`A`)||typeof e!=`string`&&to(e,`A`),c=Do(o.R,o.G,o.B,o.A);s||delete c.A;let l=n?c.L/(t+1):(100-c.L)/(t+1),u=Array(t).fill(null).map(((e,t)=>({...c,L:c.L+l*(t+1)*(1-2*n)})));switch(i){case B.HEX:default:return u.map((e=>{let t=Eo(e.H,e.S,e.L);return s&&(t.A=e.A),a?s?U.HEX({...t,A:V(t.A*z)}):U.HEX(t):s?W.HEXA(t):W.HEX(t)}));case B.RGB:return u.map((e=>{let t=Eo(e.H,e.S,e.L);return s&&(t.A=e.A),a?U.RGB(t,r):s?W.RGBA(t,r.decimals):W.RGB(t,r.decimals)}));case B.HSL:return u.map((e=>a?U.HSL(e,r):s?W.HSLA({...Eo(e.H,e.S,e.L),A:e.A},r.decimals):W.HSL(Eo(e.H,e.S,e.L),r.decimals)));case B.HWB:return u.map((e=>{let t=Eo(e.H,e.S,e.L);s&&(t.A=e.A);let n=s?W.HWBA(t,r.decimals):W.HWB(t,r.decimals);return a?U.HWB(n,r):n}));case B.CIELab:return u.map((e=>{let t=Eo(e.H,e.S,e.L);s&&(t.A=e.A);let n=s?W.CIELabA(t,r.decimals):W.CIELab(t,r.decimals);return a?U.CIELab(n,r):n}));case B.LCH:return u.map((e=>{let t=Eo(e.H,e.S,e.L),n=Mo(t.R,t.G,t.B);return s&&(n.A=e.A),a?U.LCH(n,r):s?W.LCHA({...t,A:e.A},r.decimals):W.LCH(t,r.decimals)}))}},gs={buildHarmony(e,t,n,r){let i=Xo(e),a=$o(e,i),o=Do(a.R,a.G,a.B,a.A),s=typeof e==`string`&&to(a,`A`)||typeof e!=`string`&&to(e,`A`),c=typeof e==`string`;switch(i){case B.HEX:default:return s?this.HEXA(ts(o,0),t,n,c):this.HEX(ts(o,0),t,n,c);case B.HSL:return s?this.HSLA(o,t,n,c,r):this.HSL(o,t,n,c,r);case B.HWB:return s?this.HWBA(o,t,n,c,r):this.HWB(o,t,n,c,r);case B.RGB:return s?this.RGBA(o,t,n,c,r):this.RGB(o,t,n,c,r);case B.CIELab:return s?this.CIELabA(o,t,n,c,r):this.CIELab(o,t,n,c,r);case B.LCH:return s?this.LCHA(o,t,n,c,r):this.LCH(o,t,n,c,r)}},[B.HEX]:(e,t,n,r)=>t(e,n).map((e=>r?U.HEX(Eo(e.H,e.S,e.L)):W.HEX(Eo(e.H,e.S,e.L)))),HEXA:(e,t,n,r)=>t(e,n).map((e=>r?U.HEX({...Eo(e.H,e.S,e.L),A:go(e.A)*z}):W.HEXA({...Eo(e.H,e.S,e.L),A:go(e.A)}))),[B.RGB]:(e,t,n,r,i)=>t(e,n).map((e=>r?U.RGB(Eo(e.H,e.S,e.L),i):W.RGB(Eo(e.H,e.S,e.L),i.decimals))),RGBA:(e,t,n,r,i)=>t(e,n).map((e=>r?U.RGB({...Eo(e.H,e.S,e.L),A:go(e.A)},i):W.RGBA({...Eo(e.H,e.S,e.L),A:go(e.A)},i.decimals))),[B.HSL]:(e,t,n,r,i)=>t(e,n).map((e=>r?U.HSL({H:e.H,S:e.S,L:e.L},i):W.HSL(Eo(e.H,e.S,e.L),i.decimals))),HSLA:(e,t,n,r,i)=>t(e,n).map((e=>r?U.HSL({...e,A:go(e.A)},i):W.HSLA({...Eo(e.H,e.S,e.L),A:go(e.A)},i.decimals))),[B.HWB]:(e,t,n,r,i)=>t(e,n).map((e=>{let t=Eo(e.H,e.S,e.L),n=Po(t.R,t.G,t.B);return r?U.HWB({H:n.H,W:n.W,B:n.B},i):W.HWB(t,i.decimals)})),HWBA:(e,t,n,r,i)=>t(e,n).map((e=>{let t=Eo(e.H,e.S,e.L),n=Po(t.R,t.G,t.B);return r?U.HWB({...n,A:go(e.A)},i):W.HWBA({...t,A:go(e.A)},i.decimals)})),[B.CIELab]:(e,t,n,r,i)=>t(e,n).map((e=>{let t=Eo(e.H,e.S,e.L);return r?U.CIELab(Oo(t.R,t.G,t.B),i):W.CIELab(t,i.decimals)})),CIELabA:(e,t,n,r,i)=>t(e,n).map((e=>{let t=Eo(e.H,e.S,e.L);return r?U.CIELab({...Oo(t.R,t.G,t.B),A:go(e.A)},i):W.CIELabA({...t,A:go(e.A)},i.decimals)})),[B.LCH]:(e,t,n,r,i)=>t(e,n).map((e=>{let t=Eo(e.H,e.S,e.L);return r?U.LCH(Mo(t.R,t.G,t.B),i):W.LCH(t,i.decimals)})),LCHA:(e,t,n,r,i)=>t(e,n).map((e=>{let t=Eo(e.H,e.S,e.L);return r?U.LCH({...Mo(t.R,t.G,t.B),A:go(e.A)},i):W.LCHA({...t,A:go(e.A)},i.decimals)}))},_s={mix(e,t){let n=e.map((e=>$o(e,Xo(e)))),r=t===Pa.SUBTRACTIVE?n.map((e=>{let t=((e,t,n)=>{let r=Math.min(e,t,n),i=Math.min(z-e,z-t,z-n),a=e-r,o=t-r,s=n-r,c=Math.min(a,o),l=a-c,u=(o+c)/2,d=(s+o-c)/2,f=Math.max(l,u,d)/Math.max(a,o,s),p=isNaN(f)||f===1/0||f<=0?1:f;return{R:l/p+i,Y:u/p+i,B:d/p+i}})(e.R,e.G,e.B);return to(e,`A`)&&(t.A=e.A),t})):null;function i(e){let n=t===Pa.ADDITIVE?{R:0,G:0,B:0,A:0}:{R:0,Y:0,B:0,A:0};return e.reduce(((e,n)=>{let r=to(n,`A`)?n.A:1,i={R:Math.min(e.R+n.R*r,z),B:Math.min(e.B+n.B*r,z),A:1-(1-r)*(1-e.A)},a=`G`in e?e.G:e.Y,o=`G`in n?n.G:n.Y;return{...i,...t===Pa.ADDITIVE?{G:Math.min(a+o*r,z)}:{Y:Math.min(a+o*r,z)}}}),n)}let a;if(t===Pa.ADDITIVE)a=i(n);else{let e=i(r);a=((e,t,n)=>{let r=Math.min(e,t,n),i=Math.min(z-e,z-t,z-n),a=e-r,o=t-r,s=n-r,c=Math.min(o,s),l=a+o-c,u=o+c,d=2*(s-c),f=Math.max(l,u,d)/Math.max(a,o,s),p=isNaN(f)||f===1/0||f<=0?1:f;return{R:l/p+i,G:u/p+i,B:d/p+i}})(e.R,e.Y,e.B),a.A=e.A}return{R:V(a.R),G:V(a.G),B:V(a.B),A:H(a.A,0,1)}},[B.HEX](e,t,n){let r=this.mix(e,t);return delete r.A,n?U.HEX(r):W.HEX(r)},HEXA(e,t,n){let r=this.mix(e,t);return r.A=n?go(r.A)*z:go(r.A),n?U.HEX(r):W.HEXA(r)},[B.RGB](e,t,n,r){let i=this.mix(e,t);return delete i.A,n?U.RGB(i,r):W.RGB(i,r.decimals)},RGBA(e,t,n,r){let i=this.mix(e,t);return n?U.RGB(i,r):W.RGBA(i,r.decimals)},[B.HSL](e,t,n,r){let i=this.mix(e,t),a=Do(i.R,i.G,i.B);return delete i.A,delete a.A,n?U.HSL(a,r):W.HSL(i,r.decimals)},HSLA(e,t,n,r){let i=this.mix(e,t),a=Do(i.R,i.G,i.B,i.A);return n?U.HSL(a,r):W.HSLA(i,r.decimals)},[B.HWB](e,t,n,r){let i=this.mix(e,t),a=Po(i.R,i.G,i.B);return delete i.A,delete a.A,n?U.HWB(a,r):W.HWB(i,r.decimals)},HWBA(e,t,n,r){let i=this.mix(e,t),a=Po(i.R,i.G,i.B,i.A);return n?U.HWB(a,r):W.HWBA(i,r.decimals)},[B.CIELab](e,t,n,r){let i=this.mix(e,t),a=Oo(i.R,i.G,i.B);return delete i.A,n?U.CIELab(a,r):W.CIELab(i,r.decimals)},CIELabA(e,t,n,r){let i=this.mix(e,t),a=Oo(i.R,i.G,i.B);return to(i,`A`)&&(a.A=i.A),n?U.CIELab(a,r):W.CIELabA(i,r.decimals)},[B.LCH](e,t,n,r){let i=this.mix(e,t),a=Mo(i.R,i.G,i.B);return delete i.A,n?U.LCH(a,r):W.LCH(i,r.decimals)},LCHA(e,t,n,r){let i=this.mix(e,t),a=Mo(i.R,i.G,i.B);return to(i,`A`)&&(a.A=i.A),n?U.LCH(a,r):W.LCHA(i,r.decimals)}},vs=(e,t)=>({R:V(e.R,t),G:V(e.G,t),B:V(e.B,t),...to(e,`A`)?{A:V(e.A,t)}:{}}),ys=(e,t,n,r)=>r($o(e,t),n),bs=(e,t,n,r,i)=>(n<1&&(n=5),((e,t,n)=>{let r=n-1,i=(t.R-e.R)/r,a=(t.G-e.G)/r,o=(t.B-e.B)/r,s=go(e.A),c=(go(t.A)-s)/r;return Array(n).fill(null).map(((n,l)=>l===0?e:l===r?t:{R:V(e.R+i*l),G:V(e.G+a*l),B:V(e.B+o*l),A:V(s+c*l)}))})($o(e),$o(t),n).map((e=>i(e,r))));function xs(e){let{from:t,to:n,thirdParameter:r,fourthParameter:i,translateFunction:a,cssFunction:o}=e,s=typeof r==`number`?bs(t,n,r,i?.decimals,a):bs(t,n,5,r?.decimals,a);return o?s.map((e=>o(e,es((typeof r==`number`?i:r)??{},t,n)))):s}function Ss(e){let{colors:t,secondParameter:n,thirdParameter:r,colorMixerFunction:i,css:a}=e,o=es((typeof n==`string`?r:n)??{},...t);return i(t,typeof n==`string`?n:Pa.ADDITIVE,a,o)}var Cs=(e,t,n,r)=>({[Na.ANALOGOUS]:gs.buildHarmony(t,ls,n,r),[Na.COMPLEMENTARY]:gs.buildHarmony(t,us,n,r),[Na.SPLIT_COMPLEMENTARY]:gs.buildHarmony(t,ds,n,r),[Na.TRIADIC]:gs.buildHarmony(t,fs,n,r),[Na.TETRADIC]:gs.buildHarmony(t,ps,n,r),[Na.SQUARE]:gs.buildHarmony(t,ms,n,r)})[e],ws=Object.fromEntries(Object.entries(_s).map((e=>{let[t,n]=e;return[t,n.bind(_s)]}))),Ts=class e{constructor(e,t={}){this._options=es(t,e),this.rgb=$o(e),this.update(`rgb`)}update(...e){e.includes(`rgb`)||this.updateRGB(),e.includes(`hsl`)||this.updateHSL(),e.includes(`hwb`)||this.updateHWB(),e.includes(`lab`)||this.updateLAB(),e.includes(`lch`)||this.updateLCH(),e.includes(`cmyk`)||this.updateCMYK()}updateRGB(){this.rgb={...Eo(this.hsl.H,this.hsl.S,this.hsl.L),A:this.hsl.A}}updateHSL(){this.hsl=Do(this.rgb.R,this.rgb.G,this.rgb.B,this.rgb.A)}updateHWB(){this.hwb=Po(this.rgb.R,this.rgb.G,this.rgb.B,this.rgb.A)}updateLAB(){this.lab={...Oo(this.rgb.R,this.rgb.G,this.rgb.B),A:this.rgb.A}}updateLCH(){this.lch={...Mo(this.rgb.R,this.rgb.G,this.rgb.B),A:this.rgb.A}}updateCMYK(){this.cmyk=Lo(this.rgb.R,this.rgb.G,this.rgb.B)}updateRGBFromHWB(){this.rgb={...Fo(this.hwb.H,this.hwb.W,this.hwb.B),A:this.rgb.A}}updateRGBFromLCH(){this.rgb={...No(this.lch.L,this.lch.C,this.lch.H),A:this.rgb.A}}updateRGBFromCMYK(){this.rgb={...Io(this.cmyk.C,this.cmyk.M,this.cmyk.Y,this.cmyk.K),A:this.rgb.A}}updateRGBFromLAB(){this.rgb={...ko(this.lab.L,this.lab.a,this.lab.b),A:this.rgb.A}}updateLCHFromLAB(){this.lch={...Ao(this.lab.L,this.lab.a,this.lab.b),A:this.lab.A}}updateLABromLCH(){this.lab={...jo(this.lch.L,this.lch.C,this.lch.H),A:this.lch.A}}setOptions(e={}){return this._options={...this._options,...e},this}setR(e){this.rgb.R=H(e,0,z),this.update(`rgb`)}setG(e){return this.rgb.G=H(e,0,z),this.update(`rgb`),this}setB(e){return this.rgb.B=H(e,0,z),this.update(`rgb`),this}setH(e){return this.hsl.H=ho(e),this.update(`hsl`),this}setS(e){return this.hsl.S=H(e,0,Aa),this.update(`hsl`),this}setL(e){return this.hsl.L=H(e,0,Aa),this.update(`hsl`),this}setWhiteness(e){return this.hwb.W=H(e,0,Aa),this.updateRGBFromHWB(),this.update(`rgb`,`hwb`),this}setBlackness(e){return this.hwb.B=H(e,0,Aa),this.updateRGBFromHWB(),this.update(`rgb`,`hwb`),this}setCIEL(e){return this.lab.L=H(e,0,Aa),this.updateRGBFromLAB(),this.updateLCHFromLAB(),this.update(`rgb`,`lab`,`lch`),this}setCIEa(e){return this.lab.a=H(e,-125,ja),this.updateRGBFromLAB(),this.updateLCHFromLAB(),this.update(`rgb`,`lab`,`lch`),this}setCIEb(e){return this.lab.b=H(e,-125,ja),this.updateRGBFromLAB(),this.updateLCHFromLAB(),this.update(`rgb`,`lab`,`lch`),this}setLCHL(e){return this.lch.L=H(e,0,Aa),this.updateRGBFromLCH(),this.updateLABromLCH(),this.update(`rgb`,`lab`,`lch`),this}setLCHC(e){return this.lch.C=H(e,0,Ma),this.updateRGBFromLCH(),this.updateLABromLCH(),this.update(`rgb`,`lab`,`lch`),this}setLCHH(e){return this.lch.H=ho(e),this.updateRGBFromLCH(),this.updateLABromLCH(),this.update(`rgb`,`lab`,`lch`),this}setA(e){let t=H(e,0,1);return this.rgb.A=t,this.hsl.A=t,this.hwb.A=t,this.lab.A=t,this.lch.A=t,this.cmyk.A=t,this}setC(e){return this.cmyk.C=H(e,0,100),this.updateRGBFromCMYK(),this.update(`cmyk`),this}setM(e){return this.cmyk.M=H(e,0,100),this.updateRGBFromCMYK(),this.update(`cmyk`),this}setY(e){return this.cmyk.Y=H(e,0,100),this.updateRGBFromCMYK(),this.update(`cmyk`),this}setK(e){return this.cmyk.K=H(e,0,100),this.updateRGBFromCMYK(),this.update(`cmyk`),this}get options(){return this._options}get R(){return V(this.rgb.R,this.options.decimals)}get G(){return V(this.rgb.G,this.options.decimals)}get B(){return V(this.rgb.B,this.options.decimals)}get H(){return V(this.hsl.H,this.options.decimals)}get S(){return V(this.hsl.S,this.options.decimals)}get L(){return V(this.hsl.L,this.options.decimals)}get Whiteness(){return V(this.hwb.W,this.options.decimals)}get Blackness(){return V(this.hwb.B,this.options.decimals)}get CIEL(){return V(this.lab.L,this.options.decimals)}get CIEa(){return V(this.lab.a,this.options.decimals)}get CIEb(){return V(this.lab.b,this.options.decimals)}get LCHL(){return V(this.lch.L,this.options.decimals)}get LCHC(){return V(this.lch.C,this.options.decimals)}get LCHH(){return V(this.lch.H,this.options.decimals)}get A(){return V(this.hsl.A,this.options.decimals)}get C(){return V(this.cmyk.C,this.options.decimals)}get M(){return V(this.cmyk.M,this.options.decimals)}get Y(){return V(this.cmyk.Y,this.options.decimals)}get K(){return V(this.cmyk.K,this.options.decimals)}get HEXObject(){return W.HEX(this.rgb)}get HEXAObject(){return W.HEXA(this.rgb)}get RGBObject(){return{R:this.R,G:this.G,B:this.B}}get RGBAObject(){return{...this.RGBObject,A:this.A}}get HSLObject(){return{H:this.H,S:this.S,L:this.L}}get HSLAObject(){return{...this.HSLObject,A:this.A}}get HWBObject(){return{H:this.H,W:this.Whiteness,B:this.Blackness}}get HWBAObject(){return{...this.HWBObject,A:this.A}}get CIELabObject(){return{L:this.CIEL,a:this.CIEa,b:this.CIEb}}get CIELabAObject(){return{...this.CIELabObject,A:this.A}}get LCHObject(){return{L:this.LCHL,C:this.LCHC,H:this.LCHH}}get LCHAObject(){return{...this.LCHObject,A:this.A}}get CMYKObject(){return{C:this.C,M:this.M,Y:this.Y,K:this.K}}get CMYKAObject(){return{...this.CMYKObject,A:this.A}}get HEX(){return U.HEX({R:this.R,G:this.G,B:this.B})}get HEXA(){return U.HEX({R:this.R,G:this.G,B:this.B,A:this.A*z})}get RGB(){return U.RGB({R:this.R,G:this.G,B:this.B},this.options)}get RGBA(){return U.RGB({R:this.R,G:this.G,B:this.B,A:this.A},this.options)}get HSL(){return U.HSL({H:this.H,S:this.S,L:this.L},this.options)}get HSLA(){return U.HSL({H:this.H,S:this.S,L:this.L,A:this.A},this.options)}get HWB(){return U.HWB({H:this.H,W:this.Whiteness,B:this.Blackness},this.options)}get HWBA(){return U.HWB({H:this.H,W:this.Whiteness,B:this.Blackness,A:this.A},this.options)}get CIELab(){return U.CIELab({L:this.CIEL,a:this.CIEa,b:this.CIEb},this.options)}get CIELabA(){return U.CIELab({L:this.CIEL,a:this.CIEa,b:this.CIEb,A:this.A},this.options)}get LCH(){return U.LCH({L:this.LCHL,C:this.LCHC,H:this.LCHH},this.options)}get LCHA(){return U.LCH({L:this.LCHL,C:this.LCHC,H:this.LCHH,A:this.A},this.options)}get CMYK(){return U.CMYK({C:this.C,M:this.M,Y:this.Y,K:this.K},this.options)}get CMYKA(){return U.CMYK({C:this.C,M:this.M,Y:this.Y,K:this.K,A:this.A},this.options)}static toHEXObject(e){return ys(e,Xo(e),0,W.HEX)}static toHEX(t){return U.HEX(e.toHEXObject(t))}static toHEXAObject(e){return ys(e,Xo(e),0,W.HEXA)}static toHEXA(t){return U.HEX(e.toHEXAObject(t))}static toRGBObject(e,t={}){return ys(e,Xo(e),t.decimals,W.RGB)}static toRGB(t,n={}){let r=e.toRGBObject(t,n),i=es(n,t);return U.RGB(r,i)}static toRGBAObject(e,t={}){return ys(e,Xo(e),t.decimals,W.RGBA)}static toRGBA(t,n={}){let r=e.toRGBAObject(t,n),i=es(n,t);return U.RGB(r,i)}static toHSLObject(e,t={}){return ys(e,Xo(e),t.decimals,W.HSL)}static toHSL(t,n={}){let r=e.toHSLObject(t,n),i=es(n,t);return U.HSL(r,i)}static toHSLAObject(e,t={}){return ys(e,Xo(e),t.decimals,W.HSLA)}static toHSLA(t,n={}){let r=e.toHSLAObject(t,n),i=es(n,t);return U.HSL(r,i)}static toHWBObject(e,t={}){return ys(e,Xo(e),t.decimals,W.HWB)}static toHWB(t,n={}){let r=e.toHWBObject(t,n),i=es(n,t);return U.HWB(r,i)}static toHWBAObject(e,t={}){return ys(e,Xo(e),t.decimals,W.HWBA)}static toHWBA(t,n={}){let r=e.toHWBAObject(t,n),i=es(n,t);return U.HWB(r,i)}static toCIELabObject(e,t={}){return ys(e,Xo(e),t.decimals,W.CIELab)}static toCIELab(t,n={}){let r=e.toCIELabObject(t,n),i=es(n,t);return U.CIELab(r,i)}static toCIELabAObject(e,t={}){return ys(e,Xo(e),t.decimals,W.CIELabA)}static toCIELabA(t,n={}){let r=e.toCIELabAObject(t,n),i=es(n,t);return U.CIELab(r,i)}static toLCHObject(e,t={}){return ys(e,Xo(e),t.decimals,W.LCH)}static toLCH(t,n={}){let r=e.toLCHObject(t,n),i=es(n,t);return U.LCH(r,i)}static toLCHAObject(e,t={}){return ys(e,Xo(e),t.decimals,W.LCHA)}static toLCHA(t,n={}){let r=e.toLCHAObject(t,n),i=es(n,t);return U.LCH(r,i)}static toCMYKObject(e,t={}){return ys(e,Xo(e),t.decimals,W.CMYK)}static toCMYK(t,n={}){let r=e.toCMYKObject(t,n),i=es(n,t);return U.CMYK(r,i)}static toCMYKAObject(e,t={}){return ys(e,Xo(e),t.decimals,W.CMYKA)}static toCMYKA(t,n={}){let r=e.toCMYKAObject(t,n),i=es(n,t);return U.CMYK(r,i)}static getBlendHEXObject(e,t,n=5){return bs(e,t,n,0,W.HEX)}static getBlendHEX(t,n,r=5){return e.getBlendHEXObject(t,n,r).map((e=>U.HEX(e)))}static getBlendHEXAObject(e,t,n=5){return bs(e,t,n,0,W.HEXA)}static getBlendHEXA(t,n,r=5){return e.getBlendHEXAObject(t,n,r).map((e=>U.HEX(e)))}static getBlendRGBObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.RGB})}static getBlendRGB(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.RGB,cssFunction:U.RGB})}static getBlendRGBAObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.RGBA})}static getBlendRGBA(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.RGBA,cssFunction:U.RGB})}static getBlendHSLObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HSL})}static getBlendHSL(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HSL,cssFunction:U.HSL})}static getBlendHSLAObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HSLA})}static getBlendHSLA(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HSLA,cssFunction:U.HSL})}static getBlendHWBObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HWB})}static getBlendHWB(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HWB,cssFunction:U.HWB})}static getBlendHWBAObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HWBA})}static getBlendHWBA(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.HWBA,cssFunction:U.HWB})}static getBlendCIELabObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.CIELab})}static getBlendCIELab(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.CIELab,cssFunction:U.CIELab})}static getBlendCIELabAObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.CIELabA})}static getBlendCIELabA(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.CIELabA,cssFunction:U.CIELab})}static getBlendLCHObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.LCH})}static getBlendLCH(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.LCH,cssFunction:U.LCH})}static getBlendLCHAObject(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.LCHA})}static getBlendLCHA(e,t,n,r){return xs({from:e,to:t,thirdParameter:n,fourthParameter:r,translateFunction:W.LCHA,cssFunction:U.LCH})}static getMixHEXObject(e,t=Pa.ADDITIVE){return _s.HEX(e,t,!1)}static getMixHEX(e,t=Pa.ADDITIVE){return _s.HEX(e,t,!0)}static getMixHEXAObject(e,t=Pa.ADDITIVE){return _s.HEXA(e,t,!1)}static getMixHEXA(e,t=Pa.ADDITIVE){return _s.HEXA(e,t,!0)}static getMixRGBObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.RGB,css:!1})}static getMixRGB(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.RGB,css:!0})}static getMixRGBAObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.RGBA,css:!1})}static getMixRGBA(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.RGBA,css:!0})}static getMixHSLObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HSL,css:!1})}static getMixHSL(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HSL,css:!0})}static getMixHSLAObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HSLA,css:!1})}static getMixHSLA(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HSLA,css:!0})}static getMixHWBObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HWB,css:!1})}static getMixHWB(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HWB,css:!0})}static getMixHWBAObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HWBA,css:!1})}static getMixHWBA(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.HWBA,css:!0})}static getMixCIELabObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.CIELab,css:!1})}static getMixCIELab(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.CIELab,css:!0})}static getMixCIELabAObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.CIELabA,css:!1})}static getMixCIELabA(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.CIELabA,css:!0})}static getMixLCHObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.LCH,css:!1})}static getMixLCH(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.LCH,css:!0})}static getMixLCHAObject(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.LCHA,css:!1})}static getMixLCHA(e,t,n){return Ss({colors:e,secondParameter:t,thirdParameter:n,colorMixerFunction:ws.LCHA,css:!0})}static getShades(e,t,n){return typeof t==`number`?hs(e,t,!0,es(n||{},e)):hs(e,5,!0,es(t||{},e))}static getTints(e,t,n){return typeof t==`number`?hs(e,t,!1,es(n||{},e)):hs(e,5,!1,es(t||{},e))}static getHarmony(e,t,n,r){return`${t}`in Na?Cs(t,e,vo(n)?n:Pa.ADDITIVE,es(vo(n)?r||{}:n||{},e)):vo(t)?Cs(Na.COMPLEMENTARY,e,t,es(n||{},e)):Cs(Na.COMPLEMENTARY,e,Pa.ADDITIVE,es(t||{},e))}},Es={slots:{root:`data-[disabled]:opacity-75`,picker:`flex gap-4`,selector:`rounded-md touch-none`,selectorBackground:`w-full h-full relative rounded-md`,selectorThumb:`-translate-y-1/2 -translate-x-1/2 absolute size-4 ring-2 ring-white rounded-full cursor-pointer data-[disabled]:cursor-not-allowed`,track:`w-[8px] relative rounded-md touch-none`,trackThumb:`absolute transform -translate-y-1/2 -translate-x-[4px] rtl:translate-x-[4px] size-4 rounded-full ring-2 ring-white cursor-pointer data-[disabled]:cursor-not-allowed`},variants:{size:{xs:{selector:`w-38 h-38`,track:`h-38`},sm:{selector:`w-40 h-40`,track:`h-40`},md:{selector:`w-42 h-42`,track:`h-42`},lg:{selector:`w-44 h-44`,track:`h-44`},xl:{selector:`w-46 h-46`,track:`h-46`}}},compoundVariants:[],defaultVariants:{size:`md`}},Ds=[`data-disabled`],Os=[`data-disabled`];function ks(e){let t=e.S*(e.L<50?e.L:100-e.L),n=e.L+t/100;return{h:e.H,s:e.L===0?e.S:2*t/n,v:n}}function As(e){let t=(200-e.s)*e.v/100;return{H:e.h,S:t===0||t===200?0:Math.round(e.s*e.v/(t<=100?t:200-t)),L:t/2}}var js=rn({__name:`ColorPicker`,props:oe({as:{type:null,required:!1},throttle:{type:Number,required:!1,default:50},disabled:{type:Boolean,required:!1},defaultValue:{type:String,required:!1,default:`#FFFFFF`},format:{type:String,required:!1,default:`hex`},size:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1}},{modelValue:{type:String},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=lt(`colorPicker`,e),n=Me(e,`modelValue`,{type:String}),a=Ce(),o=r(()=>Tt({extend:Tt(Es),...a.ui?.colorPicker||{}})({size:t.size})),s=r({get(){try{return ks(new Ts(n.value||t.defaultValue).HSLObject)}catch{return{h:0,s:0,v:100}}},set(e){let r=new Ts(As(e),{labUnit:`percent`,cmykUnit:`percent`,cmykFunction:`cmyk`});switch(t.format){case`rgb`:n.value=r.RGB;break;case`hsl`:n.value=r.HSL;break;case`cmyk`:n.value=r.CMYK;break;case`lab`:n.value=r.CIELab;break;default:n.value=r.HEX}}});function c(e,t,n=`both`,r={x:0,y:0},a){let o=L(r),s=L(),c=i(e),l=i(t);function u(e){if(N(a))return e.preventDefault();let n=N(t);s.value={x:e.clientX-(n?e.clientX-l.left.value+n.scrollLeft:c.left.value),y:e.clientY-(n?e.clientY-l.top.value+n.scrollTop:c.top.value)},d(e)}function d(e){if(!s.value)return;let r=N(t),{x:i,y:a}=o.value;r&&(n===`x`||n===`both`)&&(i=Math.min(Math.max(0,(e.clientX-s.value.x)/r.scrollWidth*100),100)),r&&(n===`y`||n===`both`)&&(a=Math.min(Math.max(0,(e.clientY-s.value.y)/r.scrollHeight*100),100)),o.value={x:i,y:a}}function p(){s.value&&=void 0}return Ae&&(f(t,`pointerdown`,u),f(window,`pointermove`,d),f(window,`pointerup`,p)),{position:o}}function l(e,t=`left`){return t===`right`?e*100/360:e/100*360}function d(e){return 100-e}let p=L(null),m=L(null),h=L(null),g=L(null),_=r(()=>t.disabled),{position:y}=c(m,p,`both`,{x:s.value.s,y:d(s.value.v)},_),{position:x}=c(g,h,`y`,{x:0,y:l(s.value.h,`right`)},_),{pause:C,resume:T}=Be(s,e=>{y.value={x:e.s,y:d(e.v)},x.value={x:0,y:l(e.h,`right`)}});he([y,x],()=>{C(),s.value={h:l(x.value.y),s:y.value.x,v:d(y.value.y)},v(T)},{throttle:()=>t.throttle});let ee=r(()=>new Ts(As({h:l(x.value.y),s:100,v:100})).HEX),E=r(()=>({backgroundColor:ee.value})),D=r(()=>({backgroundColor:new Ts(n.value||t.defaultValue).HEX,left:`${y.value.x}%`,top:`${y.value.y}%`})),k=r(()=>({backgroundColor:ee.value,top:`${x.value.y}%`}));return(e,n)=>(O(),S(w(wt),{as:w(t).as,"data-slot":`root`,class:u(o.value.root({class:[w(t).ui?.root,w(t).class]})),"data-disabled":_.value?!0:void 0},{default:F(()=>[P(`div`,{"data-slot":`picker`,class:u(o.value.picker({class:w(t).ui?.picker}))},[P(`div`,{ref_key:`selectorRef`,ref:p,"data-slot":`selector`,class:u(o.value.selector({class:w(t).ui?.selector})),style:b(E.value)},[P(`div`,{"data-slot":`selectorBackground`,class:u(o.value.selectorBackground({class:w(t).ui?.selectorBackground})),"data-color-picker-background":``},[P(`div`,{ref_key:`selectorThumbRef`,ref:m,"data-slot":`selectorThumb`,class:u(o.value.selectorThumb({class:w(t).ui?.selectorThumb})),style:b(D.value),"data-disabled":_.value?!0:void 0},null,14,Ds)],2)],6),P(`div`,{ref_key:`trackRef`,ref:h,"data-slot":`track`,class:u(o.value.track({class:w(t).ui?.track})),"data-color-picker-track":``},[P(`div`,{ref_key:`trackThumbRef`,ref:g,"data-slot":`trackThumb`,class:u(o.value.trackThumb({class:w(t).ui?.trackThumb})),style:b(k.value),"data-disabled":_.value?!0:void 0},null,14,Os)],2)],2)]),_:1},8,[`as`,`class`,`data-disabled`]))}},[[`__scopeId`,`data-v-9a8e9194`]]),Ms=A({__name:`Color`,props:{field:{},name:{}},setup(e){tn.debug(`name`,e.name);let{value:t}=Li(e.name),n=r(()=>({backgroundColor:t.value}));return(r,i)=>{let a=St,o=js,s=ot,c=ka,l=Ea;return O(),S(l,{label:e.field.label,icon:`i-carbon-color-palette`},{default:F(()=>[x(c,null,{content:F(()=>[x(o,{modelValue:w(t),"onUpdate:modelValue":i[0]||=e=>ze(t)?t.value=e:null,class:`p-2`},null,8,[`modelValue`]),x(s,{modelValue:w(t),"onUpdate:modelValue":i[1]||=e=>ze(t)?t.value=e:null,class:`flex-1`},null,8,[`modelValue`])]),default:F(()=>[x(a,{label:w(t)||`#FFFFFF`,color:`neutral`,variant:`outline`,block:``},{leading:F(()=>[P(`span`,{style:b(w(n)),class:`size-3 rounded-full`},null,4)]),_:1},8,[`label`])]),_:1})]),_:1},8,[`label`])}}}),Ns={slots:{base:[`relative group rounded-md inline-flex items-center disabled:cursor-not-allowed disabled:opacity-75`,`transition-colors`],leading:`absolute inset-y-0 start-0 flex items-center`,leadingIcon:`shrink-0 text-dimmed`,leadingAvatar:`shrink-0`,leadingAvatarSize:``,trailing:`absolute inset-y-0 end-0 flex items-center`,trailingIcon:`shrink-0 text-dimmed`,value:`truncate pointer-events-none`,placeholder:`truncate text-dimmed`,arrow:`fill-bg stroke-default`,content:`max-h-[min(15rem,var(--reka-select-content-available-height,15rem))] w-(--reka-select-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden origin-(--reka-select-content-transform-origin) pointer-events-auto flex flex-col`,viewport:`relative divide-y divide-default scroll-py-1 overflow-y-auto flex-1`,group:`p-1 isolate`,empty:`text-center text-muted`,label:`font-semibold text-highlighted`,separator:`-mx-1 my-1 h-px bg-border`,item:[`group relative w-full flex items-start select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50`,`transition-colors before:transition-colors`],itemLeadingIcon:[`shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default`,`transition-colors`],itemLeadingAvatar:`shrink-0`,itemLeadingAvatarSize:``,itemLeadingChip:`shrink-0`,itemLeadingChipSize:``,itemTrailing:`ms-auto inline-flex gap-1.5 items-center`,itemTrailingIcon:`shrink-0`,itemWrapper:`flex-1 flex flex-col min-w-0`,itemLabel:`truncate`,itemDescription:`truncate text-muted`},variants:{fieldGroup:{horizontal:`not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]`,vertical:`not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]`},size:{xs:{base:`px-2 py-1 text-xs gap-1`,leading:`ps-2`,trailing:`pe-2`,leadingIcon:`size-4`,leadingAvatarSize:`3xs`,trailingIcon:`size-4`,label:`p-1 text-[10px]/3 gap-1`,item:`p-1 text-xs gap-1`,itemLeadingIcon:`size-4`,itemLeadingAvatarSize:`3xs`,itemLeadingChip:`size-4`,itemLeadingChipSize:`sm`,itemTrailingIcon:`size-4`,empty:`p-2 text-xs`},sm:{base:`px-2.5 py-1.5 text-xs gap-1.5`,leading:`ps-2.5`,trailing:`pe-2.5`,leadingIcon:`size-4`,leadingAvatarSize:`3xs`,trailingIcon:`size-4`,label:`p-1.5 text-[10px]/3 gap-1.5`,item:`p-1.5 text-xs gap-1.5`,itemLeadingIcon:`size-4`,itemLeadingAvatarSize:`3xs`,itemLeadingChip:`size-4`,itemLeadingChipSize:`sm`,itemTrailingIcon:`size-4`,empty:`p-2.5 text-xs`},md:{base:`px-2.5 py-1.5 text-sm gap-1.5`,leading:`ps-2.5`,trailing:`pe-2.5`,leadingIcon:`size-5`,leadingAvatarSize:`2xs`,trailingIcon:`size-5`,label:`p-1.5 text-xs gap-1.5`,item:`p-1.5 text-sm gap-1.5`,itemLeadingIcon:`size-5`,itemLeadingAvatarSize:`2xs`,itemLeadingChip:`size-5`,itemLeadingChipSize:`md`,itemTrailingIcon:`size-5`,empty:`p-2.5 text-sm`},lg:{base:`px-3 py-2 text-sm gap-2`,leading:`ps-3`,trailing:`pe-3`,leadingIcon:`size-5`,leadingAvatarSize:`2xs`,trailingIcon:`size-5`,label:`p-2 text-xs gap-2`,item:`p-2 text-sm gap-2`,itemLeadingIcon:`size-5`,itemLeadingAvatarSize:`2xs`,itemLeadingChip:`size-5`,itemLeadingChipSize:`md`,itemTrailingIcon:`size-5`,empty:`p-3 text-sm`},xl:{base:`px-3 py-2 text-base gap-2`,leading:`ps-3`,trailing:`pe-3`,leadingIcon:`size-6`,leadingAvatarSize:`xs`,trailingIcon:`size-6`,label:`p-2 text-sm gap-2`,item:`p-2 text-base gap-2`,itemLeadingIcon:`size-6`,itemLeadingAvatarSize:`xs`,itemLeadingChip:`size-6`,itemLeadingChipSize:`lg`,itemTrailingIcon:`size-6`,empty:`p-3 text-base`}},variant:{outline:`text-highlighted bg-default ring ring-inset ring-accented hover:bg-elevated disabled:bg-default`,soft:`text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50`,subtle:`text-highlighted bg-elevated ring ring-inset ring-accented hover:bg-accented/75 disabled:bg-elevated`,ghost:`text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent`,none:`text-highlighted bg-transparent focus:outline-none`},color:{primary:``,secondary:``,success:``,info:``,warning:``,error:``,neutral:``},leading:{true:``},trailing:{true:``},loading:{true:``},highlight:{true:``},fixed:{false:``},type:{file:`file:me-1.5 file:font-medium file:text-muted file:outline-none`},position:{popper:{content:`data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in]`},"item-aligned":{content:``}},multiple:{true:``}},compoundVariants:[{color:`primary`,variant:[`outline`,`subtle`],class:`outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary`},{color:`secondary`,variant:[`outline`,`subtle`],class:`outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary`},{color:`success`,variant:[`outline`,`subtle`],class:`outline-success/25 focus-visible:outline-3 focus-visible:ring-success`},{color:`info`,variant:[`outline`,`subtle`],class:`outline-info/25 focus-visible:outline-3 focus-visible:ring-info`},{color:`warning`,variant:[`outline`,`subtle`],class:`outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning`},{color:`error`,variant:[`outline`,`subtle`],class:`outline-error/25 focus-visible:outline-3 focus-visible:ring-error`},{color:`primary`,variant:[`soft`,`ghost`],class:`outline-primary/25 focus-visible:outline-3`},{color:`secondary`,variant:[`soft`,`ghost`],class:`outline-secondary/25 focus-visible:outline-3`},{color:`success`,variant:[`soft`,`ghost`],class:`outline-success/25 focus-visible:outline-3`},{color:`info`,variant:[`soft`,`ghost`],class:`outline-info/25 focus-visible:outline-3`},{color:`warning`,variant:[`soft`,`ghost`],class:`outline-warning/25 focus-visible:outline-3`},{color:`error`,variant:[`soft`,`ghost`],class:`outline-error/25 focus-visible:outline-3`},{color:`primary`,highlight:!0,class:`ring ring-inset ring-primary`},{color:`secondary`,highlight:!0,class:`ring ring-inset ring-secondary`},{color:`success`,highlight:!0,class:`ring ring-inset ring-success`},{color:`info`,highlight:!0,class:`ring ring-inset ring-info`},{color:`warning`,highlight:!0,class:`ring ring-inset ring-warning`},{color:`error`,highlight:!0,class:`ring ring-inset ring-error`},{color:`neutral`,variant:[`outline`,`subtle`],class:`outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted`},{color:`neutral`,variant:[`soft`,`ghost`],class:`outline-inverted/25 focus-visible:outline-3`},{color:`neutral`,highlight:!0,class:`ring ring-inset ring-inverted`},{leading:!0,size:`xs`,class:`ps-7`},{leading:!0,size:`sm`,class:`ps-8`},{leading:!0,size:`md`,class:`ps-9`},{leading:!0,size:`lg`,class:`ps-10`},{leading:!0,size:`xl`,class:`ps-11`},{trailing:!0,size:`xs`,class:`pe-7`},{trailing:!0,size:`sm`,class:`pe-8`},{trailing:!0,size:`md`,class:`pe-9`},{trailing:!0,size:`lg`,class:`pe-10`},{trailing:!0,size:`xl`,class:`pe-11`},{loading:!0,leading:!0,class:{leadingIcon:`animate-spin`}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:`animate-spin`}},{fixed:!1,size:`xs`,class:`md:text-xs`},{fixed:!1,size:`sm`,class:`md:text-xs`},{fixed:!1,size:`md`,class:`md:text-sm`},{fixed:!1,size:`lg`,class:`md:text-sm`}],defaultVariants:{size:`md`,color:`primary`,variant:`outline`,position:`popper`}},Ps=Object.assign({inheritAttrs:!1},{__name:`Select`,props:{id:{type:String,required:!1},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},trailingIcon:{type:null,required:!1},selectedIcon:{type:null,required:!1},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},valueKey:{type:null,required:!1,default:`value`},labelKey:{type:null,required:!1,default:`label`},descriptionKey:{type:null,required:!1,default:`description`},items:{type:null,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},multiple:{type:Boolean,required:!1},highlight:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},class:{type:null,required:!1},ui:{type:Object,required:!1},open:{type:Boolean,required:!1},defaultOpen:{type:Boolean,required:!1},autocomplete:{type:String,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:[`change`,`blur`,`focus`,`update:modelValue`,`update:open`],setup(e,{expose:t,emit:n}){let i=e,o=n,c=ge(),f=lt(`select`,i),p=Ce(),m=ht(Fe(f,`open`,`defaultOpen`,`disabled`,`autocomplete`,`required`,`multiple`),o),_=Mt(we(()=>f.portal)),v=r(()=>f.content?.position??p.ui?.select?.defaultVariants?.position??Ns.defaultVariants?.position),y=we(()=>s(f.content,{side:`bottom`,sideOffset:8,collisionPadding:8,position:v.value})),b=we(()=>s(f.arrow,{rounded:!0})),{emitFormChange:C,emitFormInput:ee,emitFormBlur:E,emitFormFocus:A,size:te,color:j,id:ne,name:re,highlight:ie,disabled:ae,ariaAttrs:oe}=xt(i),{orientation:se,size:le}=vt(i),{isLeading:ue,isTrailing:de,leadingIconName:fe,trailingIconName:pe}=gt(we(()=>s(f,{trailingIcon:p.ui.icons.chevronDown}))),me=r(()=>le.value||te.value),he=r(()=>v.value===`item-aligned`),M=r(()=>Tt({extend:Tt(Ns),...p.ui?.select||{}})({color:j.value??f.color,variant:f.variant,size:me.value??f.size,loading:f.loading,highlight:ie.value??f.highlight,leading:ue.value||!!f.avatar||!!c.leading,trailing:de.value||!!c.trailing,fieldGroup:se.value,position:v.value,multiple:f.multiple})),ye=r(()=>f.items?.length?Oe(f.items)?f.items:[f.items]:[]),Se=r(()=>ye.value.flatMap(e=>e));function N(e){if(f.multiple&&Array.isArray(e)){let t=e.map(e=>be(Se.value,e,{labelKey:f.labelKey,valueKey:f.valueKey})).filter(e=>e!=null&&e!==``);return t.length>0?t.join(`, `):void 0}return be(Se.value,e,{labelKey:f.labelKey,valueKey:f.valueKey})}let Te=Ee(`triggerRef`);function De(){f.autofocus&&Te.value?.$el?.focus({focusVisible:!0})}ce(()=>{setTimeout(()=>{De()},f.autofocusDelay)});function ke(e){f.modelModifiers?.trim&&(typeof e==`string`||e==null)&&(e=e?.trim()??null),f.modelModifiers?.number&&(e=xe(e)),f.modelModifiers?.nullable&&(e??=null),f.modelModifiers?.optional&&!f.modelModifiers?.nullable&&e!==null&&(e??=void 0),o(`change`,new Event(`change`,{target:{value:e}})),C(),ee()}function Ae(e){e?(o(`focus`,new FocusEvent(`focus`)),A()):(o(`blur`,new FocusEvent(`blur`)),E())}function Me(e){return typeof e==`object`&&!!e}function Ne(e){e||Te.value?.$el?.dispatchEvent(new PointerEvent(`pointerdown`,{bubbles:!0,button:0}))}let Pe=Ee(`viewportRef`);return t({triggerRef:we(()=>Te.value?.$el),viewportRef:we(()=>{let e=Pe.value;return e&&typeof e==`object`&&`$el`in e?e.$el:e})}),(t,n)=>(O(),S(w(gn),d({name:w(re)},w(m),{autocomplete:w(f).autocomplete,disabled:w(ae),"default-value":w(f).defaultValue,"model-value":e.modelValue,"onUpdate:modelValue":ke,"onUpdate:open":Ae}),{default:F(({modelValue:e,open:n})=>[x(w(Vn),d({id:w(ne),ref_key:`triggerRef`,ref:Te,"data-slot":`base`,class:M.value.base({class:[w(f).ui?.base,w(f).class]})},{...t.$attrs,...w(oe)},{onClick:e=>Ne(n)}),{default:F(()=>[w(ue)||w(f).avatar||c.leading?(O(),D(`span`,{key:0,"data-slot":`leading`,class:u(M.value.leading({class:w(f).ui?.leading}))},[I(t.$slots,`leading`,{modelValue:e,open:n,ui:M.value},()=>[w(ue)&&w(fe)?(O(),S(_t,{key:0,name:w(fe),"data-slot":`leadingIcon`,class:u(M.value.leadingIcon({class:w(f).ui?.leadingIcon}))},null,8,[`name`,`class`])):w(f).avatar?(O(),S(Ct,d({key:1,size:w(f).ui?.itemLeadingAvatarSize||M.value.itemLeadingAvatarSize()},w(f).avatar,{"data-slot":`itemLeadingAvatar`,class:M.value.itemLeadingAvatar({class:w(f).ui?.itemLeadingAvatar})}),null,16,[`size`,`class`])):T(``,!0)])],2)):T(``,!0),(O(!0),D(l,null,ve([N(e)],r=>(O(),S(w(Hn),{key:r,"data-slot":r==null?`placeholder`:`value`,class:u(r==null?M.value.placeholder({class:w(f).ui?.placeholder}):M.value.value({class:w(f).ui?.value}))},{default:F(()=>[I(t.$slots,`default`,{modelValue:e,open:n,ui:M.value},()=>[g(k(r??w(f).placeholder??`\xA0`),1)])]),_:2},1032,[`data-slot`,`class`]))),128)),w(de)||c.trailing?(O(),D(`span`,{key:1,"data-slot":`trailing`,class:u(M.value.trailing({class:w(f).ui?.trailing}))},[I(t.$slots,`trailing`,{modelValue:e,open:n,ui:M.value},()=>[w(pe)?(O(),S(_t,{key:0,name:w(pe),"data-slot":`trailingIcon`,class:u(M.value.trailingIcon({class:w(f).ui?.trailingIcon}))},null,8,[`name`,`class`])):T(``,!0)])],2)):T(``,!0)]),_:2},1040,[`id`,`class`,`onClick`]),x(w(zn),h(a(w(_))),{default:F(()=>[x(w(bt),null,{default:F(()=>[x(w(kn),d({"data-slot":`content`,class:M.value.content({class:w(f).ui?.content})},y.value),{default:F(()=>[I(t.$slots,`content-top`),(O(),S(je(he.value?w(Un):`div`),{ref_key:`viewportRef`,ref:Pe,role:`presentation`,"data-slot":`viewport`,class:u(M.value.viewport({class:w(f).ui?.viewport}))},{default:F(()=>[(O(!0),D(l,null,ve(ye.value,(e,n)=>(O(),S(w(Mn),{key:`group-${n}`,"data-slot":`group`,class:u(M.value.group({class:w(f).ui?.group}))},{default:F(()=>[(O(!0),D(l,null,ve(e,(e,r)=>(O(),D(l,{key:`group-${n}-${r}`},[Me(e)&&e.type===`label`?(O(),S(w(Rn),{key:0,"data-slot":`label`,class:u(M.value.label({class:[w(f).ui?.label,e.ui?.label,e.class]}))},{default:F(()=>[g(k(w(_e)(e,w(f).labelKey)),1)]),_:2},1032,[`class`])):Me(e)&&e.type===`separator`?(O(),S(w(Bn),{key:1,"data-slot":`separator`,class:u(M.value.separator({class:[w(f).ui?.separator,e.ui?.separator,e.class]}))},null,8,[`class`])):(O(),S(w(Fn),{key:2,"data-slot":`item`,class:u(M.value.item({class:[w(f).ui?.item,Me(e)&&e.ui?.item,Me(e)&&e.class]})),disabled:Me(e)&&e.disabled,value:Me(e)?w(_e)(e,w(f).valueKey):e,onSelect:t=>Me(e)&&e.onSelect?.(t)},{default:F(()=>[I(t.$slots,`item`,{item:e,index:r,ui:M.value},()=>[I(t.$slots,`item-leading`,{item:e,index:r,ui:M.value},()=>[Me(e)&&e.icon?(O(),S(_t,{key:0,name:e.icon,"data-slot":`itemLeadingIcon`,class:u(M.value.itemLeadingIcon({class:[w(f).ui?.itemLeadingIcon,e.ui?.itemLeadingIcon]}))},null,8,[`name`,`class`])):Me(e)&&e.avatar?(O(),S(Ct,d({key:1,size:e.ui?.itemLeadingAvatarSize||w(f).ui?.itemLeadingAvatarSize||M.value.itemLeadingAvatarSize()},{ref_for:!0},e.avatar,{"data-slot":`itemLeadingAvatar`,class:M.value.itemLeadingAvatar({class:[w(f).ui?.itemLeadingAvatar,e.ui?.itemLeadingAvatar]})}),null,16,[`size`,`class`])):Me(e)&&e.chip?(O(),S(Et,d({key:2,size:e.ui?.itemLeadingChipSize||w(f).ui?.itemLeadingChipSize||M.value.itemLeadingChipSize(),inset:``,standalone:``},{ref_for:!0},e.chip,{"data-slot":`itemLeadingChip`,class:M.value.itemLeadingChip({class:[w(f).ui?.itemLeadingChip,e.ui?.itemLeadingChip]})}),null,16,[`size`,`class`])):T(``,!0)]),P(`span`,{"data-slot":`itemWrapper`,class:u(M.value.itemWrapper({class:[w(f).ui?.itemWrapper,Me(e)&&e.ui?.itemWrapper]}))},[x(w(Ln),{"data-slot":`itemLabel`,class:u(M.value.itemLabel({class:[w(f).ui?.itemLabel,Me(e)&&e.ui?.itemLabel]}))},{default:F(()=>[I(t.$slots,`item-label`,{item:e,index:r},()=>[g(k(Me(e)?w(_e)(e,w(f).labelKey):e),1)])]),_:2},1032,[`class`]),Me(e)&&(w(_e)(e,w(f).descriptionKey)||c[`item-description`])?(O(),D(`span`,{key:0,"data-slot":`itemDescription`,class:u(M.value.itemDescription({class:[w(f).ui?.itemDescription,Me(e)&&e.ui?.itemDescription]}))},[I(t.$slots,`item-description`,{item:e,index:r},()=>[g(k(w(_e)(e,w(f).descriptionKey)),1)])],2)):T(``,!0)],2),P(`span`,{"data-slot":`itemTrailing`,class:u(M.value.itemTrailing({class:[w(f).ui?.itemTrailing,Me(e)&&e.ui?.itemTrailing]}))},[I(t.$slots,`item-trailing`,{item:e,index:r,ui:M.value}),x(w(In),{"as-child":``},{default:F(()=>[x(_t,{name:w(f).selectedIcon||w(p).ui.icons.check,"data-slot":`itemTrailingIcon`,class:u(M.value.itemTrailingIcon({class:[w(f).ui?.itemTrailingIcon,Me(e)&&e.ui?.itemTrailingIcon]}))},null,8,[`name`,`class`])]),_:2},1024)],2)])]),_:2},1032,[`class`,`disabled`,`value`,`onSelect`]))],64))),128))]),_:2},1032,[`class`]))),128))]),_:3},8,[`class`])),I(t.$slots,`content-bottom`),w(f).arrow?(O(),S(w(En),d({key:0},b.value,{"data-slot":`arrow`,class:M.value.arrow({class:w(f).ui?.arrow})}),null,16,[`class`])):T(``,!0)]),_:3},16,[`class`])]),_:3})]),_:3},16)]),_:3},16,[`name`,`autocomplete`,`disabled`,`default-value`,`model-value`]))}}),Fs=A({__name:`Select`,props:{field:{},name:{}},setup(e){let t=nn();function n(){return e.name.includes(`.`)&&e.field.options?.alias?`${e.name.split(`.`).slice(0,-1).join(`.`)}.${e.field.options?.alias}`:e.field.options?.alias||e.name}let{value:i}=Li(n()),a=r(()=>e.field.options?.list?e.field.options.list===`pages`?t.dataCollections?.[t.lang]?.sitemap||[]:t.dataCollections?.[t.lang]?.[e.field.options.list]||[]:e.field.items);return(t,n)=>{let r=Ps,o=Ea;return O(),S(o,{label:e.field.label,icon:`i-jam-menu`},{default:F(()=>[x(r,{modelValue:w(i),"onUpdate:modelValue":n[0]||=e=>ze(i)?i.value=e:null,"value-key":`value`,class:`w-full`,"description-key":e.field.options?.list===`pages`?`url`:`caption`,items:w(a)},null,8,[`modelValue`,`description-key`,`items`])]),_:1},8,[`label`])}}}),Is={slots:{root:`relative inline-flex items-center`,base:[`rounded-md`,`transition-colors`],leading:`absolute inset-y-0 start-0 flex items-center`,leadingIcon:`shrink-0 text-dimmed`,leadingAvatar:`shrink-0`,leadingAvatarSize:``,trailing:`group absolute inset-y-0 end-0 flex items-center disabled:cursor-not-allowed disabled:opacity-75 focus:outline-none`,trailingIcon:`shrink-0 text-dimmed`,trailingClear:`p-0`,arrow:`fill-bg stroke-default`,content:`max-h-[min(15rem,var(--reka-combobox-content-available-height,15rem))] w-(--reka-combobox-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-combobox-content-transform-origin) pointer-events-auto flex flex-col`,viewport:`relative scroll-py-1 overflow-y-auto flex-1`,group:`p-1 isolate`,empty:`text-center text-muted`,label:`font-semibold text-highlighted`,separator:`-mx-1 my-1 h-px bg-border`,item:[`group relative w-full flex items-start gap-1.5 p-1.5 text-sm select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50`,`transition-colors before:transition-colors`],itemLeadingIcon:[`shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default`,`transition-colors`],itemLeadingAvatar:`shrink-0`,itemLeadingAvatarSize:``,itemLeadingChip:`shrink-0`,itemLeadingChipSize:``,itemTrailing:`ms-auto inline-flex gap-1.5 items-center`,itemTrailingIcon:`shrink-0`,itemWrapper:`flex-1 flex flex-col min-w-0`,itemLabel:`truncate`,itemDescription:`truncate text-muted`,tagsItem:`px-1.5 py-0.5 rounded-sm font-medium inline-flex items-center gap-0.5 ring ring-inset ring-accented bg-elevated text-default data-disabled:cursor-not-allowed data-disabled:opacity-75`,tagsItemText:`truncate`,tagsItemDelete:[`inline-flex items-center rounded-xs text-dimmed hover:text-default hover:bg-accented/75 disabled:pointer-events-none`,`transition-colors`],tagsItemDeleteIcon:`shrink-0`,tagsInput:`flex-1 border-0 bg-transparent placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75`},variants:{fieldGroup:{horizontal:{root:`group has-focus-visible:z-[1]`,base:`group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none`},vertical:{root:`group has-focus-visible:z-[1]`,base:`group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none`}},size:{xs:{base:`px-2 py-1 text-sm/4 gap-1`,leading:`ps-2`,trailing:`pe-2`,leadingIcon:`size-4`,leadingAvatarSize:`3xs`,trailingIcon:`size-4`,label:`p-1 text-[10px]/3 gap-1`,item:`p-1 text-xs gap-1`,itemLeadingIcon:`size-4`,itemLeadingAvatarSize:`3xs`,itemLeadingChip:`size-4`,itemLeadingChipSize:`sm`,itemTrailingIcon:`size-4`,tagsItem:`text-[10px]/3`,tagsItemDeleteIcon:`size-3`,empty:`p-2 text-xs`},sm:{base:`px-2.5 py-1.5 text-sm/4 gap-1.5`,leading:`ps-2.5`,trailing:`pe-2.5`,leadingIcon:`size-4`,leadingAvatarSize:`3xs`,trailingIcon:`size-4`,label:`p-1.5 text-[10px]/3 gap-1.5`,item:`p-1.5 text-xs gap-1.5`,itemLeadingIcon:`size-4`,itemLeadingAvatarSize:`3xs`,itemLeadingChip:`size-4`,itemLeadingChipSize:`sm`,itemTrailingIcon:`size-4`,tagsItem:`text-[10px]/3`,tagsItemDeleteIcon:`size-3`,empty:`p-2.5 text-xs`},md:{base:`px-2.5 py-1.5 text-base/5 gap-1.5`,leading:`ps-2.5`,trailing:`pe-2.5`,leadingIcon:`size-5`,leadingAvatarSize:`2xs`,trailingIcon:`size-5`,label:`p-1.5 text-xs gap-1.5`,item:`p-1.5 text-sm gap-1.5`,itemLeadingIcon:`size-5`,itemLeadingAvatarSize:`2xs`,itemLeadingChip:`size-5`,itemLeadingChipSize:`md`,itemTrailingIcon:`size-5`,tagsItem:`text-xs`,tagsItemDeleteIcon:`size-3.5`,empty:`p-2.5 text-sm`},lg:{base:`px-3 py-2 text-base/5 gap-2`,leading:`ps-3`,trailing:`pe-3`,leadingIcon:`size-5`,leadingAvatarSize:`2xs`,trailingIcon:`size-5`,label:`p-2 text-xs gap-2`,item:`p-2 text-sm gap-2`,itemLeadingIcon:`size-5`,itemLeadingAvatarSize:`2xs`,itemLeadingChip:`size-5`,itemLeadingChipSize:`md`,itemTrailingIcon:`size-5`,tagsItem:`text-xs`,tagsItemDeleteIcon:`size-3.5`,empty:`p-3 text-sm`},xl:{base:`px-3 py-2 text-base gap-2`,leading:`ps-3`,trailing:`pe-3`,leadingIcon:`size-6`,leadingAvatarSize:`xs`,trailingIcon:`size-6`,label:`p-2 text-sm gap-2`,item:`p-2 text-base gap-2`,itemLeadingIcon:`size-6`,itemLeadingAvatarSize:`xs`,itemLeadingChip:`size-6`,itemLeadingChipSize:`lg`,itemTrailingIcon:`size-6`,tagsItem:`text-sm`,tagsItemDeleteIcon:`size-4`,empty:`p-3 text-base`}},variant:{outline:`text-highlighted bg-default ring ring-inset ring-accented`,soft:`text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50`,subtle:`text-highlighted bg-elevated ring ring-inset ring-accented`,ghost:`text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent`,none:`text-highlighted bg-transparent focus:outline-none`},color:{primary:``,secondary:``,success:``,info:``,warning:``,error:``,neutral:``},leading:{true:``},trailing:{true:``},loading:{true:``},highlight:{true:``},fixed:{false:``},type:{file:`file:me-1.5 file:font-medium file:text-muted file:outline-none`},virtualize:{true:{viewport:`p-1 isolate`},false:{viewport:`divide-y divide-default`}},multiple:{true:{root:`flex-wrap`},false:{base:`w-full border-0 placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75`}}},compoundVariants:[{variant:`soft`,multiple:!0,class:`has-focus:bg-elevated has-focus-visible:outline-3`},{variant:`ghost`,multiple:!0,class:`has-focus:bg-elevated has-focus-visible:outline-3`},{color:`primary`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-primary`},{color:`secondary`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-secondary`},{color:`success`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-success`},{color:`info`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-info`},{color:`warning`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-warning`},{color:`error`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-error`},{color:`neutral`,multiple:!0,variant:[`outline`,`subtle`],class:`has-focus-visible:outline-3 has-focus-visible:ring-inverted`},{color:`primary`,variant:[`outline`,`subtle`],class:`outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary`},{color:`secondary`,variant:[`outline`,`subtle`],class:`outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary`},{color:`success`,variant:[`outline`,`subtle`],class:`outline-success/25 focus-visible:outline-3 focus-visible:ring-success`},{color:`info`,variant:[`outline`,`subtle`],class:`outline-info/25 focus-visible:outline-3 focus-visible:ring-info`},{color:`warning`,variant:[`outline`,`subtle`],class:`outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning`},{color:`error`,variant:[`outline`,`subtle`],class:`outline-error/25 focus-visible:outline-3 focus-visible:ring-error`},{color:`primary`,variant:[`soft`,`ghost`],class:`outline-primary/25 focus-visible:outline-3`},{color:`secondary`,variant:[`soft`,`ghost`],class:`outline-secondary/25 focus-visible:outline-3`},{color:`success`,variant:[`soft`,`ghost`],class:`outline-success/25 focus-visible:outline-3`},{color:`info`,variant:[`soft`,`ghost`],class:`outline-info/25 focus-visible:outline-3`},{color:`warning`,variant:[`soft`,`ghost`],class:`outline-warning/25 focus-visible:outline-3`},{color:`error`,variant:[`soft`,`ghost`],class:`outline-error/25 focus-visible:outline-3`},{color:`primary`,highlight:!0,class:`ring ring-inset ring-primary`},{color:`secondary`,highlight:!0,class:`ring ring-inset ring-secondary`},{color:`success`,highlight:!0,class:`ring ring-inset ring-success`},{color:`info`,highlight:!0,class:`ring ring-inset ring-info`},{color:`warning`,highlight:!0,class:`ring ring-inset ring-warning`},{color:`error`,highlight:!0,class:`ring ring-inset ring-error`},{color:`neutral`,variant:[`outline`,`subtle`],class:`outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted`},{color:`neutral`,variant:[`soft`,`ghost`],class:`outline-inverted/25 focus-visible:outline-3`},{color:`neutral`,highlight:!0,class:`ring ring-inset ring-inverted`},{leading:!0,size:`xs`,class:`ps-7`},{leading:!0,size:`sm`,class:`ps-8`},{leading:!0,size:`md`,class:`ps-9`},{leading:!0,size:`lg`,class:`ps-10`},{leading:!0,size:`xl`,class:`ps-11`},{trailing:!0,size:`xs`,class:`pe-7`},{trailing:!0,size:`sm`,class:`pe-8`},{trailing:!0,size:`md`,class:`pe-9`},{trailing:!0,size:`lg`,class:`pe-10`},{trailing:!0,size:`xl`,class:`pe-11`},{loading:!0,leading:!0,class:{leadingIcon:`animate-spin`}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:`animate-spin`}},{fixed:!1,size:`xs`,class:`md:text-xs`},{fixed:!1,size:`sm`,class:`md:text-xs`},{fixed:!1,size:`md`,class:`md:text-sm`},{fixed:!1,size:`lg`,class:`md:text-sm`}],defaultVariants:{size:`md`,color:`primary`,variant:`outline`}},Ls=Object.assign({inheritAttrs:!1},{__name:`InputMenu`,props:oe({as:{type:null,required:!1},id:{type:String,required:!1},type:{type:null,required:!1,default:`text`},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},trailingIcon:{type:null,required:!1},selectedIcon:{type:null,required:!1},deleteIcon:{type:null,required:!1},clear:{type:[Boolean,Object],required:!1},clearIcon:{type:null,required:!1},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},virtualize:{type:[Boolean,Object],required:!1,default:!1},valueKey:{type:null,required:!1},labelKey:{type:null,required:!1,default:`label`},descriptionKey:{type:null,required:!1,default:`description`},items:{type:null,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},multiple:{type:Boolean,required:!1},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},mode:{type:String,required:!1,default:`combobox`},createItem:{type:[Boolean,String,Object],required:!1},filterFields:{type:Array,required:!1},ignoreFilter:{type:Boolean,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},open:{type:Boolean,required:!1},defaultOpen:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},resetModelValueOnClear:{type:Boolean,required:!1,default:!0},highlightOnHover:{type:Boolean,required:!1},openOnClick:{type:Boolean,required:!1},openOnFocus:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},{searchTerm:{type:String,default:``},searchTermModifiers:{}}),emits:oe([`change`,`blur`,`focus`,`create`,`clear`,`highlight`,`remove-tag`,`update:modelValue`,`update:open`],[`update:searchTerm`]),setup(e,{expose:t,emit:n}){let i=e,o=n,c=ge(),f=lt(`inputMenu`,i),p=Me(e,`searchTerm`,{type:String,default:``}),{t:m}=Te(),_=Ce(),{filterGroups:y}=at(),b=r(()=>f.mode===`autocomplete`),E=Fe(f,`as`,`modelValue`,`defaultValue`,`open`,`defaultOpen`,`required`,`multiple`,`resetSearchTermOnBlur`,`resetSearchTermOnSelect`,`resetModelValueOnClear`,`highlightOnHover`,`openOnClick`,`openOnFocus`,`by`),A=De(E,`multiple`,`resetSearchTermOnSelect`,`resetModelValueOnClear`,`by`),te=ht(r(()=>b.value?A:E),o),j=r(()=>b.value?Ut:Bt),ie=Mt(we(()=>f.portal)),ae=we(()=>s(f.content,{side:`bottom`,sideOffset:8,collisionPadding:8,position:`popper`})),oe=we(()=>s(f.arrow,{rounded:!0})),se=r(()=>typeof f.clear==`object`?f.clear:{}),le=we(()=>f.virtualize?s(typeof f.virtualize==`boolean`?{}:f.virtualize,{estimateSize:Xt(Ye.value,Be.value||`md`,f.descriptionKey,!!c[`item-description`])}):!1),{emitFormBlur:ue,emitFormFocus:de,emitFormChange:fe,emitFormInput:pe,size:me,color:he,id:M,name:ye,highlight:Se,disabled:N,ariaAttrs:ke}=xt(i),{orientation:Ae,size:je}=vt(i),{isLeading:Ie,isTrailing:Le,leadingIconName:Re,trailingIconName:ze}=gt(we(()=>s(f,{trailingIcon:_.ui.icons.chevronDown}))),Be=r(()=>je.value||me.value),[Ve,He]=C(),[Ue,We]=C({props:{item:{type:[Object,String,Number,Boolean],required:!0},index:{type:Number,required:!1}}}),R=r(()=>Tt({extend:Tt(Is),..._.ui?.inputMenu||{}})({color:he.value??f.color,variant:f.variant,size:Be?.value??f.size,loading:f.loading,highlight:Se.value??f.highlight,fixed:f.fixed,leading:Ie.value||!!f.avatar||!!c.leading,trailing:Le.value||!!c.trailing,multiple:f.multiple,fieldGroup:Ae.value,virtualize:!!f.virtualize})),Ge=r(()=>qe.value.flatMap(e=>e));function Ke(e){return be(Ge.value,e,{labelKey:f.labelKey,valueKey:f.valueKey,by:f.by})??``}let qe=r(()=>f.items?.length?Oe(f.items)?f.items:[f.items]:[]),Je=r(()=>{if(f.ignoreFilter||!p.value)return qe.value;let e=Array.isArray(f.filterFields)?f.filterFields:[f.labelKey];return y(qe.value,p.value,{fields:e,isStructural:e=>dt(e)&&!!e.type&&[`label`,`separator`].includes(e.type)})}),Ye=r(()=>Je.value.flatMap(e=>e)),Xe=r(()=>{if(!f.createItem||!p.value)return!1;let e=f.valueKey?{[f.valueKey]:p.value}:p.value;return typeof f.createItem==`object`&&f.createItem.when===`always`||f.createItem===`always`?!Ye.value.find(t=>Ne(t,e,f.by??f.valueKey)):!Ye.value.length}),Ze=r(()=>typeof f.createItem==`object`?f.createItem.position:`bottom`),Qe=Ee(`inputRef`);function $e(){f.autofocus&&Qe.value?.$el?.focus()}ce(()=>{v(()=>{b.value?p.value=String(f.modelValue??f.defaultValue??``):p.value=``}),setTimeout(()=>{$e()},f.autofocusDelay)}),Pe(()=>f.modelValue,e=>{b.value&&(p.value=String(e??``))});function et(e){ee(f.modelValue)!==e&&(f.modelModifiers?.trim&&(typeof e==`string`||e==null)&&(e=e?.trim()??null),f.modelModifiers?.number&&(e=xe(e)),f.modelModifiers?.nullable&&(e??=null),f.modelModifiers?.optional&&!f.modelModifiers?.nullable&&e!==null&&(e??=void 0),o(`change`,new Event(`change`,{target:{value:e}})),fe(),pe(),b.value?p.value=String(e??``):f.resetSearchTermOnSelect&&(p.value=``))}function tt(e){b.value||(p.value=e)}function nt(e){o(`blur`,e),ue()}function rt(e){o(`focus`,e),de()}let it=L(!1);function ot(e){it.value=e;let t;e?(o(`focus`,new FocusEvent(`focus`)),de(),clearTimeout(t)):(o(`blur`,new FocusEvent(`blur`)),ue(),!b.value&&f.resetSearchTermOnBlur&&(t=setTimeout(()=>{p.value=``},100)))}function st(e,t){if(f.multiple){let n=t.filter(t=>!ne(t,e));o(`update:modelValue`,n),o(`remove-tag`,e),et(n)}}function ct(e){e.preventDefault(),e.stopPropagation(),o(`create`,p.value)}function ut(e,t){if(dt(t)){if(t.disabled){e.preventDefault();return}t.onSelect?.(e)}}function dt(e){return typeof e==`object`&&!!e}function ft(e){return f.multiple&&Array.isArray(e)?e.length===0:e==null||e===``}function pt(){o(`clear`)}let mt=Ee(`viewportRef`),yt=Ee(`comboboxRootRef`);return Pe(()=>f.items,async()=>{it.value&&(await v(),yt.value?.highlightFirstItem?.())},{flush:`post`}),t({inputRef:we(()=>Qe.value?.$el),viewportRef:we(()=>mt.value)}),(e,t)=>(O(),D(l,null,[x(w(Ve),null,{default:F(()=>[x(w(j).Item,{"data-slot":`item`,class:u(R.value.item({class:w(f).ui?.item})),value:p.value,onSelect:ct},{default:F(()=>[P(`span`,{"data-slot":`itemLabel`,class:u(R.value.itemLabel({class:w(f).ui?.itemLabel}))},[I(e.$slots,`create-item-label`,{item:p.value},()=>[g(k(w(m)(`inputMenu.create`,{label:p.value})),1)])],2)]),_:3},8,[`class`,`value`])]),_:3}),x(w(Ue),null,{default:F(({item:t,index:n})=>[dt(t)&&t.type===`label`?(O(),S(w(j).Label,{key:0,"data-slot":`label`,class:u(R.value.label({class:[w(f).ui?.label,t.ui?.label,t.class]}))},{default:F(()=>[g(k(w(_e)(t,w(f).labelKey)),1)]),_:2},1032,[`class`])):dt(t)&&t.type===`separator`?(O(),S(w(j).Separator,{key:1,"data-slot":`separator`,class:u(R.value.separator({class:[w(f).ui?.separator,t.ui?.separator,t.class]}))},null,8,[`class`])):(O(),S(w(j).Item,{key:2,"data-slot":`item`,class:u(R.value.item({class:[w(f).ui?.item,dt(t)&&t.ui?.item,dt(t)&&t.class]})),disabled:dt(t)&&t.disabled,value:w(f).valueKey&&dt(t)?w(_e)(t,w(f).valueKey):t,onSelect:e=>ut(e,t)},{default:F(()=>[I(e.$slots,`item`,{item:t,index:n,ui:R.value},()=>[I(e.$slots,`item-leading`,{item:t,index:n,ui:R.value},()=>[dt(t)&&t.icon?(O(),S(_t,{key:0,name:t.icon,"data-slot":`itemLeadingIcon`,class:u(R.value.itemLeadingIcon({class:[w(f).ui?.itemLeadingIcon,t.ui?.itemLeadingIcon]}))},null,8,[`name`,`class`])):dt(t)&&t.avatar?(O(),S(Ct,d({key:1,size:t.ui?.itemLeadingAvatarSize||w(f).ui?.itemLeadingAvatarSize||R.value.itemLeadingAvatarSize()},t.avatar,{"data-slot":`itemLeadingAvatar`,class:R.value.itemLeadingAvatar({class:[w(f).ui?.itemLeadingAvatar,t.ui?.itemLeadingAvatar]})}),null,16,[`size`,`class`])):dt(t)&&t.chip?(O(),S(Et,d({key:2,size:t.ui?.itemLeadingChipSize||w(f).ui?.itemLeadingChipSize||R.value.itemLeadingChipSize(),inset:``,standalone:``},t.chip,{"data-slot":`itemLeadingChip`,class:R.value.itemLeadingChip({class:[w(f).ui?.itemLeadingChip,t.ui?.itemLeadingChip]})}),null,16,[`size`,`class`])):T(``,!0)]),P(`span`,{"data-slot":`itemWrapper`,class:u(R.value.itemWrapper({class:[w(f).ui?.itemWrapper,dt(t)&&t.ui?.itemWrapper]}))},[P(`span`,{"data-slot":`itemLabel`,class:u(R.value.itemLabel({class:[w(f).ui?.itemLabel,dt(t)&&t.ui?.itemLabel]}))},[I(e.$slots,`item-label`,{item:t,index:n},()=>[g(k(dt(t)?w(_e)(t,w(f).labelKey):t),1)])],2),dt(t)&&(w(_e)(t,w(f).descriptionKey)||c[`item-description`])?(O(),D(`span`,{key:0,"data-slot":`itemDescription`,class:u(R.value.itemDescription({class:[w(f).ui?.itemDescription,dt(t)&&t.ui?.itemDescription]}))},[I(e.$slots,`item-description`,{item:t,index:n},()=>[g(k(w(_e)(t,w(f).descriptionKey)),1)])],2)):T(``,!0)],2),P(`span`,{"data-slot":`itemTrailing`,class:u(R.value.itemTrailing({class:[w(f).ui?.itemTrailing,dt(t)&&t.ui?.itemTrailing]}))},[I(e.$slots,`item-trailing`,{item:t,index:n,ui:R.value}),b.value?T(``,!0):(O(),S(w(j).ItemIndicator,{key:0,"as-child":``},{default:F(()=>[x(_t,{name:w(f).selectedIcon||w(_).ui.icons.check,"data-slot":`itemTrailingIcon`,class:u(R.value.itemTrailingIcon({class:[w(f).ui?.itemTrailingIcon,dt(t)&&t.ui?.itemTrailingIcon]}))},null,8,[`name`,`class`])]),_:2},1024))],2)])]),_:2},1032,[`class`,`disabled`,`value`,`onSelect`]))]),_:3}),x(w(j).Root,d({ref_key:`comboboxRootRef`,ref:yt},w(te),{name:w(ye),disabled:w(N),"data-slot":`root`,class:R.value.root({class:[w(f).ui?.root,w(f).class]}),"as-child":!!w(f).multiple&&!b.value,"ignore-filter":``,"onUpdate:modelValue":et,"onUpdate:open":ot}),{default:F(({modelValue:n,open:r})=>[x(w(j).Anchor,{"as-child":!w(f).multiple,"data-slot":`base`,class:u(R.value.base({class:w(f).ui?.base}))},{default:F(()=>[w(f).multiple&&!b.value?(O(),S(w(Kn),{key:0,"model-value":n,disabled:w(N),required:w(f).required,delimiter:``,"as-child":``,onBlur:nt,onFocus:rt,onRemoveTag:e=>st(e,n)},{default:F(({modelValue:n})=>[(O(!0),D(l,null,ve(n,(t,n)=>(O(),S(w(Xn),{key:n,value:t,"data-slot":`tagsItem`,class:u(R.value.tagsItem({class:[w(f).ui?.tagsItem,dt(t)&&t.ui?.tagsItem]}))},{default:F(()=>[x(w(Qn),{"data-slot":`tagsItemText`,class:u(R.value.tagsItemText({class:[w(f).ui?.tagsItemText,dt(t)&&t.ui?.tagsItemText]}))},{default:F(()=>[I(e.$slots,`tags-item-text`,{item:t,index:n},()=>[g(k(Ke(t)),1)])]),_:2},1032,[`class`]),x(w(Zn),{"data-slot":`tagsItemDelete`,class:u(R.value.tagsItemDelete({class:[w(f).ui?.tagsItemDelete,dt(t)&&t.ui?.tagsItemDelete]})),disabled:w(N)},{default:F(()=>[I(e.$slots,`tags-item-delete`,{item:t,index:n,ui:R.value},()=>[x(_t,{name:w(f).deleteIcon||w(_).ui.icons.close,"data-slot":`tagsItemDeleteIcon`,class:u(R.value.tagsItemDeleteIcon({class:[w(f).ui?.tagsItemDeleteIcon,dt(t)&&t.ui?.tagsItemDeleteIcon]}))},null,8,[`name`,`class`])])]),_:2},1032,[`class`,`disabled`])]),_:2},1032,[`value`,`class`]))),128)),x(w(j).Input,{modelValue:p.value,"onUpdate:modelValue":t[1]||=e=>p.value=e,"as-child":``},{default:F(()=>[x(w(qn),d({id:w(M),ref_key:`inputRef`,ref:Qe},{...e.$attrs,...w(ke)},{placeholder:w(f).placeholder,"data-slot":`tagsInput`,class:R.value.tagsInput({class:w(f).ui?.tagsInput}),onChange:t[0]||=re(()=>{},[`stop`])}),null,16,[`id`,`placeholder`,`class`])]),_:1},8,[`modelValue`])]),_:3},8,[`model-value`,`disabled`,`required`,`onRemoveTag`])):(O(),S(w(j).Input,d({key:1,id:w(M),ref_key:`inputRef`,ref:Qe},{...b.value?{}:{displayValue:Ke},...e.$attrs,...w(ke)},{type:w(f).type,placeholder:w(f).placeholder,required:w(f).required,onBlur:nt,onFocus:rt,onChange:t[2]||=re(()=>{},[`stop`]),"onUpdate:modelValue":tt}),null,16,[`id`,`type`,`placeholder`,`required`])),w(Ie)||w(f).avatar||c.leading?(O(),D(`span`,{key:2,"data-slot":`leading`,class:u(R.value.leading({class:w(f).ui?.leading}))},[I(e.$slots,`leading`,{modelValue:n,open:r,ui:R.value},()=>[w(Ie)&&w(Re)?(O(),S(_t,{key:0,name:w(Re),"data-slot":`leadingIcon`,class:u(R.value.leadingIcon({class:w(f).ui?.leadingIcon}))},null,8,[`name`,`class`])):w(f).avatar?(O(),S(Ct,d({key:1,size:w(f).ui?.itemLeadingAvatarSize||R.value.itemLeadingAvatarSize()},w(f).avatar,{"data-slot":`itemLeadingAvatar`,class:R.value.itemLeadingAvatar({class:w(f).ui?.itemLeadingAvatar})}),null,16,[`size`,`class`])):T(``,!0)])],2)):T(``,!0),w(Le)||c.trailing||w(f).clear?(O(),S(w(j).Trigger,{key:3,"data-slot":`trailing`,class:u(R.value.trailing({class:w(f).ui?.trailing}))},{default:F(()=>[I(e.$slots,`trailing`,{modelValue:n,open:r,ui:R.value},()=>[w(f).clear&&!ft(n)?(O(),S(w(j).Cancel,{key:0,"as-child":``},{default:F(()=>[x(St,d({as:`span`,icon:w(f).clearIcon||w(_).ui.icons.close,size:Be.value,variant:`link`,color:`neutral`,tabindex:`-1`},se.value,{"data-slot":`trailingClear`,class:R.value.trailingClear({class:w(f).ui?.trailingClear}),onClick:re(pt,[`stop`])}),null,16,[`icon`,`size`,`class`])]),_:1})):w(ze)?(O(),S(_t,{key:1,name:w(ze),"data-slot":`trailingIcon`,class:u(R.value.trailingIcon({class:w(f).ui?.trailingIcon}))},null,8,[`name`,`class`])):T(``,!0)])]),_:2},1032,[`class`])):T(``,!0)]),_:2},1032,[`as-child`,`class`]),x(w(j).Portal,h(a(w(ie))),{default:F(()=>[x(w(bt),null,{default:F(()=>[x(w(j).Content,d({"data-slot":`content`,class:R.value.content({class:w(f).ui?.content})},ae.value,{onFocusOutside:t[3]||=re(()=>{},[`prevent`])}),{default:F(()=>[I(e.$slots,`content-top`),x(w(j).Empty,{"data-slot":`empty`,class:u(R.value.empty({class:w(f).ui?.empty}))},{default:F(()=>[I(e.$slots,`empty`,{searchTerm:p.value},()=>[g(k(p.value?w(m)(`inputMenu.noMatch`,{searchTerm:p.value}):w(m)(`inputMenu.noData`)),1)])]),_:3},8,[`class`]),P(`div`,{ref_key:`viewportRef`,ref:mt,role:`presentation`,"data-slot":`viewport`,class:u(R.value.viewport({class:w(f).ui?.viewport}))},[w(f).virtualize?(O(),D(l,{key:0},[Xe.value&&Ze.value===`top`?(O(),S(w(He),{key:0})):T(``,!0),x(w(j).Virtualizer,d({options:Ye.value,"text-content":e=>dt(e)?w(_e)(e,w(f).labelKey):String(e)},le.value),{default:F(({option:e,virtualItem:t})=>[x(w(We),{item:e,index:t.index},null,8,[`item`,`index`])]),_:1},16,[`options`,`text-content`]),Xe.value&&Ze.value===`bottom`?(O(),S(w(He),{key:1})):T(``,!0)],64)):(O(),D(l,{key:1},[Xe.value&&Ze.value===`top`?(O(),S(w(j).Group,{key:0,"data-slot":`group`,class:u(R.value.group({class:w(f).ui?.group}))},{default:F(()=>[x(w(He))]),_:1},8,[`class`])):T(``,!0),(O(!0),D(l,null,ve(Je.value,(e,t)=>(O(),S(w(j).Group,{key:`group-${t}`,"data-slot":`group`,class:u(R.value.group({class:w(f).ui?.group}))},{default:F(()=>[(O(!0),D(l,null,ve(e,(e,n)=>(O(),S(w(We),{key:`group-${t}-${n}`,item:e,index:n},null,8,[`item`,`index`]))),128))]),_:2},1032,[`class`]))),128)),Xe.value&&Ze.value===`bottom`?(O(),S(w(j).Group,{key:1,"data-slot":`group`,class:u(R.value.group({class:w(f).ui?.group}))},{default:F(()=>[x(w(He))]),_:1},8,[`class`])):T(``,!0)],64))],2),I(e.$slots,`content-bottom`),w(f).arrow?(O(),S(w(j).Arrow,d({key:0},oe.value,{"data-slot":`arrow`,class:R.value.arrow({class:w(f).ui?.arrow})}),null,16,[`class`])):T(``,!0)]),_:3},16,[`class`])]),_:3})]),_:3},16)]),_:3},16,[`name`,`disabled`,`class`,`as-child`])],64))}}),Rs=A({__name:`Boolean`,props:{field:{},name:{}},setup(e){tn.debug(`name`,e.name);let{value:t}=Li(e.name,void 0,{initialValue:!1});return(n,r)=>{let i=Ls,a=Ea;return O(),S(a,{label:e.field.label,icon:`i-iconoir-check`},{default:F(()=>[x(i,{modelValue:w(t),"onUpdate:modelValue":r[0]||=e=>ze(t)?t.value=e:null,"value-key":`value`,items:[{value:!0,label:`Si`},{value:!1,label:`No`}]},null,8,[`modelValue`])]),_:1},8,[`label`])}}}),zs=A({__name:`MediaSelector`,props:{onlyImage:{type:Boolean},folder:{}},emits:[`close`],setup(e,{emit:t}){let n=t;return(t,r)=>{let i=qt;return O(),S(i,{ui:{content:`max-w-screen-lg`}},{content:F(()=>[x(on,{"only-image":e.onlyImage,"is-modal":``,folder:e.folder,onClose:r[0]||=e=>n(`close`,``),onSelect:r[1]||=e=>n(`close`,e)},null,8,[`only-image`,`folder`])]),_:1})}}}),Bs={class:`aspect-square checkerboard`},Vs=[`src`],Hs={key:0},Us=A({__name:`Image`,props:{field:{},name:{},modelValue:{}},setup(e){tn.debug(`image`,e.name,e.field.mediaFolder);let{value:t}=Li(e.name,void 0,{syncVModel:!0}),n=en(),r=nn(),i=an(),a=L(``),o=n.create(zs);function s(){return typeof t.value==`object`?t.value.src||``:t.value}function c(e){typeof t.value==`object`?t.value.src=e:t.value=e}let{executeImmediate:l}=y(async e=>{let t=e||s();if(!t)return;let n=r.getMediaFolder(t),o=await i.getMediaAsBlob(n);a.value=URL.createObjectURL(o)},null);async function u(){let t=await o.open({onlyImage:!0,folder:e.field.mediaFolder}).result;t&&(tn.debug(`result`,t),c(t),l(t))}return(n,r)=>{let i=ot,o=Ea;return O(),S(o,{label:e.field.label,icon:`i-lucide-image`},{default:F(()=>[P(`div`,{class:`aspect-square bg-gray-50 border-3 border-dashed border-transparent rounded hover:border-gray-400 max-w-[250px] mx-auto`,onClick:r[0]||=e=>u()},[P(`div`,Bs,[w(a)?(O(),D(`img`,{key:0,src:w(a),alt:``,class:`object-contain w-full h-full`},null,8,Vs)):T(``,!0)])]),typeof w(t)==`object`?(O(),D(`div`,Hs,[x(i,{modelValue:w(t).alt,"onUpdate:modelValue":r[1]||=e=>w(t).alt=e,placeholder:`Alt`},null,8,[`modelValue`]),x(i,{modelValue:w(t).title,"onUpdate:modelValue":r[2]||=e=>w(t).title=e,placeholder:`Title`},null,8,[`modelValue`]),x(i,{modelValue:w(t).rename,"onUpdate:modelValue":r[3]||=e=>w(t).rename=e,placeholder:`Rename`},null,8,[`modelValue`])])):T(``,!0)]),_:1},8,[`label`])}}});function Ws(e){this.content=e}Ws.prototype={constructor:Ws,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new Ws(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Ws(n)},addToStart:function(e,t){return new Ws([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Ws(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new Ws(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Ws.from(e),e.size?new Ws(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Ws.from(e),e.size?new Ws(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Ws.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Ws.from=function(e){if(e instanceof Ws)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Ws(t)};function Gs(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=Gs(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Ks(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=Ks(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var G=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.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 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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Gs(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ks(this,e,t,n)}findIndex(e){if(e==0)return Js(0,e);if(e==this.size)return Js(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Js(t+1,i):Js(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};G.empty=new G([],0);var qs={index:0,offset:0};function Js(e,t){return qs.index=e,qs.offset=t,qs}function Ys(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Ys(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Ys(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var Xs=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return 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&&Ys(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 RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}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(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};Xs.none=[];var Zs=class extends Error{},K=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=$s(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Qs(this.content,t+this.openStart,n+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(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(G.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};K.empty=new K(G.empty,0,0);function Qs(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Qs(a.content,t-i-1,n-i-1)))}function $s(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=$s(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function ec(e,t,n){if(n.openStart>e.depth)throw new Zs(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Zs(`Inconsistent open depths`);return tc(e,t,n,0)}function tc(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=tc(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return oc(a,cc(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return oc(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=lc(n,e);return oc(a,sc(e,i,o,t,r))}}function nc(e,t){if(!t.type.compatibleContent(e.type))throw new Zs(`Cannot join `+t.type.name+` onto `+e.type.name)}function rc(e,t,n){let r=e.node(n);return nc(r,t.node(n)),r}function ic(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function ac(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(ic(e.nodeAfter,r),a++));for(let e=a;e<o;e++)ic(i.child(e),r);t&&t.depth==n&&t.textOffset&&ic(t.nodeBefore,r)}function oc(e,t){return e.type.checkContent(t),e.copy(t)}function sc(e,t,n,r,i){let a=e.depth>i&&rc(e,t,i+1),o=r.depth>i&&rc(n,r,i+1),s=[];return ac(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(nc(a,o),ic(oc(a,sc(e,t,n,r,i+1)),s)):(a&&ic(oc(a,cc(e,t,i+1)),s),ac(t,n,i,s),o&&ic(oc(o,cc(n,r,i+1)),s)),ac(r,null,i,s),new G(s)}function cc(e,t,n){let r=[];return ac(null,e,n,r),e.depth>n&&ic(oc(rc(e,t,n+1),cc(e,t,n+1)),r),ac(t,null,n,r),new G(r)}function lc(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(G.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var uc=class e{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 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 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],r=e.child(t);return n?e.child(t).cut(n):r}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],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Xs.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].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 mc(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(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=pc.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else pc.set(t,r=new dc);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%fc,i}},dc=class{constructor(){this.elts=[],this.i=0}},fc=12,pc=new WeakMap,mc=class{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)}},hc=Object.create(null),gc=class e{constructor(e,t,n,r=Xs.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||G.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,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&Ys(this.attrs,t||e.defaultAttrs||hc)&&Xs.sameSet(this.marks,n||Xs.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}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 K.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new K(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return ec(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return uc.resolveCached(this,e)}resolveNoCache(e){return uc.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+`)`),vc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=G.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.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=Xs.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(!Xs.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.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(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=G.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};gc.prototype.text=void 0;var _c=class e extends gc{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):vc(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(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,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 vc(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var yc=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new bc(t,n);if(r.next==null)return e.empty;let i=xc(r);r.next&&r.err(`Unexpected trailing text`);let a=jc(Oc(i));return Mc(a,r),a}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 r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}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 r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return G.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+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 r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw 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 r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
2
|
-
`)}};yc.empty=new yc(!0);var bc=class{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 SyntaxError(e+` (in content expression '`+this.string+`')`)}};function xc(e){let t=[];do t.push(Sc(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Sc(e){let t=[];do t.push(Cc(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Cc(e){let t=Dc(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Tc(e,t);else break;return t}function wc(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Tc(e,t){let n=wc(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:wc(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Ec(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Dc(e){if(e.eat(`(`)){let t=xc(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Ec(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Oc(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function kc(e,t){return t-e}function Ac(e,t){let n=[];return r(t),n.sort(kc);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function jc(e){let t=Object.create(null);return n(Ac(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ac(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new yc(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(kc);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Mc(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Nc(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Pc(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Fc(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Ic(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new zc(e,r,t[r]);return n}var Lc=class e{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=Ic(e,n.attrs),this.defaultAttrs=Nc(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==yc.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:Pc(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new gc(this,this.computeAttrs(e),G.from(t),Xs.setFrom(n))}createChecked(e=null,t,n){return t=G.from(t),this.checkContent(t),new gc(this,this.computeAttrs(e),t,Xs.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=G.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(G.empty,!0);return i?new gc(this,e,t.append(i),Xs.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Fc(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||=e.slice(0,n);return t?t.length?t:Xs.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Rc(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var zc=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Rc(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Bc=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ic(e,r.attrs),this.excluded=null;let i=Nc(this.attrs);this.instance=i?new Xs(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Xs(this,Pc(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}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){Fc(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Vc=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=Ws.from(e.nodes),t.marks=Ws.from(e.marks||{}),this.nodes=Lc.compile(this.spec.nodes,this),this.marks=Bc.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=yc.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Hc(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Hc(this,n.split(` `))}this.nodeFromJSON=e=>gc.fromJSON(this,e),this.markFromJSON=e=>Xs.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Lc))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new _c(n,n.defaultAttrs,e,Xs.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Hc(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Uc(e){return e.tag!=null}function Wc(e){return e.style!=null}var Gc=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Uc(e))this.tags.push(e);else if(Wc(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new el(this,t,!1);return n.addAll(e,Xs.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new el(this,t,!0);return n.addAll(e,Xs.none,t.from,t.to),K.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(nl(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=rl(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=rl(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Kc={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},qc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jc={ol:!0,ul:!0},Yc=1,Xc=2,Zc=4;function Qc(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Yc:0)|(t===`full`?Xc:0)}var $c=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=Xs.none,this.match=i||(a&Zc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(G.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Yc)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=G.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(G.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&&!Kc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},el=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Qc(null,t.preserveWhitespace,0)|(n?Zc:0);i=r?new $c(r.type,r.attrs,Xs.none,!0,t.topMatch||r.type.contentMatch,a):n?new $c(null,null,Xs.none,!0,null,a):new $c(e.schema.topNodeType,null,Xs.none,!0,null,a),this.nodes=[i],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,r=this.top,i=r.options&Xc?`full`:this.localPreserveWS||(r.options&Yc)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Jc.hasOwnProperty(a)&&this.parser.normalizeLists&&tl(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:qc.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Kc.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
-
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=Xs.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):il(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Qc(e,i,a.options);a.options&Zc&&a.content.length==0&&(o|=Zc);let s=Xs.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):il(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new $c(e,t,s,r,null,o)),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;else this.localPreserveWS&&(this.nodes[t].options|=Yc);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 t=n.length-1;t>=0;t--)e+=n[t].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 r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(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 e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function tl(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Jc.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function nl(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function rl(e){let t={};for(let n in e)t[n]=e[n];return t}function il(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var al=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=sl(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=dl(sl(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&dl(sl(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return dl(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=ol(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return ol(e.marks)}};function ol(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function sl(e){return e.document||window.document}var cl=new WeakMap;function ll(e){let t=cl.get(e);return t===void 0&&cl.set(e,t=ul(e)),t}function ul(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function dl(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=ll(r))&&a.indexOf(t)>-1)throw 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&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=dl(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var fl=65535,pl=2**16;function ml(e,t){return e+t*pl}function hl(e){return e&fl}function gl(e){return(e-(e&fl))/pl}var _l=1,vl=2,yl=4,bl=8,xl=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&bl)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&yl)>0}},Sl=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=hl(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+gl(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 r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:ml(o/3,e-s),f=e==s?vl:e==u?_l:yl;return(t<0?e!=s:e!=u)&&(f|=bl),new xl(a,f,d)}r+=l-c}return n?e+r:new xl(e+r,0,null)}touches(e,t){let n=0,r=hl(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};Sl.empty=new Sl([]);var Cl=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),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 r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r: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.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}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 r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new xl(e,r,null)}},wl=Object.create(null),Tl=class{getMap(){return Sl.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=wl[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in wl)throw RangeError(`Duplicate use of step JSON ID `+e);return wl[e]=t,t.prototype.jsonID=e,t}},El=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Zs)return e.fail(t.message);throw t}}};function Dl(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Dl(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return G.fromArray(r)}var Ol=class e extends Tl{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),r=n.node(n.sharedDepth(this.to)),i=new K(Dl(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return El.fromReplace(e,this.from,this.to,i)}invert(){return new kl(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Tl.jsonID(`addMark`,Ol);var kl=class e extends Tl{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 K(Dl(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return El.fromReplace(e,this.from,this.to,n)}invert(){return new Ol(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Tl.jsonID(`removeMark`,kl);var Al=class e extends Tl{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return El.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return El.fromReplace(e,this.pos,this.pos+1,new K(G.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new jl(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Tl.jsonID(`addNodeMark`,Al);var jl=class e extends Tl{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return El.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return El.fromReplace(e,this.pos,this.pos+1,new K(G.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Al(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Tl.jsonID(`removeNodeMark`,jl);var Ml=class e extends Tl{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Pl(e,this.from,this.to)?El.fail(`Structure replace would overwrite content`):El.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Sl([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?K.empty:new K(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?K.empty:new K(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,K.fromJSON(t,n.slice),!!n.structure)}};Ml.MAP_BIAS=1,Tl.jsonID(`replace`,Ml);var Nl=class e extends Tl{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Pl(e,this.from,this.gapFrom)||Pl(e,this.gapTo,this.to)))return El.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return El.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?El.fromReplace(e,this.from,this.to,n):El.fail(`Content does not fit in gap`)}getMap(){return new Sl([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(t,n.slice),n.insert,!!n.structure)}};Tl.jsonID(`replaceAround`,Nl);function Pl(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Fl(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new kl(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Ol(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Il(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Bc){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new kl(t.from,t.to,t.style)))}function Ll(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Ml(s,l,K.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new kl(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new K(G.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Ml(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(G.empty,!0);e.replace(s,s,new K(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Rl(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function zl(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Rl(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Bl(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=G.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=G.from(r.node(e).copy(u)),d++):c--;let f=G.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=G.from(i.node(e).copy(f)),p++):l++;e.step(new Nl(c,l,o,s,new K(u.append(f),d,p),u.size-d,!0))}function Vl(e,t,n=null,r=e){let i=Ul(e,t),a=i&&Wl(r,t);return a?i.map(Hl).concat({type:t,attrs:n}).concat(a.map(Hl)):null}function Hl(e){return{type:e,attrs:null}}function Ul(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Wl(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Gl(e,t,n){let r=G.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=G.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Nl(i,a,i,a,new K(r,0,0),n.length,!0))}function Kl(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Yl(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Jl(e,t,n,a),Ll(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Nl(c,l,c+1,l-1,new K(G.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&ql(e,t,n,a),!1}})}function ql(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Jl(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
5
|
-
`))}})}function Yl(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Xl(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Nl(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new K(G.from(o),0,0),1,!0))}function Zl(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<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 e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Ql(e,t,n=1,r){let i=e.doc.resolve(t),a=G.empty,o=G.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=G.from(i.node(e).copy(a));let t=r&&r[s];o=G.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Ml(t,t,new K(a.append(o),n,n),!0))}function $l(e,t){let n=e.resolve(t),r=n.index();return tu(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function eu(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function tu(e,t){return!!(e&&t&&!e.isLeaf&&eu(e,t))}function nu(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&tu(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function ru(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Jl(e,r.node(),r.before(),s)}o.inlineContent&&Ll(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Ml(l,c.map(t+n,-1),K.empty,!0)),r===!0){let t=e.doc.resolve(l);ql(e,t.node(),t.before(),e.steps.length)}return e}function iu(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function au(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function ou(e,t,n=t,r=K.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return su(i,a,r)?new Ml(t,n,r):new cu(i,a,r).fit()}function su(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var cu=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=G.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=G.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new K(i,a,o);return e>-1?new Nl(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Ml(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=du(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(G.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=du(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new K(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=du(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new K(lu(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new K(lu(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(fu(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=uu(this.placed,t,G.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?K.empty:new K(lu(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new K(lu(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!pu(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,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=pu(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=pu(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?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=uu(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=uu(this.placed,this.depth,G.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(G.empty,!0);e.childCount&&(this.placed=uu(this.placed,this.frontier.length,e))}};function lu(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(lu(e.firstChild.content,t-1,n)))}function uu(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(uu(e.lastChild.content,t-1,n)))}function du(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function fu(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,fu(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(G.empty,!0)))),e.copy(r)}function pu(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!mu(n,a.content,o)?s:null}function mu(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function hu(e){return e.spec.defining||e.spec.definingForContent}function gu(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(su(i,a,r))return e.step(new Ml(t,n,r));let o=bu(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=hu(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new K(_u(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function _u(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(_u(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(G.empty,!0))}return e}function vu(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=iu(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new K(G.from(r),0,0))}function yu(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=bu(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function bu(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var xu=class e extends Tl{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 El.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return El.fromReplace(e,this.pos,this.pos+1,new K(G.from(r),0,+!t.isLeaf))}getMap(){return Sl.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};Tl.jsonID(`attr`,xu);var Su=class e extends Tl{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return El.ok(n)}getMap(){return Sl.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};Tl.jsonID(`docAttr`,Su);var Cu=class extends Error{};Cu=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Cu.prototype=Object.create(Error.prototype),Cu.prototype.constructor=Cu,Cu.prototype.name=`TransformError`;var wu=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Cl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Cu(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}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}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=K.empty){let r=ou(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new K(G.from(n),0,0))}delete(e,t){return this.replace(e,t,K.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return gu(this,e,t,n),this}replaceRangeWith(e,t,n){return vu(this,e,t,n),this}deleteRange(e,t){return yu(this,e,t),this}lift(e,t){return Bl(this,e,t),this}join(e,t=1){return ru(this,e,t),this}wrap(e,t){return Gl(this,e,t),this}setBlockType(e,t=e,n,r=null){return Kl(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Xl(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new xu(e,t,n)),this}setDocAttribute(e,t){return this.step(new Su(e,t)),this}addNodeMark(e,t){return this.step(new Al(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof Xs)t.isInSet(n.marks)&&this.step(new jl(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new jl(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Ql(this,e,t,n),this}addMark(e,t,n){return Fl(this,e,t,n),this}removeMark(e,t,n){return Il(this,e,t,n),this}clearIncompatible(e,t,n){return Ll(this,e,t,n),this}},Tu=Object.create(null),q=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Eu(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=K.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?K.empty:t),o==0&&Pu(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Pu(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new J(e):Nu(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Nu(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Nu(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ju(e.node(0))}static atStart(e){return Nu(e,e,0,0,1)||new ju(e)}static atEnd(e){return Nu(e,e,e.content.size,e.childCount,-1)||new ju(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Tu[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Tu)throw RangeError(`Duplicate use of selection JSON ID `+e);return Tu[e]=t,t.prototype.jsonID=e,t}getBookmark(){return J.between(this.$anchor,this.$head).getBookmark()}};q.prototype.visible=!0;var Eu=class{constructor(e,t){this.$from=e,this.$to=t}},Du=!1;function Ou(e){!Du&&!e.parent.inlineContent&&(Du=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var J=class e extends q{constructor(e,t=e){Ou(e),Ou(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=K.empty){if(super.replace(e,t),t==K.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ku(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(e)n=e.$head;else return q.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(q.findFrom(t,-r,!0)||q.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};q.jsonID(`text`,J);var ku=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return J.between(e.resolve(this.anchor),e.resolve(this.head))}},Y=class e extends q{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?q.near(a):new e(a)}content(){return new K(G.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new Au(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Y.prototype.visible=!1,q.jsonID(`node`,Y);var Au=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new ku(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Y.isSelectable(n)?new Y(t):q.near(t)}},ju=class e extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=K.empty){if(t==K.empty){e.delete(0,e.doc.content.size);let t=q.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Mu}};q.jsonID(`all`,ju);var Mu={map(){return this},resolve(e){return new ju(e)}};function Nu(e,t,n,r,i,a=!1){if(t.inlineContent)return J.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Nu(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Y.isSelectable(r))return Y.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Pu(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Ml||i instanceof Nl))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(q.near(e.doc.resolve(o),n))}var Fu=1,Iu=2,Lu=4,Ru=class extends wu{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 RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Fu)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Fu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Iu,this}ensureMarks(e){return Xs.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&Iu)>0}addStep(e,t){super.addStep(e,t),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)||Xs.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(q.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|=Lu,this}get scrolledIntoView(){return(this.updated&Lu)>0}};function zu(e,t){return!t||!e?e:e.bind(t)}var Bu=class{constructor(e,t,n){this.name=e,this.init=zu(t.init,n),this.apply=zu(t.apply,n)}},Vu=[new Bu(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Bu(`selection`,{init(e,t){return e.selection||q.atStart(t.doc)},apply(e){return e.selection}}),new Bu(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Bu(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Hu=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Vu.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Bu(e.key,e.spec.state,e))})}},Uu=class e{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 t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new Ru(this)}static create(t){let n=new Hu(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new Hu(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Hu(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=gc.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=q.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function Wu(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=Wu(i,t,{})),n[r]=i}return n}var Gu=class{constructor(e){this.spec=e,this.props={},e.props&&Wu(e.props,this,this.props),this.key=e.key?e.key.key:qu(`plugin`)}getState(e){return e[this.key]}},Ku=Object.create(null);function qu(e){return e in Ku?e+`$`+ ++Ku[e]:(Ku[e]=0,e+`$`)}var Ju=class{constructor(e=`key`){this.key=qu(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Yu=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Xu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Zu=(e,t,n)=>{let r=Xu(e,n);if(!r)return!1;let i=rd(r);if(!i){let n=r.blockRange(),i=n&&zl(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(xd(e,i,t,-1))return!0;if(r.parent.content.size==0&&(td(a,`end`)||Y.isSelectable(a)))for(let n=r.depth;;n--){let o=ou(e.doc,r.before(n),r.after(n),K.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(td(a,`end`)?q.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Y.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Qu=(e,t,n)=>{let r=Xu(e,n);if(!r)return!1;let i=rd(r);return i?ed(e,i,t):!1},$u=(e,t,n)=>{let r=id(e,n);if(!r)return!1;let i=sd(r);return i?ed(e,i,t):!1};function ed(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=ou(e.doc,i,o,K.empty);if(!s||s.from!=i||s instanceof Ml&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(J.create(t.doc,i)),n(t.scrollIntoView())}return!0}function td(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var nd=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=rd(r)}let o=a&&a.nodeBefore;return!o||!Y.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Y.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function rd(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function id(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var ad=(e,t,n)=>{let r=id(e,n);if(!r)return!1;let i=sd(r);if(!i)return!1;let a=i.nodeAfter;if(xd(e,i,t,1))return!0;if(r.parent.content.size==0&&(td(a,`start`)||Y.isSelectable(a))){let n=ou(e.doc,r.before(),r.after(),K.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(td(a,`start`)?q.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Y.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},od=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=sd(r)}let o=a&&a.nodeAfter;return!o||!Y.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Y.create(e.doc,a.pos)).scrollIntoView()),!0)};function sd(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var cd=(e,t)=>{let n=e.selection,r=n instanceof Y,i;if(r){if(n.node.isTextblock||!$l(e.doc,n.from))return!1;i=n.from}else if(i=nu(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Y.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},ld=(e,t)=>{let n=e.selection,r;if(n instanceof Y){if(n.node.isTextblock||!$l(e.doc,n.to))return!1;r=n.to}else if(r=nu(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},ud=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&zl(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},dd=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
6
|
-
`).scrollIntoView()),!0)};function fd(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var pd=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=fd(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(q.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},md=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof ju||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=fd(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(J.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},hd=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Zl(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&zl(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function gd(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Y&&t.selection.node.isBlock)return!r.parentOffset||!Zl(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=fd(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof J||t.selection instanceof ju)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Zl(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,Zl(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var _d=gd(),vd=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Y.create(e.doc,i))),!0)},yd=(e,t)=>(t&&t(e.tr.setSelection(new ju(e.doc))),!0);function bd(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||$l(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function xd(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&bd(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=G.empty;for(let e=o.length-1;e>=0;e--)s=G.from(o[e].create(null,s));s=G.from(i.copy(s));let c=e.tr.step(new Nl(t.pos-1,r,t.pos,r,new K(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&$l(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:q.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&zl(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&td(a,`start`,!0)&&td(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=G.empty;for(let e=o.length-1;e>=0;e--)r=G.from(o[e].copy(r));n(e.tr.step(new Nl(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new K(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Sd(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(J.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var Cd=Sd(-1),wd=Sd(1);function Td(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Vl(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function Ed(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function Dd(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Od=Dd(Yu,Zu,nd),kd=Dd(Yu,ad,od),Ad={Enter:Dd(dd,md,hd,_d),"Mod-Enter":pd,Backspace:Od,"Mod-Backspace":Od,"Shift-Backspace":Od,Delete:kd,"Mod-Delete":kd,"Mod-a":yd},jd={"Ctrl-h":Ad.Backspace,"Alt-Backspace":Ad[`Mod-Backspace`],"Ctrl-d":Ad.Delete,"Ctrl-Alt-Backspace":Ad[`Mod-Delete`],"Alt-Delete":Ad[`Mod-Delete`],"Alt-d":Ad[`Mod-Delete`],"Ctrl-a":Cd,"Ctrl-e":wd};for(let e in Ad)jd[e]=Ad[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function Md(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return Nd(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function Nd(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new mc(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new mc(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=Vl(a,n,r,t);return s?(e&&Pd(e,t,s,i,n),!0):!1}function Pd(e,t,n,r,i){let a=G.empty;for(let e=n.length-1;e>=0;e--)a=G.from(n[e].type.create(n[e].attrs,a));e.step(new Nl(t.start-(r?2:0),t.end,t.start,t.end,new K(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&Zl(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function Fd(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?Id(t,n,e,a):Ld(t,n,a):!0:!1}}function Id(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Nl(a-1,o,a,o,new K(G.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new mc(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=zl(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return $l(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function Ld(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?G.empty:G.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Nl(d-+!!s,f+ +!!c,d+1,f-1,new K((s?G.empty:G.from(i.copy(G.empty))).append(c?G.empty:G.from(i.copy(G.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Rd(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=G.from(r?e.create():null),o=new K(G.from(e.create(null,G.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Nl(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var zd=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Bd=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Vd=null,Hd=function(e,t,n){let r=Vd||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ud=function(){Vd=null},Wd=function(e,t,n,r){return n&&(Kd(e,t,n,r,-1)||Kd(e,t,n,r,1))},Gd=/^(img|br|input|textarea|hr)$/i;function Kd(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:qd(e))){let n=e.parentNode;if(!n||n.nodeType!=1||Zd(e)||Gd.test(e.nodeName)||e.contentEditable==`false`)return!1;t=zd(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?qd(e):0}else return!1}}function qd(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Jd(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=qd(e)}else if(e.parentNode&&!Zd(e))t=zd(e),e=e.parentNode;else return null}}function Yd(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Zd(e))t=zd(e)+1,e=e.parentNode;else return null}}function Xd(e,t,n){for(let r=t==0,i=t==qd(e);r||i;){if(e==n)return!0;let t=zd(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==qd(e)}}function Zd(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Qd=function(e){return e.focusNode&&Wd(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function $d(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function ef(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function tf(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(qd(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(qd(r.startContainer),r.startOffset)}}}var nf=typeof navigator<`u`?navigator:null,rf=typeof document<`u`?document:null,af=nf&&nf.userAgent||``,of=/Edge\/(\d+)/.exec(af),sf=/MSIE \d/.exec(af),cf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(af),lf=!!(sf||cf||of),uf=sf?document.documentMode:cf?+cf[1]:of?+of[1]:0,df=!lf&&/gecko\/(\d+)/i.test(af);df&&+(/Firefox\/(\d+)/.exec(af)||[0,0])[1];var ff=!lf&&/Chrome\/(\d+)/.exec(af),pf=!!ff,mf=ff?+ff[1]:0,hf=!lf&&!!nf&&/Apple Computer/.test(nf.vendor),gf=hf&&(/Mobile\/\w+/.test(af)||!!nf&&nf.maxTouchPoints>2),_f=gf||(nf?/Mac/.test(nf.platform):!1),vf=nf?/Win/.test(nf.platform):!1,yf=/Android \d/.test(af),bf=!!rf&&`webkitFontSmoothing`in rf.documentElement.style,xf=bf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Sf(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Cf(e,t){return typeof e==`number`?e:e[t]}function wf(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Tf(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Bd(o);continue}let e=o,n=e==a.body,s=n?Sf(a):wf(e),c=0,l=0;if(t.top<s.top+Cf(r,`top`)?l=-(s.top-t.top+Cf(i,`top`)):t.bottom>s.bottom-Cf(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+Cf(i,`top`)-s.top:t.bottom-s.bottom+Cf(i,`bottom`)),t.left<s.left+Cf(r,`left`)?c=-(s.left-t.left+Cf(i,`left`)):t.right>s.right-Cf(r,`right`)&&(c=t.right-s.right+Cf(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Bd(o)}}function Ef(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:Df(e.dom)}}function Df(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Bd(r));return t}function Of({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;kf(n,r==0?0:r-t)}function kf(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var Af=null;function jf(e){if(e.setActive)return e.setActive();if(Af)return e.focus(Af);let t=Df(e);e.focus(Af==null?{get preventScroll(){return Af={preventScroll:!0},!0}}:void 0),Af||(Af=!1,kf(t,0))}function Mf(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=Hd(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?Nf(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:Mf(n,i)}function Nf(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=Vf(r,1);if(n.top!=n.bottom&&Pf(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function Pf(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ff(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function If(e,t,n){let{node:r,offset:i}=Mf(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Lf(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function Rf(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Pf(t,i))return Rf(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function zf(e,t){let n=e.dom.ownerDocument,r,i=0,a=tf(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!Pf(t,n)||(o=Rf(e.dom,t,n),!o))return null}if(hf)for(let e=o;r&&e;e=Bd(e))e.draggable&&(r=void 0);if(o=Ff(o,t),r){if(df&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;bf&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=Lf(e,r,i,t))}s??=If(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function Bf(e){return e.top<e.bottom||e.left<e.right}function Vf(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Bf(e))return e}return Array.prototype.find.call(n,Bf)||e.getBoundingClientRect()}var Hf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Uf(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=bf||df;if(r.nodeType==3)if(o&&(Hf.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=Vf(Hd(r,i,i),n);if(df&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Vf(Hd(r,i-1,i-1),-1);if(t.top==e.top){let n=Vf(Hd(r,i,i+1),-1);if(n.top!=e.top)return Wf(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Wf(Vf(Hd(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==qd(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return Gf(e.getBoundingClientRect(),!1)}if(a==null&&i<qd(r)){let e=r.childNodes[i];if(e.nodeType==1)return Gf(e.getBoundingClientRect(),!0)}return Gf(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==qd(r))){let e=r.childNodes[i-1],t=e.nodeType==3?Hd(e,qd(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Wf(Vf(t,1),!1)}if(a==null&&i<qd(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?Hd(e,0,+!o):e.nodeType==1?e:null:null;if(t)return Wf(Vf(t,-1),!0)}return Wf(Vf(r.nodeType==3?Hd(r):r,-n),n>=0)}function Wf(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Gf(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Kf(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function qf(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Kf(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Uf(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=Hd(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Jf=/[\u0590-\u08ac]/;function Yf(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Jf.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Kf(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Xf=null,Zf=null,Qf=!1;function $f(e,t,n){return Xf==t&&Zf==n?Qf:(Xf=t,Zf=n,Qf=n==`up`||n==`down`?qf(e,t,n):Yf(e,t,n))}var ep=0,tp=1,np=2,rp=3,ip=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=ep,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 r=this.children[t];if(r==e)return n;n+=r.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 n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>zd(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof dp){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof ap&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?zd(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?zd(e.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 r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=zd(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=zd(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}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 RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((df||hf)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
|
|
7
|
-
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:zd(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(df&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&hf)&&Wd(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Wd(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&df)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}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,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?np:tp,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=rp:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?np:rp}n=a}this.dirty=np}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?np:tp;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},ap=class extends ip{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==ep&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},op=class extends ip{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},sp=class e extends ip{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=al.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&rp||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=rp&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ep){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=ep}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=Op(a,n,o,r)),t>0&&(a=Op(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},cp=class e extends ip{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=al.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=yp(u,r,n),l?c=new fp(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new up(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,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=()=>G.empty)}return e}matchesNode(e,t,n){return this.dirty==ep&&e.eq(this.node)&&bp(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new Sp(this,a&&a.node,e);Tp(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?Xs.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==np)&&(a&&this.protectLocalComposition(e,a),pp(this.contentDOM,this.children,e),gf&&Ep(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof J)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=Dp(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new op(this,i,t,r);e.input.compositionNodes.push(a),this.children=Op(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==rp||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=ep}updateOuterDeco(e){if(bp(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=_p(this.dom,this.nodeDOM,gp(this.outerDeco,this.node,t),gp(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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function lp(e,t,n,r,i){yp(r,t,e);let a=new cp(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var up=class e extends cp{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,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,r){return this.dirty==rp||this.dirty!=ep&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ep||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=ep,!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(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=rp)}get domAtom(){return!1}isText(e){return this.node.text==e}},dp=class extends ip{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ep&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},fp=class extends cp{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==rp)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}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 pp(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=xp(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof sp){let t=r?r.previousSibling:e.lastChild;pp(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=xp(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var mp=function(e){e&&(this.nodeName=e)};mp.prototype=Object.create(null);var hp=[new mp];function gp(e,t,n){if(e.length==0)return hp;let r=n?hp[0]:new mp,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new mp(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new mp(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function _p(e,t,n,r){if(n==hp&&r==hp)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=hp[0],i=t)}vp(i,o||hp[0],a)}return i}function vp(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function yp(e,t,n){return _p(e,e,hp,gp(t,n,e.nodeType!=1))}function bp(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function xp(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Sp=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Cp(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,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=ep,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=sp.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==rp&&a.dom==a.contentDOM&&(a.dirty=np),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof cp){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=rp&&bp(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=np,u.updateChildren(r,a+1),u.dirty=ep),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!bp(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=cp.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=cp.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new ap(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof sp;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof up)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((hf||pf)&&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 r=new dp(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function Cp(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof sp)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function wp(e,t){return e.type.side-t.type.side}function Tp(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(wp);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function Ep(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function Dp(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function Op(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function kp(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Qd(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Y.isSelectable(e)&&i.parent&&!(e.isInline&&Xd(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Y(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Bp(e,u,s,n)}return l}function Ap(e){return e.editable?e.hasFocus():Hp(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function jp(e,t=!1){let n=e.state.selection;if(Rp(e,n),Ap(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&pf){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Wd(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Lp(e);else{let{anchor:r,head:i}=n,a,o;Mp&&!(n instanceof J)&&(n.$from.parent.inlineContent||(a=Np(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Np(e,n.to))),e.docView.setSelection(r,i,e,t),Mp&&(a&&Fp(a),o&&Fp(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&Ip(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var Mp=hf||pf&&mf<63;function Np(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(hf&&i&&i.contentEditable==`false`)return Pp(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return Pp(i);if(a)return Pp(a)}}function Pp(e){return e.contentEditable=`true`,hf&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Fp(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function Ip(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!Ap(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Lp(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,zd(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&lf&&uf<=11&&(n.disabled=!0,n.disabled=!1)}function Rp(e,t){if(t instanceof Y){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(zp(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else zp(e)}function zp(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Bp(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||J.between(t,n,r)}function Vp(e){return e.editable&&!e.hasFocus()?!1:Hp(e)}function Hp(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Up(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Wd(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Wp(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&q.findFrom(a,t)}function Gp(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Kp(e,t,n){let r=e.state.selection;if(r instanceof J){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Gp(e,new J(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Wp(e.state,t);return n&&n instanceof Y?Gp(e,n):!1}else if(!(_f&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Y.isSelectable(i)?Gp(e,new Y(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):bf?Gp(e,new J(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Y&&r.node.isInline)return Gp(e,new J(t>0?r.$to:r.$from));else{let n=Wp(e.state,t);return n?Gp(e,n):!1}}function qp(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Jp(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Yp(e,t){return t<0?Xp(e):Zp(e)}function Xp(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(df&&n.nodeType==1&&r<qp(n)&&Jp(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Jp(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Qp(n))break;else{let t=n.previousSibling;for(;t&&Jp(t,-1);)i=n.parentNode,a=zd(t),t=t.previousSibling;if(t)n=t,r=qp(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?tm(e,n,r):i&&tm(e,i,a)}function Zp(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=qp(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Jp(e,1))a=n,o=++r;else break}else if(Qp(n))break;else{let t=n.nextSibling;for(;t&&Jp(t,1);)a=t.parentNode,o=zd(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=qp(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&tm(e,a,o)}function Qp(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function $p(e,t){for(;e&&t==e.childNodes.length&&!Zd(e);)t=zd(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function em(e,t){for(;e&&!t&&!Zd(e);)t=zd(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function tm(e,t,n){if(t.nodeType!=3){let e,r;(r=$p(t,n))?(t=r,n=0):(e=em(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Qd(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&jp(e)},50)}function nm(e,t){let n=e.state.doc.resolve(t);if(!(pf||vf)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function rm(e,t,n){let r=e.state.selection;if(r instanceof J&&!r.empty||n.indexOf(`s`)>-1||_f&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Wp(e.state,t);if(n&&n instanceof Y)return Gp(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof ju?q.near(n,t):q.findFrom(n,t);return o?Gp(e,o):!1}return!1}function im(e,t){if(!(e.state.selection instanceof J))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function am(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function om(e){if(!hf||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;am(e,n,`true`),setTimeout(()=>am(e,n,`false`),20)}return!1}function sm(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function cm(e,t){let n=t.keyCode,r=sm(t);if(n==8||_f&&n==72&&r==`c`)return im(e,-1)||Yp(e,-1);if(n==46&&!t.shiftKey||_f&&n==68&&r==`c`)return im(e,1)||Yp(e,1);if(n==13||n==27)return!0;if(n==37||_f&&n==66&&r==`c`){let t=n==37?nm(e,e.state.selection.from)==`ltr`?-1:1:-1;return Kp(e,t,r)||Yp(e,t)}else if(n==39||_f&&n==70&&r==`c`){let t=n==39?nm(e,e.state.selection.from)==`ltr`?1:-1:1;return Kp(e,t,r)||Yp(e,t)}else if(n==38||_f&&n==80&&r==`c`)return rm(e,-1,r)||Yp(e,-1);else if(n==40||_f&&n==78&&r==`c`)return om(e)||rm(e,1,r)||Yp(e,1);else if(r==(_f?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function lm(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||al.fromSchema(e.state.schema),s=bm(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=vm[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
8
|
-
|
|
9
|
-
`),slice:t}}function um(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new K(G.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
10
|
-
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=al.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=Cm(n),bf&&wm(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Gc.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!dm.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=Tm(_m(s,+u[1],+u[2]),u[4]);else if(s=K.maxOpen(fm(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=_m(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var dm=/^(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 fm(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&mm(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=hm(a[a.length-1],i.length));let n=pm(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return G.from(a)}return e}function pm(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,G.from(e));return e}function mm(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=mm(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(G.from(pm(n,e,i+1))))}}function hm(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,hm(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(G.empty,!0);return e.copy(n.append(r))}function gm(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=gm(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(G.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function _m(e,t,n){return t<e.openStart&&(e=new K(gm(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new K(gm(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var vm={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},ym=null;function bm(){return ym||=document.implementation.createHTMLDocument(`title`)}var xm=null;function Sm(e){let t=window.trustedTypes;return t?(xm||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),xm.createHTML(e)):e}function Cm(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=bm().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&vm[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=Sm(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function wm(e){let t=e.querySelectorAll(pf?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function Tm(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=G.from(t.create(r[e+1],i)),a++,o++}return new K(i,a,o)}var Em={},Dm={},Om={touchstart:!0,touchmove:!0},km=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Am(e){for(let t in Em){let n=Em[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Fm(e,t)&&!Pm(e,t)&&(e.editable||!(t.type in Dm))&&n(e,t)},Om[t]?{passive:!0}:void 0)}hf&&e.dom.addEventListener(`input`,()=>null),Nm(e)}function jm(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Mm(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Nm(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Pm(e,t))})}function Pm(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Fm(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Im(e,t){!Pm(e,t)&&Em[t.type]&&(e.editable||!(t.type in Dm))&&Em[t.type](e,t)}Dm.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Xm(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(yf&&pf&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),gf&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,$d(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||cm(e,n)?n.preventDefault():jm(e,`key`)},Dm.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Dm.keypress=(e,t)=>{let n=t;if(Xm(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||_f&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof J)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Lm(e){return{left:e.clientX,top:e.clientY}}function Rm(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function zm(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Bm(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Vm(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Y.isSelectable(r)?(Bm(e,new Y(n),`pointer`),!0):!1}function Hm(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Y&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Y.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Bm(e,Y.create(e.state.doc,i),`pointer`),!0)}function Um(e,t,n,r,i){return zm(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Hm(e,n):Vm(e,n))}function Wm(e,t,n,r){return zm(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Gm(e,t,n,r){return zm(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Km(e,n,r)}function Km(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Bm(e,J.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Bm(e,J.create(r,a+1,a+1+n.content.size),`pointer`);else if(Y.isSelectable(n))Bm(e,Y.create(r,a),`pointer`);else continue;return!0}}function qm(e){return rh(e)}var Jm=_f?`metaKey`:`ctrlKey`;Em.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=qm(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Rm(n,e.input.lastClick)&&!n[Jm]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Lm(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Ym(e,o,n,!!r)):(a==`doubleClick`?Wm:Gm)(e,o.pos,o.inside,n)?n.preventDefault():jm(e,`pointer`))};var Ym=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Jm],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Y&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&df&&!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)),jm(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(()=>jp(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(Lm(e))),this.updateAllowDefault(e),this.allowDefault||!t?jm(this.view,`pointer`):Um(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||hf&&this.mightDrag&&!this.mightDrag.node.isAtom||pf&&!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)?(Bm(this.view,q.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):jm(this.view,`pointer`)}move(e){this.updateAllowDefault(e),jm(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)}};Em.touchstart=e=>{e.input.lastTouch=Date.now(),qm(e),jm(e,`pointer`)},Em.touchmove=e=>{e.input.lastTouch=Date.now(),jm(e,`pointer`)},Em.contextmenu=e=>qm(e);function Xm(e,t){return e.composing?!0:hf&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Zm=yf?5e3:-1;Dm.compositionstart=Dm.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof J&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||pf&&vf&&Qm(e)))e.markCursor=e.state.storedMarks||n.marks(),rh(e,!0),e.markCursor=null;else if(rh(e,!t.selection.empty),df&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}$m(e,Zm)};function Qm(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}Dm.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,$m(e,20))};function $m(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>rh(e),t))}function eh(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=nh());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function th(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Jd(t.focusNode,t.focusOffset),r=Yd(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function nh(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function rh(e,t=!1){if(!(yf&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),eh(e),t||e.docView&&e.docView.dirty){let n=kp(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function ih(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var ah=lf&&uf<15||gf&&xf<604;Em.copy=Dm.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=ah?null:n.clipboardData,{dom:o,text:s}=lm(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):ih(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function oh(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function sh(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ch(e,r.value,null,i,t):ch(e,r.textContent,r.innerHTML,i,t)},50)}function ch(e,t,n,r,i){let a=um(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||K.empty)))return!0;if(!a)return!1;let o=oh(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function lh(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}Dm.paste=(e,t)=>{let n=t;if(e.composing&&!yf)return;let r=ah?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&ch(e,lh(r),r.getData(`text/html`),i,n)?n.preventDefault():sh(e,n)};var uh=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},dh=_f?`altKey`:`ctrlKey`;function fh(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[dh]:!n}Em.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Lm(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Y?i.to-1:i.to))){if(r&&r.mightDrag)o=Y.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Y.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=lm(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!pf||mf>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ah?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,ah||n.dataTransfer.setData(`text/plain`,c),e.dragging=new uh(l,fh(e,n),o)},Em.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Dm.dragover=Dm.dragenter=(e,t)=>t.preventDefault(),Dm.drop=(e,t)=>{try{ph(e,t,e.dragging)}finally{e.dragging=null}};function ph(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Lm(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=um(e,lh(t.dataTransfer),ah?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&fh(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||K.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?au(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Y.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Y(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Bp(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}Em.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&jp(e)},20))},Em.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},Em.beforeinput=(e,t)=>{if(pf&&yf&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,$d(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Dm)Em[e]=Dm[e];function mh(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var hh=class e{constructor(e,t){this.toDOM=e,this.spec=t||bh,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new vh(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&mh(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},gh=class e{constructor(e,t){this.attrs=e,this.spec=t||bh}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new vh(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&mh(this.attrs,t.attrs)&&mh(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},_h=class e{constructor(e,t){this.attrs=e,this.spec=t||bh}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new vh(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&mh(this.attrs,t.attrs)&&mh(this.spec,t.spec)}destroy(){}},vh=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,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(t,n,r){return new e(t,t,new hh(n,r))}static inline(t,n,r,i){return new e(t,n,new gh(r,i))}static node(t,n,r,i){return new e(t,n,new _h(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof gh}get widget(){return this.type instanceof hh}},yh=[],bh={},xh=class e{constructor(e,t){this.local=e.length?e:yh,this.children=t.length?t:yh}static create(e,t){return t.length?kh(t,e,0,bh):Sh}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Sh||e.maps.length==0?this:this.mapInner(e,t,0,0,n||bh)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?wh(this.children,o||[],t,n,r,i,a):o?new e(o.sort(Ah),yh):Sh}add(t,n){return n.length?this==Sh?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=Dh(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,kh(s,e,o+1,bh)),a+=3}});let o=Th(a?Oh(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(Ah):this.local,i||this.children)}remove(e){return e.length==0||this==Sh?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==Sh?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):Sh}forChild(t,n){if(this==Sh)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof gh){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(Ah),yh);return r?new Ch([t,r]):t}return r||Sh}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return jh(this.localsInner(e))}localsInner(e){if(this==Sh)return yh;if(e.inlineContent||!this.local.some(gh.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof gh||t.push(this.local[e]);return t}forEachSet(e){e(this)}};xh.empty=new xh([],[]),xh.removeOverlap=jh;var Sh=xh.empty,Ch=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,bh));return e.from(r)}forChild(t,n){if(n.isLeaf)return xh.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=Sh&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?jh(n?t:t.sort(Ah)):yh}static from(t){switch(t.length){case 0:return Sh;case 1:return t[0];default:return new e(t.every(e=>e instanceof xh)?t:t.reduce((e,t)=>e.concat(t instanceof xh?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function wh(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==Sh?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=kh(Eh(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new xh(t.sort(Ah),s)}function Th(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new vh(i.from+t,i.to+t,i.type))}return n}function Eh(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function Dh(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function Oh(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function kh(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=Dh(e,t,o+n);if(s){a=!0;let e=kh(s,t,n+o+1,r);e!=Sh&&i.push(o,o+t.nodeSize,e)}});let o=Th(a?Oh(e):e,-n).sort(Ah);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new xh(o,i):Sh}function Ah(e,t){return e.from-t.from||e.to-t.to}function jh(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),Mh(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),Mh(t,i,r.copy(a.from,r.to)));break}}}return t}function Mh(e,t,n){for(;t<e.length&&Ah(n,e[t])>0;)t++;e.splice(t,0,n)}function Nh(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Sh&&t.push(r)}),e.cursorWrapper&&t.push(xh.create(e.state.doc,[e.cursorWrapper.deco])),Ch.from(t)}var Ph={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fh=lf&&uf<=11,Ih=class{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}},Lh=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ih,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);lf&&uf<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():hf&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Fh&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,Ph)),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(Vp(this.view)){if(this.suppressingSelectionUpdates)return jp(this.view);if(lf&&uf<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wd(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 n=e.focusNode;n;n=Bd(n))t.add(n);for(let r=e.anchorNode;r;r=Bd(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.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(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Vp(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(df&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Uh(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Qd(n)&&(c=kp(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,jp(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Bh(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Wh(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||jp(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 n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(lf&&uf<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?zd(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?zd(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Rh=new WeakMap,zh=!1;function Bh(e){if(!Rh.has(e)&&(Rh.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=df,zh)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.`),zh=!0}}function Vh(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Wd(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Hh(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Vh(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Vh(e,n):null}function Uh(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Wh(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Gh(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],Qd(c)||l.push({node:c.focusNode,offset:c.focusOffset})),pf&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||Gc.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Kh,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Kh(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(hf&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||hf&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var qh=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Jh(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=kp(e,t);if(n&&!e.state.selection.eq(n)){if(pf&&yf&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,$d(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Gh(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=$h(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(gf&&e.input.lastIOSEnter>Date.now()-225||yf)&&i.some(e=>e.nodeType==1&&!qh.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,$d(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof J&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Yh(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof J&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),lf&&uf<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((gf&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,$d(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Zh(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,$d(8,`Backspace`)))){yf&&pf&&e.domObserver.suppressSelectionUpdates();return}pf&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),yf&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,$d(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Yh(e,n.doc,l.sel);t&&!(pf&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||lf&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){lf&&uf<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>jp(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Xh(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function Yh(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Bp(e,t.resolve(n.anchor),t.resolve(n.head))}function Xh(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(G.from(l).eq(e))return{mark:s,type:o}}function Zh(e,t,n,r,i){if(n-t<=i.pos-r.pos||Qh(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Qh(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Qh(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Qh(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function $h(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&eg(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&eg(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function eg(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var tg=class{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 km,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(cg),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=ig(this),rg(this),this.nodeViews=og(this),this.docView=lp(this.state.doc,ng(this),Nh(this),this.dom,this),this.domObserver=new Lh(this,(e,t,n,r)=>Jh(this,e,t,n,r)),this.domObserver.start(),Am(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&&Nm(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(cg),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];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){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(eh(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=og(this);sg(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Nm(this),this.editable=ig(this),rg(this);let o=Nh(this),s=ng(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Ef(this);if(i){this.domObserver.stop();let t=l&&(lf||pf)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&ag(n.selection,e.selection);if(l){let n=pf?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=th(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=lp(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Up(this))?jp(this,t):(Rp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&Of(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Y){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Tf(this,t.getBoundingClientRect(),e)}else Tf(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.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,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new uh(e.slice,e.move,r<0?void 0:Y.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(lf){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&&jf(this.dom),jp(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return zf(this,e)}coordsAtPos(e,t=1){return Uf(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 r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return $f(this,t||this.state,e)}pasteHTML(e,t){return ch(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return ch(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return lm(this,e)}destroy(){this.docView&&(Mm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Nh(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ud())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Im(this,e)}domSelectionRange(){let e=this.domSelection();return e?hf&&this.root.nodeType===11&&ef(this.dom.ownerDocument)==this.dom&&Hh(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};tg.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function ng(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[vh.node(0,e.state.doc.content.size,t)]}function rg(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:vh.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function ig(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function ag(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function og(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function sg(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function cg(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var lg={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},ug={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},dg=typeof navigator<`u`&&/Mac/.test(navigator.platform),fg=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),pg=0;pg<10;pg++)lg[48+pg]=lg[96+pg]=String(pg);for(var pg=1;pg<=24;pg++)lg[pg+111]=`F`+pg;for(var pg=65;pg<=90;pg++)lg[pg]=String.fromCharCode(pg+32),ug[pg]=String.fromCharCode(pg);for(var mg in lg)ug.hasOwnProperty(mg)||(ug[mg]=lg[mg]);function hg(e){var t=!(dg&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||fg&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?ug:lg)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var gg=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_g=typeof navigator<`u`&&/Win/.test(navigator.platform);function vg(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))gg?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function yg(e){let t=Object.create(null);for(let n in e)t[vg(n)]=e[n];return t}function bg(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function xg(e){return new Gu({props:{handleKeyDown:Sg(e)}})}function Sg(e){let t=yg(e);return function(e,n){let r=hg(n),i,a=t[bg(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[bg(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(_g&&n.ctrlKey&&n.altKey)&&(i=lg[n.keyCode])&&i!=r){let r=t[bg(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Cg=Object.defineProperty,wg=(e,t)=>{for(var n in t)Cg(e,n,{get:t[n],enumerable:!0})};function Tg(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Eg=class{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(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Tg({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Dg={};wg(Dg,{blur:()=>Og,clearContent:()=>kg,clearNodes:()=>Ag,command:()=>jg,createParagraphNear:()=>Mg,cut:()=>Ng,deleteCurrentNode:()=>Pg,deleteNode:()=>Ig,deleteRange:()=>Lg,deleteSelection:()=>Vg,enter:()=>Hg,exitCode:()=>Ug,extendMarkRange:()=>Xg,first:()=>Zg,focus:()=>i_,forEach:()=>a_,insertContent:()=>o_,insertContentAt:()=>f_,joinBackward:()=>h_,joinDown:()=>m_,joinForward:()=>g_,joinItemBackward:()=>__,joinItemForward:()=>v_,joinTextblockBackward:()=>y_,joinTextblockForward:()=>b_,joinUp:()=>p_,keyboardShortcut:()=>C_,lift:()=>T_,liftEmptyBlock:()=>E_,liftListItem:()=>D_,newlineInCode:()=>O_,resetAttributes:()=>j_,scrollIntoView:()=>M_,selectAll:()=>N_,selectNodeBackward:()=>P_,selectNodeForward:()=>F_,selectParentNode:()=>I_,selectTextblockEnd:()=>L_,selectTextblockStart:()=>R_,setContent:()=>B_,setMark:()=>Vv,setMeta:()=>Hv,setNode:()=>Uv,setNodeSelection:()=>Wv,setTextDirection:()=>Gv,setTextSelection:()=>Kv,sinkListItem:()=>qv,splitBlock:()=>Yv,splitListItem:()=>Xv,toggleList:()=>ey,toggleMark:()=>ty,toggleNode:()=>ny,toggleWrap:()=>ry,undoInputRule:()=>iy,unsetAllMarks:()=>ay,unsetMark:()=>oy,unsetTextDirection:()=>sy,updateAttributes:()=>cy,wrapIn:()=>ly,wrapInList:()=>uy});var Og=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),kg=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Ag=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=zl(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},jg=e=>t=>e(t),Mg=()=>({state:e,dispatch:t})=>md(e,t),Ng=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new J(r.doc.resolve(Math.max(o-1,0)))),!0},Pg=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function Fg(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Ig=e=>({tr:t,state:n,dispatch:r})=>{let i=Fg(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},Lg=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},Rg=e=>e.content?/^text(\*|\+)/.test(e.content):!1,zg=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return Rg(r)?n===`left`?e.start()-1:e.end()+1:e.pos},Bg=(e,t,n)=>({from:zg(e,n,`left`),to:zg(t,n,`right`)}),Vg=()=>({state:e,dispatch:t})=>{let{$from:n,$to:r}=e.selection;if(e.selection.empty)return!1;let{from:i,to:a}=Bg(n,r,e.schema);return t&&(e.tr.deleteRange(i,a).scrollIntoView(),t(e.tr)),!0},Hg=()=>({commands:e})=>e.keyboardShortcut(`Enter`),Ug=()=>({state:e,dispatch:t})=>pd(e,t);function Wg(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function Gg(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:Wg(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function Kg(e,t,n={}){return e.find(e=>e.type===t&&Gg(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function qg(e,t,n={}){return!!Kg(e,t,n)}function Jg(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!Kg([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&qg([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&qg([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function Yg(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var Xg=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=Yg(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=Jg(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=J.create(o,e.from,e.to);n.setSelection(t)}}return!0},Zg=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function Qg(e){return e instanceof J}function $g(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function e_(e,t=null){if(!t)return null;let n=q.atStart(e),r=q.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?J.create(e,$g(0,i,a),$g(e.content.size,i,a)):J.create(e,$g(t,i,a),$g(t,i,a))}function t_(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function n_(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function r_(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var i_=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(n_()||t_())&&r.dom.focus(),r_()&&!n_()&&!t_()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!Qg(n.state.selection))return o(),!0;let s=e_(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},a_=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),o_=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),s_=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&s_(r)}return e};function c_(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return s_(n)}function l_(e,t,n){if(e instanceof gc||e instanceof G)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return G.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),l_(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new Vc({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?Gc.fromSchema(a).parseSlice(c_(e),n.parseOptions):Gc.fromSchema(a).parse(c_(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=Gc.fromSchema(t);return n.slice?r.parseSlice(c_(e),n.parseOptions).content:r.parse(c_(e),n.parseOptions)}return l_(``,t,n)}function u_(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Ml||i instanceof Nl))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(q.near(e.doc.resolve(o),n))}var d_=e=>!(`type`in e),f_=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{l_(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=l_(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((d_(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof G){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else{f=i;let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,a=t.isText||t.isTextblock,o=t.content.size>0;n&&a&&o&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&u_(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},p_=()=>({state:e,dispatch:t})=>cd(e,t),m_=()=>({state:e,dispatch:t})=>ld(e,t),h_=()=>({state:e,dispatch:t})=>Zu(e,t),g_=()=>({state:e,dispatch:t})=>ad(e,t),__=()=>({state:e,dispatch:t,tr:n})=>{try{let r=nu(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},v_=()=>({state:e,dispatch:t,tr:n})=>{try{let r=nu(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},y_=()=>({state:e,dispatch:t})=>Qu(e,t),b_=()=>({state:e,dispatch:t})=>$u(e,t);function x_(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function S_(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))n_()||x_()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var C_=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=S_(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function w_(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?Fg(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>Gg(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var T_=(e,t={})=>({state:n,dispatch:r})=>w_(n,Fg(e,n.schema),t)?ud(n,r):!1,E_=()=>({state:e,dispatch:t})=>hd(e,t),D_=e=>({state:t,dispatch:n})=>Fd(Fg(e,t.schema))(t,n),O_=()=>({state:e,dispatch:t})=>dd(e,t);function k_(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function A_(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var j_=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=k_(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=Fg(e,r.schema)),s===`mark`&&(o=Yg(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,A_(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(A_(a.attrs,t))))})})}),c},M_=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),N_=()=>({tr:e,dispatch:t})=>{if(t){let t=new ju(e.doc);e.setSelection(t)}return!0},P_=()=>({state:e,dispatch:t})=>nd(e,t),F_=()=>({state:e,dispatch:t})=>od(e,t),I_=()=>({state:e,dispatch:t})=>vd(e,t),L_=()=>({state:e,dispatch:t})=>wd(e,t),R_=()=>({state:e,dispatch:t})=>Cd(e,t);function z_(e,t,n={},r={}){return l_(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var B_=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=z_(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!n),!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function V_(e,t){let n=Yg(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function H_(e,t){let n=new wu(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function U_(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function W_(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function G_(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function K_(e){return t=>G_(t.$from,e)}function X(e,t,n){return e.config[t]===void 0&&e.parent?X(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?X(e.parent,t,n):null}):e.config[t]}function q_(e){return e.map(e=>{let t=X(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...q_(t())]:e}).flat(10)}function J_(e,t){let n=al.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function Y_(e){return typeof e==`function`}function X_(e,t=void 0,...n){return Y_(e)?t?e.bind(t)(...n):e(...n):e}function Z_(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Q_(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function $_(e){let t=[],{nodeExtensions:n,markExtensions:r}=Q_(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=X(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=X(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function ev(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s<o;s+=1){let o=e[s];if(o===`'`&&!i){r=!r,n+=o;continue}if(o===`"`&&!r){i=!i,n+=o;continue}if(!r&&!i){if(o===`(`){a+=1,n+=o;continue}if(o===`)`&&a>0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}return n&&t.push(n),t}function tv(e){let t=[],n=ev(e||``),r=n.length;for(let e=0;e<r;e+=1){let r=n[e],i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();a&&o&&t.push([a,o])}return t}function nv(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...tv(n[e]),...tv(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function rv(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>nv(e,t),{})}function iv(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function av(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):iv(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function ov(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&Z_(t)?!1:t!=null))}function sv(e){let t={};return!e?.attribute?.isRequired&&`default`in(e?.attribute||{})&&(t.default=e.attribute.default),e?.attribute?.validate!==void 0&&(t.validate=e.attribute.validate),[e.name,t]}function cv(e,t){let n=$_(e),{nodeExtensions:r,markExtensions:i}=Q_(e);return new Vc({topNode:r.find(e=>X(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=ov({...e.reduce((e,t)=>{let n=X(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:X_(X(r,`content`,a)),marks:X_(X(r,`marks`,a)),group:X_(X(r,`group`,a)),inline:X_(X(r,`inline`,a)),atom:X_(X(r,`atom`,a)),selectable:X_(X(r,`selectable`,a)),draggable:X_(X(r,`draggable`,a)),code:X_(X(r,`code`,a)),whitespace:X_(X(r,`whitespace`,a)),linebreakReplacement:X_(X(r,`linebreakReplacement`,a)),defining:X_(X(r,`defining`,a)),isolating:X_(X(r,`isolating`,a)),attrs:Object.fromEntries(i.map(sv))}),s=X_(X(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>av(e,i)));let c=X(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:rv(e,i)}));let l=X(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=ov({...e.reduce((e,t)=>{let n=X(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:X_(X(r,`inclusive`,a)),excludes:X_(X(r,`excludes`,a)),group:X_(X(r,`group`,a)),spanning:X_(X(r,`spanning`,a)),code:X_(X(r,`code`,a)),attrs:Object.fromEntries(i.map(sv))}),s=X_(X(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>av(e,i)));let c=X(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:rv(e,i)})),[r.name,o]}))})}function lv(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function uv(e){return e.sort((e,t)=>{let n=X(e,`priority`)||100,r=X(t,`priority`)||100;return n>r?-1:+(n<r)})}function dv(e){let t=uv(q_(e)),n=lv(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function fv(e,t){return cv(dv(e),t)}function pv(e,t){let n=fv(t),r=c_(e);return Gc.fromSchema(n).parse(r).toJSON()}function mv(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
|
|
11
|
-
|
|
12
|
-
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function hv(e,t){return mv(e,{from:0,to:e.content.size},t)}function gv(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function _v(e,t){let n=Fg(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function vv(e,t){let n=k_(typeof t==`string`?t:t.name,e.schema);return n===`node`?_v(e,t):n===`mark`?V_(e,t):{}}function yv(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function bv(e){let t=yv(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function xv(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),bv(r)}function Sv(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=Jg(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var Cv=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]};function wv(e,t){return t.nodes[e]||t.marks[e]||null}function Tv(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var Ev=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function Dv(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?Yg(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>Gg(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>Gg(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function Ov(e,t,n={}){if(!t)return w_(e,null,n)||Dv(e,null,n);let r=k_(t,e.schema);return r===`node`?w_(e,t,n):r===`mark`?Dv(e,t,n):!1}var kv=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=K_(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Av=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function jv(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function Mv(e,t){let{nodeExtensions:n}=Q_(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=X_(X(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function Nv(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(Nv(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function Pv(e){return e instanceof Y}function Fv({selection:e,pos:t,nodeSize:n,selectedOnTextSelection:r=!1}){let{from:i,to:a}=e;return!!(i<=t&&a>=t+n||r&&Qg(e)&&i>t&&a<t+n)}var Iv=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function Lv(e,t){let n=t.mapping.mapResult(e.position);return{position:new Iv(n.pos),mapResult:n}}function Rv(e){return new Iv(e)}function zv(e,t,n){let r=e.state.doc.content.size,i=$g(t,0,r),a=$g(n,0,r),o=e.coordsAtPos(i),s=e.coordsAtPos(a,-1),c=Math.min(o.top,s.top),l=Math.max(o.bottom,s.bottom),u=Math.min(o.left,s.left),d=Math.max(o.right,s.right),f={top:c,bottom:l,left:u,right:d,width:d-u,height:l-c,x:u,y:c};return{...f,toJSON:()=>f}}function Bv(e,t,n){let{selection:r}=t,i=null;if(Qg(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var Vv=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=Yg(e,r.schema);if(i)if(o){let e=V_(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return Bv(r,n,c)},Hv=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Uv=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=Fg(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>Ed(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>Ed(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},Wv=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=$g(e,0,n.content.size),i=Y.create(n,r);t.setSelection(i)}return!0},Gv=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},Kv=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=J.atStart(n).from,o=J.atEnd(n).to,s=$g(r,a,o),c=$g(i,a,o),l=J.create(n,s,c);t.setSelection(l)}return!0},qv=e=>({state:t,dispatch:n})=>Rd(Fg(e,t.schema))(t,n);function Jv(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var Yv=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=Tv(l,s.node().type.name,s.node().attrs);if(a instanceof Y&&a.node.isBlock)return!s.parentOffset||!Zl(o,s.pos)?!1:(r&&(e&&Jv(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:U_(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=Zl(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&Zl(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof J&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&Jv(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},Xv=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=Fg(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=G.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=G.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...Tv(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(G.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new K(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(J.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...Tv(d,u.type.name,u.attrs),...t},m={...Tv(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!Zl(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},Zv=(e,t)=>{let n=K_(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&$l(e.doc,n.pos)&&e.join(n.pos),!0},Qv=(e,t)=>{let n=K_(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&$l(e.doc,r)&&e.join(r),!0};function $v(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return J.between(r,i)}var ey=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=Fg(e,o.schema),m=Fg(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=K_(e=>Mv(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&Mv(w.type.name,d)?{node:w,pos:0,depth:0}:null,ee=x??T,E=!!x&&y.depth>=1&&y.depth-x.depth<=1,D=!!T;if((E||D)&&ee){if(ee.node.type===p)return S&&D?c().command(({tr:e,dispatch:t})=>{let n=$v(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(Mv(ee.node.type.name,d)&&p.validContent(ee.node.content))return c().command(()=>(a.setNodeMarkup(ee.pos,p),!0)).command(()=>Zv(a,p)).command(()=>Qv(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>Zv(a,p)).command(()=>Qv(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>Zv(a,p)).command(()=>Qv(a,p)).run()},ty=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=Yg(e,r.schema);return Dv(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},ny=(e,t,n={})=>({state:r,commands:i})=>{let a=Fg(e,r.schema),o=Fg(t,r.schema),s=w_(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},ry=(e,t={})=>({state:n,commands:r})=>{let i=Fg(e,n.schema);return w_(n,i,t)?r.lift(i):r.wrapIn(i,t)},iy=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},ay=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},oy=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=Yg(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=Jg(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},sy=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},cy=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=k_(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=Fg(e,r.schema)),s===`mark`&&(o=Yg(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r<s&&a&&a===e.type&&(c=!0,f=Math.max(r,s),p=Math.min(r+e.nodeSize,l),u=r,d=e),r>=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},ly=(e,t={})=>({state:n,dispatch:r})=>Td(Fg(e,n.schema),t)(n,r),uy=(e,t={})=>({state:n,dispatch:r})=>Md(Fg(e,n.schema),t)(n,r),dy=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},fy=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},py=(e,t)=>{if(Wg(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function my(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=Ev(c)+i;return a.forEach(e=>{if(l)return;let a=py(u,e.find);if(!a)return;let c=s.state.tr,d=Tg({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new Eg({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(e.undoable&&c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function hy(e){let{editor:t,rules:n}=e,r=new Gu({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:J_(G.from(e),a.schema);let{from:i}=s;my({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return my({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&my({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?my({editor:t,from:a.pos,to:a.pos,text:`
|
|
13
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function gy(e){return Object.prototype.toString.call(e).slice(8,-1)}function _y(e){return gy(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function vy(e,t){let n={...e};return _y(e)&&_y(t)&&Object.keys(t).forEach(r=>{_y(t[r])&&_y(e[r])?n[r]=vy(e[r],t[r]):n[r]=t[r]}),n}var yy=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...X_(X(this,`addOptions`,{name:this.name}))}}get storage(){return{...X_(X(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>vy(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},by=class e extends yy{constructor(){super(...arguments),this.type=`mark`}static create(t={}){return new e(typeof t==`function`?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function xy(e){return typeof e==`number`}var Sy=class{constructor(e){this.find=e.find,this.handler=e.handler}},Cy=(e,t,n)=>{if(Wg(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function wy(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Eg({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(e.type?.spec?.code||!(e.isText||e.isTextblock||e.isInline))return;let f=e.content?.size??e.nodeSize??0,p=Math.max(r,t),m=Math.min(i,t+f);p>=m||Cy(e.isText?e.text||``:e.textBetween(p-t,m-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=p+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var Ty=null,Ey=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Dy(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!wy({editor:t,state:Tg({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new Gu({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(Ty=t)},i=()=>{Ty&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=Ty;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:J_(G.from(t),r.schema);let{from:n}=d,i=n+t.length,a=Ey(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!xy(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var Oy=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=dv(e),this.schema=cv(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=X(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:wv(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this;return uv([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:wv(t.name,this.schema)},r=[],i=X(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&X(t,`exitable`,n)&&(a.ArrowRight=()=>by.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=xg(a);r.push(o);let s=X(t,`addInputRules`,n);if(jv(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=hy({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=X(t,`addPasteRules`,n);if(jv(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=Dy({editor:e,rules:t});r.push(...n)}}let l=X(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r})}get attributes(){return $_(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Q_(this.extensions);return Object.fromEntries(t.filter(e=>!!X(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=X(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Fg(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:rv(r,n)})]:[]}))}dispatchTransaction(e){let{editor:t}=this;return uv([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:wv(n.name,this.schema)},i=X(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return uv([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:wv(n.name,this.schema)},i=X(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=Q_(this.extensions);return Object.fromEntries(t.filter(e=>!!X(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=X(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Yg(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=rv(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{db(i,e,t)}})}]:[]}))}destroy(){this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:wv(e.name,this.schema)};e.type===`mark`&&(X_(X(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=X(e,`onBeforeCreate`,t),r=X(e,`onCreate`,t),i=X(e,`onUpdate`,t),a=X(e,`onSelectionUpdate`,t),o=X(e,`onTransaction`,t),s=X(e,`onFocus`,t),c=X(e,`onBlur`,t),l=X(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};Oy.resolve=dv,Oy.sort=uv,Oy.flatten=q_,wg({},{ClipboardTextSerializer:()=>Ay,Commands:()=>jy,Delete:()=>My,Drop:()=>Ny,Editable:()=>Py,FocusEvents:()=>Iy,Keymap:()=>Ly,Paste:()=>Ry,Tabindex:()=>zy,TextDirection:()=>By,focusEventsPluginKey:()=>Fy});var ky=class e extends yy{constructor(){super(...arguments),this.type=`extension`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Ay=ky.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Gu({key:new Ju(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=gv(n);return mv(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),jy=ky.create({name:`commands`,addCommands(){return{...Dg}}}),My=ky.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){let n=()=>{var n;if(((n=this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(n,e)??e.getMeta(`y-sync$`))return;let r=H_(e.before,[e,...t]);xv(r).forEach(t=>{r.mapping.mapResult(t.oldRange.from).deletedAfter&&r.mapping.mapResult(t.oldRange.to).deletedBefore&&r.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,i)=>{let a=i+n.nodeSize-2,o=t.oldRange.from<=i&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:i,to:a,newFrom:r.mapping.map(i),newTo:r.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:r})})});let i=r.mapping;r.steps.forEach((t,n)=>{if(t instanceof kl){let a=i.slice(n).map(t.from,-1),o=i.slice(n).map(t.to),s=i.invert().map(a,-1),c=i.invert().map(o),l=a>0?r.doc.nodeAt(a-1)?.marks.some(e=>e.eq(t.mark)):!1,u=r.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:a,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:r})}})};this.editor.options.coreExtensionOptions?.delete?.async??!0?setTimeout(n,0):n()}}),Ny=ky.create({name:`drop`,addProseMirrorPlugins(){return[new Gu({key:new Ju(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Py=ky.create({name:`editable`,addProseMirrorPlugins(){return[new Gu({key:new Ju(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Fy=new Ju(`focusEvents`),Iy=ky.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new Gu({key:Fy,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),Ly=ky.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:q.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return n_()||x_()?i:r},addProseMirrorPlugins(){return[new Gu({key:new Ju(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=q.atStart(t.doc).from,l=q.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!Nv(n.doc))return;let u=n.tr,d=Tg({state:n,transaction:u}),{commands:f}=new Eg({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),Ry=ky.create({name:`paste`,addProseMirrorPlugins(){return[new Gu({key:new Ju(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),zy=ky.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Gu({key:new Ju(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),By=ky.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Q_(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Gu({key:new Ju(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Vy=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??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\u2019t 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}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||this.children.length===0)return r;let i=Object.keys(t);return this.children.forEach(a=>{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Hy=`.ProseMirror {
|
|
14
|
-
position: relative;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ProseMirror {
|
|
18
|
-
word-wrap: break-word;
|
|
19
|
-
white-space: pre-wrap;
|
|
20
|
-
white-space: break-spaces;
|
|
21
|
-
-webkit-font-variant-ligatures: none;
|
|
22
|
-
font-variant-ligatures: none;
|
|
23
|
-
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.ProseMirror [contenteditable="false"] {
|
|
27
|
-
white-space: normal;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
31
|
-
white-space: pre-wrap;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.ProseMirror pre {
|
|
35
|
-
white-space: pre-wrap;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
img.ProseMirror-separator {
|
|
39
|
-
display: inline !important;
|
|
40
|
-
border: none !important;
|
|
41
|
-
margin: 0 !important;
|
|
42
|
-
width: 0 !important;
|
|
43
|
-
height: 0 !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.ProseMirror-gapcursor {
|
|
47
|
-
display: none;
|
|
48
|
-
pointer-events: none;
|
|
49
|
-
position: absolute;
|
|
50
|
-
margin: 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.ProseMirror-gapcursor:after {
|
|
54
|
-
content: "";
|
|
55
|
-
display: block;
|
|
56
|
-
position: absolute;
|
|
57
|
-
top: -2px;
|
|
58
|
-
width: 20px;
|
|
59
|
-
border-top: 1px solid black;
|
|
60
|
-
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@keyframes ProseMirror-cursor-blink {
|
|
64
|
-
to {
|
|
65
|
-
visibility: hidden;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.ProseMirror-hideselection *::selection {
|
|
70
|
-
background: transparent;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
74
|
-
background: transparent;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.ProseMirror-hideselection * {
|
|
78
|
-
caret-color: transparent;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
82
|
-
display: block;
|
|
83
|
-
}`;function Uy(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var Wy=class extends dy{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Lv,createMappablePosition:Rv},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),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:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc(),n=e_(t,this.options.autofocus);this.editorState=Uu.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}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&&typeof document<`u`&&(this.css=Uy(Hy,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!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,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Y_(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[Py,Ay.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),jy,Iy,Ly,zy.configure({value:this.options.coreExtensionOptions?.tabindex?.value}),Ny,Ry,My,By.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new Oy(e,this)}createCommandManager(){this.commandManager=new Eg({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=z_(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=z_(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new tg(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let 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(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return vv(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return Ov(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return J_(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
84
|
-
|
|
85
|
-
`,textSerializers:n={}}=e||{};return hv(this.state.doc,{blockSeparator:t,textSerializers:{...gv(this.schema),...n}})}get isEmpty(){return Nv(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText?t.nodeAfter:null;return new Vy(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Gy(e){return new fy({find:e.find,handler:({state:t,range:n,match:r})=>{let i=X_(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(Sv(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Ky(e){return new fy({find:e.find,handler:({state:t,range:n,match:r})=>{let i=X_(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function qy(e){return new fy({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=X_(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Jy(e){return new fy({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=X_(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&Vl(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&$l(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Yy=e=>`touches`in e,Xy=class{constructor(e){this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e?.options?.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type?(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0):!1}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,Yy(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return r<this.minSize.width&&(r=this.minSize.width,i=r/this.aspectRatio),i<this.minSize.height&&(i=this.minSize.height,r=i*this.aspectRatio),this.maxSize?.width&&r>this.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};function Zy(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Y){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function Qy(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)}function $y(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/&/g,`&`)}function eb(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function tb(){return typeof navigator<`u`?/Firefox/.test(navigator.userAgent):!1}wg({},{createAtomBlockMarkdownSpec:()=>ib,createBlockMarkdownSpec:()=>ab,createInlineMarkdownSpec:()=>cb,parseAttributes:()=>nb,parseIndentedBlocks:()=>lb,renderNestedMarkdownContent:()=>ub,serializeAttributes:()=>rb});function nb(e){if(!e?.trim())return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(` `));let a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{let i=n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1]||`0`,10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,``).replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,``).replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,``).trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function rb(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e===`class`||e===`id`||(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function ib(e){let{nodeName:t,name:n,parseAttributes:r=nb,serializeAttributes:i=rb,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:s}=e,c=n||t,l=e=>{if(!s)return e;let t={};return s.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let r={...a,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${c}(?:\\s|$)`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,i){let a=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),s=e.match(a);if(!s)return;let l=r(s[1]||``);if(!o.find(e=>!(e in l)))return{type:t,raw:s[0],attributes:l}}},renderMarkdown:e=>{let t=i(l(e.attrs||{}));return`:::${c}${t?` {${t}}`:``} :::`}}}function ab(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=nb,serializeAttributes:a=rb,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m)if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m);return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=a(u(e.attrs||{}));return`:::${l}${n?` {${n}}`:``}
|
|
86
|
-
|
|
87
|
-
${t.renderChildren(e.content||[],`
|
|
88
|
-
|
|
89
|
-
`)}
|
|
90
|
-
|
|
91
|
-
:::`}}}function ob(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i]=a||o,r=n.exec(e)}return t}function sb(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function cb(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=ob,serializeAttributes:a=sb,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=a(u(e.attrs||{})),i=n?` ${n}`:``;return s?`[${l}${i}]`:`[${l}${i}]${t}[/${l}]`}}}function lb(e,t,n){let r=e.split(`
|
|
92
|
-
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],c=e.match(t.itemPattern);if(!c){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}
|
|
93
|
-
`;continue}else return}let l=t.extractItemData(c),{indentLevel:u,mainContent:d}=l;a=`${a}${e}
|
|
94
|
-
`;let f=[d];for(o+=1;o<r.length;){let e=r[o];if(e.trim()===``){let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((r[o+1+t].match(/^(\s*)/)?.[1]?.length||0)>u){f.push(e),a=`${a}${e}
|
|
95
|
-
`,o+=1;continue}else break}if((e.match(/^(\s*)/)?.[1]?.length||0)>u)f.push(e),a=`${a}${e}
|
|
96
|
-
`,o+=1;else break}let p,m=f.slice(1);if(m.length>0){let e=m.map(e=>e.slice(u+s)).join(`
|
|
97
|
-
`);e.trim()&&(p=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let h=t.createToken(l,p);i.push(h)}if(i.length!==0)return{items:i,raw:a}}function ub(e,t,n,r){if(!e||!Array.isArray(e.content))return``;let i=typeof n==`function`?n(r):n,[a,...o]=e.content,s=`${i}${t.renderChildren([a])}`;return o&&o.length>0&&o.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=r.split(`
|
|
98
|
-
`).map(e=>e?t.indent(e):t.indent(``)).join(`
|
|
99
|
-
`);s+=e.type===`paragraph`?`
|
|
100
|
-
|
|
101
|
-
${n}`:`
|
|
102
|
-
${n}`}}),s}function db(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var fb=class e extends yy{constructor(){super(...arguments),this.type=`node`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},pb=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t;let{view:n}=this.editor,r=e.target,i=r.nodeType===3?r.parentElement?.closest(`[data-drag-handle]`):r.closest(`[data-drag-handle]`);if(!this.dom||this.contentDOM?.contains(r)||!i)return;let a=0,o=0;if(this.dom!==i){let t=this.dom.getBoundingClientRect(),n=i.getBoundingClientRect(),r=e.offsetX??e.nativeEvent?.offsetX,s=e.offsetY??e.nativeEvent?.offsetY;a=n.x-t.x+r,o=n.y-t.y+s}let s=this.dom.cloneNode(!0);try{let e=this.dom.getBoundingClientRect();s.style.width=`${Math.round(e.width)}px`,s.style.height=`${Math.round(e.height)}px`,s.style.boxSizing=`border-box`,s.style.pointerEvents=`none`}catch{}let c=null;try{c=document.createElement(`div`),c.style.position=`absolute`,c.style.top=`-9999px`,c.style.left=`-9999px`,c.style.pointerEvents=`none`,c.appendChild(s),document.body.appendChild(c),(t=e.dataTransfer)==null||t.setDragImage(s,a,o)}finally{c&&setTimeout(()=>{try{c?.remove()}catch{}},0)}let l=this.getPos();if(typeof l!=`number`)return;let u=Y.create(n.state.doc,l),d=n.state.tr.setSelection(u);n.dispatch(d)}stopEvent(e){if(!this.dom)return!1;if(typeof this.options.stopEvent==`function`)return this.options.stopEvent({event:e});let t=e.target;if(!(this.dom.contains(t)&&!this.contentDOM?.contains(t)))return!1;let n=e.type.startsWith(`drag`),r=e.type===`dragover`||e.type===`dragenter`,i=e.type===`drop`;if(([`INPUT`,`BUTTON`,`SELECT`,`TEXTAREA`].includes(t.tagName)||t.isContentEditable)&&!i&&!n)return!0;let{isEditable:a}=this.editor,{isDragging:o}=this,s=!!this.node.type.spec.draggable,c=Y.isSelectable(this.node),l=e.type===`copy`,u=e.type===`paste`,d=e.type===`cut`,f=e.type===`mousedown`;if(!s&&c&&n&&e.target===this.dom&&e.preventDefault(),s&&n&&!o&&e.target===this.dom)return e.preventDefault(),!1;if(s&&a&&!o&&f){let e=t.closest(`[data-drag-handle]`);e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener(`dragend`,()=>{this.isDragging=!1},{once:!0}),document.addEventListener(`drop`,()=>{this.isDragging=!1},{once:!0}),document.addEventListener(`mouseup`,()=>{this.isDragging=!1},{once:!0}))}return!(o||r||i||l||u||d||f&&c)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation==`function`?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type===`selection`||this.dom.contains(e.target)&&e.type===`childList`&&(n_()||t_())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===e.target&&e.type===`attributes`?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return typeof n==`number`?(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0):!1})}deleteNode(){let e=this.getPos();if(typeof e!=`number`)return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function mb(e){return new Sy({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=X_(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(Sv(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var hb=/(^|[^`])`([^`]+)`(?!`)$/,gb=/(^|[^`])`([^`]+)`(?!`)/g,_b=by.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,nv(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Gy({find:hb,type:this.type})]},addPasteRules(){return[mb({find:gb,type:this.type})]}}),vb=_b,yb=fb.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,nv(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Zy(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return Pv(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(J.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Y.create(t.doc,n.pos)):t.setSelection(J.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(J.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ky({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),bb=yb,xb=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Sb=fb.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,nv(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new Xy({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Ky({find:xb,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function Cb(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Qy(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function wb(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
103
|
-
`);return/\s/.test(n)}):!1}var Tb=new Ju(`suggestion`);function Eb({pluginKey:e=Tb,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=Cb,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!wb(i);function w(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new Gu({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!C({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),xh.create(e.doc,[vh.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var Db=Eb;function Ob({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new Ju,command:({editor:e,range:t,props:i})=>{var a;(e.view.state.selection.$to.nodeAfter?.text)?.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:n,attrs:{...i,mentionSuggestionChar:r}},{type:`text`,text:` `}]).run(),(a=e.view.dom.ownerDocument.defaultView?.getSelection())==null||a.collapseToEnd()},allow:({state:e,range:t})=>{let r=e.doc.resolve(t.from),i=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(i)},...t}}function kb(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>Ob({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function Ab(e,t){let n=kb(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var jb=fb.create({name:`mention`,priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){return`${t?.char??`@`}${e.attrs.label??e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){return[`span`,nv(this.HTMLAttributes,e.HTMLAttributes),`${n?.char??`@`}${t.attrs.label??t.attrs.id}`]},suggestions:[],suggestion:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:`@`,parseHTML:e=>e.getAttribute(`data-mention-suggestion-char`),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=Ab(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),[`span`,nv({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=nv({"data-type":this.name},this.options.HTMLAttributes,t);let i=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof i==`string`?[`span`,nv({"data-type":this.name},this.options.HTMLAttributes,t),i]:i},...cb({nodeName:`mention`,name:`@`,selfClosing:!0,allowedAttributes:[`id`,`label`,{name:`mentionSuggestionChar`,skipIfDefault:`@`}],parseAttributes:e=>{let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i===`char`?`mentionSuggestionChar`:i]=a??o,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e===`mentionSuggestionChar`?`char`:e}="${t}"`).join(` `)}),renderText({node:e}){let t={options:this.options,node:e,suggestion:Ab(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel===void 0?this.options.renderText(t):(console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),this.options.renderLabel(t))},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;if(!i)return!1;let o=new gc,s=0;return t.doc.nodesBetween(a-1,a,(e,t)=>{if(e.type.name===this.name)return n=!0,o=e,s=t,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?``:o.attrs.mentionSuggestionChar,s,s+o.nodeSize),n})}},addProseMirrorPlugins(){return kb(this).map(Eb)}});function Mb(e={}){return new Gu({view(t){return new Nb(t,e)}})}var Nb=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=au(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},Pb=class e extends q{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):q.near(r)}content(){return K.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Fb(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Lb(e)||!Rb(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Y.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};Pb.prototype.visible=!1,Pb.findFrom=Pb.findGapCursorFrom,q.jsonID(`gapcursor`,Pb);var Fb=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Pb.valid(t)?new Pb(t):q.near(t)}};function Ib(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Lb(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Ib(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Rb(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Ib(e.type))return!0;if(e.inlineContent)return!1}}return!0}function zb(){return new Gu({props:{decorations:Wb,createSelectionBetween(e,t,n){return t.pos==n.pos&&Pb.valid(n)?new Pb(n):null},handleClick:Hb,handleKeyDown:Bb,handleDOMEvents:{beforeinput:Ub}}})}var Bb=Sg({ArrowLeft:Vb(`horiz`,-1),ArrowRight:Vb(`horiz`,1),ArrowUp:Vb(`vert`,-1),ArrowDown:Vb(`vert`,1)});function Vb(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof J){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=Pb.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Pb(c))),!0):!1}}function Hb(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Pb.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Y.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Pb(r))),!0)}function Ub(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Pb))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=G.empty;for(let e=r.length-1;e>=0;e--)i=G.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new K(i,0,0));return a.setSelection(J.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Wb(e){if(!(e.selection instanceof Pb))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,xh.create(e.doc,[vh.widget(e.selection.head,t,{key:`gapcursor`})])}var Gb=200,Kb=function(){};Kb.prototype.append=function(e){return e.length?(e=Kb.from(e),!this.length&&e||e.length<Gb&&this.leafAppend(e)||this.length<Gb&&e.leafPrepend(this)||this.appendInner(e)):this},Kb.prototype.prepend=function(e){return e.length?Kb.from(e).append(this):this},Kb.prototype.appendInner=function(e){return new Jb(this,e)},Kb.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Kb.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Kb.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Kb.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Kb.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Kb.from=function(e){return e instanceof Kb?e:e&&e.length?new qb(e):Kb.empty};var qb=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Gb)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Gb)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Kb);Kb.empty=new qb([]);var Jb=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Kb),Yb=500,Xb=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new Qb(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Qb(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new Qb(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>ex&&(s=Zb(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Cl;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Qb(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Qb(i,o,l))}else r.push(new Qb(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new Qb(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Yb&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Qb(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Kb.from(i.reverse()),a)}};Xb.empty=new Xb(Kb.empty,0);function Zb(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Qb=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},$b=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},ex=20;function tx(e,t,n,r){let i=n.getMeta(lx),a;if(i)return i.historyState;n.getMeta(ux)&&(e=new $b(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(lx))return o.getMeta(lx).redo?new $b(e.done.addTransform(n,void 0,r,cx(t)),e.undone,rx(n.mapping.maps),e.prevTime,e.prevComposition):new $b(e.done,e.undone.addTransform(n,void 0,r,cx(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!nx(n,e.prevRanges)),s=o?ix(e.prevRanges,n.mapping):rx(n.mapping.maps);return new $b(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,cx(t)),Xb.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new $b(e.done.rebased(n,a),e.undone.rebased(n,a),ix(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new $b(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ix(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function nx(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function rx(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function ix(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function ax(e,t,n){let r=cx(t),i=lx.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new $b(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(lx,{redo:n,historyState:c})}var ox=!1,sx=null;function cx(e){let t=e.plugins;if(sx!=t){ox=!1,sx=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){ox=!0;break}}return ox}var lx=new Ju(`history`),ux=new Ju(`closeHistory`);function dx(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Gu({key:lx,state:{init(){return new $b(Xb.empty,Xb.empty,null,0,-1)},apply(t,n,r){return tx(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?px:n==`historyRedo`?mx:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function fx(e,t){return(n,r)=>{let i=lx.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=ax(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var px=fx(!1,!0),mx=fx(!0,!0);ky.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Gu({key:new Ju(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var hx=ky.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Mb(this.options)]}});ky.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new Gu({key:new Ju(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return xh.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(vh.node(t,t+e.nodeSize,{class:this.options.className}))}),xh.create(e,a)}}})]}});var gx=ky.create({name:`gapCursor`,addProseMirrorPlugins(){return[zb()]},extendNodeSchema(e){return{allowGapCursor:X_(X(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),_x=`placeholder`,vx=new Ju(`tiptap__placeholder`),yx=200;function bx(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),vh.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function xx({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty,c={emptyEditor:t.emptyEditorClass,emptyNode:t.emptyNodeClass};if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),l=i.depth>0?i.node(1):i.nodeAfter,u=i.depth>0?i.before(1):a;if(l&&l.type.isTextblock&&Nv(l)){let r=a>=u&&a<=u+l.nodeSize;o.push(bx({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:c,node:l,pos:u}))}}else{let i=vx.getState(e.state),l=i?.topPos??0,u=i?.bottomPos??r.content.size;r.nodesBetween(l,u,(r,i)=>{let l=a>=i&&a<=i+r.nodeSize,u=!r.isLeaf&&Nv(r);return r.type.isTextblock&&(l||!t.showOnlyCurrent)&&u&&o.push(bx({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:l,placeholder:t.placeholder,classes:c,node:r,pos:i})),t.includeChildren})}return xh.create(r,o)}function Sx(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function Cx(e){let t=getComputedStyle(e),n=`${t.overflow} ${t.overflowY} ${t.overflowX}`;return/auto|scroll|overlay/.test(n)}function wx(e){let t=e;for(;t;){if(Cx(t))return t;let e=t.parentElement;if(!e){let e=t.getRootNode();if(e instanceof ShadowRoot){t=e.host;continue}return window}t=e}return window}function Tx(e){return e===window?{top:0,bottom:window.innerHeight}:e.getBoundingClientRect()}function Ex({doc:e,view:t,scrollContainer:n}){let r=t.dom.getBoundingClientRect(),i=n?Tx(n):{top:0,bottom:window.innerHeight},a=Math.max(r.top,i.top)-yx,o=Math.min(r.bottom,i.bottom)+yx;if(a>=o)return{top:0,bottom:e.content.size};let s=getComputedStyle(t.dom).direction===`rtl`?Math.max(r.right-2,r.left+2):r.left+2,c=t.posAtCoords({left:s,top:a+2}),l=t.posAtCoords({left:s,top:o-2});return{top:c?c.pos:0,bottom:l?l.pos:e.content.size}}var Dx={init(){return{topPos:null,bottomPos:null}},apply(e,t){let n=e.getMeta(vx);return n?.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:t.topPos===null?null:e.mapping.map(t.topPos),bottomPos:t.bottomPos===null?null:e.mapping.map(t.bottomPos)}:t}};function Ox(e){let t=wx(e.dom),n=()=>{let n=Ex({view:e,doc:e.state.doc,scrollContainer:t}),r=vx.getState(e.state);if(r?.topPos===n.top&&r?.bottomPos===n.bottom)return;let i=e.state.tr.setMeta(vx,{positions:n});e.dispatch(i)},r=null,i=0,a=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;let e=performance.now();e-i>=150?(i=e,n()):a()}))};return t.addEventListener(`scroll`,a,{passive:!0}),n(),{update(t,n){e.state.doc.content.size!==n.doc.content.size&&a()},destroy:()=>{r!==null&&cancelAnimationFrame(r),t.removeEventListener(`scroll`,a)}}}function kx({editor:e,options:t}){let n=t.dataAttribute?`data-${Sx(t.dataAttribute)}`:`data-${_x}`;return new Gu({key:vx,state:Dx,view:Ox,props:{decorations:({doc:r,selection:i})=>xx({editor:e,options:t,dataAttribute:n,doc:r,selection:i})}})}var Ax=ky.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:_x,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[kx({editor:this.editor,options:this.options})]}});ky.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new Gu({key:new Ju(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||Pv(n.selection)||e.view.dragging?null:xh.create(n.doc,[vh.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function jx({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var Mx=ky.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new Ju(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new Gu({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!jx({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!jx({node:r,types:n})}}})]}}),Nx=ky.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>px(e,t),redo:()=>({state:e,dispatch:t})=>mx(e,t)}},addProseMirrorPlugins(){return[dx(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Px=Ax;function Fx(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ix=Fx();function Lx(e){Ix=e}var Rx={exec:()=>null};function zx(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Vx.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Bx=(()=>{try{return!0}catch{return!1}})(),Vx={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Hx=/^(?:[ \t]*(?:\n|$))+/,Ux=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Wx=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gx=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Kx=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,qx=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Jx=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Yx=zx(Jx).replace(/bull/g,qx).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Xx=zx(Jx).replace(/bull/g,qx).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Zx=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Qx=/^[^\n]+/,$x=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,eS=zx(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,$x).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tS=zx(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,qx).getRegex(),nS=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,rS=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,iS=zx(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,rS).replace(`tag`,nS).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),aS=zx(Zx).replace(`hr`,Gx).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,nS).getRegex(),oS={blockquote:zx(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,aS).getRegex(),code:Ux,def:eS,fences:Wx,heading:Kx,hr:Gx,html:iS,lheading:Yx,list:tS,newline:Hx,paragraph:aS,table:Rx,text:Qx},sS=zx(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Gx).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,nS).getRegex(),cS={...oS,lheading:Xx,table:sS,paragraph:zx(Zx).replace(`hr`,Gx).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,sS).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,nS).getRegex()},lS={...oS,html:zx(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,rS).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Rx,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:zx(Zx).replace(`hr`,Gx).replace(`heading`,` *#{1,6} *[^
|
|
104
|
-
]`).replace(`lheading`,Yx).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},uS=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,dS=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,fS=/^( {2,}|\\)\n(?!\s*$)/,pS=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mS=/[\p{P}\p{S}]/u,hS=/[\s\p{P}\p{S}]/u,gS=/[^\s\p{P}\p{S}]/u,_S=zx(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,hS).getRegex(),vS=/(?!~)[\p{P}\p{S}]/u,yS=/(?!~)[\s\p{P}\p{S}]/u,bS=/(?:[^\s\p{P}\p{S}]|~)/u,xS=zx(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Bx?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),SS=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,CS=zx(SS,`u`).replace(/punct/g,mS).getRegex(),wS=zx(SS,`u`).replace(/punct/g,vS).getRegex(),TS=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,ES=zx(TS,`gu`).replace(/notPunctSpace/g,gS).replace(/punctSpace/g,hS).replace(/punct/g,mS).getRegex(),DS=zx(TS,`gu`).replace(/notPunctSpace/g,bS).replace(/punctSpace/g,yS).replace(/punct/g,vS).getRegex(),OS=zx(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,gS).replace(/punctSpace/g,hS).replace(/punct/g,mS).getRegex(),kS=zx(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,mS).getRegex(),AS=zx(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,gS).replace(/punctSpace/g,hS).replace(/punct/g,mS).getRegex(),jS=zx(/\\(punct)/,`gu`).replace(/punct/g,mS).getRegex(),MS=zx(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),NS=zx(rS).replace(`(?:-->|$)`,`-->`).getRegex(),PS=zx(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,NS).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),FS=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,IS=zx(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,FS).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),LS=zx(/^!?\[(label)\]\[(ref)\]/).replace(`label`,FS).replace(`ref`,$x).getRegex(),RS=zx(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,$x).getRegex(),zS=zx(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,LS).replace(`nolink`,RS).getRegex(),BS=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,VS={_backpedal:Rx,anyPunctuation:jS,autolink:MS,blockSkip:xS,br:fS,code:dS,del:Rx,delLDelim:Rx,delRDelim:Rx,emStrongLDelim:CS,emStrongRDelimAst:ES,emStrongRDelimUnd:OS,escape:uS,link:IS,nolink:RS,punctuation:_S,reflink:LS,reflinkSearch:zS,tag:PS,text:pS,url:Rx},HS={...VS,link:zx(/^!?\[(label)\]\((.*?)\)/).replace(`label`,FS).getRegex(),reflink:zx(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,FS).getRegex()},US={...VS,emStrongRDelimAst:DS,emStrongLDelim:wS,delLDelim:kS,delRDelim:AS,url:zx(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,BS).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:zx(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,BS).getRegex()},WS={...US,br:zx(fS).replace(`{2,}`,`*`).getRegex(),text:zx(US.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},GS={normal:oS,gfm:cS,pedantic:lS},KS={normal:VS,gfm:US,breaks:WS,pedantic:HS},qS={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},JS=e=>qS[e];function YS(e,t){if(t){if(Vx.escapeTest.test(e))return e.replace(Vx.escapeReplace,JS)}else if(Vx.escapeTestNoEncode.test(e))return e.replace(Vx.escapeReplaceNoEncode,JS);return e}function XS(e){try{e=encodeURI(e).replace(Vx.percentDecode,`%`)}catch{return null}return e}function ZS(e,t){let n=e.replace(Vx.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Vx.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Vx.slashPipe,`|`);return n}function QS(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function $S(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function eC(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function tC(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function nC(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
105
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
106
|
-
`)}var rC=class{options;rules;lexer;constructor(e){this.options=e||Ix}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:QS(e,`
|
|
107
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=nC(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=QS(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:QS(t[0],`
|
|
108
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=QS(t[0],`
|
|
109
|
-
`).split(`
|
|
110
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
111
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
112
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
113
|
-
${s}`:s,r=r?`${r}
|
|
114
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
115
|
-
`+e.join(`
|
|
116
|
-
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
117
|
-
`+e.join(`
|
|
118
|
-
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
119
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=eC(t[2].split(`
|
|
120
|
-
`,1)[0],t[1].length),l=e.split(`
|
|
121
|
-
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
122
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
123
|
-
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
124
|
-
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
125
|
-
`+l}u=!l.trim(),r+=p+`
|
|
126
|
-
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ZS(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
127
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(ZS(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
128
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=QS(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=$S(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),tC(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return tC(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},iC=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ix,this.options.tokenizer=this.options.tokenizer||new rC,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Vx,block:GS.normal,inline:KS.normal};this.options.pedantic?(t.block=GS.pedantic,t.inline=KS.pedantic):this.options.gfm&&(t.block=GS.gfm,this.options.breaks?t.inline=KS.breaks:t.inline=KS.gfm),this.tokenizer.rules=t}static get rules(){return{block:GS,inline:KS}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Vx.carriageReturn,`
|
|
129
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Vx.tabCharGlobal,` `).replace(Vx.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
130
|
-
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
131
|
-
`)?``:`
|
|
132
|
-
`)+r.raw,n.text+=`
|
|
133
|
-
`+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
134
|
-
`)?``:`
|
|
135
|
-
`)+r.raw,n.text+=`
|
|
136
|
-
`+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
|
|
137
|
-
`)?``:`
|
|
138
|
-
`)+r.raw,a.text+=`
|
|
139
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
140
|
-
`)?``:`
|
|
141
|
-
`)+r.raw,n.text+=`
|
|
142
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},aC=class{options;parser;constructor(e){this.options=e||Ix}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Vx.notSpaceStart)?.[0],i=e.replace(Vx.endingNewline,``)+`
|
|
143
|
-
`;return r?`<pre><code class="language-`+YS(r)+`">`+(n?i:YS(i,!0))+`</code></pre>
|
|
144
|
-
`:`<pre><code>`+(n?i:YS(i,!0))+`</code></pre>
|
|
145
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
146
|
-
${this.parser.parse(e)}</blockquote>
|
|
147
|
-
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
148
|
-
`}hr(e){return`<hr>
|
|
149
|
-
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
150
|
-
`+r+`</`+i+`>
|
|
151
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
152
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
153
|
-
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
154
|
-
<thead>
|
|
155
|
-
`+t+`</thead>
|
|
156
|
-
`+r+`</table>
|
|
157
|
-
`}tablerow({text:e}){return`<tr>
|
|
158
|
-
${e}</tr>
|
|
159
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
160
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${YS(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=XS(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+YS(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=XS(e);if(i===null)return YS(n);e=i;let a=`<img src="${e}" alt="${YS(n)}"`;return t&&(a+=` title="${YS(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:YS(e.text)}},oC=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},sC=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ix,this.options.renderer=this.options.renderer||new aC,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new oC}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},cC=class{options;block;constructor(e){this.options=e||Ix}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?iC.lex:iC.lexInline}provideParser(e=this.block){return e?sC.parse:sC.parseInline}},lC=new class{defaults=Fx();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=sC;Renderer=aC;TextRenderer=oC;Lexer=iC;Tokenizer=rC;Hooks=cC;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new aC(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new rC(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new cC;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];cC.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&cC.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return iC.lex(e,t??this.defaults)}parser(e,t){return sC.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?iC.lex:iC.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?sC.parse:sC.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?iC.lex:iC.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?sC.parse:sC.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
161
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+YS(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function uC(e,t){return lC.parse(e,t)}uC.options=uC.setOptions=function(e){return lC.setOptions(e),uC.defaults=lC.defaults,Lx(uC.defaults),uC},uC.getDefaults=Fx,uC.defaults=Ix,uC.use=function(...e){return lC.use(...e),uC.defaults=lC.defaults,Lx(uC.defaults),uC},uC.walkTokens=function(e,t){return lC.walkTokens(e,t)},uC.parseInline=lC.parseInline,uC.Parser=sC,uC.parser=sC.parse,uC.Renderer=aC,uC.TextRenderer=oC,uC.Lexer=iC,uC.lexer=iC.lex,uC.Tokenizer=rC,uC.Hooks=cC,uC.parse=uC,uC.options,uC.setOptions,uC.use,uC.walkTokens,uC.parseInline,sC.parse,iC.lex;function dC(e,t){let n=t.split(`
|
|
162
|
-
`).flatMap(e=>[e,``]).map(t=>`${e}${t}`).join(`
|
|
163
|
-
`);return n.slice(0,n.length-1)}function fC(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&Object.is(e[n],t[n])):!1}function pC(e,t){let n=[];return Array.from(e.entries()).forEach(([e,r])=>{if(!t){n.push(e);return}(t.marks||[]).find(t=>t.type===e&&fC(t.attrs,r.attrs))||n.push(e)}),n}function mC(e,t){let n=[];return Array.from(t.entries()).forEach(([t,r])=>{let i=e.get(t);(!i||!fC(i.attrs,r.attrs))&&n.push({type:t,mark:r})}),n}function hC(e,t,n,r){let i=!n,a=n&&(!n.marks||n.marks.length===0),o=n&&n.marks&&!r(t,new Map(n.marks.map(e=>[e.type,e]))),s=[];return(i||a||o)&&(n&&n.marks?Array.from(e.entries()).reverse().forEach(([e,t])=>{n.marks.find(n=>n.type===e&&fC(n.attrs,t.attrs))||s.push(e)}):(i||a)&&s.push(...Array.from(e.keys()).reverse())),s}function gC(e,t){let n=``;return Array.from(e.keys()).reverse().forEach(r=>{let i=t(r,e.get(r));i&&(n=i+n)}),e.clear(),n}function _C(e,t,n){let r=``;return Array.from(e.entries()).forEach(([e,i])=>{let a=n(e,i);a&&(r+=a),t.set(e,i)}),r}function vC(e){let t=(e.raw||e.text||``).match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return t?{isTask:!0,checked:t[2].toLowerCase()===`x`,indentLevel:t[1].length}:{isTask:!1,indentLevel:0}}function yC(e,t){return typeof e==`string`?t:`json`}var bC=e=>{let t=window.HTMLUnknownElement;return typeof t==`function`&&e instanceof t},xC=class{constructor(e){this.activeParseLexer=null,this.extensionRanks=new Map,this.baseExtensions=[],this.extensions=[],this.codeTypes=new Set,this.schemaParseDomTagsCache=null,this.lastParseResult=null,this.markedInstance=e?.marked??uC,this.indentStyle=e?.indentation?.style??`space`,this.indentSize=e?.indentation?.size??2,this.baseExtensions=e?.extensions||[],e?.markedOptions&&typeof this.markedInstance.setOptions==`function`&&this.markedInstance.setOptions(e.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,e?.extensions&&(this.baseExtensions=e.extensions,uv(q_(e.extensions)).forEach(e=>this.registerExtension(e)))}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle===`space`?` `:` `}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(e){this.extensions.push(e);let t=X_(X(e,`code`)),n=e.name;t&&this.codeTypes.add(n),this.extensionRanks.has(n)||this.extensionRanks.set(n,this.extensionRanks.size);let r=X(e,`markdownTokenName`)||n,i=X(e,`parseMarkdown`),a=X(e,`renderMarkdown`),o=X(e,`markdownTokenizer`),s=X(e,`markdownOptions`)??null,c={tokenName:r,nodeName:n,parseMarkdown:i,renderMarkdown:a,isIndenting:s?.indentsContent??!1,htmlReopen:s?.htmlReopen,tokenizer:o};if(r&&i){let e=this.registry.get(r)||[];e.push(c),this.registry.set(r,e)}if(a){let e=this.nodeTypeRegistry.get(n)||[];e.push(c),this.nodeTypeRegistry.set(n,e)}o&&this.hasMarked()&&this.registerTokenizer(o)}createLexer(){return new this.markedInstance.Lexer}createTokenizerHelpers(e){return{inlineTokens:t=>e.inlineTokens(t),blockTokens:t=>e.blockTokens(t)}}tokenizeInline(e){return(this.activeParseLexer??this.createLexer()).inlineTokens(e)}registerTokenizer(e){if(!this.hasMarked())return;let{name:t,start:n,level:r=`inline`,tokenize:i}=e,a=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this),s;s=n?typeof n==`function`?n:e=>e.indexOf(n):e=>{let t=i(e,[],this.createTokenizerHelpers(this.createLexer()));return t&&t.raw?e.indexOf(t.raw):-1};let c={name:t,level:r,start:s,tokenizer(e,n){let r=i(e,n,this.lexer?a(this.lexer):a(o()));if(r&&r.type)return{...r,type:r.type||t,raw:r.raw||``,tokens:r.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[c]})}getHandlersForToken(e){try{return this.registry.get(e)||[]}catch{return[]}}getHandlerForToken(e){let t=this.getHandlersForToken(e);if(t.length>0)return t[0];let n=this.getHandlersForNodeType(e);return n.length>0?n[0]:void 0}getHandlersForNodeType(e){try{return this.nodeTypeRegistry.get(e)||[]}catch{return[]}}serialize(e){if(!e)return``;let t=this.renderNodes(e,e);return this.isEmptyOutput(t)?``:t}isEmptyOutput(e){return!e||e.trim()===``?!0:e.replace(/ /g,``).replace(/\u00A0/g,``).trim()===``}parse(e){if(!this.hasMarked())throw Error(`No marked instance available for parsing`);let t=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{let t=n.lex(e);return{type:`doc`,content:this.parseTokens(t,!0)}}finally{this.activeParseLexer=t}}parseTokens(e,t=!1){let n=e.reduce((e,t,n)=>(t.type!==`space`&&e.push(n),e),[]),r=-1,i=0;return e.flatMap((e,a)=>{for(;i<n.length&&n[i]<a;)r=n[i],i+=1;if(t&&e.type===`space`){let t=n[i]??-1;return this.createImplicitEmptyParagraphsFromSpace(e,r,t)}let o=this.parseToken(e,t);return o===null?[]:Array.isArray(o)?o:[o]})}createImplicitEmptyParagraphsFromSpace(e,t,n){let r=this.countParagraphSeparators(e.raw||``);if(r===0)return[];let i=Math.max(r-(t===-1||n===-1?0:1),0);return Array.from({length:i},()=>({type:`paragraph`,content:[]}))}countParagraphSeparators(e){return(e.replace(/\r\n/g,`
|
|
164
|
-
`).match(/\n\n/g)||[]).length}parseToken(e,t=!1){if(!e.type)return null;if(e.type===`list`)return this.parseListToken(e);let n=this.getHandlersForToken(e.type),r=this.createParseHelpers();if(n.find(t=>{if(!t.parseMarkdown)return!1;let n=t.parseMarkdown(e,r),i=this.normalizeParseResult(n);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let e=this.lastParseResult;return this.lastParseResult=null,e}return this.parseFallbackToken(e,t)}parseListToken(e){if(!e.items||e.items.length===0)return this.parseTokenWithHandlers(e);let t=e.items.some(e=>vC(e).isTask),n=e.items.some(e=>!vC(e).isTask);if(!t||!n||this.getHandlersForToken(`taskList`).length===0)return this.parseTokenWithHandlers(e);let r=[],i=[],a=null;for(let t=0;t<e.items.length;t+=1){let n=e.items[t],{isTask:o,checked:s,indentLevel:c}=vC(n),l=n;if(o){let e=(n.raw||n.text||``).split(`
|
|
165
|
-
`),t=e[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),r=t?t[2]:``,i=[];if(e.length>1&&e.slice(1).join(`
|
|
166
|
-
`).trim()){let t=e.slice(1),n=t.filter(e=>e.trim());if(n.length>0){let e=Math.min(...n.map(e=>e.length-e.trimStart().length)),r=t.map(t=>t.trim()?t.slice(e):``).join(`
|
|
167
|
-
`).trim();r&&(i=this.markedInstance.lexer(`${r}
|
|
168
|
-
`))}}l={type:`taskItem`,raw:``,mainContent:r,indentLevel:c,checked:s??!1,text:r,tokens:this.tokenizeInline(r),nestedTokens:i}}let u=o?`taskList`:`list`;a===u?i.push(l):(i.length>0&&r.push({type:a,items:i}),i=[l],a=u)}i.length>0&&r.push({type:a,items:i});let o=[];for(let t=0;t<r.length;t+=1){let n=r[t],i={...e,type:n.type,items:n.items},a=this.parseToken(i);a&&(Array.isArray(a)?o.push(...a):o.push(a))}return o.length>0?o:null}parseTokenWithHandlers(e){if(!e.type)return null;let t=this.getHandlersForToken(e.type),n=this.createParseHelpers();if(t.find(t=>{if(!t.parseMarkdown)return!1;let r=t.parseMarkdown(e,n),i=this.normalizeParseResult(r);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let e=this.lastParseResult;return this.lastParseResult=null,e}return this.parseFallbackToken(e)}createParseHelpers(){return{parseInline:e=>this.parseInlineTokens(e),tokenizeInline:e=>this.tokenizeInline(e),parseChildren:e=>this.parseTokens(e),parseBlockChildren:e=>this.parseTokens(e,!0),createTextNode:(e,t)=>({type:`text`,text:e,marks:t||void 0}),createNode:(e,t,n)=>{let r={type:e,attrs:t||void 0,content:n||void 0};return(!t||Object.keys(t).length===0)&&delete r.attrs,r},applyMark:(e,t,n)=>({mark:e,content:t,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}parseInlineTokens(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r.type===`text`)t.push({type:`text`,text:$y(r.text||``)});else if(r.type===`html`){let i=(r.raw??r.text??``).toString(),a=/^<\/[\s]*[\w-]+/i.test(i),o=i.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!a&&o&&!/\/>$/.test(i)){let r=o[1],a=this.escapeRegex(r),s=RegExp(`^<\\/\\s*${a}\\b`,`i`),c=-1,l=[i];for(let t=n+1;t<e.length;t+=1){let n=e[t],r=(n.raw??n.text??``).toString();if(l.push(r),n.type===`html`&&s.test(r)){c=t;break}}if(c!==-1){let e=l.join(``),r={type:`html`,raw:e,text:e,block:!1},i=this.parseHTMLToken(r);if(i){let e=this.normalizeParseResult(i);Array.isArray(e)?t.push(...e):e&&t.push(e)}n=c;continue}}let s=this.parseHTMLToken(r);if(s){let e=this.normalizeParseResult(s);Array.isArray(e)?t.push(...e):e&&t.push(e)}}else if(r.type){let e=this.getHandlerForToken(r.type);if(e&&e.parseMarkdown){let n=this.createParseHelpers(),i=e.parseMarkdown(r,n);if(this.isMarkResult(i)){let e=this.applyMarkToContent(i.mark,i.content,i.attrs);t.push(...e)}else{let e=this.normalizeParseResult(i);Array.isArray(e)?t.push(...e):e&&t.push(e)}}else r.tokens&&t.push(...this.parseInlineTokens(r.tokens))}}return t}applyMarkToContent(e,t,n){return t.map(t=>{if(t.type===`text`){let r=t.marks||[],i=n?{type:e,attrs:n}:{type:e};return{...t,marks:[...r,i]}}return{...t,content:t.content?this.applyMarkToContent(e,t.content,n):void 0}})}isMarkResult(e){return e&&typeof e==`object`&&`mark`in e}normalizeParseResult(e){return e?this.isMarkResult(e)?e.content:e:null}parseFallbackToken(e,t=!1){switch(e.type){case`paragraph`:return{type:`paragraph`,content:e.tokens?this.parseInlineTokens(e.tokens):[]};case`heading`:return{type:`heading`,attrs:{level:e.depth||1},content:e.tokens?this.parseInlineTokens(e.tokens):[]};case`text`:return{type:`text`,text:$y(e.text||``)};case`html`:return this.parseHTMLToken(e);case`space`:return null;default:return e.tokens?this.parseTokens(e.tokens,t):null}}parseHTMLToken(e){let t=e.text||e.raw||``;if(!t.trim())return null;if(typeof window>`u`)return e.block?{type:`paragraph`,content:[{type:`text`,text:t}]}:{type:`text`,text:t};if(this.isUnrecognizedHtml(t))return this.htmlAsLiteralText(t,!!e.block);try{let n=pv(t,this.baseExtensions);return n.type===`doc`&&n.content?e.block?n.content:n.content.length===1&&n.content[0].type===`paragraph`&&n.content[0].content?n.content[0].content:n.content:n}catch(e){throw Error(`Failed to parse HTML in markdown: ${e}`)}}isUnrecognizedHtml(e){if(typeof window>`u`||window.DOMParser===void 0)return!1;let t=new window.DOMParser().parseFromString(`<body>${e}</body>`,`text/html`).body.querySelectorAll(`*`);if(t.length===0)return!1;let n=this.getSchemaParseDomTags();return Array.from(t).some(e=>{if(!bC(e))return!1;let t=e.tagName.toLowerCase();return!n.has(t)})}getSchemaParseDomTags(){if(this.schemaParseDomTagsCache)return this.schemaParseDomTagsCache;let e=new Set;try{let t=fv(this.baseExtensions),n=t=>{let n=t?.parseDOM;Array.isArray(n)&&n.forEach(t=>{if(typeof t?.tag==`string`){let n=t.tag.match(/^[a-zA-Z][\w-]*/);n&&e.add(n[0].toLowerCase())}})};Object.values(t.nodes).forEach(e=>n(e.spec)),Object.values(t.marks).forEach(e=>n(e.spec))}catch{}return this.schemaParseDomTagsCache=e,e}htmlAsLiteralText(e,t){let n=e.replace(/\s+$/,``);return n?t?{type:`paragraph`,content:[{type:`text`,text:n}]}:{type:`text`,text:n}:null}encodeTextForMarkdown(e,t,n){return n?.type!=null&&this.codeTypes.has(n.type)||(t.marks||[]).some(e=>this.codeTypes.has(typeof e==`string`?e:e.type))?e:eb(e)}renderNodeToMarkdown(e,t,n=0,r=0,i={}){if(e.type===`text`)return this.encodeTextForMarkdown(e.text||``,e,t);if(!e.type)return``;let a=this.getHandlerForToken(e.type);if(!a)return``;let o=Array.isArray(t?.content)&&n>0?t.content[n-1]:void 0,s={renderChildren:(t,i)=>{let o=a.isIndenting?r+1:r;return!Array.isArray(t)&&t.content?this.renderNodes(t.content,e,i||``,n,o):this.renderNodes(t,e,i||``,n,o)},renderChild:(t,n)=>{let i=a.isIndenting?r+1:r;return this.renderNodeToMarkdown(t,e,n,i)},indent:e=>this.indentString+e,wrapInBlock:dC},c={index:n,level:r,parentType:t?.type,previousNode:o,meta:{parentAttrs:t?.attrs,...i}};return a.renderMarkdown?.call(a,e,s,c)||``}renderNodes(e,t,n=``,r=0,i=0){return Array.isArray(e)?this.renderNodesWithMarkBoundaries(e,t,n,i):e.type?this.renderNodeToMarkdown(e,t,r,i):``}renderNodesWithMarkBoundaries(e,t,n=``,r=0){let i=[],a=new Map,o=new Set,s=new Map;return e.forEach((n,c)=>{let l=c<e.length-1?e[c+1]:null;if(n.type)if(n.type===`text`){let e=this.encodeTextForMarkdown(n.text||``,n,t),r=new Map((n.marks||[]).map(e=>[e.type,e])),c=this.getMarksToOpenForSerialization(a,r,l),u=pC(r,l),d=u.filter(e=>a.has(e)),f=d.length>0&&c.length>0,p=``;if(u.length>0&&!f){let t=e.match(/(\s+)$/);t&&(p=t[1],e=e.slice(0,-p.length))}f||u.slice().reverse().forEach(t=>{if(!a.has(t))return;let n=r.get(t),i=this.getMarkClosing(t,n,s.get(t));i&&(e+=i),a.has(t)&&(a.delete(t),s.delete(t))});let m=``;if(c.length>0){let t=e.match(/^(\s+)/);t&&(m=t[1],e=e.slice(m.length))}c.forEach(({type:t,mark:n})=>{let r=o.has(t)?`html`:`markdown`,i=this.getMarkOpening(t,n,r);i&&(e=i+e),s.set(t,r),o.delete(t)}),f||c.slice().reverse().forEach(({type:e,mark:t})=>{a.set(e,t)}),e=m+e;let h;if(f){let e=new Set((l?.marks||[]).map(e=>e.type));c.forEach(({type:t})=>{e.has(t)&&this.getHtmlReopenTags(t)&&o.add(t)});let t=Array.from(a.keys()),n=d.slice().sort((e,n)=>t.indexOf(n)-t.indexOf(e));h=[...c.map(e=>e.type),...n]}else h=hC(a,r,l,this.markSetsEqual.bind(this));let g=``;if(h.length>0){let t=e.match(/(\s+)$/);t&&(g=t[1],e=e.slice(0,-g.length))}h.forEach(t=>{let n=a.get(t)??r.get(t),i=this.getMarkClosing(t,n,s.get(t));i&&(e+=i),a.delete(t),s.delete(t)}),e+=g,e+=p,i.push(e)}else{let e=new Set((n.marks||[]).map(e=>e.type)),o=new Map,l=new Map;a.forEach((t,n)=>{e.has(n)&&(o.set(n,t),l.set(n,s.get(n)??`markdown`))});let u=gC(a,(e,t)=>this.getMarkClosing(e,t,s.get(e)));s.clear();let d=this.renderNodeToMarkdown(n,t,c,r),f=n.type===`hardBreak`?``:_C(o,a,(e,t)=>{let n=l.get(e)??`markdown`;return s.set(e,n),this.getMarkOpening(e,t,n)});i.push(u+d+f)}}),i.join(n)}getMarkOpening(e,t,n=`markdown`){if(n===`html`)return this.getHtmlReopenTags(e)?.open||``;let r=this.getHandlersForNodeType(e),i=r.length>0?r[0]:void 0;if(!i||!i.renderMarkdown)return``;let a=`__TIPTAP_MARKDOWN_PLACEHOLDER__`,o={type:e,attrs:t.attrs||{},content:[{type:`text`,text:a}]};try{let e=i.renderMarkdown(o,{renderChildren:()=>a,renderChild:()=>a,indent:e=>e,wrapInBlock:(e,t)=>e+t},{index:0,level:0,parentType:`text`,meta:{}}),t=e.indexOf(a);return t>=0?e.substring(0,t):``}catch(t){throw Error(`Failed to get mark opening for ${e}: ${t}`)}}getMarkClosing(e,t,n=`markdown`){if(n===`html`)return this.getHtmlReopenTags(e)?.close||``;let r=this.getHandlersForNodeType(e),i=r.length>0?r[0]:void 0;if(!i||!i.renderMarkdown)return``;let a=`__TIPTAP_MARKDOWN_PLACEHOLDER__`,o={type:e,attrs:t.attrs||{},content:[{type:`text`,text:a}]};try{let e=i.renderMarkdown(o,{renderChildren:()=>a,renderChild:()=>a,indent:e=>e,wrapInBlock:(e,t)=>e+t},{index:0,level:0,parentType:`text`,meta:{}}),t=e.indexOf(a),n=t+33;return t>=0?e.substring(n):``}catch(t){throw Error(`Failed to get mark closing for ${e}: ${t}`)}}getHtmlReopenTags(e){let t=this.getHandlersForNodeType(e);return(t.length>0?t[0]:void 0)?.htmlReopen}markSetsEqual(e,t){return e.size===t.size?Array.from(e.entries()).every(([e,n])=>{let r=t.get(e);return r&&fC(n.attrs,r.attrs)}):!1}getMarksToOpenForSerialization(e,t,n){let r=mC(e,t);if(r.length<=1)return r;let i=n?.marks||[],a=(e,t)=>i.some(n=>n.type===e&&fC(n.attrs,t)),o=(e,t)=>{let n=this.extensionRanks.get(e.type)??2**53-1,r=this.extensionRanks.get(t.type)??2**53-1;return n===r?e.type.localeCompare(t.type):r-n},s=r.filter(e=>!a(e.type,e.mark.attrs)).sort(o),c=r.filter(e=>a(e.type,e.mark.attrs)).sort(o);return[...s,...c]}},SC=ky.create({name:`markdown`,addOptions(){return{indentation:{style:`space`,size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(e,t)=>{if(!t?.contentType||yC(e,t?.contentType)!==`markdown`||!this.editor.markdown)return Dg.setContent(e,t);let n=this.editor.markdown.parse(e);return Dg.setContent(n,t)},insertContent:(e,t)=>{if(!t?.contentType||yC(e,t?.contentType)!==`markdown`||!this.editor.markdown)return Dg.insertContent(e,t);let n=this.editor.markdown.parse(e);return Dg.insertContent(n,t)},insertContentAt:(e,t,n)=>{if(!n?.contentType||yC(t,n?.contentType)!==`markdown`||!this.editor.markdown)return Dg.insertContentAt(e,t,n);let r=this.editor.markdown.parse(t);return Dg.insertContentAt(e,r,n)}}},addStorage(){return{manager:new xC({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new xC({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||yC(this.editor.options.content,this.editor.options.contentType)!==`markdown`)return;if(!this.editor.markdown)throw Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!=`string`)throw Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');let e=this.editor.markdown.parse(this.editor.options.content);e.content?.length&&(this.editor.options.content=e)}}),CC=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},wC=/^\s*>\s$/,TC=fb.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return CC(`blockquote`,{...nv(this.options.HTMLAttributes,e),children:CC(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
169
|
-
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
|
|
170
|
-
`))}),n.join(`
|
|
171
|
-
>
|
|
172
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Jy({find:wC,type:this.type})]}}),EC=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,DC=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,OC=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,kC=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,AC=by.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return CC(`strong`,{...nv(this.options.HTMLAttributes,e),children:CC(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Gy({find:EC,type:this.type}),Gy({find:OC,type:this.type})]},addPasteRules(){return[mb({find:DC,type:this.type}),mb({find:kC,type:this.type})]}}),jC=4,MC=/^```([a-z]+)?[\s\n]$/,NC=/^~~~([a-z]+)?[\s\n]$/,PC=fb.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:jC,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,nv(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
|
|
173
|
-
`):`\`\`\`${r}
|
|
174
|
-
|
|
175
|
-
\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??jC,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
|
|
176
|
-
`,`
|
|
177
|
-
`).split(`
|
|
178
|
-
`).map(e=>o+e).join(`
|
|
179
|
-
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??jC,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
|
|
180
|
-
`,`
|
|
181
|
-
`).split(`
|
|
182
|
-
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(J.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
|
|
183
|
-
`,`
|
|
184
|
-
`).split(`
|
|
185
|
-
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
|
|
186
|
-
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
187
|
-
|
|
188
|
-
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(q.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[qy({find:MC,type:this.type,getAttributes:e=>({language:e[1]})}),qy({find:NC,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Gu({key:new Ju(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
189
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(J.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),FC=fb.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
190
|
-
|
|
191
|
-
`):``}),IC=fb.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,nv(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
192
|
-
`},renderMarkdown:()=>`
|
|
193
|
-
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),LC=fb.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,nv(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>qy({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),RC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,BC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,VC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,HC=by.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,nv(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Gy({find:RC,type:this.type}),Gy({find:BC,type:this.type})]},addPasteRules(){return[mb({find:zC,type:this.type}),mb({find:VC,type:this.type})]}}),UC=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,WC=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,GC=`numeric`,KC=`ascii`,qC=`alpha`,JC=`asciinumeric`,YC=`alphanumeric`,XC=`domain`,ZC=`emoji`,QC=`scheme`,$C=`slashscheme`,ew=`whitespace`;function tw(e,t){return e in t||(t[e]=[]),t[e]}function nw(e,t,n){t[GC]&&(t[JC]=!0,t[YC]=!0),t[KC]&&(t[JC]=!0,t[qC]=!0),t[JC]&&(t[YC]=!0),t[qC]&&(t[YC]=!0),t[YC]&&(t[XC]=!0),t[ZC]&&(t[XC]=!0);for(let r in t){let t=tw(r,n);t.indexOf(e)<0&&t.push(e)}}function rw(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function iw(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}iw.groups={},iw.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=iw.groups;let i;return t&&t.j?i=t:(i=new iw(t),n&&r&&nw(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=iw.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new iw,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new iw,a&&(r&&(o.t&&typeof o.t==`string`?nw(a,Object.assign(rw(o.t,r),n),r):n&&nw(a,n,r)),o.t=a),i.j[e]=o,o}};var Z=(e,t,n,r,i)=>e.ta(t,n,r,i),aw=(e,t,n,r,i)=>e.tr(t,n,r,i),ow=(e,t,n,r,i)=>e.ts(t,n,r,i),Q=(e,t,n,r,i)=>e.tt(t,n,r,i),sw=`WORD`,cw=`UWORD`,lw=`ASCIINUMERICAL`,uw=`ALPHANUMERICAL`,dw=`LOCALHOST`,fw=`TLD`,pw=`UTLD`,mw=`SCHEME`,hw=`SLASH_SCHEME`,gw=`NUM`,_w=`WS`,vw=`NL`,yw=`OPENBRACE`,bw=`CLOSEBRACE`,xw=`OPENBRACKET`,Sw=`CLOSEBRACKET`,Cw=`OPENPAREN`,ww=`CLOSEPAREN`,Tw=`OPENANGLEBRACKET`,Ew=`CLOSEANGLEBRACKET`,Dw=`FULLWIDTHLEFTPAREN`,Ow=`FULLWIDTHRIGHTPAREN`,kw=`LEFTCORNERBRACKET`,Aw=`RIGHTCORNERBRACKET`,jw=`LEFTWHITECORNERBRACKET`,Mw=`RIGHTWHITECORNERBRACKET`,Nw=`FULLWIDTHLESSTHAN`,Pw=`FULLWIDTHGREATERTHAN`,Fw=`AMPERSAND`,Iw=`APOSTROPHE`,Lw=`ASTERISK`,Rw=`AT`,zw=`BACKSLASH`,Bw=`BACKTICK`,Vw=`CARET`,Hw=`COLON`,Uw=`COMMA`,Ww=`DOLLAR`,Gw=`DOT`,Kw=`EQUALS`,qw=`EXCLAMATION`,Jw=`HYPHEN`,Yw=`PERCENT`,Xw=`PIPE`,Zw=`PLUS`,Qw=`POUND`,$w=`QUERY`,eT=`QUOTE`,tT=`FULLWIDTHMIDDLEDOT`,nT=`SEMI`,rT=`SLASH`,iT=`TILDE`,aT=`UNDERSCORE`,oT=`EMOJI`,sT=`SYM`,cT=Object.freeze({__proto__:null,ALPHANUMERICAL:uw,AMPERSAND:Fw,APOSTROPHE:Iw,ASCIINUMERICAL:lw,ASTERISK:Lw,AT:Rw,BACKSLASH:zw,BACKTICK:Bw,CARET:Vw,CLOSEANGLEBRACKET:Ew,CLOSEBRACE:bw,CLOSEBRACKET:Sw,CLOSEPAREN:ww,COLON:Hw,COMMA:Uw,DOLLAR:Ww,DOT:Gw,EMOJI:oT,EQUALS:Kw,EXCLAMATION:qw,FULLWIDTHGREATERTHAN:Pw,FULLWIDTHLEFTPAREN:Dw,FULLWIDTHLESSTHAN:Nw,FULLWIDTHMIDDLEDOT:tT,FULLWIDTHRIGHTPAREN:Ow,HYPHEN:Jw,LEFTCORNERBRACKET:kw,LEFTWHITECORNERBRACKET:jw,LOCALHOST:dw,NL:vw,NUM:gw,OPENANGLEBRACKET:Tw,OPENBRACE:yw,OPENBRACKET:xw,OPENPAREN:Cw,PERCENT:Yw,PIPE:Xw,PLUS:Zw,POUND:Qw,QUERY:$w,QUOTE:eT,RIGHTCORNERBRACKET:Aw,RIGHTWHITECORNERBRACKET:Mw,SCHEME:mw,SEMI:nT,SLASH:rT,SLASH_SCHEME:hw,SYM:sT,TILDE:iT,TLD:fw,UNDERSCORE:aT,UTLD:pw,UWORD:cw,WORD:sw,WS:_w}),lT=/[a-z]/,uT=/\p{L}/u,dT=/\p{Emoji}/u,fT=/\d/,pT=/\s/,mT=`\r`,hT=`
|
|
194
|
-
`,gT=`️`,_T=``,vT=``,yT=null,bT=null;function xT(e=[]){let t={};iw.groups=t;let n=new iw;yT??=TT(UC),bT??=TT(WC),Q(n,`'`,Iw),Q(n,`{`,yw),Q(n,`}`,bw),Q(n,`[`,xw),Q(n,`]`,Sw),Q(n,`(`,Cw),Q(n,`)`,ww),Q(n,`<`,Tw),Q(n,`>`,Ew),Q(n,`(`,Dw),Q(n,`)`,Ow),Q(n,`「`,kw),Q(n,`」`,Aw),Q(n,`『`,jw),Q(n,`』`,Mw),Q(n,`<`,Nw),Q(n,`>`,Pw),Q(n,`&`,Fw),Q(n,`*`,Lw),Q(n,`@`,Rw),Q(n,"`",Bw),Q(n,`^`,Vw),Q(n,`:`,Hw),Q(n,`,`,Uw),Q(n,`$`,Ww),Q(n,`.`,Gw),Q(n,`=`,Kw),Q(n,`!`,qw),Q(n,`-`,Jw),Q(n,`%`,Yw),Q(n,`|`,Xw),Q(n,`+`,Zw),Q(n,`#`,Qw),Q(n,`?`,$w),Q(n,`"`,eT),Q(n,`/`,rT),Q(n,`;`,nT),Q(n,`~`,iT),Q(n,`_`,aT),Q(n,`\\`,zw),Q(n,`・`,tT);let r=aw(n,fT,gw,{[GC]:!0});aw(r,fT,r);let i=aw(r,lT,lw,{[JC]:!0}),a=aw(r,uT,uw,{[YC]:!0}),o=aw(n,lT,sw,{[KC]:!0});aw(o,fT,i),aw(o,lT,o),aw(i,fT,i),aw(i,lT,i);let s=aw(n,uT,cw,{[qC]:!0});aw(s,lT),aw(s,fT,a),aw(s,uT,s),aw(a,fT,a),aw(a,lT),aw(a,uT,a);let c=Q(n,hT,vw,{[ew]:!0}),l=Q(n,mT,_w,{[ew]:!0}),u=aw(n,pT,_w,{[ew]:!0});Q(n,vT,u),Q(l,hT,c),Q(l,vT,u),aw(l,pT,u),Q(u,mT),Q(u,hT),aw(u,pT,u),Q(u,vT,u);let d=aw(n,dT,oT,{[ZC]:!0});Q(d,`#`),aw(d,dT,d),Q(d,gT,d);let f=Q(d,_T);Q(f,`#`),aw(f,dT,d);let p=[[lT,o],[fT,i]],m=[[lT,null],[uT,s],[fT,a]];for(let e=0;e<yT.length;e++)wT(n,yT[e],fw,sw,p);for(let e=0;e<bT.length;e++)wT(n,bT[e],pw,cw,m);nw(fw,{tld:!0,ascii:!0},t),nw(pw,{utld:!0,alpha:!0},t),wT(n,`file`,mw,sw,p),wT(n,`mailto`,mw,sw,p),wT(n,`http`,hw,sw,p),wT(n,`https`,hw,sw,p),wT(n,`ftp`,hw,sw,p),wT(n,`ftps`,hw,sw,p),nw(mw,{scheme:!0,ascii:!0},t),nw(hw,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[QC]:!0}:{[$C]:!0};r.indexOf(`-`)>=0?i[XC]=!0:lT.test(r)?fT.test(r)?i[JC]=!0:i[KC]=!0:i[GC]=!0,ow(n,r,r,i)}return ow(n,`localhost`,dw,{ascii:!0}),n.jd=new iw(sT),{start:n,tokens:Object.assign({groups:t},cT)}}function ST(e,t){let n=CT(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function CT(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function wT(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new iw(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new iw(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function TT(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var ET={defaultProtocol:`http`,events:null,format:OT,formatHref:OT,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function DT(e,t=null){let n=Object.assign({},ET);e&&(n=Object.assign(n,e instanceof DT?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}DT.prototype={o:ET,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:ET[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function OT(e){return e}function kT(e,t){this.t=`token`,this.v=e,this.tk=t}kT.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=ET.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function AT(e,t){class n extends kT{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var jT=AT(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),MT=AT(`text`),NT=AT(`nl`),PT=AT(`url`,{isLink:!0,toHref(e=ET.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==dw&&e[1].t===Hw}}),FT=e=>new iw(e);function IT({groups:e}){let t=e.domain.concat([Fw,Lw,Rw,zw,Bw,Vw,Ww,Kw,Jw,gw,Yw,Xw,Zw,Qw,rT,sT,iT,aT]),n=[Iw,Hw,Uw,Gw,qw,Yw,$w,eT,nT,Tw,Ew,yw,bw,Sw,xw,Cw,ww,Dw,Ow,kw,Aw,jw,Mw,Nw,Pw],r=[Fw,Iw,Lw,zw,Bw,Vw,Ww,Kw,Jw,yw,bw,Yw,Xw,Zw,Qw,$w,rT,sT,iT,aT],i=FT(),a=Q(i,iT);Z(a,r,a),Z(a,e.domain,a);let o=FT(),s=FT(),c=FT();Z(i,e.domain,o),Z(i,e.scheme,s),Z(i,e.slashscheme,c),Z(o,r,a),Z(o,e.domain,o);let l=Q(o,Rw);Q(a,Rw,l),Q(s,Rw,l),Q(c,Rw,l);let u=Q(a,Gw);Z(u,r,a),Z(u,e.domain,a);let d=FT();Z(l,e.domain,d),Z(d,e.domain,d);let f=Q(d,Gw);Z(f,e.domain,d);let p=FT(jT);Z(f,e.tld,p),Z(f,e.utld,p),Q(l,dw,p);let m=Q(d,Jw);Q(m,Jw,m),Z(m,e.domain,d),Z(p,e.domain,d),Q(p,Gw,f),Q(p,Jw,m);let h=Q(o,Jw),g=Q(o,Gw);Q(h,Jw,h),Z(h,e.domain,o),Z(g,r,a),Z(g,e.domain,o);let _=FT(PT);Z(g,e.tld,_),Z(g,e.utld,_),Z(_,e.domain,o),Z(_,r,a),Q(_,Gw,g),Q(_,Jw,h),Q(_,Rw,l);let v=Q(_,Hw),y=FT(PT);Z(v,e.numeric,y);let b=FT(PT),x=FT();Z(b,t,b),Z(b,n,x),Z(x,t,b),Z(x,n,x),Q(_,rT,b),Q(y,rT,b);let S=Q(s,Hw),C=Q(Q(Q(c,Hw),rT),rT);Z(s,e.domain,o),Q(s,Gw,g),Q(s,Jw,h),Z(c,e.domain,o),Q(c,Gw,g),Q(c,Jw,h),Z(S,e.domain,b),Q(S,rT,b),Q(S,$w,b),Z(C,e.domain,b),Z(C,t,b),Q(C,rT,b);let w=[[yw,bw],[xw,Sw],[Cw,ww],[Tw,Ew],[Dw,Ow],[kw,Aw],[jw,Mw],[Nw,Pw]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=Q(b,r);Q(x,r,a);let o=FT(PT);Z(a,t,o);let s=FT();Z(a,n,s),Q(a,i,b),Z(o,t,o),Z(o,n,s),Z(s,t,o),Z(s,n,s),Q(o,i,b),Q(s,i,b)}return Q(i,dw,_),Q(i,vw,NT),{start:i,tokens:cT}}function LT(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(RT(MT,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(RT(e,t,r))}}return o.length>0&&a.push(RT(MT,t,o)),a}function RT(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var zT=typeof console<`u`&&console&&console.warn||(()=>{}),BT=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,VT={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function HT(){return iw.groups={},VT.scanner=null,VT.parser=null,VT.tokenQueue=[],VT.pluginQueue=[],VT.customSchemes=[],VT.initialized=!1,VT}function UT(e,t=!1){if(VT.initialized&&zT(`linkifyjs: already initialized - will not register custom scheme "${e}" ${BT}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
195
|
-
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
196
|
-
2. Cannot start or end with "-"
|
|
197
|
-
3. "-" cannot repeat`);VT.customSchemes.push([e,t])}function WT(){VT.scanner=xT(VT.customSchemes);for(let e=0;e<VT.tokenQueue.length;e++)VT.tokenQueue[e][1]({scanner:VT.scanner});VT.parser=IT(VT.scanner.tokens);for(let e=0;e<VT.pluginQueue.length;e++)VT.pluginQueue[e][1]({scanner:VT.scanner,parser:VT.parser});return VT.initialized=!0,VT}function GT(e){return VT.initialized||WT(),LT(VT.parser.start,e,ST(VT.scanner.start,e))}GT.scan=ST;function KT(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new DT(n),i=GT(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var qT=`[\0- \xA0 -\u2029 ]`,JT=new RegExp(qT),YT=RegExp(`${qT}$`),XT=new RegExp(qT,`g`);function ZT(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function QT(e){return new Gu({key:new Ju(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(xv(H_(n.doc,[...t])).forEach(({newRange:t})=>{let n=W_(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!YT.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(JT).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=GT(n).map(t=>t.toObject(e.defaultProtocol));if(!ZT(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Sv(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function $T(e){return new Gu({key:new Ju(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=vv(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}function eE(e){return new Gu({key:new Ju(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=KT(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function tE(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(XT,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,`i`))}var nE=by.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){UT(e);return}UT(e.scheme,e.optionalSlashes)})},onDestroy(){HT()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!tE(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!tE(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!tE(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,nv(this.options.HTMLAttributes,e),0]:[`a`,nv(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!tE(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!tE(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[mb({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=KT(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!tE(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(QT({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!tE(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push($T({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(eE({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),rE=Object.defineProperty,iE=(e,t)=>{for(var n in t)rE(e,n,{get:t[n],enumerable:!0})},aE=`listItem`,oE=`textStyle`,sE=/^\s*([-+*])\s$/,cE=fb.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,nv(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
198
|
-
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(aE,this.editor.getAttributes(oE)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Jy({find:sE,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Jy({find:sE,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(oE),editor:this.editor})),[e]}});function lE(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function uE(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var dE=fb.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,nv(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(lE(e))return{type:`listItem`,content:[{type:`paragraph`,content:uE(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>ub(e,t,e=>e.parentType===`bulletList`?`- `:e.parentType===`orderedList`?`${(e.meta?.parentAttrs?.start||1)+e.index}. `:`- `,n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});iE({},{findListItemPos:()=>fE,getNextListDepth:()=>pE,handleBackspace:()=>_E,handleDelete:()=>bE,hasListBefore:()=>mE,hasListItemAfter:()=>xE,hasListItemBefore:()=>hE,listItemHasSubList:()=>gE,nextListIsDeeper:()=>vE,nextListIsHigher:()=>yE});var fE=(e,t)=>{let{$from:n}=t.selection,r=Fg(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},pE=(e,t)=>{let n=fE(e,t);if(!n)return!1;let[,r]=Cv(t,e,n.$pos.pos+4);return r},mE=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},hE=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return!(r.index()===0||r.nodeBefore?.type.name!==e)},gE=(e,t,n)=>{if(!n)return!1;let r=Fg(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},_E=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!w_(e.state,t)&&mE(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!w_(e.state,t)||!Av(e.state))return!1;let r=fE(t,e.state);if(!r)return!1;let i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=gE(t,e.state,i);return hE(t,e.state)&&!a?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},vE=(e,t)=>{let n=pE(e,t),r=fE(e,t);return!r||!n?!1:n>r.depth},yE=(e,t)=>{let n=pE(e,t),r=fE(e,t);return!r||!n?!1:n<r.depth},bE=(e,t)=>{if(!w_(e.state,t)||!kv(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:vE(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():yE(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},xE=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return!(r.index()===r.parent.childCount-1||r.nodeAfter?.type.name!==e)},SE=ky.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&bE(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&bE(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&_E(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&_E(e,n,r)&&(t=!0)}),t}}}}),CE=/^(\s*)(\d+)\.\s+(.*)$/,wE=/^\s/;function TE(e){let t=e.trimStart();return/^[-+*]\s+/.test(t)||/^\d+\.\s+/.test(t)||/^>\s?/.test(t)||/^```/.test(t)||/^~~~/.test(t)}function EE(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&TE(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function DE(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(CE);if(!a)break;let[,o,s,c]=a,l=o.length,u=[c],d=n+1,f=[i],p=!1;for(;d<e.length;){let t=e[d];if(t.match(CE))break;if(t.trim()===``)f.push(t),u.push(``),p=!0,d+=1;else if(t.match(wE))f.push(t),u.push(t.slice(l+2)),d+=1;else{if(p)break;f.push(t),u.push(t),d+=1}}t.push({indent:l,number:parseInt(s,10),content:u.join(`
|
|
199
|
-
`).trim(),contentLines:u,raw:f.join(`
|
|
200
|
-
`)}),r=d,n=d}return[t,r]}function OE(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=EE(a.contentLines),c=o.join(`
|
|
201
|
-
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
202
|
-
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=OE(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,items:e,raw:f.map(e=>e.raw).join(`
|
|
203
|
-
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function kE(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var AE=`listItem`,jE=`textStyle`,ME=/^(\d+)\.\s$/,NE=fb.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,nv(this.options.HTMLAttributes,n),0]:[`ol`,nv(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.items?kE(e.items,t):[];return n===1?{type:`orderedList`,content:r}:{type:`orderedList`,attrs:{start:n},content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
204
|
-
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(`
|
|
205
|
-
`),[i,a]=DE(r);if(i.length===0)return;let o=OE(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(`
|
|
206
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AE,this.editor.getAttributes(jE)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=Jy({find:ME,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Jy({find:ME,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(jE)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),PE=/^\s*(\[([( |x])?\])\s$/,FE=fb.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,nv(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>ub(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=rv(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Jy({find:PE,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),IE=fb.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,nv(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
207
|
-
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=lb(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=lb(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ky.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(cE.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(dE.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(SE.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(NE.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(FE.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(IE.configure(this.options.taskList)),e}});var LE=` `,RE=`\xA0`,zE=fb.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,nv(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===LE||n[0].text===LE||n[0].raw===RE||n[0].text===RE)&&r.length===1&&r[0].type===`text`&&(r[0].text===LE||r[0].text===RE)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?LE:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),BE=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,VE=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,HE=by.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,nv(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Gy({find:BE,type:this.type})]},addPasteRules(){return[mb({find:VE,type:this.type})]}}),UE=fb.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),WE=by.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,nv(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),GE=ky.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(AC.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(TC.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(cE.configure(this.options.bulletList)),this.options.code!==!1&&e.push(_b.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(PC.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(FC.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(hx.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(gx.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(IC.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(LC.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(Nx.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(yb.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(HC.configure(this.options.italic)),this.options.listItem!==!1&&e.push(dE.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(SE.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(nE.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(NE.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(zE.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(HE.configure(this.options.strike)),this.options.text!==!1&&e.push(UE.configure(this.options.text)),this.options.underline!==!1&&e.push(WE.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(Mx.configure(this.options?.trailingNode)),e}});function KE(e){return ue((t,n)=>({get(){return t(),e},set(t){e=t,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})}}))}var qE=class extends Wy{constructor(e={}){return super(e),this.contentComponent=null,this.appContext=null,this.reactiveState=KE(this.view.state),this.reactiveExtensionStorage=KE(this.extensionStorage),this.on(`beforeTransaction`,({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),me(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){let n=super.registerPlugin(e,t);return this.reactiveState&&(this.reactiveState.value=n),n}unregisterPlugin(e){let t=super.unregisterPlugin(e);return this.reactiveState&&t&&(this.reactiveState.value=t),t}},JE=A({name:`EditorContent`,props:{editor:{default:null,type:Object}},setup(e){let t=L(),n=Ve();return M(()=>{let r=e.editor;r&&r.options.element&&t.value&&v(()=>{if(!t.value||!r.view.dom?.parentNode)return;let e=w(t.value);t.value.append(...r.view.dom.parentNode.childNodes),r.contentComponent=n.ctx._,n&&(r.appContext={...n.appContext,provides:n.provides}),r.setOptions({element:e}),r.createNodeViews()})}),_(()=>{let t=e.editor;t&&(t.contentComponent=null,t.appContext=null)}),{rootEl:t}},render(){return ie(`div`,{ref:e=>{this.rootEl=e}})}});A({name:`NodeViewContent`,props:{as:{type:String,default:`div`}},render(){return ie(this.as,{style:{whiteSpace:`pre-wrap`},"data-node-view-content":``})}});var YE=A({name:`NodeViewWrapper`,props:{as:{type:String,default:`div`}},inject:[`onDragStart`,`decorationClasses`],render(){var e;return ie(this.as,{class:this.decorationClasses,style:{whiteSpace:`normal`},"data-node-view-wrapper":``,onDragstart:this.onDragStart},(e=this.$slots).default?.call(e))}}),XE=(e={})=>{let t=c();return ce(()=>{t.value=new qE(e)}),_(()=>{var e;(e=t.value)==null||e.destroy()}),t},ZE=class{constructor(e,{props:t={},editor:n}){this.destroyed=!1,this.editor=n,this.component=me(e),this.el=document.createElement(`div`),this.props=te(t),this.renderedComponent=this.renderComponent()}get element(){return this.renderedComponent.el}get ref(){return this.renderedComponent.vNode?.component?.exposed?this.renderedComponent.vNode.component.exposed:this.renderedComponent.vNode?.component?.proxy}renderComponent(){if(this.destroyed)return this.renderedComponent;let e=ie(this.component,this.props);return this.editor.appContext&&(e.appContext=this.editor.appContext),typeof document<`u`&&this.el&&j(e,this.el),{vNode:e,destroy:()=>{this.el&&j(null,this.el),this.el=null,e=null},el:this.el?this.el.firstElementChild:null}}updateProps(e={}){this.destroyed||(Object.entries(e).forEach(([e,t])=>{this.props[e]=t}),this.renderComponent())}destroy(){this.destroyed||(this.destroyed=!0,this.renderedComponent.destroy())}};A({name:`MarkViewContent`,props:{as:{type:String,default:`span`}},render(){return ie(this.as,{style:{whiteSpace:`inherit`},"data-mark-view-content":``})}});var QE=class extends pb{constructor(e,t,n){super(e,t,n),this.cachedExtensionWithSyncedStorage=null,this.handlePositionUpdate=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}))},this.options.trackNodeViewPosition&&this.editor.on(`update`,this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode()},n=e,r=this.onDragStart.bind(this);this.decorationClasses=L(this.getDecorationClasses());let i=A({extends:{...this.component},props:Object.keys(e),template:this.component.template,setup:e=>{var n;return t(`onDragStart`,r),t(`decorationClasses`,this.decorationClasses),(n=this.component).setup?.call(n,e,{expose:()=>void 0})},__scopeId:this.component.__scopeId,__cssModules:this.component.__cssModules,__name:this.component.__name,__file:this.component.__file});this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.currentPos=this.getPos(),this.renderer=new ZE(i,{editor:this.editor,props:n})}get dom(){if(!this.renderer.element||!this.renderer.element.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.dom.querySelector(`[data-node-view-content]`)}handleSelectionUpdate(){let e=this.getPos();if(typeof e==`number`)if(Fv({selection:this.editor.state.selection,pos:e,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,n){let r=e=>{this.decorationClasses.value=this.getDecorationClasses(),this.renderer.updateProps(e)};if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e.type!==this.node.type)return!1;if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,this.decorationClasses.value=this.getDecorationClasses(),!0;this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos();let i={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(i.getPos=()=>this.getPos()),r(i),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element&&this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element&&this.renderer.element.classList.remove(`ProseMirror-selectednode`)}getDecorationClasses(){return this.decorations.flatMap(e=>e.type.attrs.class).join(` `)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off(`update`,this.handlePositionUpdate)}};function $E(e,t){return n=>n.editor.contentComponent?new QE(typeof e==`function`&&`__vccOpts`in e?e.__vccOpts:e,n,t):{}}function eD(e,t){if(!t?.schema)return!1;let n=typeof e==`string`?e:e.name;return t.schema.spec.marks.get(n)!==void 0}function tD(e,t){if(!e)return!1;let{selection:n}=e.state,{$from:r,to:i}=n;return t.some(t=>e.state.doc.nodesBetween(r.pos,i,e=>e.type.name===t))}function nD(e,t){return e?e.extensionManager.extensions.some(e=>e.name===t):!1}function rD(e){let t=`toggle${e.charAt(0).toUpperCase()}${e.slice(1)}`;return{canExecute:e=>e.can()[t](),execute:e=>e.chain().focus()[t](),isActive:t=>t.isActive(e),isDisabled:e=>tD(e,[`image`])||e.isActive(`code`)}}function iD(e){let t=`set${e.charAt(0).toUpperCase()}${e.slice(1)}`;return{canExecute:e=>e.can()[t](),execute:e=>e.chain().focus()[t](),isActive:t=>t.isActive(e),isDisabled:e=>tD(e,[`image`])||e.isActive(`code`)}}function aD(e){return{canExecute:t=>t.can()[e](),execute:t=>t.chain()[e](),isActive:()=>!1,isDisabled:void 0}}function oD(){return{canExecute:(e,t)=>e.can().toggleMark(t.mark),execute:(e,t)=>e.chain().focus().toggleMark(t.mark),isActive:(e,t)=>e.isActive(t.mark),isDisabled:(e,t)=>!eD(t.mark,e)||tD(e,[`image`])}}function sD(){return{canExecute:(e,t)=>e.can().setTextAlign(t.align),execute:(e,t)=>e.chain().focus().setTextAlign(t.align),isActive:(e,t)=>e.isActive({textAlign:t.align}),isDisabled:e=>!nD(e,`textAlign`)||tD(e,[`image`,`horizontalRule`])}}function cD(){return{canExecute:(e,t)=>e.can().toggleHeading({level:t.level}),execute:(e,t)=>e.chain().focus().toggleHeading({level:t.level}),isActive:(e,t)=>e.isActive(`heading`,{level:t.level}),isDisabled:e=>tD(e,[`image`])||e.isActive(`code`)}}function lD(){return{canExecute:e=>e.can().setLink({href:``})||e.can().unsetLink(),execute:(e,t)=>{let n=e.chain(),r=e.getAttributes(`link`).href,i=e.isActive(`code`);if(r)return n.focus().unsetLink();let a=t?.href||prompt(`Enter the URL:`);return a?i?n.focus().extendMarkRange(`code`).setLink({href:a}):n.focus().setLink({href:a}):n},isActive:e=>e.isActive(`link`),isDisabled:e=>{if(!nD(e,`link`)||tD(e,[`image`]))return!0;let{selection:t}=e.state;return t.empty&&!e.isActive(`link`)}}}function uD(){return{canExecute:e=>e.can().setImage({src:``}),execute:(e,t)=>{let n=e.chain().focus();if(t?.src)return n.setImage({src:t.src});let r=prompt(`Enter the image URL:`);return r?n.setImage({src:r}):n},isActive:e=>e.isActive(`image`),isDisabled:e=>!nD(e,`image`)}}function dD(e){let t={bulletList:`toggleBulletList`,orderedList:`toggleOrderedList`,taskList:`toggleTaskList`}[e],n=e===`taskList`?`taskItem`:`listItem`,r=[`bulletList`,`orderedList`,`taskList`];return{canExecute:e=>e.can()[t]()||e.isActive(`listItem`)||r.some(t=>nD(e,t)&&e.isActive(t)),execute:i=>{let{state:a}=i,{selection:o}=a,s=i.chain().focus();if(o.node){let e=o.node,t=e.firstChild?.firstChild,n=e.lastChild?.lastChild,r=t?o.from+t.nodeSize:o.from+1,i=n?o.to-n.nodeSize:o.to-1;s=s.setTextSelection({from:r,to:i}).clearNodes()}if(i.isActive(e)){let e=s.liftListItem(n);for(let t of r)nD(i,t)&&(e=e.lift(t));return e.selectTextblockEnd()}if(r.some(e=>nD(i,e)&&i.isActive(e))){let e=i.isActive(`taskList`)?`taskItem`:`listItem`,n=s.liftListItem(e);for(let e of r)nD(i,e)&&(n=n.lift(e));return n[t]().selectTextblockEnd()}return s[t]().selectTextblockEnd()},isActive:t=>t.isActive(e),isDisabled:t=>nD(t,e)?tD(t,[`image`])||t.isActive(`code`):!0}}function fD(e){return{canExecute:(t,n)=>{if(n?.pos==null||!t.state.doc.nodeAt(n.pos))return!1;let r=t.state.doc.resolve(n.pos),i=r.parent,a=r.index();return e===`up`?a>0:a<i.childCount-1},execute:(t,n)=>{if(n?.pos==null)return t.chain();let r=t.state.doc.nodeAt(n.pos);if(!r)return t.chain();let i=t.state.doc.resolve(n.pos),a=i.parent,o=i.index();if(e===`up`&&o>0){let e=a.child(o-1),i=n.pos-e.nodeSize;return t.chain().focus().deleteRange({from:n.pos,to:n.pos+r.nodeSize}).insertContentAt(i,r.toJSON())}if(e===`down`&&o<a.childCount-1){let e=a.child(o+1),i=n.pos+e.nodeSize;return t.chain().focus().deleteRange({from:n.pos,to:n.pos+r.nodeSize}).insertContentAt(i,r.toJSON())}return t.chain()},isActive:()=>!1,isDisabled:void 0}}function pD(){return{mark:oD(),textAlign:sD(),heading:cD(),link:lD(),image:uD(),blockquote:rD(`blockquote`),bulletList:dD(`bulletList`),orderedList:dD(`orderedList`),taskList:dD(`taskList`),codeBlock:rD(`codeBlock`),horizontalRule:iD(`horizontalRule`),paragraph:iD(`paragraph`),undo:aD(`undo`),redo:aD(`redo`),clearFormatting:{canExecute:(e,t)=>t?.pos==null?e.can().clearNodes()||e.can().unsetAllMarks():!!e.state.doc.nodeAt(t.pos),execute:(e,t)=>{if(t?.pos!=null){let n=e.state.doc.nodeAt(t.pos);if(!n)return e.chain();let r=t.pos+1,i=t.pos+n.nodeSize-1;return e.chain().focus().setTextSelection({from:r,to:i}).clearNodes().unsetAllMarks()}return e.chain().focus().clearNodes().unsetAllMarks()},isActive:()=>!1,isDisabled:void 0},duplicate:{canExecute:(e,t)=>t?.pos==null?!1:!!e.state.doc.nodeAt(t.pos),execute:(e,t)=>{if(t?.pos==null)return e.chain();let n=e.state.doc.nodeAt(t.pos);return n?e.chain().focus().insertContentAt(t.pos+n.nodeSize,n.toJSON()):e.chain()},isActive:()=>!1,isDisabled:void 0},delete:{canExecute:(e,t)=>t?.pos==null?!1:!!e.state.doc.nodeAt(t.pos),execute:(e,t)=>{if(t?.pos==null)return e.chain();let n=e.state.doc.nodeAt(t.pos);return n?e.chain().focus().deleteRange({from:t.pos,to:t.pos+n.nodeSize}):e.chain()},isActive:()=>!1,isDisabled:void 0},moveUp:fD(`up`),moveDown:fD(`down`),suggestion:{canExecute:()=>!0,execute:(e,t)=>{let{state:n}=e,{selection:r}=n,{$from:i}=r;if(t?.pos!==void 0){let r=n.doc.nodeAt(t.pos);if(r){let n=t.pos+r.nodeSize;return e.chain().focus().insertContentAt(n,{type:`paragraph`,content:[{type:`text`,text:`/`}]})}}let a=i.node(i.depth),o=i.before(i.depth)+a.nodeSize;return e.chain().focus().insertContentAt(o,{type:`paragraph`,content:[{type:`text`,text:`/`}]})},isActive:()=>!1,isDisabled:void 0},mention:{canExecute:()=>!0,execute:e=>{let{state:t}=e,{selection:n}=t,{$from:r}=n,i=r.parent.textBetween(Math.max(0,r.parentOffset-1),r.parentOffset,void 0,` `),a=i&&i!==` `;return e.chain().focus().insertContent(a?` @`:`@`)},isActive:()=>!1,isDisabled:void 0},emoji:{canExecute:()=>!0,execute:e=>{let{state:t}=e,{selection:n}=t,{$from:r}=n,i=r.parent.textBetween(Math.max(0,r.parentOffset-1),r.parentOffset,void 0,` `),a=i&&i!==` `;return e.chain().focus().insertContent(a?` :`:`:`)},isActive:()=>!1,isDisabled:void 0}}}function mD(e,t,n){let r={...pD(),...n};return Oe(t)?t.map(t=>mD(e,t,n)):t.filter(Boolean).map(t=>{if(`type`in t)return t;let{kind:i,children:a,...o}=t,s=a?.length?mD(e,a,n):void 0;if(i){let n=r[i];return n?{...o,children:s,disabled:n.isDisabled?.(e,t)||!n.canExecute(e,t),active:n.isActive(e,t),onSelect:()=>n.execute(e,t).run()}:{...o,children:s}}return{...o,children:s}})}function hD(e){let t=[];return e.offset&&t.push(it(typeof e.offset==`boolean`?void 0:e.offset)),e.flip&&t.push(Ge(typeof e.flip==`boolean`?void 0:e.flip)),e.shift&&t.push(He(typeof e.shift==`boolean`?void 0:e.shift)),e.size&&t.push(rt(typeof e.size==`boolean`?void 0:e.size)),e.autoPlacement&&t.push(st(typeof e.autoPlacement==`boolean`?void 0:e.autoPlacement)),e.hide&&t.push(R(typeof e.hide==`boolean`?void 0:e.hide)),e.inline&&t.push(Xe(typeof e.inline==`boolean`?void 0:e.inline)),t}var gD={slots:{root:``,content:`relative size-full flex-1`,base:[`w-full outline-none *:my-5 *:first:mt-0 *:last:mb-0 sm:px-8 selection:bg-primary/20`,`[&_p]:leading-7`,`[&_a]:text-primary [&_a]:border-b [&_a]:border-transparent [&_a]:hover:border-primary [&_a]:font-medium`,`[&_a]:transition-colors`,`[&_a>code]:border-dashed [&_a:hover>code]:border-primary [&_a:hover>code]:text-primary`,`[&_a>code]:transition-colors`,`[&_.mention]:text-primary [&_.mention]:font-medium`,`[&_:is(h1,h2,h3,h4,h5,h6)]:text-highlighted [&_:is(h1,h2,h3,h4,h5,h6)]:font-bold`,`[&_h1]:text-3xl`,`[&_h2]:text-2xl`,`[&_h3]:text-xl`,`[&_h4]:text-lg`,`[&_h5]:text-base`,`[&_h6]:text-base`,`[&_:is(h1,h2,h3,h4,h5,h6)>code]:border-dashed [&_:is(h1,h2,h3,h4,h5,h6)>code]:font-bold`,`[&_h2>code]:text-xl/6`,`[&_h3>code]:text-lg/5`,`[&_blockquote]:border-s-4 [&_blockquote]:border-accented [&_blockquote]:ps-4 [&_blockquote]:italic`,`[&_[data-type=horizontalRule]]:my-8 [&_[data-type=horizontalRule]]:py-2`,`[&_hr]:border-t [&_hr]:border-default`,`[&_pre]:text-sm/6 [&_pre]:border [&_pre]:border-muted [&_pre]:bg-muted [&_pre]:rounded-md [&_pre]:px-4 [&_pre]:py-3 [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:overflow-x-auto`,`[&_pre_code]:p-0 [&_pre_code]:text-inherit [&_pre_code]:font-inherit [&_pre_code]:rounded-none [&_pre_code]:inline [&_pre_code]:border-0 [&_pre_code]:bg-transparent`,`[&_code]:px-1.5 [&_code]:py-0.5 [&_code]:text-sm [&_code]:font-mono [&_code]:font-medium [&_code]:rounded-md [&_code]:inline-block [&_code]:border [&_code]:border-muted [&_code]:text-highlighted [&_code]:bg-muted`,`[&_:is(ul,ol)]:ps-6`,`[&_ul]:list-disc [&_ul]:marker:text-(--ui-border-accented)`,`[&_ol]:list-decimal [&_ol]:marker:text-muted`,`[&_li]:my-1.5 [&_li]:ps-1.5`,`[&_img]:rounded-md [&_img]:block [&_img]:max-w-full [&_img.ProseMirror-selectednode]:outline-2 [&_img.ProseMirror-selectednode]:outline-primary`,`[&_.ProseMirror-selectednode:not(img):not(pre):not([data-node-view-wrapper])]:bg-primary/20`]},variants:{placeholderMode:{firstLine:{base:`[&_:is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child]:before:content-[attr(data-placeholder)] [&_:is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child]:before:text-dimmed [&_:is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child]:before:float-start [&_:is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child]:before:h-0 [&_:is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child]:before:pointer-events-none`},everyLine:{base:`[&_:is(p,h1,h2,h3,h4,h5,h6).is-empty]:before:content-[attr(data-placeholder)] [&_:is(p,h1,h2,h3,h4,h5,h6).is-empty]:before:text-dimmed [&_:is(p,h1,h2,h3,h4,h5,h6).is-empty]:before:float-start [&_:is(p,h1,h2,h3,h4,h5,h6).is-empty]:before:h-0 [&_:is(p,h1,h2,h3,h4,h5,h6).is-empty]:before:pointer-events-none`}}},defaultVariants:{placeholderMode:`everyLine`}},_D=Object.assign({inheritAttrs:!1},{__name:`Editor`,props:{as:{type:null,required:!1},modelValue:{type:null,required:!1},contentType:{type:String,required:!1},starterKit:{type:Object,required:!1},placeholder:{type:[String,Object],required:!1},markdown:{type:Object,required:!1},image:{type:[Boolean,Object],required:!1,default:!0},mention:{type:[Boolean,Object],required:!1,default:!0},handlers:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},extensions:{type:Array,required:!1},injectCSS:{type:Boolean,required:!1},injectNonce:{type:null,required:!1},autofocus:{type:[String,Number,Boolean,null],required:!1},editable:{type:Boolean,required:!1},textDirection:{type:String,required:!1},editorProps:{type:Object,required:!1},parseOptions:{type:Object,required:!1},coreExtensionOptions:{type:Object,required:!1},enableInputRules:{type:[Array,Boolean],required:!1},enablePasteRules:{type:[Array,Boolean],required:!1},enableCoreExtensions:{type:[Boolean,Object],required:!1},enableContentCheck:{type:Boolean,required:!1},emitContentError:{type:Boolean,required:!1},onBeforeCreate:{type:Function,required:!1},onCreate:{type:Function,required:!1},onMount:{type:Function,required:!1},onUnmount:{type:Function,required:!1},onContentError:{type:Function,required:!1},onUpdate:{type:Function,required:!1},onSelectionUpdate:{type:Function,required:!1},onTransaction:{type:Function,required:!1},onFocus:{type:Function,required:!1},onBlur:{type:Function,required:!1},onDestroy:{type:Function,required:!1},onPaste:{type:Function,required:!1},onDrop:{type:Function,required:!1},onDelete:{type:Function,required:!1},enableExtensionDispatchTransaction:{type:Boolean,required:!1}},emits:[`update:modelValue`],setup(e,{expose:n,emit:i}){let a=e,o=i,c=lt(`editor`,a),d=pe(),f=Ce(),p=r(()=>Tt({extend:Tt(gD),...f.ui?.editor||{}})({placeholderMode:typeof c.placeholder==`object`?c.placeholder.mode:void 0})),m=ht(De(c,`starterKit`,`extensions`,`editorProps`,`contentType`,`class`,`placeholder`,`markdown`,`image`,`mention`,`handlers`)),h=r(()=>s(c.editorProps,{attributes:{autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`,...d,class:p.value.base({class:c.ui?.base})}})),g=r(()=>c.contentType||(typeof c.modelValue==`string`?`html`:`json`)),_=r(()=>s(c.starterKit,{code:!1,horizontalRule:!1,dropcursor:{color:`var(--ui-primary)`,width:2},link:{openOnClick:!1}})),v=r(()=>{let{mode:e,...t}=(typeof c.placeholder==`string`?{placeholder:c.placeholder}:c.placeholder)||{};return s(t,{showOnlyWhenEditable:!1,showOnlyCurrent:!0})}),y=r(()=>s(c.markdown,{markedOptions:{gfm:!0}})),b=r(()=>typeof c.image==`boolean`?{}:c.image),C=r(()=>s(typeof c.mention==`boolean`?{}:c.mention,{HTMLAttributes:{class:`mention`},renderText({node:e}){return`${e.attrs.mentionSuggestionChar??`@`}${e.attrs.label??e.attrs.id}`},renderHTML({options:e,node:t}){return[`span`,nv({"data-type":`mention`},e.HTMLAttributes),`${t.attrs.mentionSuggestionChar??`@`}${t.attrs.label??t.attrs.id}`]}})),ee=r(()=>[g.value===`markdown`&&SC.configure(y.value),GE.configure(_.value),vb.extend({excludes:`code`}),bb.extend({renderHTML(){return[`div`,nv(this.options.HTMLAttributes,{"data-type":this.name}),[`hr`]]}}),c.image!==!1&&Sb.configure(b.value),c.mention!==!1&&jb.configure(C.value),c.placeholder&&Px.configure(v.value),...c.extensions||[]].filter(e=>!!e)),E=XE({...m.value,content:c.modelValue,contentType:g.value,extensions:ee.value,editorProps:h.value,onCreate:({editor:e})=>{c.placeholder&&e.view.dispatch(e.state.tr)},onUpdate:({editor:e})=>{let t;try{g.value===`html`?t=e.getHTML():g.value===`json`?t=e.getJSON():g.value===`markdown`&&(t=e.getMarkdown())}catch{t=e.getText()}o(`update:modelValue`,t)}});Pe(()=>c.modelValue,e=>{if(!(!E.value||e==null)&&(g.value===`html`?E.value.getHTML():g.value===`json`?JSON.stringify(E.value.getJSON()):g.value===`markdown`?E.value.getMarkdown():E.value.getText())!==(g.value===`json`&&typeof e==`object`?JSON.stringify(e):String(e))){let t=E.value.state.selection.from;E.value.commands.setContent(e,{contentType:g.value}),t<=E.value.state.doc.content.size&&E.value.commands.setTextSelection(t)}});let k=r(()=>({...pD(),...c.handlers}));return t(`editorHandlers`,k),n({editor:E}),(e,t)=>(O(),S(w(wt),{as:w(c).as,"data-slot":`root`,class:u(p.value.root({class:[w(c).ui?.root,w(c).class]}))},{default:F(()=>[w(E)?(O(),D(l,{key:0},[I(e.$slots,`default`,{editor:w(E),handlers:k.value}),x(w(JE),{role:`presentation`,editor:w(E),"data-slot":`content`,class:u(p.value.content({class:w(c).ui?.content}))},null,8,[`editor`,`class`])],64)):T(``,!0)]),_:3},8,[`as`,`class`]))}}),vD,yD;if(typeof WeakMap<`u`){let e=new WeakMap;vD=t=>e.get(t),yD=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;vD=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},yD=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var bD=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return vD(e)||yD(e,xD(e))}};function xD(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=SD(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new bD(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&CD(s,o,e),s}function SD(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function CD(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=wD(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function wD(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function TD(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}new Ju(`selectingCells`);function ED(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function DD(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function OD(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=ED(t.$head)||kD(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function kD(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function AD(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function jD(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function MD(e,t,n){let r=e.node(-1),i=bD.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function ND(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}var PD=class e extends q{constructor(e,t=e){let n=e.node(-1),r=bD.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Eu(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(AD(r)&&AD(i)&&jD(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return J.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=bD.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=ND(e,0,l)),u>0&&(e=ND(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(G.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new K(G.from(o),1,1)}replace(e,t=K.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?K.empty:t)}let i=q.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new K(G.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=bD.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=bD.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=bD.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=bD.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new FD(this.$anchorCell.pos,this.$headCell.pos)}};PD.prototype.visible=!1,q.jsonID(`cell`,PD);var FD=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&jD(t,n)?new PD(t,n):q.near(n,1)}};new Ju(`fix-tables`);function ID(e){let t=e.selection,n=OD(e),r=n.node(-1),i=n.start(-1),a=bD.get(r);return{...t instanceof PD?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function LD(e){return function(t,n){if(!DD(t))return!1;if(n){let r=TD(t.schema),i=ID(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function RD(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function zD(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?LD(e):function(t,n){if(!DD(t))return!1;if(n){let r=TD(t.schema),i=ID(t),a=t.tr,o=RD(`row`,i,r),s=RD(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}zD(`row`,{useDeprecatedLogic:!0}),zD(`column`,{useDeprecatedLogic:!0}),zD(`cell`,{useDeprecatedLogic:!0});function BD(e,t){let n=e.selection;if(!(n instanceof PD))return!1;if(t){let r=e.tr,i=TD(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new K(i,0,0))}),r.docChanged&&t(r)}return!0}Sg({ArrowLeft:HD(`horiz`,-1),ArrowRight:HD(`horiz`,1),ArrowUp:HD(`vert`,-1),ArrowDown:HD(`vert`,1),"Shift-ArrowLeft":UD(`horiz`,-1),"Shift-ArrowRight":UD(`horiz`,1),"Shift-ArrowUp":UD(`vert`,-1),"Shift-ArrowDown":UD(`vert`,1),Backspace:BD,"Mod-Backspace":BD,Delete:BD,"Mod-Delete":BD});function VD(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function HD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof PD)return VD(n,r,q.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=WD(i,e,t);if(o==null)return!1;if(e==`horiz`)return VD(n,r,q.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=MD(i,e,t),s;return s=a?q.near(a,1):t<0?q.near(n.doc.resolve(i.before(-1)),-1):q.near(n.doc.resolve(i.after(-1)),1),VD(n,r,s)}}}function UD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof PD)o=a;else{let r=WD(i,e,t);if(r==null)return!1;o=new PD(n.doc.resolve(r))}let s=MD(o.$headCell,e,t);return s?VD(n,r,new PD(o.$anchorCell,s)):!1}}function WD(e,t,n){if(!(e.state.selection instanceof J))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}new Ju(`tableColumnResizing`);function GD(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var KD=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Qg(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Ge(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(He(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(it(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(We(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(rt(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(st(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(R(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Xe(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=zv(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Y){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof PD){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():GD(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&$e(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},qD=e=>new Gu({key:typeof e.pluginKey==`string`?new Ju(e.pluginKey):e.pluginKey,view:t=>new KD({view:t,...e})}),JD=A({name:`BubbleMenu`,inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:void 0},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:n}){let r=L(null),i=e.pluginKey??new Ju(`bubbleMenu`);return ce(()=>{let{editor:t,options:n,resizeDelay:a,appendTo:o,shouldShow:s,getReferencedVirtualElement:c,updateDelay:l}=e,u=r.value;u&&(u.style.visibility=`hidden`,u.style.position=`absolute`,u.remove(),v(()=>{t.registerPlugin(qD({editor:t,element:u,options:n,pluginKey:i,resizeDelay:a,appendTo:o,shouldShow:s,getReferencedVirtualElement:c,updateDelay:l}))}))}),_(()=>{let{editor:t}=e;t.unregisterPlugin(i)}),()=>ie(`div`,{ref:r,...n},t.default?.call(t))}}),YD=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return hv(e,{textSerializers:gv(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Ge(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(He(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(it(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(We(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(rt(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(st(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(R(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Xe(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){if(!this.view?.dom?.parentNode)return;let{selection:e}=this.editor.state,t=zv(this.view,e.from,e.to);$e({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},XD=e=>new Gu({key:typeof e.pluginKey==`string`?new Ju(e.pluginKey):e.pluginKey,view:t=>new YD({view:t,...e})}),ZD=A({name:`FloatingMenu`,inheritAttrs:!1,props:{pluginKey:{type:null,default:void 0},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:n}){let r=L(null),i=e.pluginKey??new Ju(`floatingMenu`);return ce(()=>{let{editor:t,updateDelay:n,resizeDelay:a,options:o,appendTo:s,shouldShow:c}=e,l=r.value;l&&(l.style.visibility=`hidden`,l.style.position=`absolute`,l.remove(),t.registerPlugin(XD({pluginKey:i,editor:t,element:l,updateDelay:n,resizeDelay:a,options:o,appendTo:s,shouldShow:c})))}),_(()=>{let{editor:t}=e;t.unregisterPlugin(i)}),()=>ie(`div`,{ref:r,...n},t.default?.call(t))}}),QD={slots:{content:`flex items-center gap-1 bg-default text-highlighted shadow-sm rounded-sm ring ring-default h-6 px-2.5 py-1 text-xs select-none data-[state=delayed-open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-tooltip-content-transform-origin) pointer-events-auto`,arrow:`fill-bg stroke-default`,text:`truncate`,kbds:`hidden lg:inline-flex items-center shrink-0 gap-0.5 not-first-of-type:before:content-['·'] not-first-of-type:before:me-0.5`,kbdsSize:`sm`}},$D={__name:`Tooltip`,props:{text:{type:String,required:!1},kbds:{type:Array,required:!1},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},reference:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},defaultOpen:{type:Boolean,required:!1},open:{type:Boolean,required:!1},delayDuration:{type:Number,required:!1},disableHoverableContent:{type:Boolean,required:!1},disableClosingTrigger:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},ignoreNonKeyboardFocus:{type:Boolean,required:!1}},emits:[`update:open`],setup(e,{emit:t}){let n=e,i=t,o=ge(),c=lt(`tooltip`,n),f=Ce(),p=$t(),m=ht(Fe(c,`defaultOpen`,`open`,`delayDuration`,`disableHoverableContent`,`disableClosingTrigger`,`ignoreNonKeyboardFocus`),i),g=Mt(we(()=>c.portal)),_=we(()=>s(c.content,p.content.value,{side:`bottom`,sideOffset:8,collisionPadding:8})),v=we(()=>s(c.arrow,{rounded:!0})),y=r(()=>Tt({extend:Tt(QD),...f.ui?.tooltip||{}})({side:_.value.side}));return(e,t)=>(O(),S(w(rr),d(w(m),{disabled:!(w(c).text||w(c).kbds?.length||o.content)||w(c).disabled}),{default:F(({open:t})=>[o.default||w(c).reference?(O(),S(w(cr),d({key:0},e.$attrs,{"as-child":``,reference:w(c).reference,class:w(c).class}),{default:F(()=>[I(e.$slots,`default`,{open:t})]),_:2},1040,[`reference`,`class`])):T(``,!0),x(w(sr),h(a(w(g))),{default:F(()=>[x(w(bt),null,{default:F(()=>[x(w(or),d(_.value,{"data-slot":`content`,class:y.value.content({class:[!o.default&&w(c).class,w(c).ui?.content]})}),{default:F(()=>[I(e.$slots,`content`,{ui:y.value},()=>[w(c).text?(O(),D(`span`,{key:0,"data-slot":`text`,class:u(y.value.text({class:w(c).ui?.text}))},k(w(c).text),3)):T(``,!0),w(c).kbds?.length?(O(),D(`span`,{key:1,"data-slot":`kbds`,class:u(y.value.kbds({class:w(c).ui?.kbds}))},[(O(!0),D(l,null,ve(w(c).kbds,(e,t)=>(O(),S(Vt,d({key:t,size:w(c).ui?.kbdsSize||y.value.kbdsSize()},{ref_for:!0},typeof e==`string`?{value:e}:e),null,16,[`size`]))),128))],2)):T(``,!0)]),w(c).arrow?(O(),S(w($n),d({key:0},v.value,{"data-slot":`arrow`,class:y.value.arrow({class:w(c).ui?.arrow})}),null,16,[`class`])):T(``,!0)]),_:3},16,[`class`])]),_:3})]),_:3},16)]),_:3},16,[`disabled`]))}},eO={slots:{root:`focus:outline-none`,base:`flex items-stretch gap-1.5`,group:`flex items-center gap-0.5`,separator:`w-px self-stretch bg-border`},variants:{layout:{bubble:{base:`bg-default border border-default rounded-lg p-1`},floating:{base:`bg-default border border-default rounded-lg p-1`},fixed:{base:``}}}},tO=Object.assign({inheritAttrs:!1},{__name:`EditorToolbar`,props:{as:{type:null,required:!1},color:{type:null,required:!1,default:`neutral`},variant:{type:null,required:!1,default:`ghost`},activeColor:{type:null,required:!1,default:`primary`},activeVariant:{type:null,required:!1,default:`soft`},size:{type:null,required:!1,default:`sm`},items:{type:null,required:!1},editor:{type:Object,required:!0},class:{type:null,required:!1},ui:{type:Object,required:!1},layout:{type:String,required:!1,default:`fixed`},pluginKey:{type:[Object,String],required:!1},updateDelay:{type:Number,required:!1},resizeDelay:{type:Number,required:!1},shouldShow:{type:[Function,null],required:!1},appendTo:{type:Function,required:!1,skipCheck:!0},getReferencedVirtualElement:{type:Function,required:!1},options:{type:Object,required:!1}},setup(e){let t=lt(`editorToolbar`,e),n=Ce(),i=p(`editorHandlers`,r(()=>pD())),a=r(()=>({bubble:JD,floating:ZD,fixed:`template`})[t.layout]),o=ht(De(t,`as`,`color`,`variant`,`activeColor`,`activeVariant`,`size`,`items`,`layout`,`editor`,`class`,`ui`)),c=r(()=>s(t.options,{offset:8,shift:{padding:8}})),f=r(()=>Tt({extend:Tt(eO),...n.ui?.editorToolbar||{}})({layout:t.layout})),m=r(()=>t.items?.length?Oe(t.items)?t.items:[t.items]:[]);function h(e){return t.editor?.isEditable?`items`in e&&e.items?.length?e.items?.some(e=>h(e))||!1:`kind`in e?(i?.value?.[e.kind])?.isActive(t.editor,e)||!1:e.active??!1:!1}function g(e){if(!t.editor?.isEditable)return!0;if(`items`in e&&e.items?.length){let t=(Oe(e.items)?e.items.flat():e.items).filter(e=>e.type!==`separator`&&e.type!==`label`);return t.length===0?!0:t.every(e=>g(e))}if(!(`kind`in e))return e.disabled??!1;let n=i?.value?.[e.kind];return n?n.isDisabled?.(t.editor,e)?!0:!n.canExecute(t.editor,e):!1}function _(e,n){if(!t.editor?.isEditable||g(n))return;if(`items`in n||!(`kind`in n)){if(`onClick`in n)for(let t of Array.isArray(n.onClick)?n.onClick:[n.onClick])t?.(e);return}let r=i?.value?.[n.kind];r&&r.execute(t.editor,n).run()}function v(e){if(e.items)return(Oe(e.items)?e.items.flat():e.items).find(e=>`kind`in e?h(e):!1)}function y(e){let n=le(e,[`kind`,`mark`,`align`,`level`,`href`,`src`,`pos`,`items`,`slot`,`checkedIcon`,`loadingIcon`,`externalIcon`,`content`,`arrow`,`portal`,`modal`,`tooltip`,`onClick`]);if(`items`in e&&e.items?.length){let t=v(e);t?.icon&&(n.icon=t.icon),t?.label&&n.label!==void 0&&(n.label=t.label)}return s(n,{color:t.color,activeColor:t.activeColor,activeVariant:t.activeVariant,variant:t.variant,size:t.size})}function b(e){return s(Ie(e,[`size`,`checkedIcon`,`loadingIcon`,`externalIcon`,`content`,`arrow`,`portal`,`modal`,`ui`]),{modal:!1,size:t.size})}function C(e){let t=`children`in e&&Array.isArray(e.children)?e.children.map(C):void 0;if(!(`kind`in e))return t?{...e,children:t}:e;let n=e;return{...n,...t&&{children:t},active:h(n),disabled:g(n),onSelect:e=>_(e,n)}}function ee(e){return e.items?Oe(e.items)?e.items.map(e=>e.map(C)):[e.items.map(C)]:[]}return(e,n)=>(O(),S(w(wt),d({as:a.value},a.value===`template`?{...e.$attrs}:{editor:w(t).editor,tabindex:-1,class:f.value.root({class:w(t).ui?.root}),...w(o),options:c.value,...e.$attrs}),{default:F(()=>[x(w(wt),{as:w(t).as,role:`toolbar`,"data-slot":`base`,class:u(f.value.base({class:[w(t).ui?.base,w(t).class]}))},{default:F(()=>[(O(!0),D(l,null,ve(m.value,(n,r)=>(O(),D(l,{key:`group-${r}`},[P(`div`,{role:`group`,"data-slot":`group`,class:u(f.value.group({class:w(t).ui?.group}))},[(O(!0),D(l,null,ve(n,(t,n)=>I(e.$slots,t.slot||`item`,{key:`group-${r}-${n}`,item:t,index:n,isActive:h,isDisabled:g,onClick:_},()=>[`items`in t&&t.items?.length?(O(),S(Gt,d({key:0,ref_for:!0},b(t),{items:ee(t)}),{default:F(()=>[t.tooltip?(O(),S($D,d({key:0,disabled:g(t)},{ref_for:!0},{...t.tooltip||{}}),{default:F(()=>[x(St,d({active:h(t),disabled:g(t)},{ref_for:!0},y(t),{onClick:e=>_(e,t)}),null,16,[`active`,`disabled`,`onClick`])]),_:2},1040,[`disabled`])):(O(),S(St,d({key:1,active:h(t),disabled:g(t)},{ref_for:!0},y(t),{onClick:e=>_(e,t)}),null,16,[`active`,`disabled`,`onClick`]))]),_:2},1040,[`items`])):t.tooltip?(O(),S($D,d({key:1,disabled:g(t)},{ref_for:!0},{...t.tooltip||{}}),{default:F(()=>[x(St,d({active:h(t),disabled:g(t)},{ref_for:!0},y(t),{ui:t.ui,onClick:e=>_(e,t)}),null,16,[`active`,`disabled`,`ui`,`onClick`])]),_:2},1040,[`disabled`])):(O(),S(St,d({key:2,active:h(t),disabled:g(t)},{ref_for:!0},y(t),{ui:t.ui,onClick:e=>_(e,t)}),null,16,[`active`,`disabled`,`ui`,`onClick`]))])),128))],2),r<m.value.length-1?(O(),S(w(Yt),{key:0,"data-slot":`separator`,class:u(f.value.separator({class:w(t).ui?.separator})),orientation:`vertical`},null,8,[`class`])):T(``,!0)],64))),128))]),_:3},8,[`as`,`class`])]),_:3},16,[`as`]))}}),nO=()=>new Map,rO=e=>{let t=nO();return e.forEach((e,n)=>{t.set(n,e)}),t},iO=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},aO=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},oO=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},sO=()=>new Set,cO=e=>e[e.length-1],lO=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},uO=Array.from,dO=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},fO=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},pO=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},mO=Array.isArray,hO=class{constructor(){this._observers=nO()}on(e,t){return iO(this._observers,e,sO).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return uO((this._observers.get(e)||nO()).values()).forEach(e=>e(...t))}destroy(){this._observers=nO()}},gO=Math.floor,_O=Math.abs,vO=(e,t)=>e<t?e:t,yO=(e,t)=>e>t?e:t;Number.isNaN;var bO=e=>e===0?1/e<0:e<0,xO=1<<17,SO=1<<18,CO=1<<19,wO=1<<20,TO=1<<21,EO=1<<22,DO=1<<23,OO=1<<24,kO=1<<25,AO=1<<26,jO=1<<27,MO=1<<28,NO=1<<29;xO-1,SO-1,CO-1,wO-1,TO-1,EO-1,DO-1,OO-1,kO-1,AO-1,jO-1,MO-1,NO-1;var PO=2**53-1,FO=-(2**53-1),IO=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&gO(e)===e);Number.isNaN,Number.parseInt;var LO=String.fromCharCode;String.fromCodePoint,LO(65535);var RO=e=>e.toLowerCase(),zO=/^\s*/g,BO=e=>e.replace(zO,``),VO=/([A-Z])/g,HO=(e,t)=>BO(e.replace(VO,e=>`${t}${RO(e)}`)),UO=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},WO=typeof TextEncoder<`u`?new TextEncoder:null,GO=WO?e=>WO.encode(e):UO,KO=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});KO&&KO.decode(new Uint8Array).length===1&&(KO=null);var qO=(e,t)=>pO(t,()=>e).join(``),JO=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},YO=()=>new JO,XO=e=>{let t=YO();return e(t),QO(t)},ZO=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},QO=e=>{let t=new Uint8Array(ZO(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},$O=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(yO(n,t)*2),e.cpos=0)},ek=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},tk=ek,nk=(e,t)=>{for(;t>127;)ek(e,128|127&t),t=gO(t/128);ek(e,127&t)},rk=(e,t)=>{let n=bO(t);for(n&&(t=-t),ek(e,(t>63?128:0)|(n?64:0)|63&t),t=gO(t/64);t>0;)ek(e,(t>127?128:0)|127&t),t=gO(t/128)},ik=new Uint8Array(3e4),ak=ik.length/3,ok=WO&&WO.encodeInto?(e,t)=>{if(t.length<ak){let n=WO.encodeInto(t,ik).written||0;nk(e,n);for(let t=0;t<n;t++)ek(e,ik[t])}else ck(e,GO(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;nk(e,r);for(let t=0;t<r;t++)ek(e,n.codePointAt(t))},sk=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=vO(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(yO(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},ck=(e,t)=>{nk(e,t.byteLength),sk(e,t)},lk=(e,t)=>{$O(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},uk=(e,t)=>lk(e,4).setFloat32(0,t,!1),dk=(e,t)=>lk(e,8).setFloat64(0,t,!1),fk=(e,t)=>lk(e,8).setBigInt64(0,t,!1),pk=new DataView(new ArrayBuffer(4)),mk=e=>(pk.setFloat32(0,e),pk.getFloat32(0)===e),hk=(e,t)=>{switch(typeof t){case`string`:ek(e,119),ok(e,t);break;case`number`:IO(t)&&_O(t)<=2147483647?(ek(e,125),rk(e,t)):mk(t)?(ek(e,124),uk(e,t)):(ek(e,123),dk(e,t));break;case`bigint`:ek(e,122),fk(e,t);break;case`object`:if(t===null)ek(e,126);else if(mO(t)){ek(e,117),nk(e,t.length);for(let n=0;n<t.length;n++)hk(e,t[n])}else if(t instanceof Uint8Array)ek(e,116),ck(e,t);else{ek(e,118);let n=Object.keys(t);nk(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];ok(e,i),hk(e,t[i])}}break;case`boolean`:ek(e,t?120:121);break;default:ek(e,127)}},gk=class extends JO{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&nk(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},_k=e=>{e.count>0&&(rk(e.encoder,e.count===1?e.s:-e.s),e.count>1&&nk(e.encoder,e.count-2))},vk=class{constructor(){this.encoder=new JO,this.s=0,this.count=0}write(e){this.s===e?this.count++:(_k(this),this.count=1,this.s=e)}toUint8Array(){return _k(this),QO(this.encoder)}},yk=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);rk(e.encoder,t),e.count>1&&nk(e.encoder,e.count-2)}},bk=class{constructor(){this.encoder=new JO,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(yk(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return yk(this),QO(this.encoder)}},xk=class{constructor(){this.sarr=[],this.s=``,this.lensE=new vk}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new JO;return this.sarr.push(this.s),this.s=``,ok(e,this.sarr.join(``)),sk(e,this.lensE.toUint8Array()),QO(e)}},Sk=e=>Error(e),Ck=()=>{throw Sk(`Method unimplemented`)},wk=()=>{throw Sk(`Unexpected case`)},Tk=Sk(`Unexpected end of array`),Ek=Sk(`Integer out of Range`),Dk=class{constructor(e){this.arr=e,this.pos=0}},Ok=e=>new Dk(e),kk=e=>e.pos!==e.arr.length,Ak=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},jk=e=>Ak(e,Nk(e)),Mk=e=>e.arr[e.pos++],Nk=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>PO)throw Ek}throw Tk},Pk=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>PO)throw Ek}throw Tk},Fk=KO?e=>KO.decode(jk(e)):e=>{let t=Nk(e);if(t===0)return``;{let n=String.fromCodePoint(Mk(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Mk(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ik=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Lk=[e=>void 0,e=>null,Pk,e=>Ik(e,4).getFloat32(0,!1),e=>Ik(e,8).getFloat64(0,!1),e=>Ik(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Fk,e=>{let t=Nk(e),n={};for(let r=0;r<t;r++){let t=Fk(e);n[t]=Rk(e)}return n},e=>{let t=Nk(e),n=[];for(let r=0;r<t;r++)n.push(Rk(e));return n},jk],Rk=e=>Lk[127-Mk(e)](e),zk=class extends Dk{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),kk(this)?this.count=Nk(this)+1:this.count=-1),this.count--,this.s}},Bk=class extends Dk{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Pk(this);let e=bO(this.s);this.count=1,e&&(this.s=-this.s,this.count=Nk(this)+2)}return this.count--,this.s}},Vk=class extends Dk{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Pk(this),t=e&1;this.diff=gO(e/2),this.count=1,t&&(this.count=Nk(this)+2)}return this.s+=this.diff,this.count--,this.s}},Hk=class{constructor(e){this.decoder=new Bk(e),this.str=Fk(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Uk=crypto.getRandomValues.bind(crypto),Wk=Math.random,Gk=()=>Uk(new Uint32Array(1))[0],Kk=e=>e[gO(Wk()*e.length)],qk=`10000000-1000-4000-8000-100000000000`,Jk=()=>qk.replace(/[018]/g,e=>(e^Gk()&15>>e/4).toString(16)),Yk=Date.now,Xk=e=>new Promise(e);Promise.all.bind(Promise);var Zk=e=>e===void 0?null:e,Qk=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Qk=localStorage)}catch{}var $k=Qk,eA=Symbol(`Equality`),tA=(e,t)=>e===t||!!e?.[eA]?.(t)||!1,nA=e=>typeof e==`object`,rA=Object.assign,iA=Object.keys,aA=(e,t)=>{for(let n in e)t(e[n],n)},oA=e=>iA(e).length,sA=e=>{for(let t in e)return!1;return!0},cA=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},lA=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),uA=(e,t)=>e===t||oA(e)===oA(t)&&cA(e,(e,n)=>(e!==void 0||lA(t,n))&&tA(t[n],e)),dA=Object.freeze,fA=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&fA(e[t])}return dA(e)},pA=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&pA(e,t,n+1)}},mA=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[eA]!=null)return e[eA](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!mA(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(oA(e)!==oA(t))return!1;for(let n in e)if(!lA(e,n)||!mA(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!mA(e[n],t[n]))return!1;break;default:return!1}return!0},hA=(e,t)=>t.includes(e),gA=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,_A=typeof window<`u`&&typeof document<`u`&&!gA;typeof navigator<`u`&&/Mac/.test(navigator.platform);var vA,yA=[],bA=()=>{if(vA===void 0)if(gA){vA=nO();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&vA.set(t,``),t=r):t===null?yA.push(r):(vA.set(t,r),t=null)}t!==null&&vA.set(t,``)}else typeof location==`object`?(vA=nO(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);vA.set(`--${HO(t,`-`)}`,n),vA.set(`-${HO(t,`-`)}`,n)}})):vA=nO();return vA},xA=e=>bA().has(e),SA=e=>Zk(gA?{}[e.toUpperCase().replaceAll(`-`,`_`)]:$k.getItem(e)),CA=e=>xA(`--`+e)||SA(e)!==null,wA=CA(`production`),TA=gA&&hA({}.FORCE_COLOR,[`true`,`1`,`2`])||!xA(`--no-colors`)&&!CA(`no-color`)&&(!gA||process.stdout.isTTY)&&(!gA||xA(`--color`)||SA(`COLORTERM`)!==null||(SA(`TERM`)||``).includes(`color`)),EA=_A?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=LO(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),DA=e=>XO(t=>hk(t,e)),OA=class{constructor(e,t){this.left=e,this.right=t}},kA=(e,t)=>new OA(e,t),AA=e=>e.next()>=.5,jA=(e,t,n)=>gO(e.next()*(n+1-t)+t),MA=(e,t,n)=>gO(e.next()*(n+1-t)+t),NA=(e,t,n)=>MA(e,t,n),PA=e=>LO(NA(e,97,122)),FA=(e,t=0,n=20)=>{let r=NA(e,t,n),i=``;for(let t=0;t<r;t++)i+=PA(e);return i},IA=(e,t)=>t[NA(e,0,t.length-1)],LA=Symbol(`0schema`),RA=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(qO(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
208
|
-
`)}},zA=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[eA]?tA(e,t):mO(e)?dO(e,e=>fO(t,t=>zA(e,t))):nA(e)?cA(e,(e,n)=>zA(e,t[n])):!1,BA=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),zA(t,n)}equals(e){return this.constructor===e.constructor&&mA(this.shape,e.shape)}[LA](){return!0}[eA](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ck()}get nullable(){return yj(this,Pj)}get optional(){return new ZA(this)}cast(e){return Rj(e,this),e}expect(e){return Rj(e,this),e}},VA=class extends BA{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},HA=(e,t=null)=>new VA(e,t);HA(VA);var UA=class extends BA{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},WA=e=>new UA(e);HA(UA);var GA=class extends BA{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},KA=(...e)=>new GA(e),qA=HA(GA),JA=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),YA=e=>{if(kj.check(e))return[JA(e)];if(qA.check(e))return e.shape.map(e=>e+``);if(Oj.check(e))return[`[+-]?\\d+.?\\d*`];if(Aj.check(e))return[`.*`];if(bj.check(e))return e.shape.map(YA).flat(1);wk()};HA(class extends BA{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(YA).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var XA=Symbol(`optional`),ZA=class extends BA{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[XA](){return!0}},QA=HA(ZA),$A=class extends BA{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new $A,HA($A);var ej=class e extends BA{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):cA(this.shape,(n,r)=>{let i=this._isPartial&&!lA(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},tj=e=>new ej(e),nj=HA(ej),rj=WA(e=>e!=null&&(e.constructor===Object||e.constructor==null)),ij=class extends BA{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&cA(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},aj=(e,t)=>new ij(e,t),oj=HA(ij),sj=class extends BA{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&cA(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},cj=(...e)=>new sj(e);HA(sj);var lj=class extends BA{constructor(e){super(),this.shape=e.length===1?e[0]:new vj(e)}check(e,t){let n=mO(e)&&dO(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},uj=(...e)=>new lj(e),dj=HA(lj),fj=WA(e=>mO(e)),pj=class extends BA{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},mj=(e,t=null)=>new pj(e,t);HA(pj);var hj=mj(BA),gj=HA(class extends BA{constructor(e){super(),this.len=e.length-1,this.args=cj(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),_j=WA(e=>typeof e==`function`);HA(class extends BA{constructor(e){super(),this.shape=e}check(e,t){let n=dO(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var vj=class extends BA{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=fO(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},yj=(...e)=>e.findIndex(e=>bj.check(e))>=0?yj(...e.map(e=>Lj(e)).map(e=>bj.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new vj(e),bj=HA(vj),xj=()=>!0,Sj=WA(xj),Cj=HA(UA,e=>e.shape===xj),wj=WA(e=>typeof e==`bigint`),Tj=WA(e=>e===wj),Ej=WA(e=>typeof e==`symbol`);WA(e=>e===Ej);var Dj=WA(e=>typeof e==`number`),Oj=WA(e=>e===Dj),kj=WA(e=>typeof e==`string`),Aj=WA(e=>e===kj),jj=WA(e=>typeof e==`boolean`),Mj=WA(e=>e===jj),Nj=KA(void 0);HA(GA,e=>e.shape.length===1&&e.shape[0]===void 0),KA(void 0);var Pj=KA(null),Fj=HA(GA,e=>e.shape.length===1&&e.shape[0]===null);HA(Uint8Array),HA(VA,e=>e.shape===Uint8Array);var Ij=yj(Dj,kj,Pj,Nj,wj,jj,Ej);(()=>{let e=uj(Sj),t=aj(kj,Sj),n=yj(Dj,kj,Pj,jj,e,t);return e.shape=n,t.shape.values=n,n})();var Lj=e=>{if(hj.check(e))return e;if(rj.check(e)){let t={};for(let n in e)t[n]=Lj(e[n]);return tj(t)}else if(fj.check(e))return yj(...e.map(Lj));else if(Ij.check(e))return KA(e);else if(_j.check(e))return HA(e);wk()},Rj=wA?()=>{}:(e,t)=>{let n=new RA;if(!t.check(e,n))throw Sk(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},zj=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Lj(e),h:t}),this}else(e){return this.if(Sj,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Sk(`Unhandled pattern`)}}},Bj=(e=>new zj(e))(Sj).if(Oj,(e,t)=>jA(t,FO,PO)).if(Aj,(e,t)=>FA(t)).if(Mj,(e,t)=>AA(t)).if(Tj,(e,t)=>BigInt(jA(t,FO,PO))).if(bj,(e,t)=>Vj(t,IA(t,e.shape))).if(nj,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(QA.check(i)){if(AA(t))continue;i=i.shape}n[r]=Bj(i,t)}return n}).if(dj,(e,t)=>{let n=[],r=MA(t,0,42);for(let i=0;i<r;i++)n.push(Vj(t,e.shape));return n}).if(qA,(e,t)=>IA(t,e.shape)).if(Fj,(e,t)=>null).if(gj,(e,t)=>{let n=Vj(t,e.res);return()=>n}).if(Cj,(e,t)=>Vj(t,IA(t,[Dj,kj,Pj,Nj,wj,jj,uj(Dj),aj(yj(`a`,`b`,`c`),Dj)]))).if(oj,(e,t)=>{let n={},r=jA(t,0,3);for(let i=0;i<r;i++){let r=Vj(t,e.shape.keys);n[r]=Vj(t,e.shape.values)}return n}).done(),Vj=(e,t)=>Bj(Lj(t),e),Hj=typeof document<`u`?document:{};WA(e=>e.nodeType===qj),typeof DOMParser<`u`&&new DOMParser,WA(e=>e.nodeType===Wj),WA(e=>e.nodeType===Gj);var Uj=e=>aO(e,(e,t)=>`${t}:${e};`).join(``),Wj=Hj.ELEMENT_NODE,Gj=Hj.TEXT_NODE;Hj.CDATA_SECTION_NODE,Hj.COMMENT_NODE;var Kj=Hj.DOCUMENT_NODE;Hj.DOCUMENT_TYPE_NODE;var qj=Hj.DOCUMENT_FRAGMENT_NODE;WA(e=>e.nodeType===Kj);var Jj=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Yj=(e,t)=>new Jj(setTimeout(t,e)),Xj=Symbol,Zj=Xj(),Qj=Xj(),$j=Xj(),eM=Xj(),tM=Xj(),nM=Xj(),rM=Xj(),iM=Xj(),aM=Xj(),oM=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Yk();var sM={[Zj]:kA(`font-weight`,`bold`),[Qj]:kA(`font-weight`,`normal`),[$j]:kA(`color`,`blue`),[tM]:kA(`color`,`green`),[eM]:kA(`color`,`grey`),[nM]:kA(`color`,`red`),[rM]:kA(`color`,`purple`),[iM]:kA(`color`,`orange`),[aM]:kA(`color`,`black`)},cM=TA?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=nO(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=sM[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Uj(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:oM,lM=(...e)=>{console.log(...cM(e)),dM.forEach(t=>t.print(e))},uM=(...e)=>{console.warn(...cM(e)),e.unshift(iM),dM.forEach(t=>t.print(e))},dM=sO(),fM=e=>({[Symbol.iterator](){return this},next:e}),pM=(e,t)=>fM(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),mM=(e,t)=>fM(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),hM=class{constructor(e,t){this.clock=e,this.len=t}},gM=class{constructor(){this.clients=new Map}},_M=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])bN(e,i,o.clock,o.len,n)}}),vM=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=gO((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},yM=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&vM(n,t.clock)!==null},bM=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new hM(r.clock,yO(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},xM=e=>{let t=new gM;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)lO(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return bM(t),t},SM=(e,t,n,r)=>{iO(e.clients,t,()=>[]).push(new hM(n,r))},CM=()=>new gM,wM=e=>{let t=CM();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new hM(i,a))}}r.length>0&&t.clients.set(n,r)}),t},TM=(e,t)=>{nk(e.restEncoder,t.clients.size),uO(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),nk(e.restEncoder,t);let r=n.length;nk(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},EM=e=>{let t=new gM,n=Nk(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Nk(e.restDecoder),r=Nk(e.restDecoder);if(r>0){let i=iO(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new hM(e.readDsClock(),e.readDsLen()))}}return t},DM=(e,t,n)=>{let r=new gM,i=Nk(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Nk(e.restDecoder),a=Nk(e.restDecoder),o=n.clients.get(i)||[],s=fN(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&SM(r,i,s,a-s);let e=mN(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,NF(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,NF(t,c,a-c.id.clock)),c.delete(t))}else SM(r,i,n,a-n)}}if(r.clients.size>0){let e=new FM;return nk(e.restEncoder,0),TM(e,r),e.toUint8Array()}return null},OM=Gk,kM=class e extends hO{constructor({guid:e=Jk(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=OM(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new uN,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Xk(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Xk(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&ON(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(uO(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ON(this,e,t)}get(e,t=eP){let n=iO(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==eP&&r!==t)if(r===eP){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,xP)}getText(e=``){return this.get(e,HP)}getMap(e=``){return this.get(e,wP)}getXmlElement(e=``){return this.get(e,qP)}getXmlFragment(e=``){return this.get(e,GP)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,uO(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,ON(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},AM=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Nk(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Nk(this.restDecoder)+1;return this.dsCurrVal+=e,e}},jM=class extends AM{constructor(e){super(e),this.keys=[],Nk(e),this.keyClockDecoder=new Vk(jk(e)),this.clientDecoder=new Bk(jk(e)),this.leftClockDecoder=new Vk(jk(e)),this.rightClockDecoder=new Vk(jk(e)),this.infoDecoder=new zk(jk(e),Mk),this.stringDecoder=new Hk(jk(e)),this.parentInfoDecoder=new zk(jk(e),Mk),this.typeRefDecoder=new Bk(jk(e)),this.lenDecoder=new Bk(jk(e))}readLeftID(){return new JM(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new JM(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Rk(this.restDecoder)}readBuf(){return jk(this.restDecoder)}readJSON(){return Rk(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},MM=class{constructor(){this.restEncoder=YO()}toUint8Array(){return QO(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){nk(this.restEncoder,e)}writeDsLen(e){nk(this.restEncoder,e)}},NM=class extends MM{writeLeftID(e){nk(this.restEncoder,e.client),nk(this.restEncoder,e.clock)}writeRightID(e){nk(this.restEncoder,e.client),nk(this.restEncoder,e.clock)}writeClient(e){nk(this.restEncoder,e)}writeInfo(e){tk(this.restEncoder,e)}writeString(e){ok(this.restEncoder,e)}writeParentInfo(e){nk(this.restEncoder,+!!e)}writeTypeRef(e){nk(this.restEncoder,e)}writeLen(e){nk(this.restEncoder,e)}writeAny(e){hk(this.restEncoder,e)}writeBuf(e){ck(this.restEncoder,e)}writeJSON(e){ok(this.restEncoder,JSON.stringify(e))}writeKey(e){ok(this.restEncoder,e)}},PM=class{constructor(){this.restEncoder=YO(),this.dsCurrVal=0}toUint8Array(){return QO(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,nk(this.restEncoder,t)}writeDsLen(e){e===0&&wk(),nk(this.restEncoder,e-1),this.dsCurrVal+=e}},FM=class extends PM{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new bk,this.clientEncoder=new vk,this.leftClockEncoder=new bk,this.rightClockEncoder=new bk,this.infoEncoder=new gk(tk),this.stringEncoder=new xk,this.parentInfoEncoder=new gk(tk),this.typeRefEncoder=new vk,this.lenEncoder=new vk}toUint8Array(){let e=YO();return nk(e,0),ck(e,this.keyClockEncoder.toUint8Array()),ck(e,this.clientEncoder.toUint8Array()),ck(e,this.leftClockEncoder.toUint8Array()),ck(e,this.rightClockEncoder.toUint8Array()),ck(e,QO(this.infoEncoder)),ck(e,this.stringEncoder.toUint8Array()),ck(e,QO(this.parentInfoEncoder)),ck(e,this.typeRefEncoder.toUint8Array()),ck(e,this.lenEncoder.toUint8Array()),sk(e,QO(this.restEncoder)),QO(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){hk(this.restEncoder,e)}writeBuf(e){ck(this.restEncoder,e)}writeJSON(e){hk(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},IM=(e,t,n,r)=>{r=yO(r,t[0].id.clock);let i=mN(t,r);nk(e.restEncoder,t.length-i),e.writeClient(n),nk(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},LM=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{fN(t,n)>e&&r.set(n,e)}),dN(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),nk(e.restEncoder,r.size),uO(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{IM(e,t.clients.get(n),n,r)})},RM=(e,t)=>{let n=nO(),r=Nk(e.restDecoder);for(let i=0;i<r;i++){let r=Nk(e.restDecoder),i=Array(r),a=e.readClient(),o=Nk(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new nF($(a,o),t),o+=t;break}case 10:{let t=Nk(e.restDecoder);i[n]=new BF($(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new IF($(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,LF(e,r));i[n]=c,o+=c.length}}}}return n},zM=(e,t,n)=>{let r=[],i=uO(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new uN,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==BF){let i=iO(d,u.id.client,()=>fN(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,fN(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new FM;return LM(e,s,new Map),nk(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},BM=(e,t)=>LM(e,t.doc.store,t.beforeState),VM=(e,t,n,r=new jM(e))=>ON(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=zM(e,i,RM(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<fN(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=LN([o.update,a.update])}}else i.pendingStructs=a;let s=DM(r,e,i);if(i.pendingDs){let t=new jM(Ok(i.pendingDs));Nk(t.restDecoder);let n=DM(t,e,i);s&&n?i.pendingDs=LN([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,HM(e.doc,t)}},n,!1),HM=(e,t,n,r=jM)=>{let i=Ok(t);VM(i,e,n,new r(i))},UM=class{constructor(){this.l=[]}},WM=()=>new UM,GM=(e,t)=>e.l.push(t),KM=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},qM=(e,t,n)=>pA(e.l,[t,n]),JM=class{constructor(e,t){this.client=e,this.clock=t}},YM=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,$=(e,t)=>new JM(e,t),XM=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw wk()},ZM=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},QM=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},$M=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},eN=(e,t,n=0)=>new $M(e,t,n),tN=(e,t,n)=>{let r=null,i=null;return e._item===null?i=XM(e):r=$(e._item.id.client,e._item.id.clock),new QM(r,i,t,n)},nN=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return tN(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return tN(e,$(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return tN(e,r.lastId,n);r=r.right}return tN(e,null,n)},rN=(e,t)=>{let n=hN(e,t);return{item:n,diff:t.clock-n.id.clock}},iN=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(fN(r,i.client)<=i.clock)return null;let e=n?jF(r,i):rN(r,i),t=e.item;if(!(t instanceof IF))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(fN(r,a.client)<=a.clock)return null;let{item:e}=n?jF(r,a):{item:hN(r,a)};if(e instanceof IF&&e.content instanceof kF)c=e.content.type;else return null}else throw wk();l=s>=0?c._length:0}return eN(c,l,e.assoc)},aN=class{constructor(e,t){this.ds=e,this.sv=t}},oN=(e,t)=>new aN(e,t);oN(CM(),new Map);var sN=e=>oN(wM(e.store),dN(e.store)),cN=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!yM(t.ds,e.id),lN=(e,t)=>{let n=iO(e.meta,lN,sO),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<fN(r,n)&&_N(e,$(n,t))}),_M(e,t.ds,e=>{}),n.add(t))},uN=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},dN=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},fN=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},pN=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw wk()}n.push(t)},mN=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=gO(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=gO((n+r)/2)}throw wk()},hN=(e,t)=>{let n=e.clients.get(t.client);return n[mN(n,t.clock)]},gN=(e,t,n)=>{let r=mN(t,n),i=t[r];return i.id.clock<n&&i instanceof IF?(t.splice(r+1,0,NF(e,i,n-i.id.clock)),r+1):r},_N=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[gN(e,n,t.clock)]},vN=(e,t,n)=>{let r=t.clients.get(n.client),i=mN(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==nF&&r.splice(i+1,0,NF(e,a,n.clock-a.id.clock+1)),a},yN=(e,t,n)=>{let r=e.clients.get(t.id.client);r[mN(r,t.id.clock)]=n},bN=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=gN(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&gN(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},xN=class{constructor(e,t,n){this.doc=e,this.deleteSet=new gM,this.beforeState=dN(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},SN=(e,t)=>t.deleteSet.clients.size===0&&!oO(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(bM(t.deleteSet),BM(e,t),TM(e,t.deleteSet),!0),CN=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&iO(e.changed,t,sO).add(n)},wN=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof IF&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},TN=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=mN(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof IF&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},EN=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=vO(r.length-1,1+mN(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+wN(r,e)}})},DN=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{bM(a),n.afterState=dN(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{qM(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&zP(n)})}),pA(e,[])}finally{r.gc&&TN(a,i,r.gcFilter),EN(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=yO(mN(e,r),1);for(let t=e.length-1;t>=n;)t-=1+wN(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=mN(r,n);a+1<r.length&&wN(r,a+1)>1||a>0&&wN(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(lM(iM,Zj,`[yjs] `,Qj,nM,`Changed the client-id because another client seems to be using it.`),r.clientID=OM()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new NM;SN(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new FM;SN(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):DN(e,t+1)}}},ON=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new xN(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&DN(i,0)}}return o},kN=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},AN=(e,t,n)=>{_M(e,n.deletions,n=>{n instanceof IF&&t.scope.some(t=>t===e.doc||ZM(t,n))&&MF(n,!1)})},jN=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;ON(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;_M(n,o.insertions,e=>{if(e instanceof IF){if(e.redone!==null){let{item:t,diff:i}=jF(r,e.id);i>0&&(t=_N(n,$(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ZM(t,e))&&c.push(e)}}),_M(n,o.deletions,e=>{e instanceof IF&&a.some(t=>t===n.doc||ZM(t,e))&&!yM(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=FF(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},MN=class extends hO{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=mO(e)?e[0].doc:e instanceof kM?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new gM;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&SM(i,n,r,a)});let a=Yk(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=xM([t.deletions,e.deleteSet]),t.insertions=xM([t.insertions,i])}else r.push(new kN(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),_M(e,e.deleteSet,t=>{t instanceof IF&&this.scope.some(n=>n===e.doc||ZM(n,t))&&MF(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=mO(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof eP?e.doc!==this.doc:e!==this.doc)&&uM(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>AN(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>AN(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=jN(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=jN(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*NN(e){let t=Nk(e.restDecoder);for(let n=0;n<t;n++){let t=Nk(e.restDecoder),n=e.readClient(),r=Nk(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Nk(e.restDecoder);yield new BF($(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new IF($(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,LF(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new nF($(n,r),t),r+=t}}}}var PN=class{constructor(e,t){this.gen=NN(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===BF);return this.curr}},FN=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},IN=(e,t)=>{if(e.constructor===nF){let{client:n,clock:r}=e.id;return new nF($(n,r+t),e.length-t)}else if(e.constructor===BF){let{client:n,clock:r}=e.id;return new BF($(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new IF($(r,i+t),null,$(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},LN=(e,t=jM,n=FM)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ok(e))),i=r.map(e=>new PN(e,!0)),a=null,o=new n,s=new FN(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===BF?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)zN(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===BF)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{zN(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new BF($(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===BF?a.struct.length-=t:n=IN(n,t)),a.struct.mergeWith(n)||(zN(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==BF;n=e.next())zN(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(zN(s,a.struct,a.offset),a=null),BN(s),TM(o,xM(r.map(e=>EM(e)))),o.toUint8Array()},RN=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:QO(e.encoder.restEncoder)}),e.encoder.restEncoder=YO(),e.written=0)},zN=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&RN(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),nk(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},BN=e=>{RN(e);let t=e.encoder.restEncoder;nk(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];nk(t,r.written),sk(t,r.restEncoder)}},VN=`You must not compute changes after the event-handler fired.`,HN=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=UN(this.currentTarget,this.target)}deletes(e){return yM(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Sk(VN);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=cO(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=cO(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=cO(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Sk(VN);let t=this.target,n=sO(),r=sO(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},UN=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},WN=()=>{uM(`Invalid access: Add Yjs type to a document before reading data.`)},GN=80,KN=0,qN=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=KN++}},JN=e=>{e.timestamp=KN++},YN=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=KN++},XN=(e,t,n)=>{if(e.length>=GN){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return YN(r,t,n),r}else{let r=new qN(t,n);return e.push(r),r}},ZN=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>_O(t-e.index)<_O(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,JN(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&_O(n.index-i)<r.parent.length/GN?(YN(n,r,i),n):XN(e._searchMarker,r,i)},QN=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=yO(t,i.index+n))}},$N=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;iO(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;qM(r._eH,n,t)},eP=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=WM(),this._dEH=WM(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ck()}clone(){throw Ck()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){GM(this._eH,e)}observeDeep(e){GM(this._dEH,e)}unobserve(e){KM(this._eH,e)}unobserveDeep(e){KM(this._dEH,e)}toJSON(){}},tP=(e,t,n)=>{e.doc??WN(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},nP=e=>{e.doc??WN();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},rP=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&cN(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},iP=(e,t)=>{let n=0,r=e._start;for(e.doc??WN();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},aP=(e,t)=>{let n=[];return iP(e,(r,i)=>{n.push(t(r,i,e))}),n},oP=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},sP=(e,t)=>{e.doc??WN();let n=ZN(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},cP=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new IF($(o,fN(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new _F(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new IF($(o,fN(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new rF(new Uint8Array(n))),i.integrate(e,0);break;case kM:i=new IF($(o,fN(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new cF(n)),i.integrate(e,0);break;default:if(n instanceof eP)i=new IF($(o,fN(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new kF(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},lP=()=>Sk(`Length exceeded!`),uP=(e,t,n,r)=>{if(n>t._length)throw lP();if(n===0)return t._searchMarker&&QN(t._searchMarker,n,r.length),cP(e,t,null,r);let i=n,a=ZN(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&_N(e,$(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&QN(t._searchMarker,i,r.length),cP(e,t,o,r)},dP=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return cP(e,t,r,n)},fP=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=ZN(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&_N(e,$(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&_N(e,$(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw lP();t._searchMarker&&QN(t._searchMarker,i,-a+r)},pP=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},mP=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new _F([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new _F([r]);break;case Uint8Array:s=new rF(r);break;case kM:s=new cF(r);break;default:if(r instanceof eP)s=new kF(r);else throw Error(`Unexpected content type`)}new IF($(o,fN(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},hP=(e,t)=>{e.doc??WN();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},gP=e=>{let t={};return e.doc??WN(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},_P=(e,t)=>{e.doc??WN();let n=e._map.get(t);return n!==void 0&&!n.deleted},vP=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&cN(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},yP=e=>(e.doc??WN(),pM(e._map.entries(),e=>!e[1].deleted)),bP=class extends HN{},xP=class e extends eP{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof eP?e.clone():e)),t}get length(){return this.doc??WN(),this._length}_callObserver(e,t){super._callObserver(e,t),$N(this,e,new bP(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):ON(this.doc,n=>{uP(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):ON(this.doc,t=>{dP(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):ON(this.doc,n=>{fP(n,this,e,t)})}get(e){return sP(this,e)}toArray(){return nP(this)}slice(e=0,t=this.length){return tP(this,e,t)}toJSON(){return this.map(e=>e instanceof eP?e.toJSON():e)}map(e){return aP(this,e)}forEach(e){iP(this,e)}[Symbol.iterator](){return oP(this)}_write(e){e.writeTypeRef(SF)}},SP=e=>new xP,CP=class extends HN{constructor(e,t,n){super(e,t),this.keysChanged=n}},wP=class e extends eP{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof eP?e.clone():e)}),t}_callObserver(e,t){$N(this,e,new CP(this,e,t))}toJSON(){this.doc??WN();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof eP?r.toJSON():r}}),e}get size(){return[...yP(this)].length}keys(){return mM(yP(this),e=>e[0])}values(){return mM(yP(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return mM(yP(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??WN(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):ON(this.doc,t=>{pP(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):ON(this.doc,n=>{mP(n,this,e,t)}),t}get(e){return hP(this,e)}has(e){return _P(this,e)}clear(){this.doc===null?this._prelimContent.clear():ON(this.doc,e=>{this.forEach(function(t,n,r){pP(e,r,n)})})}_write(e){e.writeTypeRef(CF)}},TP=e=>new wP,EP=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&uA(e,t),DP=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&wk(),this.right.content.constructor){case fF:this.right.deleted||jP(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},OP=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case fF:t.right.deleted||jP(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&_N(e,$(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},kP=(e,t,n,r)=>{let i=new Map,a=r?ZN(t,n):null;return a?OP(e,new DP(a.p.left,a.p,a.index,i),n-a.index):OP(e,new DP(null,t._start,0,i),n)},AP=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===fF&&EP(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new IF($(a,fN(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new fF(o,r));l.integrate(e,0),n.right=l,n.forward()})},jP=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},MP=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===fF&&EP(t[e.right.content.key]??null,e.right.content.value));)e.forward()},NP=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!EP(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new IF($(a,fN(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new fF(s,c)),n.right.integrate(e,0),n.forward()}}return o},PP=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;MP(n,i);let s=NP(e,t,n,i),c=r.constructor===String?new yF(r):r instanceof eP?new kF(r):new uF(r),{left:l,right:u,index:d}=n;t._searchMarker&&QN(t._searchMarker,n.index,c.getLength()),u=new IF($(o,fN(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),AP(e,t,n,s)},FP=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;MP(n,i);let s=NP(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===fF));){if(!n.right.deleted)switch(n.right.content.constructor){case fF:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(EP(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&_N(e,$(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
209
|
-
`;n.right=new IF($(o,fN(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new yF(i)),n.right.integrate(e,0),n.forward()}AP(e,t,n,s)},IP=(e,t,n,r,i)=>{let a=t,o=nO();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===fF){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case fF:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&jP(i,n);break}}}t=t.right}return s},LP=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===fF){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},RP=e=>{let t=0;return ON(e.doc,n=>{let r=e._start,i=e._start,a=nO(),o=rO(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case fF:jP(o,i.content);break;default:t+=IP(n,r,i,a,o),a=rO(o),r=i;break}i=i.right}}),t},zP=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&bN(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===fF&&e.constructor!==nF&&t.add(e.parent)})}ON(n,n=>{_M(e,e.deleteSet,e=>{if(e instanceof nF||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===fF?t.add(r):LP(n,e)});for(let e of t)RP(e)})},BP=(e,t,n)=>{let r=n,i=rO(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case kF:case uF:case yF:n<t.right.length&&_N(e,$(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&IP(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&QN(o._searchMarker,t.index,-r+n),t},VP=class extends HN{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];ON(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},sA(o)||(e.attributes=rA({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case kF:case uF:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case yF:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case fF:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(EP(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),EP(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;EP(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(EP(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),jP(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},HP=class e extends eP{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??WN(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new VP(this,e,t);$N(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??WN();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===yF&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):ON(this.doc,n=>{let r=new DP(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
210
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&PP(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&BP(n,r,a.delete):FP(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??WN();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(cN(s,e)||t!==void 0&&cN(s,t))switch(s.content.constructor){case yF:{let r=i.get(`ychange`);e!==void 0&&!cN(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!cN(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case kF:case uF:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case fF:cN(s,e)&&(c(),jP(i,s.content));break}s=s.right}c()};return e||t?ON(a,n=>{e&&lN(n,e),t&&lN(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):ON(r,r=>{let i=kP(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),PP(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):ON(r,r=>{let i=kP(r,this,e,!n);PP(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):ON(n,n=>{BP(n,kP(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):ON(r,r=>{let i=kP(r,this,e,!1);i.right!==null&&FP(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):ON(this.doc,t=>{pP(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):ON(this.doc,n=>{mP(n,this,e,t)})}getAttribute(e){return hP(this,e)}getAttributes(){return gP(this)}_write(e){e.writeTypeRef(wF)}},UP=e=>new HP,WP=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??WN()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===qP||t.constructor===GP)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},GP=class e extends eP{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof eP?e.clone():e)),t}get length(){return this.doc??WN(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new WP(this,e)}querySelector(e){e=e.toUpperCase();let t=new WP(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),uO(new WP(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){$N(this,e,new YP(this,t,e))}toString(){return aP(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),iP(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):ON(this.doc,n=>{uP(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)ON(this.doc,n=>{let r=e&&e instanceof eP?e._item:e;cP(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Sk(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):ON(this.doc,n=>{fP(n,this,e,t)})}toArray(){return nP(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return sP(this,e)}slice(e=0,t=this.length){return tP(this,e,t)}forEach(e){iP(this,e)}_write(e){e.writeTypeRef(EF)}},KP=e=>new GP,qP=class e extends GP{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return aA(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof eP?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):ON(this.doc,t=>{pP(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):ON(this.doc,n=>{mP(n,this,e,t)})}getAttribute(e){return hP(this,e)}hasAttribute(e){return _P(this,e)}getAttributes(e){return e?vP(this,e):gP(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return iP(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(TF),e.writeKey(this.nodeName)}},JP=e=>new qP(e.readKey()),YP=class extends HN{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},XP=class e extends wP{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(DF),e.writeKey(this.hookName)}},ZP=e=>new XP(e.readKey()),QP=class e extends HP{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(OF)}},$P=e=>new QP,eF=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ck()}mergeWith(e){return!1}write(e,t,n){throw Ck()}integrate(e,t){throw Ck()}},tF=0,nF=class extends eF{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),pN(e.doc.store,this)}write(e,t){e.writeInfo(tF),e.writeLen(this.length-t)}getMissing(e,t){return null}},rF=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Ck()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},iF=e=>new rF(e.readBuf()),aF=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){SM(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},oF=e=>new aF(e.readLen()),sF=(e,t)=>new kM({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),cF=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(sF(this.doc.guid,this.opts))}splice(e){throw Ck()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},lF=e=>new cF(sF(e.readString(),e.readAny())),uF=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Ck()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},dF=e=>new uF(e.readJSON()),fF=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Ck()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},pF=e=>new fF(e.readKey(),e.readJSON()),mF=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},hF=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new mF(n)},gF=SA(`node_env`)===`development`,_F=class e{constructor(e){this.arr=e,gF&&fA(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},vF=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new _F(n)},yF=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},bF=e=>new yF(e.readString()),xF=[SP,TP,UP,JP,KP,ZP,$P],SF=0,CF=1,wF=2,TF=3,EF=4,DF=5,OF=6,kF=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Ck()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},AF=e=>new kF(xF[e.readTypeRef()](e)),jF=(e,t)=>{let n=t,r=0,i;do r>0&&(n=$(n.client,n.clock+r)),i=hN(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof IF);return{item:i,diff:r}},MF=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},NF=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new IF($(r,i+n),t,$(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=$(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},PF=(e,t)=>fO(e,e=>yM(e.deletions,t)),FF=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return _N(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||FF(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=_N(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:_N(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:_N(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||yM(r,d.right.id)||PF(a.undoStack,d.right.id)||PF(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=_N(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=$(c,fN(s,c)),h=new IF(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,MF(h,!0),h.integrate(e,0),h},IF=class e extends eF{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=fN(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=fN(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===JM&&this.id.client!==this.parent.client&&this.parent.clock>=fN(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=vN(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=_N(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===nF||this.right&&this.right.constructor===nF)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===JM){let e=hN(n,this.parent);e.constructor===nF?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=vN(e,e.doc.store,$(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),YM(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(YM(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(hN(e.doc.store,n.origin)))r.has(hN(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),pN(e.doc.store,this),this.content.integrate(e,this),CN(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new nF(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:$(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&YM(e.origin,this.lastId)&&this.right===e&&YM(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),SM(e.deleteSet,this.id.client,this.id.clock,this.length),CN(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw wk();this.content.gc(e),t?yN(e,this,new nF(this.id,this.length)):this.content=new aF(this.length)}write(e,t){let n=t>0?$(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=XM(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===JM?(e.writeParentInfo(!1),e.writeLeftID(t)):wk();i!==null&&e.writeString(i)}this.content.write(e,t)}},LF=(e,t)=>RF[t&31](e),RF=[()=>{wk()},oF,hF,iF,bF,dF,pF,AF,vF,lF,()=>{wk()}],zF=10,BF=class extends eF{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){wk()}write(e,t){e.writeInfo(zF),nk(e.restEncoder,this.length-t)}getMissing(e,t){return null}},VF=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},HF=`__ $YJS$ __`;VF[HF]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),VF[HF]=!0;var UF=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},WF=/[\uD800-\uDBFF]/,GF=/[\uDC00-\uDFFF]/,KF=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&WF.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&GF.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},qF=(e,t)=>e>>>t|e<<32-t,JF=e=>qF(e,2)^qF(e,13)^qF(e,22),YF=e=>qF(e,6)^qF(e,11)^qF(e,25),XF=e=>qF(e,7)^qF(e,18)^e>>>3,ZF=e=>qF(e,17)^qF(e,19)^e>>>10,QF=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$F=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),eI=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set($F),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=ZF(t[e-2])+t[e-7]+XF(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+YF(o)+(o&s^~o&c)+QF[e]+t[e]>>>0,d=JF(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/NO,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},tI=e=>new eI().digest(e),nI=new Ju(`y-sync`),rI=new Ju(`y-undo`);new Ju(`yjs-cursor`);var iI=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},aI=e=>EA(iI(tI(DA(e)))),oI=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!yM(t.ds,e.id),sI=[{light:`#ecd44433`,dark:`#ecd444`}],cI=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=sO();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Kk(t))}return e.get(n)},lI=(e,{colors:t=sI,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new pI(e,a),c=new Gu({props:{editable:e=>{let t=nI.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:nI,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(nI);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&Yj(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=rI.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},nI)})}},destroy:()=>{s.destroy()}})});return c},uI=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new ju(e.doc));else if(t.type===`node`){let r=LI(n.doc,n.type,t.anchor,n.mapping);e.setSelection(dI(e,r))}else{let r=LI(n.doc,n.type,t.anchor,n.mapping),i=LI(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(J.between(e.doc.resolve(r),e.doc.resolve(i)))}},dI=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?Y.create(e.doc,t):J.near(n)},fI=(e,t)=>({type:t.selection.jsonID,anchor:FI(t.selection.anchor,e.type,e.mapping),head:FI(t.selection.head,e.type,e.mapping)}),pI=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=UF(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=fI(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(_A&&this._domSelectionInView===null&&(Yj(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=Hj.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=oN(CM(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(nI,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>hI(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(G.from(e),0,0));t.setMeta(nI,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>hI(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(G.from(t),0,0));if(e){let t=vO(yO(e.anchor,0),n.doc.content.size),r=vO(yO(e.head,0),n.doc.content.size);n.setSelection(J.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(nI,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=sN(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&wk(),r=new kM({gc:!1}),HM(r,t),t=sN(r),HM(r,e),e=sN(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[mN(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{_M(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:cI(n.colorMapping,n.colors,r)}},s=rP(i,new aN(t.ds,e.sv)).map(n=>!n._item.deleted||oI(n._item,e)||oI(n._item,t)?hI(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(G.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(nI,{isChangeOrigin:!0}))},nI)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=nI.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);_M(t,t.deleteSet,e=>{if(e.constructor===IF){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>mI(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(G.from(n),0,0));uI(r,this.beforeTransactionSelection,this),r=r.setMeta(nI,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof MN}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{NI(this.doc,this.type,e,this),this.beforeTransactionSelection=fI(this,this.prosemirrorView.state)},nI)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},mI=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof qP)return hI(e,t,n,r,i,a);throw Ck()}return o},hI=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof qP){let s=mI(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof HP&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=gI(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):rP(e,new aN(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(oI(e._item,r)?oI(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch{return e.doc.transact(t=>{e._item.delete(t)},nI),n.mapping.delete(e),null}},gI=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,jI(n.attributes,t)))}}catch{return e.doc.transact(t=>{e._item.delete(t)},nI),null}return o},_I=(e,t)=>{let n=new QP,r=e.map(e=>({insert:e.text,attributes:MI(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},vI=(e,t)=>{let n=new qP(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,SI(e).map(e=>yI(e,t))),t.mapping.set(n,e),n},yI=(e,t)=>e instanceof Array?_I(e,t):vI(e,t),bI=e=>typeof e==`object`&&!!e,xI=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||bI(o)&&bI(s)&&xI(o,s)}return r},SI=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},CI=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&iA(e.attributes||{}).length===t[n].marks.length&&cA(e.attributes,(e,r)=>{let i=AI(r),a=t[n].marks;return a.find(e=>e.type.name===i)?xI(e,a.find(e=>e.type.name===i)?.attrs):!1}))},wI=(e,t)=>{if(e instanceof qP&&!(t instanceof Array)&&PI(e,t)){let n=SI(t);return e._length===n.length&&xI(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>wI(e,n[t]))}return e instanceof QP&&t instanceof Array&&CI(e,t)},TI=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),EI=(e,t,n)=>{let r=e.toArray(),i=SI(t),a=i.length,o=r.length,s=vO(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(TI(n.mapping.get(e),t))u=!0;else if(!wI(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(TI(n.mapping.get(e),t))u=!0;else if(!wI(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},DI=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof yF?t+=n.content.str:n.content instanceof fF&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},OI=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=DI(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,MI(e.marks,n))})),{insert:o,remove:s,index:c}=KF(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},kI=/(.*)(--[a-zA-Z0-9+/=]{8})$/,AI=e=>kI.exec(e)?.[1]??e,jI=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(AI(r),e[r]));return n},MI=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=iO(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${aI(e.toJSON())}`:e.type.name]=e.attrs}}),n},NI=(e,t,n,r)=>{if(t instanceof qP&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof qP){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=SI(n),a=i.length,o=t.toArray(),s=o.length,c=vO(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!TI(r.mapping.get(e),t))if(wI(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!TI(r.mapping.get(e),t))if(wI(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof QP&&c instanceof Array)CI(n,c)||OI(n,c,r),l+=1;else{let i=n instanceof qP&&PI(n,c),a=d instanceof qP&&PI(d,f);if(i&&a){let e=EI(n,c,r),t=EI(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(NI(e,n,c,r),l+=1):a?(NI(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[yI(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof QP?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(yI(i[t],r));t.insert(l,e)}},nI)},PI=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,FI=(e,t,n)=>{if(e===0)return nN(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof QP){if(r._length>=e)return nN(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new QM(r._item===null?null:r._item.id,r._item===null?XM(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new QM(r._item===null?null:r._item.id,r._item===null?XM(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw wk();if(e===0&&r.constructor!==QP&&r!==t)return II(r._item.parent,r._item)}return nN(t,t._length,-1)},II=(e,t)=>{let n=null,r=null;return e._item===null?r=XM(e):n=$(e._item.id.client,e._item.id.clock),new QM(n,r,t.id)},LI=(e,t,n,r)=>{let i=iN(n,e);if(i===null||i.type!==t&&!ZM(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===QP)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof QP?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof QP?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},RI=e=>{let t=rI.getState(e).undoManager;if(t!=null)return t.undo(),!0},zI=e=>{let t=rI.getState(e).undoManager;if(t!=null)return t.redo(),!0},BI=new Set([`paragraph`]),VI=(e,t)=>!(e instanceof IF)||!(e.content instanceof kF)||!(e.content.type instanceof HP||e.content.type instanceof qP&&t.has(e.content.type.nodeName))||e.content.type._length===0,HI=({protectedNodes:e=BI,trackedOrigins:t=[],undoManager:n=null}={})=>new Gu({key:rI,state:{init:(r,i)=>{let a=nI.getState(i),o=n||new MN(a.type,{trackedOrigins:new Set([nI].concat(t)),deleteFilter:t=>VI(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=nI.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:fI(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=nI.getState(e.state),n=rI.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,rI.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}});function UI(e){return!!e.getMeta(nI)}function WI(e,t){let n=nI.getState(e);return LI(n.doc,n.type,t,n.binding.mapping)||0}function GI(e,t){let n=nI.getState(e);return FI(t,n.type,n.binding.mapping)}var KI=class e extends Iv{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function qI(e,t){return new KI(e,GI(t,e))}function JI(e,t,n){let r=e instanceof KI?e.yRelativePosition:null;if(UI(t)&&r)return{position:new KI(WI(n,r),r),mapResult:null};let i=Lv(e,t),a=i.position.position;return{position:new KI(a,r??GI(n,a)),mapResult:i.mapResult}}ky.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>JI(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>qI(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),rI.getState(t).undoManager.undoStack.length===0?!1:n?RI(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),rI.getState(t).undoManager.redoStack.length===0?!1:n?zI(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=HI(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=rI.getState(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[lI(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new Gu({key:new Ju(`filterInvalidContent`),filterTransaction:t=>{if(!UI(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!1}}})].filter(Boolean)}});function YI(e){if(!e.length)return xh.empty;let t=[],n=e[0].$from.node(0);return e.forEach(e=>{let n=e.$from.pos,r=e.$from.nodeAfter;r&&t.push(vh.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),xh.create(n,t)}function XI(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function ZI(e,t,n,r={}){let i=[],a=e.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n==`number`&&n>=0||(n=e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos));let s=new mc(e,t,n),c=s.depth===0?0:a.resolve(s.start).posAtIndex(0);return s.parent.forEach((n,r)=>{let l=c+r,u=l+n.nodeSize,d=XI(l,n.nodeSize,n),f=o?t.pos>=d.start&&e.pos<=d.end:t.pos>d.start&&e.pos<d.end;if(l<s.start||l>=s.end||!f)return;let p=new Eu(a.resolve(l),a.resolve(u));i.push(p)}),i}var QI=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return new $I(e.resolve(this.anchor),e.resolve(this.head))}},$I=class e extends q{constructor(e,t,n,r=1){let{doc:i}=e,a=e===t,o=e.pos===i.content.size&&t.pos===i.content.size,s=a&&!o?i.resolve(t.pos+(r>0?1:-1)):t,c=a&&o?i.resolve(e.pos-(r>0?1:-1)):e,l=ZI(c.min(s),c.max(s),n),u=s.pos>=e.pos?l[0].$from:l[l.length-1].$to,d=s.pos>=e.pos?l[l.length-1].$to:l[0].$from;super(u,d,l),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof e&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){return new e(t.resolve(n.map(this.anchor)),t.resolve(n.map(this.head)))}toJSON(){return{type:`nodeRange`,anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){let{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){let t=this.ranges.slice(0,-1),n=t[0].$from,r=t[t.length-1].$to;return new e(n,r,this.depth)}let n=this.ranges[0],r=t.resolve(Math.max(0,n.$from.pos-1));return new e(this.$anchor,r,this.depth)}extendForwards(){let{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){let t=this.ranges.slice(1),n=t[0].$from,r=t[t.length-1].$to;return new e(r,n,this.depth)}let n=this.ranges[this.ranges.length-1],r=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new e(this.$anchor,r,this.depth)}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n,r,i=1){return new this(e.resolve(t),e.resolve(n),r,i)}getBookmark(){return new QI(this.anchor,this.head)}};$I.prototype.visible=!1;function eL(e){return e instanceof $I}ky.create({name:`nodeRange`,addOptions(){return{depth:void 0,key:`Mod`}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!eL(a)){let e=$I.create(i,s,c,t,-1);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendBackwards();return o.setSelection(l),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!eL(a)){let e=$I.create(i,s,c,t);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendForwards();return o.setSelection(l),n.dispatch(o),!0},"Mod-a":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,tr:a}=r,o=$I.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;eL(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new Gu({key:new Ju(`nodeRange`),props:{attributes:()=>e?{class:`ProseMirror-noderangeselection`}:{class:``},handleDOMEvents:{mousedown:(e,n)=>{let{key:r}=this.options,i=/Mac/.test(navigator.platform),a=!!n.shiftKey,o=!!n.ctrlKey,s=!!n.altKey,c=!!n.metaKey;return(r==null||r===`Shift`&&a||r===`Control`&&o||r===`Alt`&&s||r===`Meta`&&c||r===`Mod`&&(i?c:o))&&(t=!0),t&&document.addEventListener(`mouseup`,()=>{t=!1;let{state:n}=e,{doc:r,selection:i,tr:a}=n,{$anchor:o,$head:s}=i;if(o.sameParent(s))return;let c=$I.create(r,o.pos,s.pos,this.options.depth);a.setSelection(c),e.dispatch(a)},{once:!0}),!1}},decorations:n=>{let{selection:r}=n,i=eL(r);if(e=!1,!t)return i?(e=!0,YI(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=ZI(a,o,this.options.depth);return s.length?(e=!0,YI(s)):null}}})]}});function tL(e,t){let n=getComputedStyle(e);if(t)return t.filter(e=>e.trim().length>0).map(e=>`${e}:${n.getPropertyValue(e)};`).join(``);let r=``;for(let e=0;e<n.length;e+=1)r+=`${n[e]}:${n.getPropertyValue(n[e])};`;return r}function nL(e,t){let n=e.cloneNode(!0),r=[e,...Array.from(e.getElementsByTagName(`*`))],i=[n,...Array.from(n.getElementsByTagName(`*`))];return r.forEach((e,n)=>{i[n].style.cssText=tL(e,t)}),n}var rL=[{id:`listItemFirstChild`,evaluate:({parent:e,isFirst:t})=>t&&e&&[`listItem`,`taskItem`].includes(e.type.name)?1e3:0},{id:`listWrapperDeprioritize`,evaluate:({node:e})=>{let t=[`listItem`,`taskItem`],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},{id:`tableStructure`,evaluate:({node:e,parent:t})=>[`tableRow`,`tableCell`,`tableHeader`].includes(e.type.name)||t&&t.type.name===`tableHeader`?1e3:0},{id:`inlineContent`,evaluate:({node:e})=>e.isInline||e.isText?1e3:0}],iL={edges:[`left`,`top`],threshold:12,strength:500};function aL(e){return e===void 0||e===`left`?{...iL}:e===`right`?{edges:[`right`,`top`],threshold:12,strength:500}:e===`both`?{edges:[`left`,`right`,`top`],threshold:12,strength:500}:e===`none`?{edges:[],threshold:0,strength:0}:{...iL,...e}}function oL(e,t,n){if(n.edges.length===0)return!1;let r=t.getBoundingClientRect(),{threshold:i,edges:a}=n;return a.some(t=>t===`left`?e.x-r.left<i:t===`right`?r.right-e.x<i:t===`top`?e.y-r.top<i:t===`bottom`?r.bottom-e.y<i:!1)}function sL(e,t,n,r){return!t||n.edges.length===0?0:oL(e,t,n)?n.strength*r:0}var cL=1e3;function lL(e,t,n,r){let i=cL,a=!1;if(t.every(t=>{let n=t.evaluate(e);return i-=n,i<=0?(a=!0,!1):!0}),a)return-1;let o=e.view.nodeDOM(e.pos);return i-=sL(r,o,n,e.depth),i<=0?-1:i}function uL(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function dL(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;let r=e.posAtCoords({left:t.x,top:t.y});if(!r)return null;let{doc:i}=e.state,a=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...rL),o.push(...n.rules);let s=Array.from({length:a.depth},(e,t)=>a.depth-t).map(r=>{let i=a.node(r),s=a.before(r);if(n.allowedContainers&&r>0&&!uL(a,r,n.allowedContainers))return null;let c=r>0?a.node(r-1):null,l=r>0?a.index(r-1):0,u=c?c.childCount:1,d=lL({node:i,pos:s,depth:r,parent:c,index:l,isFirst:l===0,isLast:l===u-1,$pos:a,view:e},o,n.edgeDetection,t);return d<0?null:{node:i,pos:s,depth:r,score:d,dom:e.nodeDOM(s)}}).filter(e=>e!==null),c=a.nodeAfter;if(c&&c.isAtom&&!c.isInline){let i=r.pos,l=a.depth+1,u=a.parent,d=a.index(),f=u.childCount,p=!0;if(n.allowedContainers&&(p=uL(a,l,n.allowedContainers)),p){let r=lL({node:c,pos:i,depth:l,parent:u,index:d,isFirst:d===0,isLast:d===f-1,$pos:a,view:e},o,n.edgeDetection,t);if(r>=0){let t=e.nodeDOM(i);t&&s.push({node:c,pos:i,depth:l,score:r,dom:t})}}}if(s.length===0)return null;s.sort((e,t)=>t.score===e.score?t.depth-e.depth:t.score-e.score);let l=s[0];return l.dom?{node:l.node,pos:l.pos,dom:l.dom}:null}function fL(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function pL(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function mL(e,t,n,r=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;let i=e.dom,a=i.firstElementChild,o=i.lastElementChild;if(!a||!o)return null;let s=a.getBoundingClientRect(),c=o.getBoundingClientRect();if(!pL(s)||!pL(c))return null;let l=Math.min(Math.max(s.top+r,n),c.bottom-r),u=.5,d=Math.abs(s.left-c.left)<u,f=Math.abs(s.right-c.right)<u,p=s;d&&f&&(p=s);let m=Math.min(Math.max(p.left+r,t),p.right-r);return!Number.isFinite(m)||!Number.isFinite(l)?null:{x:m,y:l}}var hL=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=mL(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=dL(a,{x:c,y:l},i);return e?{resultElement:e.dom,resultNode:e.node,pos:e.pos}:{resultElement:null,resultNode:null,pos:null}}let u=a.root.elementsFromPoint(c,l),d;if(Array.prototype.some.call(u,e=>{if(!a.dom.contains(e))return!1;let t=fL(e,a);return t?(d=t,!0):!1}),!d){let e=a.posAtCoords({left:c,top:l});if(e){let t=o.doc.resolve(e.pos),n=Math.min(t.depth,1),r=n>0?t.before(n):t.pos,i=o.doc.nodeAt(r);if(i){let e=a.nodeDOM(r);return{resultElement:e instanceof HTMLElement?e:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}let f;try{f=a.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}let p=o.doc.nodeAt(f);if(!p){let e=o.doc.resolve(f),t=e.parent;return{resultElement:d,resultNode:t,pos:e.start()}}return{resultElement:d,resultNode:p,pos:f}};function gL(e,t){let n=e.nodeDOM(t);if(n instanceof Element&&n!==e.dom)return n;let{node:r,offset:i}=e.domAtPos(t),a=r.childNodes[i];return a instanceof Element?a:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function _L(e,t){let n=gL(e,t);return(n?getComputedStyle(n).direction:getComputedStyle(e.dom).direction)||`ltr`}function vL(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function yL(e,t){return e===`rtl`?t:0}function bL(e,t,n,r){let{doc:i}=t.view.state;if(n?.enabled&&r?.node&&r.pos>=0){let e=r.pos,t=r.pos+r.node.nodeSize;return[{$from:i.resolve(e),$to:i.resolve(t)}]}let a=hL({editor:t,x:e.clientX,y:e.clientY,direction:`right`,nestedOptions:n});if(!a.resultNode||a.pos===null)return[];let o=a.resultNode.isText||a.resultNode.isAtom?0:-1;return ZI(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function xL(e,t,n,r,i){let{view:a}=t;if(!e.dataTransfer)return;let{empty:o,$from:s,$to:c}=a.state.selection,l=bL(e,t,n,r),u=ZI(s,c,0,{extendOnBoundaryOverlap:!1}),d=u.some(e=>l.find(t=>t.$from===e.$from&&t.$to===e.$to)),f=o||!d?l:u;if(!f.length)return;let{tr:p}=a.state,m=document.createElement(`div`),h=f[0].$from.pos,g=f[f.length-1].$to.pos,_=_L(a,h);m.setAttribute(`dir`,_);let v=n?.enabled&&r?.node,y,b;v?(y=a.state.doc.slice(h,g),b=Y.create(a.state.doc,h)):(b=$I.create(a.state.doc,h,g),y=b.content()),f.forEach(e=>{let t=gL(a,e.$from.pos);if(!t)return;let n=nL(t,i);n.style.margin=`0`,m.append(n)}),m.style.position=`absolute`,m.style.top=`-10000px`,document.body.append(m),e.dataTransfer.clearData();let x=yL(_,m.getBoundingClientRect().width);e.dataTransfer.setDragImage(m,x,0);let S=!1,C=()=>{S||(S=!0,vL(m),document.removeEventListener(`drop`,C),document.removeEventListener(`dragend`,C))},w=b instanceof Y?b:void 0;a.dragging={slice:y,move:!0,node:w},p.setSelection(b),a.dispatch(p),document.addEventListener(`drop`,C),document.addEventListener(`dragend`,C)}var SL=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},CL=(e,t)=>{let n=e.nodeAt(t),r=e.resolve(t),{depth:i}=r,a=n;for(;i>0;){let e=r.node(i);--i,i===0&&(a=e)}return a},wL=(e,t)=>{let n=nI.getState(e);return n?FI(t,n.type,n.binding.mapping):null},TL=(e,t)=>{let n=nI.getState(e);return n?LI(n.doc,n.type,t,n.binding.mapping)||0:-1},EL=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},DL=new Ju(`dragHandle`),OL=({pluginKey:e=DL,element:t,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:a,onElementDragStart:o,onElementDragEnd:s,nestedOptions:c,dragImageProperties:l})=>{let u=document.createElement(`div`),d=!1,f=null,p=-1,m,h=null,g=null;function _(){t&&(t.style.visibility=`hidden`,t.style.pointerEvents=`none`)}function v(){if(t){if(!n.isEditable){_();return}t.style.visibility=``,t.style.pointerEvents=`auto`}}function y(e){$e(i?.()||{getBoundingClientRect:()=>e.getBoundingClientRect()},t,r).then(e=>{Object.assign(t.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`})})}function b(e){o?.(e),xL(e,n,c,{node:f,pos:p},l),t&&(t.dataset.dragging=`true`),setTimeout(()=>{t&&(t.style.pointerEvents=`none`)},0)}function x(e){s?.(e),_(),t&&(t.style.pointerEvents=`auto`,t.dataset.dragging=`false`)}function S(){if(tb()){let e=n.view.dom;requestAnimationFrame(()=>{e.isContentEditable&&(e.contentEditable=`false`,e.contentEditable=`true`)})}}return u.appendChild(t),{unbind(){t.removeEventListener(`dragstart`,b),t.removeEventListener(`dragend`,x),document.removeEventListener(`drop`,S),h&&(cancelAnimationFrame(h),h=null,g=null)},plugin:new Gu({key:typeof e==`string`?new Ju(e):e,state:{init(){return{locked:!1}},apply(e,r,i,o){let s=e.getMeta(`lockDragHandle`),c=e.getMeta(`hideDragHandle`);if(s!==void 0&&(d=s),c)return _(),d=!1,f=null,p=-1,a?.({editor:n,node:null,pos:-1}),r;if(e.docChanged&&p!==-1&&t)if(UI(e)){let e=TL(o,m);e!==p&&(p=e)}else{let t=e.mapping.map(p);t!==p&&(p=t,m=wL(o,p))}return r}},view:e=>{var r;return t.draggable=!0,t.style.pointerEvents=`auto`,t.dataset.dragging=`false`,(r=n.view.dom.parentElement)==null||r.appendChild(u),u.style.pointerEvents=`none`,u.style.position=`absolute`,u.style.top=`0`,u.style.left=`0`,t.addEventListener(`dragstart`,b),t.addEventListener(`dragend`,x),document.addEventListener(`drop`,S),{update(r,i){if(!t)return;if(!n.isEditable){_();return}if(d?t.draggable=!1:t.draggable=!0,e.state.doc.eq(i.doc)||p===-1)return;let o=e.nodeDOM(p);if(o=EL(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=CL(n.state.doc,s),l=SL(n.state.doc,s);f=c,p=l,m=wL(e.state,p),a?.({editor:n,node:f,pos:p}),y(o)},destroy(){t.removeEventListener(`dragstart`,b),t.removeEventListener(`dragend`,x),document.removeEventListener(`drop`,S),h&&(cancelAnimationFrame(h),h=null,g=null),t&&vL(u)}}},props:{handleDOMEvents:{keydown(e){return!t||d?!1:e.hasFocus()?(_(),f=null,p=-1,a?.({editor:n,node:null,pos:-1}),!1):!1},mouseleave(e,t){return d||t.target&&!u.contains(t.relatedTarget)&&(_(),f=null,p=-1,a?.({editor:n,node:null,pos:-1})),!1},mousemove(e,r){return!t||d||(g={x:r.clientX,y:r.clientY},h)||(h=requestAnimationFrame(()=>{if(h=null,!g)return;let{x:t,y:r}=g;g=null;let i=hL({x:t,y:r,direction:`right`,editor:n,nestedOptions:c});if(!i.resultElement)return;let o=i.resultElement,s=i.resultNode,l=i.pos;if(!c?.enabled){if(o=EL(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=CL(n.state.doc,t),l=SL(n.state.doc,t)}s!==f&&(f=s,p=l??-1,m=wL(e.state,p),a?.({editor:n,node:f,pos:p}),y(o),v())})),!1}}}})}};function kL(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:aL(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:aL(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:aL(e.edgeDetection)}}var AL={placement:`left-start`,strategy:`absolute`};ky.create({name:`dragHandle`,addOptions(){return{render(){let e=document.createElement(`div`);return e.classList.add(`drag-handle`),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta(`lockDragHandle`,this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta(`lockDragHandle`,this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta(`lockDragHandle`,this.options.locked))}},addProseMirrorPlugins(){let e=this.options.render(),t=kL(this.options.nested);return[OL({computePositionConfig:{...AL,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t,dragImageProperties:this.options.dragImageProperties}).plugin]}});var jL=A({name:`DragHandleVue`,props:{pluginKey:{type:[String,Object],default:DL},editor:{type:Object,required:!0},computePositionConfig:{type:Object,default:()=>({})},onNodeChange:{type:Function,default:null},onElementDragStart:{type:Function,default:null},onElementDragEnd:{type:Function,default:null},class:{type:String,default:`drag-handle`},nested:{type:[Boolean,Object],default:!1}},setup(e,{slots:t}){let n=L(null),r=c(null),i=()=>{let{editor:t,pluginKey:i,onNodeChange:a,onElementDragEnd:o,onElementDragStart:s,computePositionConfig:c,nested:l}=e;if(!n.value||!e.editor||e.editor.isDestroyed)return;n.value.style.visibility=`hidden`;let u=kL(l),d=OL({editor:t,element:n.value,pluginKey:i,computePositionConfig:{...AL,...c},onNodeChange:a,onElementDragStart:s,onElementDragEnd:o,nestedOptions:u});r.value=d,e.editor.registerPlugin(d.plugin)},a=()=>{var t,n;r.value&&=(e.editor&&!e.editor.isDestroyed&&e.editor.unregisterPlugin(e.pluginKey),(n=(t=r.value).unbind)==null||n.call(t),null)};return ce(async()=>{await v(),i()}),Pe(()=>e.nested,()=>{a(),i()},{deep:!0}),_(()=>{a()}),()=>ie(`div`,{ref:n,class:e.class,style:{position:`absolute`},"data-dragging":`false`},t.default?.call(t))}}),ML={slots:{root:`hidden sm:flex items-center justify-center transition-all duration-200 ease-out`,handle:`cursor-grab px-1`}},NL=Object.assign({inheritAttrs:!1},{__name:`EditorDragHandle`,props:{icon:{type:null,required:!1},color:{type:null,required:!1,default:`neutral`},variant:{type:null,required:!1,default:`ghost`},options:{type:Object,required:!1},editor:{type:Object,required:!0},ui:{type:Object,required:!1},pluginKey:{type:[Object,String],required:!1},nestedOptions:{type:Object,required:!1},onElementDragStart:{type:Function,required:!1},onElementDragEnd:{type:Function,required:!1},getReferencedVirtualElement:{type:Function,required:!1},dragImageProperties:{type:Array,required:!1},nested:{type:[Boolean,Object],required:!1},label:{type:String,required:!1},activeColor:{type:null,required:!1},activeVariant:{type:null,required:!1},size:{type:null,required:!1,default:`sm`},square:{type:Boolean,required:!1},block:{type:Boolean,required:!1},loadingAuto:{type:Boolean,required:!1},onClick:{type:[Function,Array],required:!1},class:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1},as:{type:null,required:!1},type:{type:null,required:!1},disabled:{type:Boolean,required:!1},exactActiveClass:{type:String,required:!1},viewTransition:{type:Boolean,required:!1}},emits:[`nodeChange`,`hover`],setup(e,{emit:t}){let n=e,i=t,a=lt(`editorDragHandle`,n),o=ht(Fe(a,`pluginKey`,`nested`,`nestedOptions`,`onElementDragEnd`,`onElementDragStart`,`getReferencedVirtualElement`)),c=ht(De(a,`icon`,`options`,`editor`,`pluginKey`,`nested`,`nestedOptions`,`onElementDragEnd`,`onElementDragStart`,`getReferencedVirtualElement`,`class`,`ui`)),l=Ce(),u=r(()=>Tt({extend:Tt(ML),...l.ui?.editorDragHandle||{}})()),f=r(()=>s(a.options,{strategy:`absolute`,placement:`left-start`,offset:({rects:e})=>{let t=e.reference.height,n=e.floating.height;return t>40?{alignmentAxis:0,mainAxis:8}:{alignmentAxis:(t-n)/2,mainAxis:8}},flip:{},shift:{},size:!1,autoPlacement:!1,hide:!1,inline:!1})),p=r(()=>hD(f.value)),m=r(()=>({placement:f.value.placement,strategy:f.value.strategy,middleware:p.value})),h=L();function g({pos:e}){if(h.value=e,e==null||e<0)return;let t=a.editor.state.doc.nodeAt(e);t&&i(`hover`,{node:t.toJSON(),pos:e})}function _(){if(!a.editor)return;let e=h.value;if(e==null||e<0)return;let t=a.editor.state.doc.nodeAt(e);if(t){let n={node:t.toJSON(),pos:e};return i(`nodeChange`,n),a.editor.chain().setNodeSelection(e).run(),n}}return(e,t)=>(O(),S(w(jL),d(w(o),{"compute-position-config":m.value,editor:w(a).editor,"on-node-change":g,"data-slot":`root`,class:u.value.root({class:[w(a).ui?.root,w(a).class]}),onClick:_}),{default:F(()=>[I(e.$slots,`default`,{ui:u.value,onClick:_},()=>[x(St,d({...w(c),icon:w(a).icon||w(l).ui.icons.drag,...e.$attrs},{"data-slot":`handle`,class:u.value.handle({class:[w(a).ui?.handle,w(a).class]}),ui:w(Re)(u.value,w(a).ui)}),null,16,[`class`,`ui`])])]),_:3},16,[`compute-position-config`,`editor`,`class`]))}}),PL={class:`flex`},FL={class:`flex-1`},IL={class:`flex items-center mr-0.5`},LL=A({__name:`EditorHeading`,props:{editor:{},autoOpen:{type:Boolean},heading:{type:Boolean}},setup(e){let t=e,n=L(!1),i=L(``),a=r(()=>t.editor.isActive(`link`)),o=r(()=>{if(!t.editor.isEditable)return!0;let{selection:e}=t.editor.state;return e.empty&&!t.editor.isActive(`link`)});Pe(()=>t.editor,(e,t,n)=>{if(!e)return;let r=()=>{let{href:t}=e.getAttributes(`link`);i.value=t||``};r(),e.on(`selectionUpdate`,r),n(()=>{e.off(`selectionUpdate`,r)})},{immediate:!0}),Pe(a,e=>{e&&t.autoOpen&&(n.value=!0)});function s(){if(!i.value)return;let{selection:e}=t.editor.state,r=e.empty,a=t.editor.isActive(`code`),o=t.editor.chain().focus();a&&!r?o=o.extendMarkRange(`code`).setLink({href:i.value}):(o=o.extendMarkRange(`link`).setLink({href:i.value}),r&&(o=o.insertContent({type:`text`,text:i.value}))),o.run(),n.value=!1}function c(){t.editor.chain().focus().extendMarkRange(`link`).unsetLink().setMeta(`preventAutolink`,!0).run(),i.value=``,n.value=!1}function l(e){e.key===`Enter`&&(e.preventDefault(),s())}return(e,t)=>{let r=St,u=$D,d=Ps,f=Zt,p=ka;return O(),S(p,{open:w(n),"onUpdate:open":t[1]||=e=>ze(n)?n.value=e:null,ui:{content:`p-0.5`}},{content:F(()=>[P(`div`,PL,[P(`div`,FL,[x(d,{modelValue:w(i),"onUpdate:modelValue":t[0]||=e=>ze(i)?i.value=e:null,autofocus:``,items:[`h1`,`h2`,`h3`,`h4`,`h5`],class:`w-36`,onKeydown:l},null,8,[`modelValue`])]),P(`div`,null,[P(`div`,IL,[x(r,{icon:`i-lucide-corner-down-left`,variant:`ghost`,size:`sm`,disabled:!w(i)&&!w(a),title:`Apply link`,onClick:s},null,8,[`disabled`]),x(f,{orientation:`vertical`,class:`h-6 mx-1`}),x(r,{icon:`i-lucide-trash`,color:`neutral`,variant:`ghost`,size:`sm`,disabled:!w(i)&&!w(a),title:`Remove link`,onClick:c},null,8,[`disabled`])])])])]),default:F(()=>[x(u,{text:`Link`},{default:F(()=>[x(r,{icon:`i-lucide-heading`,color:`neutral`,"active-color":`primary`,variant:`ghost`,"active-variant":`soft`,size:`sm`,active:w(a),disabled:w(o)},null,8,[`active`,`disabled`])]),_:1})]),_:1},8,[`open`])}}}),RL=A({__name:`Editor`,props:{name:{},field:{}},setup(e){tn.debug(`name`,e.name);let{value:t}=Li(e.name),n=[[{kind:`mark`,mark:`bold`,icon:`i-lucide-bold`,tooltip:{text:`Bold`}},{kind:`mark`,mark:`italic`,icon:`i-lucide-italic`,tooltip:{text:`Italic`}},{kind:`mark`,mark:`underline`,icon:`i-lucide-underline`,tooltip:{text:`Underline`}},{kind:`mark`,mark:`strike`,icon:`i-lucide-strikethrough`,tooltip:{text:`Strikethrough`}},{slot:`link`,icon:`i-lucide-heading`}]];return(r,i)=>{let a=NL,o=tO,s=_D,c=Ea;return O(),S(c,{label:e.field.label,icon:`i-iconoir-edit`},{default:F(()=>[x(s,{modelValue:w(t),"onUpdate:modelValue":i[0]||=e=>ze(t)?t.value=e:null,class:`w-full min-h-21 border border-gray-300 rounded-lg`,"content-type":`html`},{default:F(({editor:e})=>[x(a,{editor:e},null,8,[`editor`]),x(o,{editor:e,items:n},{link:F(()=>[x(LL,{editor:e},null,8,[`editor`])]),_:2},1032,[`editor`])]),_:1},8,[`modelValue`])]),_:1},8,[`label`])}}}),zL={key:0,class:`pb-3`},BL=A({__name:`FieldShow`,props:{path:{},field:{}},setup(e){let t=na(),n=r(()=>{let n=e.path?.split(`.`)||[];if(n.length===0)return t;let r=t.value;for(let e of n)r=r[e];return r||{}}),i=r(()=>{if(console.log(`field...show`,e.field.name),!e.field?.options?.show)return!0;let t=e.field?.options?.show||{};return Object.entries(t).every(([e,t])=>n.value[e]===t)});return(e,t)=>w(i)?(O(),D(`div`,zL,[I(e.$slots,`default`)])):T(``,!0)}}),VL={slots:{root:`relative inline-flex items-center`,base:[`w-full rounded-md border-0 appearance-none placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75`,`transition-colors`],leading:`absolute start-0 flex items-start`,leadingIcon:`shrink-0 text-dimmed`,leadingAvatar:`shrink-0`,leadingAvatarSize:``,trailing:`absolute end-0 flex items-start`,trailingIcon:`shrink-0 text-dimmed`},variants:{fieldGroup:{horizontal:{root:`group has-focus-visible:z-[1]`,base:`group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none`},vertical:{root:`group has-focus-visible:z-[1]`,base:`group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none`}},size:{xs:{base:`px-2 py-1 text-sm/4 gap-1`,leading:`ps-2 inset-y-1`,trailing:`pe-2 inset-y-1`,leadingIcon:`size-4`,leadingAvatarSize:`3xs`,trailingIcon:`size-4`},sm:{base:`px-2.5 py-1.5 text-sm/4 gap-1.5`,leading:`ps-2.5 inset-y-1.5`,trailing:`pe-2.5 inset-y-1.5`,leadingIcon:`size-4`,leadingAvatarSize:`3xs`,trailingIcon:`size-4`},md:{base:`px-2.5 py-1.5 text-base/5 gap-1.5`,leading:`ps-2.5 inset-y-1.5`,trailing:`pe-2.5 inset-y-1.5`,leadingIcon:`size-5`,leadingAvatarSize:`2xs`,trailingIcon:`size-5`},lg:{base:`px-3 py-2 text-base/5 gap-2`,leading:`ps-3 inset-y-2`,trailing:`pe-3 inset-y-2`,leadingIcon:`size-5`,leadingAvatarSize:`2xs`,trailingIcon:`size-5`},xl:{base:`px-3 py-2 text-base gap-2`,leading:`ps-3 inset-y-2`,trailing:`pe-3 inset-y-2`,leadingIcon:`size-6`,leadingAvatarSize:`xs`,trailingIcon:`size-6`}},variant:{outline:`text-highlighted bg-default ring ring-inset ring-accented`,soft:`text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50`,subtle:`text-highlighted bg-elevated ring ring-inset ring-accented`,ghost:`text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent`,none:`text-highlighted bg-transparent focus:outline-none`},color:{primary:``,secondary:``,success:``,info:``,warning:``,error:``,neutral:``},leading:{true:``},trailing:{true:``},loading:{true:``},highlight:{true:``},fixed:{false:``},type:{file:`file:me-1.5 file:font-medium file:text-muted file:outline-none`},autoresize:{true:{base:`resize-none`}}},compoundVariants:[{color:`primary`,variant:[`outline`,`subtle`],class:`outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary`},{color:`secondary`,variant:[`outline`,`subtle`],class:`outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary`},{color:`success`,variant:[`outline`,`subtle`],class:`outline-success/25 focus-visible:outline-3 focus-visible:ring-success`},{color:`info`,variant:[`outline`,`subtle`],class:`outline-info/25 focus-visible:outline-3 focus-visible:ring-info`},{color:`warning`,variant:[`outline`,`subtle`],class:`outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning`},{color:`error`,variant:[`outline`,`subtle`],class:`outline-error/25 focus-visible:outline-3 focus-visible:ring-error`},{color:`primary`,variant:[`soft`,`ghost`],class:`outline-primary/25 focus-visible:outline-3`},{color:`secondary`,variant:[`soft`,`ghost`],class:`outline-secondary/25 focus-visible:outline-3`},{color:`success`,variant:[`soft`,`ghost`],class:`outline-success/25 focus-visible:outline-3`},{color:`info`,variant:[`soft`,`ghost`],class:`outline-info/25 focus-visible:outline-3`},{color:`warning`,variant:[`soft`,`ghost`],class:`outline-warning/25 focus-visible:outline-3`},{color:`error`,variant:[`soft`,`ghost`],class:`outline-error/25 focus-visible:outline-3`},{color:`primary`,highlight:!0,class:`ring ring-inset ring-primary`},{color:`secondary`,highlight:!0,class:`ring ring-inset ring-secondary`},{color:`success`,highlight:!0,class:`ring ring-inset ring-success`},{color:`info`,highlight:!0,class:`ring ring-inset ring-info`},{color:`warning`,highlight:!0,class:`ring ring-inset ring-warning`},{color:`error`,highlight:!0,class:`ring ring-inset ring-error`},{color:`neutral`,variant:[`outline`,`subtle`],class:`outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted`},{color:`neutral`,variant:[`soft`,`ghost`],class:`outline-inverted/25 focus-visible:outline-3`},{color:`neutral`,highlight:!0,class:`ring ring-inset ring-inverted`},{leading:!0,size:`xs`,class:`ps-7`},{leading:!0,size:`sm`,class:`ps-8`},{leading:!0,size:`md`,class:`ps-9`},{leading:!0,size:`lg`,class:`ps-10`},{leading:!0,size:`xl`,class:`ps-11`},{trailing:!0,size:`xs`,class:`pe-7`},{trailing:!0,size:`sm`,class:`pe-8`},{trailing:!0,size:`md`,class:`pe-9`},{trailing:!0,size:`lg`,class:`pe-10`},{trailing:!0,size:`xl`,class:`pe-11`},{loading:!0,leading:!0,class:{leadingIcon:`animate-spin`}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:`animate-spin`}},{fixed:!1,size:`xs`,class:`md:text-xs`},{fixed:!1,size:`sm`,class:`md:text-xs`},{fixed:!1,size:`md`,class:`md:text-sm`},{fixed:!1,size:`lg`,class:`md:text-sm`}],defaultVariants:{size:`md`,color:`primary`,variant:`outline`}},HL=[`id`,`value`,`name`,`rows`,`placeholder`,`disabled`,`required`],UL=Object.assign({inheritAttrs:!1},{__name:`Textarea`,props:{as:{type:null,required:!1},id:{type:String,required:!1},name:{type:String,required:!1},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},autoresize:{type:Boolean,required:!1},autoresizeDelay:{type:Number,required:!1,default:0},disabled:{type:Boolean,required:!1},rows:{type:Number,required:!1,default:3},maxrows:{type:Number,required:!1,default:0},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:[`update:modelValue`,`blur`,`change`],setup(e,{expose:t,emit:n}){let i=e,a=n,o=ge(),s=lt(`textarea`,i),c=ye(s,`modelValue`,a,{defaultValue:s.defaultValue}),l=Ce(),{emitFormFocus:f,emitFormBlur:p,emitFormInput:m,emitFormChange:h,size:g,color:_,id:y,name:b,highlight:x,disabled:C,ariaAttrs:ee}=xt(i,{deferInputValidation:!0}),{isLeading:E,isTrailing:k,leadingIconName:A,trailingIconName:te}=gt(s),j=r(()=>Tt({extend:Tt(VL),...l.ui?.textarea||{}})({color:_.value??s.color,variant:s.variant,size:g?.value??s.size,loading:s.loading,highlight:x.value??s.highlight,fixed:s.fixed,autoresize:s.autoresize,leading:E.value||!!s.avatar||!!o.leading,trailing:k.value||!!o.trailing})),ne=Ee(`textareaRef`);function re(e){s.modelModifiers?.trim&&(typeof e==`string`||e==null)&&(e=e?.trim()??null),s.modelModifiers?.number&&(e=xe(e)),s.modelModifiers?.nullable&&(e||=null),s.modelModifiers?.optional&&!s.modelModifiers?.nullable&&e!==null&&(e||=void 0),c.value=e,m()}function ie(e){le(),s.modelModifiers?.lazy||re(e.target.value)}function ae(e){let t=e.target.value;s.modelModifiers?.lazy&&re(t),s.modelModifiers?.trim&&(e.target.value=t.trim()),h(),a(`change`,e)}function oe(e){p(),a(`blur`,e)}function se(){s.autofocus&&ne.value?.focus()}function le(){if(s.autoresize&&ne.value){ne.value.rows=s.rows;let e=ne.value.style.overflow;ne.value.style.overflow=`hidden`;let t=window.getComputedStyle(ne.value),n=Number.parseInt(t.paddingTop)+Number.parseInt(t.paddingBottom),r=Number.parseInt(t.lineHeight),{scrollHeight:i}=ne.value,a=(i-n)/r;a>s.rows&&(ne.value.rows=s.maxrows?Math.min(a,s.maxrows):a),ne.value.style.overflow=e}}return Pe(c,()=>{v(le)}),ce(()=>{setTimeout(()=>{se()},s.autofocusDelay),setTimeout(async()=>{await v(),le()},s.autoresizeDelay)}),t({textareaRef:ne,autoResize:le}),(e,t)=>(O(),S(w(wt),{as:w(s).as,"data-slot":`root`,class:u(j.value.root({class:[w(s).ui?.root,w(s).class]}))},{default:F(()=>[P(`textarea`,d({id:w(y),ref_key:`textareaRef`,ref:ne,value:w(c),name:w(b),rows:w(s).rows,placeholder:w(s).placeholder,"data-slot":`base`,class:j.value.base({class:w(s).ui?.base}),disabled:w(C),required:w(s).required},{...e.$attrs,...w(ee)},{onInput:ie,onBlur:oe,onChange:ae,onFocus:t[0]||=(...e)=>w(f)&&w(f)(...e)}),null,16,HL),I(e.$slots,`default`,{ui:j.value}),w(E)||w(s).avatar||o.leading?(O(),D(`span`,{key:0,"data-slot":`leading`,class:u(j.value.leading({class:w(s).ui?.leading}))},[I(e.$slots,`leading`,{ui:j.value},()=>[w(E)&&w(A)?(O(),S(_t,{key:0,name:w(A),"data-slot":`leadingIcon`,class:u(j.value.leadingIcon({class:w(s).ui?.leadingIcon}))},null,8,[`name`,`class`])):w(s).avatar?(O(),S(Ct,d({key:1,size:w(s).ui?.leadingAvatarSize||j.value.leadingAvatarSize()},w(s).avatar,{"data-slot":`leadingAvatar`,class:j.value.leadingAvatar({class:w(s).ui?.leadingAvatar})}),null,16,[`size`,`class`])):T(``,!0)])],2)):T(``,!0),w(k)||o.trailing?(O(),D(`span`,{key:1,"data-slot":`trailing`,class:u(j.value.trailing({class:w(s).ui?.trailing}))},[I(e.$slots,`trailing`,{ui:j.value},()=>[w(te)?(O(),S(_t,{key:0,name:w(te),"data-slot":`trailingIcon`,class:u(j.value.trailingIcon({class:w(s).ui?.trailingIcon}))},null,8,[`name`,`class`])):T(``,!0)])],2)):T(``,!0)]),_:3},8,[`as`,`class`]))}}),WL=A({__name:`Text`,props:{field:{},name:{}},setup(e){tn.debug(`name`,e.name);let{value:t}=Li(e.name);return(n,r)=>{let i=UL,a=Ea;return O(),S(a,{label:e.field.label,icon:`i-iconoir-text`},{default:F(()=>[x(i,{modelValue:w(t),"onUpdate:modelValue":r[0]||=e=>ze(t)?t.value=e:null,class:`w-full`,autoresize:``,rows:1},null,8,[`modelValue`])]),_:1},8,[`label`])}}}),GL=A({__name:`Fields`,props:{fields:{},base:{}},setup(e){let t=fe();ke();function n(e,t){let r=e.shift();tn.log(`currentPath`,e,r,t);let i=t.find(e=>e.name===r);return i?(i.widget===`list`&&e.length>0&&e.shift(),e.length===0?i:n(e,i.fields||[])):{}}let i=r(()=>{if(e.base)return{fields:e.fields};let t=a(``);return!t||!t.length?{fields:e.fields}:n(t.split(`.`),e.fields)||[]});function a(n){let r=t.params.file;return[...e.base?[...e.base?.split(`.`)]:(typeof r==`string`?[r]:r).slice(1),n].filter(Boolean).join(`.`).trim()}return(e,t)=>{let n=WL,r=BL,o=RL,s=Us,c=Rs,u=Fs,d=Ms,f=Da,p=Sa,m=ha;return O(),D(`div`,null,[(O(!0),D(l,null,ve(w(i).fields,e=>(O(),D(`div`,{key:e.name},[e.widget===`string`?(O(),S(r,{key:0,field:e,path:a(``)},{default:F(()=>[x(n,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`editor`?(O(),S(r,{key:1,field:e,path:a(``)},{default:F(()=>[x(o,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`image`?(O(),S(r,{key:2,field:e,path:a(``)},{default:F(()=>[x(s,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`boolean`?(O(),S(r,{key:3,field:e,path:a(``)},{default:F(()=>[x(c,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`select`?(O(),S(r,{key:4,field:e,path:a(``)},{default:F(()=>[x(u,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`color`?(O(),S(r,{key:5,field:e,path:a(``)},{default:F(()=>[x(d,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`relation`?(O(),S(r,{key:6,field:e,path:a(``)},{default:F(()=>[x(f,{name:a(e.name),field:e},null,8,[`name`,`field`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`object`?(O(),S(r,{key:7,field:e,path:a(``)},{default:F(()=>[x(p,{field:e,fields:e.fields||[],base:a(e.name)},null,8,[`field`,`fields`,`base`])]),_:2},1032,[`field`,`path`])):T(``,!0),e.widget===`list`?(O(),S(r,{key:8,field:e,path:a(``)},{default:F(()=>[x(m,{field:e,fields:e.fields||[],base:a(e.name)},null,8,[`field`,`fields`,`base`])]),_:2},1032,[`field`,`path`])):T(``,!0)]))),128))])}}});export{Ps as _,_D as a,ta as b,mD as c,ZE as d,Db as f,Us as g,Ju as h,$D as i,YE as l,nv as m,NL as n,hD as o,fb as p,tO as r,pD as s,GL as t,$E as u,ka as v,Zi as x,qi as y};
|