@woven-canvas/vue 1.0.10 → 1.0.12
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/build/components/ActionBar.vue.d.ts.map +1 -1
- package/build/components/EditableText.vue.d.ts.map +1 -1
- package/build/components/FileDropZone.vue.d.ts.map +1 -1
- package/build/components/FloatingMenu.vue.d.ts.map +1 -1
- package/build/components/FloatingMenuBar.vue.d.ts.map +1 -1
- package/build/components/Toolbar.vue.d.ts +2 -2
- package/build/components/Toolbar.vue.d.ts.map +1 -1
- package/build/components/ToolbarButton.vue.d.ts +1 -0
- package/build/components/ToolbarButton.vue.d.ts.map +1 -1
- package/build/components/WovenCanvasCore.vue.d.ts +0 -2
- package/build/components/WovenCanvasCore.vue.d.ts.map +1 -1
- package/build/components/blocks/ElbowArrow.vue.d.ts.map +1 -1
- package/build/components/blocks/FrameBlock.vue.d.ts +4 -0
- package/build/components/blocks/FrameBlock.vue.d.ts.map +1 -0
- package/build/components/blocks/ImageBlock.vue.d.ts.map +1 -1
- package/build/components/buttons/MenuTooltip.vue.d.ts.map +1 -1
- package/build/components/tools/EmbedTool.vue.d.ts.map +1 -1
- package/build/components/tools/FrameTool.vue.d.ts +3 -0
- package/build/components/tools/FrameTool.vue.d.ts.map +1 -0
- package/build/components/tools/ImageTool.vue.d.ts.map +1 -1
- package/build/composables/index.d.ts +1 -1
- package/build/composables/index.d.ts.map +1 -1
- package/build/composables/useClipboard.d.ts +15 -0
- package/build/composables/useClipboard.d.ts.map +1 -1
- package/build/composables/useImageCreation.d.ts.map +1 -1
- package/build/composables/useTextStretchBehavior.d.ts.map +1 -1
- package/build/composables/useToolbar.d.ts +5 -1
- package/build/composables/useToolbar.d.ts.map +1 -1
- package/build/composables/useTooltipSingleton.d.ts +14 -3
- package/build/composables/useTooltipSingleton.d.ts.map +1 -1
- package/build/helpers/snapshot.d.ts +11 -0
- package/build/helpers/snapshot.d.ts.map +1 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8331 -5638
- package/build/index.umd.cjs +27 -25
- package/build/injection/index.d.ts +0 -1
- package/build/injection/index.d.ts.map +1 -1
- package/build/injection/toolbar.d.ts +5 -1
- package/build/injection/toolbar.d.ts.map +1 -1
- package/build/singletons/PlacementDrawState.d.ts +12 -0
- package/build/singletons/PlacementDrawState.d.ts.map +1 -0
- package/build/singletons/index.d.ts +1 -0
- package/build/singletons/index.d.ts.map +1 -1
- package/build/style.css +1 -1
- package/build/systems/blockPlacementSystem.d.ts +2 -9
- package/build/systems/blockPlacementSystem.d.ts.map +1 -1
- package/build/systems/doubleClickCreateSystem.d.ts.map +1 -1
- package/build/systems/drawPlacementSystem.d.ts +2 -0
- package/build/systems/drawPlacementSystem.d.ts.map +1 -0
- package/build/systems/index.d.ts +2 -1
- package/build/systems/index.d.ts.map +1 -1
- package/build/systems/undoRedoSystem.d.ts.map +1 -1
- package/package.json +8 -8
- package/build/injection/tooltip.d.ts +0 -15
- package/build/injection/tooltip.d.ts.map +0 -1
package/build/index.umd.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(R,Le){typeof exports=="object"&&typeof module<"u"?Le(exports,require("@woven-ecs/canvas-store"),require("@woven-canvas/plugin-arrows"),require("vue"),require("@woven-canvas/core"),require("@woven-canvas/math"),require("@woven-canvas/plugin-eraser"),require("@woven-canvas/plugin-pen"),require("@woven-canvas/plugin-selection"),require("@woven-canvas/plugin-canvas-controls"),require("@woven-canvas/plugin-tapes")):typeof define=="function"&&define.amd?define(["exports","@woven-ecs/canvas-store","@woven-canvas/plugin-arrows","vue","@woven-canvas/core","@woven-canvas/math","@woven-canvas/plugin-eraser","@woven-canvas/plugin-pen","@woven-canvas/plugin-selection","@woven-canvas/plugin-canvas-controls","@woven-canvas/plugin-tapes"],Le):(R=typeof globalThis<"u"?globalThis:R||self,Le(R.Vue={},R.WovenEcsCanvasStore,R.WovenCanvasPluginArrows,R.Vue,R.WovenCanvasCore,R.WovenCanvasMath,R.WovenCanvasPluginEraser,R.WovenCanvasPluginPen,R.WovenCanvasPluginSelection,R.WovenCanvasPluginCanvasControls,R.WovenCanvasPluginTapes))})(this,function(R,Le,ee,a,w,ae,qo,Jo,te,_s,pp){"use strict";const Ls=[{kind:ee.ArrowHeadKind.None,label:"None",gap:0,svg:""},{kind:ee.ArrowHeadKind.V,label:"Arrow",gap:15,svg:'<polyline points="-10,-7 -1,0 -10,7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />'},{kind:ee.ArrowHeadKind.Delta,label:"Triangle",gap:20,svg:'<polygon points="-1,0 -12,-7 -12,7" fill="currentColor" />'},{kind:ee.ArrowHeadKind.Circle,label:"Circle",gap:0,svg:'<circle cx="-6" cy="0" r="6" fill="currentColor" />'},{kind:ee.ArrowHeadKind.Diamond,label:"Diamond",gap:0,svg:'<polygon points="0,0 -7,-6 -14,0 -7,6" fill="currentColor" />'}];function Rn(n){return Ls.find(e=>e.kind===n)}const ca=Symbol.for("__woven_canvas_dropdown_active__"),da=Symbol.for("__woven_canvas_dropdown_level__"),ua=Symbol.for("__woven_canvas_floating_menu__"),Vs=Symbol.for("__woven_canvas_toolbar__"),fa=Symbol.for("__woven_canvas_tooltip__"),ke=Symbol.for("__woven_canvas__");function me(n,e){const t=a.inject(ke);if(!t)throw new Error("useComponent must be used within a WovenCanvas component");const o=a.shallowRef(null),r=t.getEditor();if(r){const i=r._getContext();w.hasComponent(i,n,e)&&(o.value=e.snapshot(i,n))}const s=t.subscribeComponent(n,e.name,i=>{o.value=i});return a.onUnmounted(()=>{s()}),o}const mp={key:0},gp=["x1","y1","x2","y2","stroke","stroke-width"],yp=["x1","y1","x2","y2","stroke","stroke-width"],kp=["points","fill"],wp=["cx","cy","r","fill"],bp=["points","fill"],Cp=15,xp=2,xt=a.defineComponent({__name:"ArrowHead",props:{position:{},direction:{},thickness:{},color:{},arrowThickness:{},kind:{}},setup(n){const e=n,t=a.computed(()=>{const l=Math.hypot(e.direction[0],e.direction[1]);if(l===0)return null;const c=(e.arrowThickness/xp)**.33,d=Cp*c,u=[e.direction[0]/l,e.direction[1]/l],f=[-u[1],u[0]];return{unitDir:u,perpDir:f,size:d}}),o=a.computed(()=>{if(!t.value)return null;const{unitDir:l,perpDir:c,size:d}=t.value,u=d,f=d,p=[e.position[0]-l[0]*u+c[0]*(f/2),e.position[1]-l[1]*u+c[1]*(f/2)],h=[e.position[0]-l[0]*u-c[0]*(f/2),e.position[1]-l[1]*u-c[1]*(f/2)];return{p1:p,p2:h}}),r=a.computed(()=>{if(!t.value)return null;const{unitDir:l,perpDir:c,size:d}=t.value,u=d,f=d,p=[l[0]*(d*.4),l[1]*(d*.4)],h=[e.position[0]-l[0]*u+p[0],e.position[1]-l[1]*u+p[1]],m=[h[0]+c[0]*(f/2),h[1]+c[1]*(f/2)],g=[h[0]-c[0]*(f/2),h[1]-c[1]*(f/2)],y=[e.position[0]+p[0],e.position[1]+p[1]];return`${y[0]},${y[1]} ${m[0]},${m[1]} ${g[0]},${g[1]}`}),s=a.computed(()=>{if(!t.value)return null;const{unitDir:l,size:c}=t.value,d=c*.8,u=[l[0]*d,l[1]*d];return{center:[e.position[0]-l[0]*d+u[0],e.position[1]-l[1]*d+u[1]],radius:d}}),i=a.computed(()=>{if(!t.value)return null;const{unitDir:l,perpDir:c,size:d}=t.value,u=1.6*d,f=1.6*d,p=[l[0]*(d*.8),l[1]*(d*.8)],h=[e.position[0]-l[0]*(u/2)+p[0],e.position[1]-l[1]*(u/2)+p[1]],m=[e.position[0]-l[0]*u+p[0],e.position[1]-l[1]*u+p[1]],g=[h[0]+c[0]*(f/2),h[1]+c[1]*(f/2)],y=[h[0]-c[0]*(f/2),h[1]-c[1]*(f/2)],k=[e.position[0]+p[0],e.position[1]+p[1]];return`${k[0]},${k[1]} ${g[0]},${g[1]} ${m[0]},${m[1]} ${y[0]},${y[1]}`});return(l,c)=>t.value?(a.openBlock(),a.createElementBlock("g",mp,[n.kind===a.unref(ee.ArrowHeadKind).V&&o.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createElementVNode("line",{x1:o.value.p1[0],y1:o.value.p1[1],x2:n.position[0],y2:n.position[1],stroke:n.color,"stroke-width":n.thickness,"stroke-linecap":"round"},null,8,gp),a.createElementVNode("line",{x1:o.value.p2[0],y1:o.value.p2[1],x2:n.position[0],y2:n.position[1],stroke:n.color,"stroke-width":n.thickness,"stroke-linecap":"round"},null,8,yp)],64)):n.kind===a.unref(ee.ArrowHeadKind).Delta&&r.value?(a.openBlock(),a.createElementBlock("polygon",{key:1,points:r.value,fill:n.color},null,8,kp)):n.kind===a.unref(ee.ArrowHeadKind).Circle&&s.value?(a.openBlock(),a.createElementBlock("circle",{key:2,cx:s.value.center[0],cy:s.value.center[1],r:s.value.radius,fill:n.color},null,8,wp)):n.kind===a.unref(ee.ArrowHeadKind).Diamond&&i.value?(a.openBlock(),a.createElementBlock("polygon",{key:3,points:i.value,fill:n.color},null,8,bp)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0)}}),Sp={class:"arrow-svg",preserveAspectRatio:"none"},Ep=["d","stroke","stroke-width"],vp=["x1","y1","x2","y2","stroke","stroke-width"],Mp=["d"],Tp=["x1","y1","x2","y2"],Np=a.defineComponent({__name:"ArcArrow",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=a.ref(0),r=a.ref(0),s=me(e.entityId,w.Color),i=me(e.entityId,ee.ArcArrow);let l=null;a.onMounted(()=>{t.value&&(l=new ResizeObserver(()=>{t.value&&(o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),l.observe(t.value),o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),a.onUnmounted(()=>{l==null||l.disconnect()});const c=a.computed(()=>{if(!s.value)return"#000000";const C=s.value.red.toString(16).padStart(2,"0"),x=s.value.green.toString(16).padStart(2,"0"),E=s.value.blue.toString(16).padStart(2,"0");return`#${C}${x}${E}`}),d=a.computed(()=>{var C;return((C=i.value)==null?void 0:C.value[6])??2}),u=a.computed(()=>`${d.value}px`),f=a.computed(()=>e.hovered||e.selected),p=a.computed(()=>{if(!i.value)return!1;const C=i.value.value,x=ae.Arc.create(C[0],C[1],C[2],C[3],C[4],C[5],C[6]);return!ae.Arc.isCollinear(x)}),h=a.computed(()=>{if(!i.value)return null;const C=i.value.value,x=o.value,E=r.value;return ae.Arc.create(C[0]*x,C[1]*E,C[2]*x,C[3]*E,C[4]*x,C[5]*E,C[6])}),m=a.computed(()=>!h.value||!p.value?null:ae.Arc.compute(h.value)),g=a.computed(()=>{var $,F,J,K;if(!i.value||!h.value)return null;const C=h.value,x=i.value.startArrowHead,E=i.value.endArrowHead,M=ae.Arc.length(C);let S=i.value.trimStart;if(($=e.connector)!=null&&$.startBlock&&x!=="none"){const U=((F=Rn(x))==null?void 0:F.gap)??0,j=M>0?U/M:0;S+=j}let v=i.value.trimEnd;if((J=e.connector)!=null&&J.endBlock&&E!=="none"){const U=((K=Rn(E))==null?void 0:K.gap)??0,j=M>0?U/M:0;v+=j}const T=1-v,B=ae.Arc.parametricToPoint(C,S),P=ae.Arc.parametricToPoint(C,T),O=b(ae.Arc.directionAt(C,S)),_=ae.Arc.directionAt(C,T);return{start:B,end:P,startDir:O,endDir:_,tStart:S,tEnd:T,startHead:x,endHead:E}}),y=a.computed(()=>{if(!g.value||!m.value||!p.value)return"";const{start:C,end:x,tStart:E,tEnd:M}=g.value,{radius:S,clockwise:v,arcAngle:T}=m.value,P=T*(M-E)>Math.PI?1:0,O=v?0:1;return`M ${C[0]} ${C[1]} A ${S} ${S} 0 ${P} ${O} ${x[0]} ${x[1]}`}),k=a.computed(()=>!g.value||p.value?null:{x1:g.value.start[0],y1:g.value.start[1],x2:g.value.end[0],y2:g.value.end[1]});function b(C){return[-C[0],-C[1]]}return(C,x)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-arc-arrow"},[(a.openBlock(),a.createElementBlock("svg",Sp,[p.value&&y.value?(a.openBlock(),a.createElementBlock("path",{key:0,d:y.value,stroke:c.value,fill:"none","stroke-width":u.value,"stroke-linecap":"round"},null,8,Ep)):k.value?(a.openBlock(),a.createElementBlock("line",{key:1,x1:k.value.x1,y1:k.value.y1,x2:k.value.x2,y2:k.value.y2,stroke:c.value,fill:"none","stroke-width":u.value,"stroke-linecap":"round"},null,8,vp)):a.createCommentVNode("",!0),g.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[g.value.startHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:0,position:g.value.start,direction:g.value.startDir,thickness:u.value,"arrow-thickness":d.value,color:c.value,kind:g.value.startHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),g.value.endHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:1,position:g.value.end,direction:g.value.endDir,thickness:u.value,"arrow-thickness":d.value,color:c.value,kind:g.value.endHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),f.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[p.value&&y.value?(a.openBlock(),a.createElementBlock("path",{key:0,d:y.value,class:"highlight-overlay",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,Mp)):k.value?(a.openBlock(),a.createElementBlock("line",{key:1,x1:k.value.x1,y1:k.value.y1,x2:k.value.x2,y2:k.value.y2,class:"highlight-overlay",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,Tp)):a.createCommentVNode("",!0),g.value.startHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:2,position:g.value.start,direction:g.value.startDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":d.value,color:"var(--wov-highlighted-block-outline-color)",kind:g.value.startHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0),g.value.endHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:3,position:g.value.end,direction:g.value.endDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":d.value,color:"var(--wov-highlighted-block-outline-color)",kind:g.value.endHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)]))],512))}}),an=(n,e)=>{const t=n.__vccOpts||n;for(const[o,r]of e)t[o]=r;return t},ha=an(Np,[["__scopeId","data-v-de24f4c2"]]),Ap={},Bp={class:"wov-arrow-handle"};function Ip(n,e){return a.openBlock(),a.createElementBlock("div",Bp,[...e[0]||(e[0]=[a.createElementVNode("div",{class:"wov-arrow-handle-inner"},null,-1)])])}const pa=an(Ap,[["render",Ip]]),Op={},Rp={class:"wov-arrow-terminal"};function Pp(n,e){return a.openBlock(),a.createElementBlock("div",Rp,[...e[0]||(e[0]=[a.createElementVNode("div",{class:"wov-arrow-terminal-ring"},[a.createElementVNode("div",{class:"wov-arrow-terminal-fill"})],-1)])])}const ma=an(Op,[["render",Pp]]),Dp={class:"arrow-svg",preserveAspectRatio:"none"},_p=["x1","y1","x2","y2"],Lp=["x1","y1","x2","y2","stroke","stroke-width"],Vp=["x1","y1","x2","y2"],ga=an(a.defineComponent({__name:"ElbowArrow",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=a.ref(0),r=a.ref(0),s=me(e.entityId,w.Color),i=me(e.entityId,ee.ElbowArrow),l=a.computed(()=>e.hovered||e.selected);let c=null;a.onMounted(()=>{t.value&&(c=new ResizeObserver(()=>{t.value&&(o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),c.observe(t.value),o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),a.onUnmounted(()=>{c==null||c.disconnect()});const d=a.computed(()=>{if(!s.value)return"#000000";const g=s.value.red.toString(16).padStart(2,"0"),y=s.value.green.toString(16).padStart(2,"0"),k=s.value.blue.toString(16).padStart(2,"0");return`#${g}${y}${k}`}),u=a.computed(()=>{var g;return((g=i.value)==null?void 0:g.thickness)??2}),f=a.computed(()=>`${u.value}px`),p=a.computed(()=>{if(!i.value)return[];const g=i.value,y=o.value,k=r.value,b=[];for(let C=0;C<g.pointCount;C++){const x=g.points[C*2]*y,E=g.points[C*2+1]*k;b.push([x,E])}return b}),h=a.computed(()=>{const g=p.value;if(g.length<2)return[];const y=[];for(let k=0;k<g.length-1;k++)y.push({start:g[k],end:g[k+1]});return y}),m=a.computed(()=>{var T,B,P,O;if(!i.value||p.value.length<2)return null;const g=i.value,y=[...p.value.map(_=>[..._])],k=g.startArrowHead,b=g.endArrowHead,C=[y[1][0]-y[0][0],y[1][1]-y[0][1]],x=[y[y.length-1][0]-y[y.length-2][0],y[y.length-1][1]-y[y.length-2][1]];let E=g.trimStart;if((T=e.connector)!=null&&T.startBlock&&k!=="none"){const _=Math.hypot(C[0],C[1]),$=((B=Rn(k))==null?void 0:B.gap)??0,F=_>0?$/_:0;E+=F}let M=g.trimEnd;if((P=e.connector)!=null&&P.endBlock&&b!=="none"){const _=Math.hypot(x[0],x[1]),$=((O=Rn(b))==null?void 0:O.gap)??0,F=_>0?$/_:0;M+=F}y[0]=[y[0][0]+(y[1][0]-y[0][0])*E,y[0][1]+(y[1][1]-y[0][1])*E];const S=y.length-1;y[S]=[y[S-1][0]+(y[S][0]-y[S-1][0])*(1-M),y[S-1][1]+(y[S][1]-y[S-1][1])*(1-M)];const v=[];for(let _=0;_<y.length-1;_++)v.push({start:y[_],end:y[_+1]});return ae.Vec2.scale(C,-1),{points:y,lines:v,startPos:y[0],endPos:y[y.length-1],startDir:C,endDir:x,startHead:k,endHead:b}});return(g,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-elbow-arrow"},[(a.openBlock(),a.createElementBlock("svg",Dp,[l.value&&h.value.length>0?(a.openBlock(!0),a.createElementBlock(a.Fragment,{key:0},a.renderList(h.value,(k,b)=>(a.openBlock(),a.createElementBlock("line",{key:"bg-"+b,x1:k.start[0],y1:k.start[1],x2:k.end[0],y2:k.end[1],class:"highlight-bg",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))","stroke-dasharray":"calc(12px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,_p))),128)):a.createCommentVNode("",!0),m.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(m.value.lines,(k,b)=>(a.openBlock(),a.createElementBlock("line",{key:b,x1:k.start[0],y1:k.start[1],x2:k.end[0],y2:k.end[1],stroke:d.value,fill:"none","stroke-width":f.value,"stroke-linecap":"round"},null,8,Lp))),128)),m.value.startHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:0,position:m.value.startPos,direction:m.value.startDir,thickness:f.value,"arrow-thickness":u.value,color:d.value,kind:m.value.startHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),m.value.endHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:1,position:m.value.endPos,direction:m.value.endDir,thickness:f.value,"arrow-thickness":u.value,color:d.value,kind:m.value.endHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),l.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(m.value.lines,(k,b)=>(a.openBlock(),a.createElementBlock("line",{key:"hl-"+b,x1:k.start[0],y1:k.start[1],x2:k.end[0],y2:k.end[1],class:"highlight-overlay",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,Vp))),128)),m.value.startHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:0,position:m.value.startPos,direction:m.value.startDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":u.value,color:"var(--wov-highlighted-block-outline-color)",kind:m.value.startHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0),m.value.endHead!=="none"?(a.openBlock(),a.createBlock(xt,{key:1,position:m.value.endPos,direction:m.value.endDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":u.value,color:"var(--wov-highlighted-block-outline-color)",kind:m.value.endHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)]))],512))}}),[["__scopeId","data-v-8859c689"]]),$p={class:"wov-embed-block"},zp={key:0,class:"wov-embed-placeholder"},Fp=["src","allow"],ya=a.defineComponent({__name:"EmbedBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const t=me(n.entityId,w.Embed),o=a.computed(()=>t.value&&(t.value.embedUrl||t.value.url)||null),r=a.computed(()=>{if(!t.value)return"";switch(t.value.provider){case w.EmbedProvider.Youtube:return"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";case w.EmbedProvider.Spotify:return"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture";case w.EmbedProvider.GoogleMaps:return"fullscreen";case w.EmbedProvider.GoogleCalendar:return"fullscreen";case w.EmbedProvider.GoogleSlides:return"fullscreen";case w.EmbedProvider.Figma:return"fullscreen";default:return"fullscreen"}}),s=a.computed(()=>{if(!t.value)return"Embed";switch(t.value.provider){case w.EmbedProvider.Youtube:return"YouTube";case w.EmbedProvider.Spotify:return"Spotify";case w.EmbedProvider.GoogleMaps:return"Google Maps";case w.EmbedProvider.GoogleCalendar:return"Google Calendar";case w.EmbedProvider.GoogleSlides:return"Google Slides";case w.EmbedProvider.Figma:return"Figma";case w.EmbedProvider.GithubGist:return"GitHub Gist";case w.EmbedProvider.Tldraw:return"tldraw";default:return"Embed"}});return(i,l)=>(a.openBlock(),a.createElementBlock("div",$p,[o.value?(a.openBlock(),a.createElementBlock("iframe",{key:1,src:o.value,allow:r.value,allowfullscreen:"",frameborder:"0",class:"wov-embed-iframe",style:a.normalizeStyle({pointerEvents:n.edited?"auto":"none"})},null,12,Fp)):(a.openBlock(),a.createElementBlock("div",zp,[a.createElementVNode("span",null,a.toDisplayString(s.value),1)]))]))}}),{PI:Hp}=Math,ro=Hp+1e-4,ka=.5,wa=[1,1];function ba(n,e,t,o=r=>r){return n*o(.5-e*(.5-t))}const{min:$s}=Math;function Ca(n,e,t){let o=$s(1,e/t);return $s(1,n+($s(1,1-o)-n)*(o*.275))}function Up(n){return[-n[0],-n[1]]}function dt(n,e){return[n[0]+e[0],n[1]+e[1]]}function xa(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function _t(n,e){return[n[0]-e[0],n[1]-e[1]]}function zs(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Lt(n,e){return[n[0]*e,n[1]*e]}function Fs(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function jp(n,e){return[n[0]/e,n[1]/e]}function Sa(n){return[n[1],-n[0]]}function Hs(n,e){let t=e[0];return n[0]=e[1],n[1]=-t,n}function Ea(n,e){return n[0]*e[0]+n[1]*e[1]}function Wp(n,e){return n[0]===e[0]&&n[1]===e[1]}function Kp(n){return Math.hypot(n[0],n[1])}function va(n,e){let t=n[0]-e[0],o=n[1]-e[1];return t*t+o*o}function Ma(n){return jp(n,Kp(n))}function qp(n,e){return Math.hypot(n[1]-e[1],n[0]-e[0])}function Us(n,e,t){let o=Math.sin(t),r=Math.cos(t),s=n[0]-e[0],i=n[1]-e[1],l=s*r-i*o,c=s*o+i*r;return[l+e[0],c+e[1]]}function Ta(n,e,t,o){let r=Math.sin(o),s=Math.cos(o),i=e[0]-t[0],l=e[1]-t[1],c=i*s-l*r,d=i*r+l*s;return n[0]=c+t[0],n[1]=d+t[1],n}function Na(n,e,t){return dt(n,Lt(_t(e,n),t))}function Jp(n,e,t,o){let r=t[0]-e[0],s=t[1]-e[1];return n[0]=e[0]+r*o,n[1]=e[1]+s*o,n}function Aa(n,e,t){return dt(n,Lt(e,t))}const ve=[0,0],Vt=[0,0],$t=[0,0];function Gp(n,e){let t=Aa(n,Ma(Sa(_t(n,dt(n,[1,1])))),-e),o=[],r=1/13;for(let s=r;s<=1;s+=r)o.push(Us(t,n,ro*2*s));return o}function Yp(n,e,t){let o=[],r=1/t;for(let s=r;s<=1;s+=r)o.push(Us(e,n,ro*s));return o}function Xp(n,e,t){let o=_t(e,t),r=Lt(o,.5),s=Lt(o,.51);return[_t(n,r),_t(n,s),dt(n,s),dt(n,r)]}function Qp(n,e,t,o){let r=[],s=Aa(n,e,t),i=1/o;for(let l=i;l<1;l+=i)r.push(Us(s,n,ro*3*l));return r}function Zp(n,e,t){return[dt(n,Lt(e,t)),dt(n,Lt(e,t*.99)),_t(n,Lt(e,t*.99)),_t(n,Lt(e,t))]}function Ba(n,e,t){return n===!1||n===void 0?0:n===!0?Math.max(e,t):n}function em(n,e,t){return n.slice(0,10).reduce((o,r)=>{let s=r.pressure;return e&&(s=Ca(o,r.distance,t)),(o+s)/2},n[0].pressure)}function tm(n,e={}){let{size:t=16,smoothing:o=.5,thinning:r=.5,simulatePressure:s=!0,easing:i=K=>K,start:l={},end:c={},last:d=!1}=e,{cap:u=!0,easing:f=K=>K*(2-K)}=l,{cap:p=!0,easing:h=K=>--K*K*K+1}=c;if(n.length===0||t<=0)return[];let m=n[n.length-1].runningLength,g=Ba(l.taper,t,m),y=Ba(c.taper,t,m),k=(t*o)**2,b=[],C=[],x=em(n,s,t),E=ba(t,r,n[n.length-1].pressure,i),M,S=n[0].vector,v=n[0].point,T=v,B=v,P=T,O=!1;for(let K=0;K<n.length;K++){let{pressure:U}=n[K],{point:j,vector:Q,distance:ne,runningLength:oe}=n[K],Re=K===n.length-1;if(!Re&&m-oe<3)continue;r?(s&&(U=Ca(x,ne,t)),E=ba(t,r,U,i)):E=t/2,M===void 0&&(M=E);let ue=oe<g?f(oe/g):1,et=m-oe<y?h((m-oe)/y):1;E=Math.max(.01,E*Math.min(ue,et));let ye=(Re?n[K]:n[K+1]).vector,sn=Re?1:Ea(Q,ye),Ds=Ea(Q,S)<0&&!O,oo=sn!==null&&sn<0;if(Ds||oo){Hs(ve,S),Fs(ve,ve,E);for(let Ct=0;Ct<=1;Ct+=.07692307692307693)zs(Vt,j,ve),Ta(Vt,Vt,j,ro*Ct),B=[Vt[0],Vt[1]],b.push(B),xa($t,j,ve),Ta($t,$t,j,ro*-Ct),P=[$t[0],$t[1]],C.push(P);v=B,T=P,oo&&(O=!0);continue}if(O=!1,Re){Hs(ve,Q),Fs(ve,ve,E),b.push(_t(j,ve)),C.push(dt(j,ve));continue}Jp(ve,ye,Q,sn),Hs(ve,ve),Fs(ve,ve,E),zs(Vt,j,ve),B=[Vt[0],Vt[1]],(K<=1||va(v,B)>k)&&(b.push(B),v=B),xa($t,j,ve),P=[$t[0],$t[1]],(K<=1||va(T,P)>k)&&(C.push(P),T=P),x=U,S=Q}let _=[n[0].point[0],n[0].point[1]],$=n.length>1?[n[n.length-1].point[0],n[n.length-1].point[1]]:dt(n[0].point,[1,1]),F=[],J=[];if(n.length===1){if(!(g||y)||d)return Gp(_,M||E)}else{g||y&&n.length===1||(u?F.push(...Yp(_,C[0],13)):F.push(...Xp(_,b[0],C[0])));let K=Sa(Up(n[n.length-1].vector));y||g&&n.length===1?J.push($):p?J.push(...Qp($,K,E,29)):J.push(...Zp($,K,E))}return b.concat(J,C.reverse(),F)}const Ia=[0,0];function Oa(n){return n!=null&&n>=0}function nm(n,e={}){var p;let{streamline:t=.5,size:o=16,last:r=!1}=e;if(n.length===0)return[];let s=.15+(1-t)*.85,i=Array.isArray(n[0])?n:n.map(({x:h,y:m,pressure:g=ka})=>[h,m,g]);if(i.length===2){let h=i[1];i=i.slice(0,-1);for(let m=1;m<5;m++)i.push(Na(i[0],h,m/4))}i.length===1&&(i=[...i,[...dt(i[0],wa),...i[0].slice(2)]]);let l=[{point:[i[0][0],i[0][1]],pressure:Oa(i[0][2])?i[0][2]:.25,vector:[...wa],distance:0,runningLength:0}],c=!1,d=0,u=l[0],f=i.length-1;for(let h=1;h<i.length;h++){let m=r&&h===f?[i[h][0],i[h][1]]:Na(u.point,i[h],s);if(Wp(u.point,m))continue;let g=qp(m,u.point);if(d+=g,h<f&&!c){if(d<o)continue;c=!0}zs(Ia,u.point,m),u={point:m,pressure:Oa(i[h][2])?i[h][2]:ka,vector:Ma(Ia),distance:g,runningLength:d},l.push(u)}return l[0].vector=((p=l[1])==null?void 0:p.vector)||[0,0],l}function js(n,e={}){return tm(nm(n,e),e)}const om={class:"wov-eraser-stroke"},rm={preserveAspectRatio:"none"},sm=["d"],im="#88888833",Ra=a.defineComponent({__name:"Eraser",props:{entityId:{}},setup(n){const e=n,t=me(e.entityId,qo.EraserStroke),o=me(e.entityId,w.Block),r=a.shallowRef("");function s(l,c){return(l+c)/2}function i(l,c,d,u,f,p){if(l<=4)return"";const h=[],m=Math.min(l,qo.POINTS_CAPACITY);for(let x=0;x<m;x++){const E=(c+x)%qo.POINTS_CAPACITY*2;h.push([d[E]-f,d[E+1]-p])}const g=js(h,{size:u,start:{taper:66,cap:!0}});if(g.length<3)return"";let y=g[0],k=g[1];const b=g[2];let C=`M${y[0].toFixed(2)},${y[1].toFixed(2)} Q${k[0].toFixed(2)},${k[1].toFixed(2)} ${s(k[0],b[0]).toFixed(2)},${s(k[1],b[1]).toFixed(2)} T`;for(let x=2;x<g.length-1;x++)y=g[x],k=g[x+1],C+=`${s(y[0],k[0]).toFixed(2)},${s(y[1],k[1]).toFixed(2)} `;return C+=`${k[0].toFixed(2)},${k[1].toFixed(2)} `,C+="Z",C}return a.watch([t,o],([l,c])=>{if(!l||!c){r.value="";return}const d=l.radius??8,[u,f]=c.position;r.value=i(l.pointCount,l.firstPointIndex,l.points,2*d,u,f)},{immediate:!0}),(l,c)=>(a.openBlock(),a.createElementBlock("div",om,[(a.openBlock(),a.createElementBlock("svg",rm,[a.createElementVNode("path",{d:r.value,fill:im},null,8,sm)]))]))}}),lm={class:"wov-image-block"},am={key:0,class:"wov-image-placeholder"},cm={key:1,class:"wov-image-placeholder wov-image-error"},dm=["src","alt"],um={key:3,class:"wov-image-upload-overlay"},fm={class:"wov-image-upload-status"},Pa=a.defineComponent({__name:"ImageBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},async setup(n){let e,t;const o=n,r=a.inject(ke);if(!r)throw new Error("ImageBlock must be used within a WovenCanvas component");const s=r,i=me(o.entityId,w.Asset),l=me(o.entityId,w.Image),c=s.getAssetManager(),d=i.value;let u=null;c&&(d!=null&&d.identifier)&&(u=([e,t]=a.withAsyncContext(()=>c.getDisplayUrl(d.identifier)),e=await e,t(),e));const f=a.ref(u),p=a.ref(!u),h=a.ref(!1);let m=!0;a.onUnmounted(()=>{m=!1});async function g(){const b=i.value;if(!b){p.value=!1;return}try{p.value=!0,h.value=!1;const C=await(c==null?void 0:c.getDisplayUrl(b.identifier));if(!m)return;C?(f.value=C,p.value=!1):b.uploadState===w.UploadState.Failed&&(h.value=!0,p.value=!1)}catch(C){if(!m)return;console.error("Failed to get display URL:",C),h.value=!0,p.value=!1}}a.watch(()=>i.value,()=>{g()},{immediate:!0}),a.onMounted(()=>{g()});const y=a.computed(()=>{const b=i.value;if(!b)return null;switch(b.uploadState){case w.UploadState.Pending:return"Loading...";case w.UploadState.Uploading:return"Loading...";case w.UploadState.Failed:return"Failed";default:return null}}),k=a.computed(()=>({width:"100%",height:"100%",objectFit:"fill"}));return(b,C)=>{var x;return a.openBlock(),a.createElementBlock("div",lm,[p.value&&!f.value?(a.openBlock(),a.createElementBlock("div",am)):h.value?(a.openBlock(),a.createElementBlock("div",cm,[...C[0]||(C[0]=[a.createElementVNode("span",null,"Failed to load image",-1)])])):f.value?(a.openBlock(),a.createElementBlock("img",{key:2,src:f.value,alt:((x=a.unref(l))==null?void 0:x.alt)||"",style:a.normalizeStyle(k.value),draggable:"false"},null,12,dm)):a.createCommentVNode("",!0),y.value?(a.openBlock(),a.createElementBlock("div",um,[a.createElementVNode("span",fm,a.toDisplayString(y.value),1)])):a.createCommentVNode("",!0)])}}}),hm=["data-complete"],pm={preserveAspectRatio:"none"},mm=["d","fill"],gm={key:0,class:"highlight",preserveAspectRatio:"none"},ym=["d"],Da=an(a.defineComponent({__name:"PenStroke",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=me(e.entityId,Jo.PenStroke),o=me(e.entityId,w.Block),r=me(e.entityId,w.Color),s=a.shallowRef(""),i=a.shallowRef("");function l(f,p){return(f+p)/2}function c(f,p,h){if(p<=4||f.length<3){const b=h/2;return`M ${b},0 a ${b},${b} 0 1 0 0.0001 0`}let m=f[0],g=f[1];const y=f[2];let k=`M${m[0].toFixed(2)},${m[1].toFixed(2)} Q${g[0].toFixed(2)},${g[1].toFixed(2)} ${l(g[0],y[0]).toFixed(2)},${l(g[1],y[1]).toFixed(2)} T`;for(let b=2;b<f.length-1;b++)m=f[b],g=f[b+1],k+=`${l(m[0],g[0]).toFixed(2)},${l(m[1],g[1]).toFixed(2)} `;return k+=`${g[0].toFixed(2)},${g[1].toFixed(2)} `,k+="Z",k}a.watch([t,o],([f,p])=>{if(!f||!p){s.value="",i.value="";return}if(!f.originalWidth||!f.originalHeight){s.value="",i.value="";return}const h=p.size[0]/f.originalWidth,m=p.size[1]/f.originalHeight,g=[];for(let k=0;k<f.pointCount;k++){const b=f.points[k*2],C=f.points[k*2+1],x=(b-f.originalLeft)*h,E=(C-f.originalTop)*m;f.hasPressure?g.push([x,E,f.pressures[k]]):g.push([x,E])}const y=js(g,{last:f.isComplete,size:f.thickness,simulatePressure:!f.hasPressure});if(s.value=c(y,f.pointCount,f.thickness),f.isComplete){const k=g.length===1?f.thickness:1,b=js(g,{last:!0,size:k,simulatePressure:!f.hasPressure});i.value=c(b,f.pointCount,k)}},{immediate:!0});const d=a.computed(()=>r.value?`rgb(${r.value.red}, ${r.value.green}, ${r.value.blue})`:"#000000"),u=a.computed(()=>e.selected||e.hovered);return(f,p)=>{var h;return a.openBlock(),a.createElementBlock("div",{class:"wov-pen-stroke","data-complete":((h=a.unref(t))==null?void 0:h.isComplete)||void 0},[(a.openBlock(),a.createElementBlock("svg",pm,[a.createElementVNode("path",{d:s.value,fill:d.value},null,8,mm)])),u.value?(a.openBlock(),a.createElementBlock("svg",gm,[a.createElementVNode("path",{d:i.value,stroke:"var(--wov-highlighted-block-outline-color)",style:{"stroke-width":"calc(1px / var(--wov-zoom))"},fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,8,ym)])):a.createCommentVNode("",!0)],8,hm)}}}),[["__scopeId","data-v-73f3bc07"]]);function ce(){const n=a.inject(ke);if(!n)throw new Error("useEditorContext must be used within a WovenCanvas component");return{getEditor:()=>n.getEditor(),setDefaults:(e,t)=>n.setDefaults(e,t),getDefaults:e=>n.getDefaults(e),nextEditorTick(e){return new Promise(t=>{const o=n.getEditor();o&&o.nextTick(r=>{e==null||e(r),t(r)})})}}}const so={rectangle:"M0,0 L100,0 L100,100 L0,100 Z",ellipse:"M50,0 A50,50 0 1,1 50,100 A50,50 0 1,1 50,0",triangle:"M50,0 L100,100 L0,100 Z",diamond:"M50,0 L100,50 L50,100 L0,50 Z",pentagon:"M50,0 L100,38.2 L80.9,100 L19.1,100 L0,38.2 Z",hexagon:"M50,0 L100,25 L100,75 L50,100 L0,75 L0,25 Z",star:"M50,0 L61.8,38.2 L100,38.2 L69.1,61.8 L80.9,100 L50,76.4 L19.1,100 L30.9,61.8 L0,38.2 L38.2,38.2 Z",heart:"M50,16 C44,7 37,0 26,0 11,0 0,12 0,28 0,60 16,65 50,100 84,65 100,60 100,28 100,12 89,0 74,0 63,0 56,7 50,16 Z",arrow:"M0,35 L60,35 L60,0 L100,50 L60,100 L60,65 L0,65 Z"};function Me(n){this.content=n}Me.prototype={constructor:Me,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,r=o.find(n),s=o.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new Me(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Me(t)},addToStart:function(n,e){return new Me([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Me(t)},addBefore:function(n,e,t){var o=this.remove(e),r=o.content.slice(),s=o.find(n);return r.splice(s==-1?r.length:s,0,e,t),new Me(r)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Me.from(n),n.size?new Me(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Me.from(n),n.size?new Me(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Me.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Me.from=function(n){if(n instanceof Me)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Me(e)};function _a(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(o),s=e.child(o);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let i=0;r.text[i]==s.text[i];i++)t++;return t}if(r.content.size||s.content.size){let i=_a(r.content,s.content,t+1);if(i!=null)return i}t+=r.nodeSize}}function La(n,e,t,o){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:o};let i=n.child(--r),l=e.child(--s),c=i.nodeSize;if(i==l){t-=c,o-=c;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let d=0,u=Math.min(i.text.length,l.text.length);for(;d<u&&i.text[i.text.length-d-1]==l.text[l.text.length-d-1];)d++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let d=La(i.content,l.content,t-1,o-1);if(d)return d}t-=c,o-=c}}class I{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,r=0,s){for(let i=0,l=0;l<t;i++){let c=this.content[i],d=l+c.nodeSize;if(d>e&&o(c,r+l,s||null,i)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),o,r+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,r){let s="",i=!0;return this.nodesBetween(e,t,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&o&&(i?i=!1:s+=o),s+=d},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(o)&&(r[r.length-1]=t.withText(t.text+o.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new I(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],r=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],c=i+l.nodeSize;c>e&&((i<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),r+=l.nodeSize),i=c}return new I(o,r)}cutByIndex(e,t){return e==t?I.empty:e==0&&t==this.content.length?this:new I(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-o.nodeSize;return r[e]=t,new I(r,s)}addToStart(e){return new I([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new I(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,o=0;t<this.content.length;t++){let r=this.content[t];e(r,o,t),o+=r.nodeSize}}findDiffStart(e,t=0){return _a(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return La(this,e,t,o)}findIndex(e){if(e==0)return Go(0,e);if(e==this.size)return Go(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,o=0;;t++){let r=this.child(t),s=o+r.nodeSize;if(s>=e)return s==e?Go(t+1,s):Go(t,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return I.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new I(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return I.empty;let t,o=0;for(let r=0;r<e.length;r++){let s=e[r];o+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new I(t||e,o)}static from(e){if(!e)return I.empty;if(e instanceof I)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new I([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}I.empty=new I([],0);const Ws={index:0,offset:0};function Go(n,e){return Ws.index=n,Ws.offset=e,Ws}function Yo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let o=0;o<n.length;o++)if(!Yo(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Yo(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}let re=class la{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!o&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),o=!0),t&&t.push(s)}}return t||(t=e.slice()),o||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&&Yo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=o.create(t.attrs);return o.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return la.none;if(e instanceof la)return[e];let t=e.slice();return t.sort((o,r)=>o.type.rank-r.type.rank),t}};re.none=[];class Xo extends Error{}class z{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=$a(this.content,e+this.openStart,t);return o&&new z(o,this.openStart,this.openEnd)}removeBetween(e,t){return new z(Va(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return z.empty;let o=t.openStart||0,r=t.openEnd||0;if(typeof o!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new z(I.fromJSON(e,t.content),o,r)}static maxOpen(e,t=!0){let o=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)o++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new z(e,o,r)}}z.empty=new z(I.empty,0,0);function Va(n,e,t){let{index:o,offset:r}=n.findIndex(e),s=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(r==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,s.copy(Va(s.content,e-r-1,t-r-1)))}function $a(n,e,t,o){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r);if(s==e||i.isText)return o&&!o.canReplace(r,r,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=$a(i.content,e-s-1,t,i);return l&&n.replaceChild(r,i.copy(l))}function km(n,e,t){if(t.openStart>n.depth)throw new Xo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xo("Inconsistent open depths");return za(n,e,t,0)}function za(n,e,t,o){let r=n.index(o),s=n.node(o);if(r==e.index(o)&&o<n.depth-t.openStart){let i=za(n,e,t,o+1);return s.copy(s.content.replaceChild(r,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return dn(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=wm(t,n);return dn(s,Ha(n,i,l,e,o))}else return dn(s,Qo(n,e,o))}function Fa(n,e){if(!e.type.compatibleContent(n.type))throw new Xo("Cannot join "+e.type.name+" onto "+n.type.name)}function Ks(n,e,t){let o=n.node(t);return Fa(o,e.node(t)),o}function cn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function io(n,e,t,o){let r=(e||n).node(t),s=0,i=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(cn(n.nodeAfter,o),s++));for(let l=s;l<i;l++)cn(r.child(l),o);e&&e.depth==t&&e.textOffset&&cn(e.nodeBefore,o)}function dn(n,e){return n.type.checkContent(e),n.copy(e)}function Ha(n,e,t,o,r){let s=n.depth>r&&Ks(n,e,r+1),i=o.depth>r&&Ks(t,o,r+1),l=[];return io(null,n,r,l),s&&i&&e.index(r)==t.index(r)?(Fa(s,i),cn(dn(s,Ha(n,e,t,o,r+1)),l)):(s&&cn(dn(s,Qo(n,e,r+1)),l),io(e,t,r,l),i&&cn(dn(i,Qo(t,o,r+1)),l)),io(o,null,r,l),new I(l)}function Qo(n,e,t){let o=[];if(io(null,n,t,o),n.depth>t){let r=Ks(n,e,t+1);cn(dn(r,Qo(n,e,t+1)),o)}return io(e,null,t,o),new I(o)}function wm(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(I.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class lo{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],r=e.child(t);return o?e.child(t).cut(o):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 o=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=o.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return re.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),r=e.maybeChild(t);if(!o){let l=o;o=r,r=l}let s=o.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!r||!s[i].isInSet(r.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!r||!o[s].isInSet(r.marks))&&(o=o[s--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Zo(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],r=0,s=t;for(let i=e;;){let{index:l,offset:c}=i.content.findIndex(s),d=s-c;if(o.push(i,l,r+c),!d||(i=i.child(l),i.isText))break;s=d-1,r+=c+1}return new lo(t,o,s)}static resolveCached(e,t){let o=Ua.get(e);if(o)for(let s=0;s<o.elts.length;s++){let i=o.elts[s];if(i.pos==t)return i}else Ua.set(e,o=new bm);let r=o.elts[o.i]=lo.resolve(e,t);return o.i=(o.i+1)%Cm,r}}class bm{constructor(){this.elts=[],this.i=0}}const Cm=12,Ua=new WeakMap;class Zo{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const xm=Object.create(null);let St=class aa{constructor(e,t,o,r=re.none){this.type=e,this.attrs=t,this.marks=r,this.content=o||I.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,o,r=0){this.content.nodesBetween(e,t,o,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,o,r){return this.content.textBetween(e,t,o,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,o){return this.type==e&&Yo(this.attrs,t||e.defaultAttrs||xm)&&re.sameSet(this.marks,o||re.none)}copy(e=null){return e==this.content?this:new aa(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new aa(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,o=!1){if(e==t)return z.empty;let r=this.resolve(e),s=this.resolve(t),i=o?0:r.sharedDepth(t),l=r.start(i),d=r.node(i).content.cut(r.pos-l,s.pos-l);return new z(d,r.depth-i,s.depth-i)}replace(e,t,o){return km(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let r=this.content.child(t-1);return{node:r,index:t-1,offset:o-r.nodeSize}}resolve(e){return lo.resolveCached(this,e)}resolveNoCache(e){return lo.resolve(this,e)}rangeHasMark(e,t,o){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(o.isInSet(s.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()+")"),ja(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,o=I.empty,r=0,s=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,r,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=r;c<s;c++)if(!this.type.allowsMarks(o.child(c).marks))return!1;return!0}canReplaceWith(e,t,o,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(o),i=s&&s.matchFragment(this.content,t);return i?i.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=re.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!re.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let r=I.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,o);return s.type.checkAttrs(s.attrs),s}};St.prototype.text=void 0;class er extends St{constructor(e,t,o,r){if(super(e,t,null,r),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ja(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new er(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new er(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ja(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class un{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Sm(e,t);if(o.next==null)return un.empty;let r=Wa(o);o.next&&o.err("Unexpected trailing text");let s=Bm(Am(r));return Im(s,o),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let r=this;for(let s=t;r&&s<o;s++)r=r.matchType(e.child(s).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 o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let r=[this];function s(i,l){let c=i.matchFragment(e,o);if(c&&(!t||c.validEnd))return I.from(l.map(d=>d.createAndFill()));for(let d=0;d<i.next.length;d++){let{type:u,next:f}=i.next[d];if(!(u.isText||u.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let p=s(f,l.concat(u));if(p)return p}}return null}return s(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let r=o.shift(),s=r.match;if(s.matchType(e)){let i=[];for(let l=r;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:c}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||c.validEnd)&&(o.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let r=0;r<o.next.length;r++)e.indexOf(o.next[r].next)==-1&&t(o.next[r].next)}return t(this),e.map((o,r)=>{let s=r+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)s+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return s}).join(`
|
|
2
|
-
`)}}un.empty=new un(!0);class Sm{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Wa(n){let e=[];do e.push(Em(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Em(n){let e=[];do e.push(vm(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function vm(n){let e=Nm(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Mm(n,e);else break;return e}function Ka(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Mm(n,e){let t=Ka(n),o=t;return n.eat(",")&&(n.next!="}"?o=Ka(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Tm(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let r=[];for(let s in t){let i=t[s];i.isInGroup(e)&&r.push(i)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function Nm(n){if(n.eat("(")){let e=Wa(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Tm(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Am(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,c){let d={term:c,to:l};return e[i].push(d),d}function r(i,l){i.forEach(c=>c.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((c,d)=>c.concat(s(d,l)),[]);if(i.type=="seq")for(let c=0;;c++){let d=s(i.exprs[c],l);if(c==i.exprs.length-1)return d;r(d,l=t())}else if(i.type=="star"){let c=t();return o(l,c),r(s(i.expr,c),c),[o(c)]}else if(i.type=="plus"){let c=t();return r(s(i.expr,l),c),r(s(i.expr,c),c),[o(c)]}else{if(i.type=="opt")return[o(l)].concat(s(i.expr,l));if(i.type=="range"){let c=l;for(let d=0;d<i.min;d++){let u=t();r(s(i.expr,c),u),c=u}if(i.max==-1)r(s(i.expr,c),c);else for(let d=i.min;d<i.max;d++){let u=t();o(c,u),r(s(i.expr,c),u),c=u}return[o(c)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function qa(n,e){return e-n}function Ja(n,e){let t=[];return o(e),t.sort(qa);function o(r){let s=n[r];if(s.length==1&&!s[0].term)return o(s[0].to);t.push(r);for(let i=0;i<s.length;i++){let{term:l,to:c}=s[i];!l&&t.indexOf(c)==-1&&o(c)}}}function Bm(n){let e=Object.create(null);return t(Ja(n,0));function t(o){let r=[];o.forEach(i=>{n[i].forEach(({term:l,to:c})=>{if(!l)return;let d;for(let u=0;u<r.length;u++)r[u][0]==l&&(d=r[u][1]);Ja(n,c).forEach(u=>{d||r.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let s=e[o.join(",")]=new un(o.indexOf(n.length-1)>-1);for(let i=0;i<r.length;i++){let l=r[i][1].sort(qa);s.next.push({type:r[i][0],next:e[l.join(",")]||t(l)})}return s}}function Im(n,e){for(let t=0,o=[n];t<o.length;t++){let r=o[t],s=!r.validEnd,i=[];for(let l=0;l<r.next.length;l++){let{type:c,next:d}=r.next[l];i.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),o.indexOf(d)==-1&&o.push(d)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ga(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function Ya(n,e){let t=Object.create(null);for(let o in n){let r=e&&e[o];if(r===void 0){let s=n[o];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=r}return t}function Xa(n,e,t,o){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function Qa(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Rm(n,o,e[o]);return t}let Za=class cp{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=Qa(e,o.attrs),this.defaultAttrs=Ga(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==un.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:Ya(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new St(this,this.computeAttrs(e),I.from(t),re.setFrom(o))}createChecked(e=null,t,o){return t=I.from(t),this.checkContent(t),new St(this,this.computeAttrs(e),t,re.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=I.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(I.empty,!0);return s?new St(this,e,t.append(s),re.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Xa(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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:re.none:e}static compile(e,t){let o=Object.create(null);e.forEach((s,i)=>o[s]=new cp(s,t,i));let r=t.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let s in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function Om(n,e,t){let o=t.split("|");return r=>{let s=r===null?"null":typeof r;if(o.indexOf(s)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${s}`)}}class Rm{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Om(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class tr{constructor(e,t,o,r){this.name=e,this.rank=t,this.schema=o,this.spec=r,this.attrs=Qa(e,r.attrs),this.excluded=null;let s=Ga(this.attrs);this.instance=s?new re(this,s):null}create(e=null){return!e&&this.instance?this.instance:new re(this,Ya(this.attrs,e))}static compile(e,t){let o=Object.create(null),r=0;return e.forEach((s,i)=>o[s]=new tr(s,r++,t,i)),o}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){Xa(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ec{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Me.from(e.nodes),t.marks=Me.from(e.marks||{}),this.nodes=Za.compile(this.spec.nodes,this),this.marks=tr.compile(this.spec.marks,this);let o=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=o[i]||(o[i]=un.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?tc(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:tc(this,i.split(" "))}this.nodeFromJSON=r=>St.fromJSON(this,r),this.markFromJSON=r=>re.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Za){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,o,r)}text(e,t){let o=this.nodes.text;return new er(o,o.defaultAttrs,e,re.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 new RangeError("Unknown node type: "+e);return t}}function tc(n,e){let t=[];for(let o=0;o<e.length;o++){let r=e[o],s=n.marks[r],i=s;if(s)t.push(s);else for(let l in n.marks){let c=n.marks[l];(r=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&t.push(i=c)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Pm(n){return n.tag!=null}function Dm(n){return n.style!=null}class Et{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(r=>{if(Pm(r))this.tags.push(r);else if(Dm(r)){let s=/[^=]*/.exec(r.style)[0];o.indexOf(s)<0&&o.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let o=new sc(this,t,!1);return o.addAll(e,re.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new sc(this,t,!0);return o.addAll(e,re.none,t.from,t.to),z.maxOpen(o.finish())}matchTag(e,t,o){for(let r=o?this.tags.indexOf(o)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(Vm(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,o,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let c=i.getAttrs(t);if(c===!1)continue;i.attrs=c||void 0}return i}}}static schemaRules(e){let t=[];function o(r){let s=r.priority==null?50:r.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(i=>{o(i=ic(i)),i.mark||i.ignore||i.clearMark||(i.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(i=>{o(i=ic(i)),i.node||i.ignore||i.mark||(i.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Et(e,Et.schemaRules(e)))}}const nc={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},_m={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},oc={ol:!0,ul:!0},ao=1,qs=2,co=4;function rc(n,e,t){return e!=null?(e?ao:0)|(e==="full"?qs:0):n&&n.whitespace=="pre"?ao|qs:t&~co}class nr{constructor(e,t,o,r,s,i){this.type=e,this.attrs=t,this.marks=o,this.solid=r,this.options=i,this.content=[],this.activeMarks=re.none,this.match=s||(i&co?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(I.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,r;return(r=o.findWrapping(e.type))?(this.match=o,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ao)){let o=this.content[this.content.length-1],r;if(o&&o.isText&&(r=/[ \t\r\n\u000c]+$/.exec(o.text))){let s=o;o.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=I.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(I.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&&!nc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class sc{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,i=rc(null,t.preserveWhitespace,0)|(o?co:0);r?s=new nr(r.type,r.attrs,re.none,!0,t.topMatch||r.type.contentMatch,i):o?s=new nr(null,null,re.none,!0,null,i):s=new nr(e.schema.topNodeType,null,re.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,r=this.top,s=r.options&qs?"full":this.localPreserveWS||(r.options&ao)>0,{schema:i}=this.parser;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s)if(s==="full")o=o.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(i.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=o.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[c]&&this.insertNode(i.text(l[c]),t,!/\S/.test(l[c]));o=""}else o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(o=o.slice(1))}o&&this.insertNode(i.text(o),t,!/\S/.test(o)),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let r=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;
|
|
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 o=e.style;if(o&&o.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],i=o.getPropertyValue(s);if(i)for(let l=void 0;;){let c=this.parser.matchStyle(s,i,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?t=t.filter(d=>!c.clearMark(d)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,o,r){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let c=this.enter(i,t.attrs||null,o,t.preserveWhitespace);c&&(s=!0,o=c)}else{let c=this.parser.schema.marks[t.mark];o=o.concat(c.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,o,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,o,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,o),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,o,r){let s=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=r==null?null:e.childNodes[r];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,o){let r,s;for(let i=this.open,l=0;i>=0;i--){let c=this.nodes[i],d=c.findWrapping(e);if(d&&(!r||r.length>d.length+l)&&(r=d,s=c,!d.length))break;if(c.solid){if(o)break;l+=2}}if(!r)return null;this.sync(s);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],null,t,!1);return t}insertNode(e,t,o){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t,o);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=re.none;for(let l of r.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):lc(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,o,r){let s=this.findPlace(e.create(t),o,!1);return s&&(s=this.enterInner(e,t,o,!0,r)),s}enterInner(e,t,o,r=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=rc(e,s,i.options);i.options&co&&i.content.length==0&&(l|=co);let c=re.none;return o=o.filter(d=>(i.type?i.type.allowsMarkType(d.type):lc(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new nr(e,t,c,r,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=ao)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let r=o.length-1;r>=0;r--)e+=o[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].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,o){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)&(o?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("/"),o=this.options.context,r=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),s=-(o?o.depth+1:0)+(r?0:1),i=(l,c)=>{for(;l>=0;l--){let d=t[l];if(d==""){if(l==t.length-1||l==0)continue;for(;c>=s;c--)if(i(l-1,c))return!0;return!1}else{let u=c>0||c==0&&r?this.nodes[c].type:o&&c>=s?o.node(c-s).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Lm(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&oc.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function Vm(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ic(n){let e={};for(let t in n)e[t]=n[t];return e}function lc(n,e){let t=e.schema.nodes;for(let o in t){let r=t[o];if(!r.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:d,next:u}=l.edge(c);if(d==e||s.indexOf(u)<0&&i(u))return!0}};if(i(r.contentMatch))return!0}}class fn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Js(t).createDocumentFragment());let r=o,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,c=0;for(;l<s.length&&c<i.marks.length;){let d=i.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(s[l][0])||d.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)r=s.pop()[1];for(;c<i.marks.length;){let d=i.marks[c++],u=this.serializeMark(d,i.isInline,t);u&&(s.push([d,r]),r.appendChild(u.dom),r=u.contentDOM||u.dom)}}r.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:r}=or(Js(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(o),o=s.dom)}return o}serializeMark(e,t,o={}){let r=this.marks[e.type.name];return r&&or(Js(o),r(e,t),null,e.attrs)}static renderSpec(e,t,o=null,r){return or(e,t,o,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new fn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ac(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return ac(e.marks)}}function ac(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Js(n){return n.document||window.document}const cc=new WeakMap;function $m(n){let e=cc.get(n);return e===void 0&&cc.set(n,e=zm(n)),e}function zm(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let r=0;r<o.length;r++)t(o[r]);else for(let r in o)t(o[r])}return t(n),e}function or(n,e,t,o){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(s=$m(o))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=r.indexOf(" ");i>0&&(t=r.slice(0,i),r=r.slice(i+1));let l,c=t?n.createElementNS(t,r):n.createElement(r),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&c.style?c.style.cssText=d[f]:c.setAttribute(f,d[f])}}for(let f=u;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:h,contentDOM:m}=or(n,p,t,o);if(c.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:c,contentDOM:l}}const dc=65535,uc=Math.pow(2,16);function Fm(n,e){return n+e*uc}function fc(n){return n&dc}function Hm(n){return(n-(n&dc))/uc}const hc=1,pc=2,rr=4,mc=8;class Gs{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&mc)>0}get deletedBefore(){return(this.delInfo&(hc|rr))>0}get deletedAfter(){return(this.delInfo&(pc|rr))>0}get deletedAcross(){return(this.delInfo&rr)>0}}class Ue{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ue.empty)return Ue.empty}recover(e){let t=0,o=fc(e);if(!this.inverted)for(let r=0;r<o;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[o*3]+t+Hm(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let r=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[l+s],u=this.ranges[l+i],f=c+d;if(e<=f){let p=d?e==c?-1:e==f?1:t:t,h=c+r+(p<0?0:u);if(o)return h;let m=e==(t<0?c:f)?null:Fm(l/3,e-c),g=e==c?pc:e==f?hc:rr;return(t<0?e!=c:e!=f)&&(g|=mc),new Gs(h,g,m)}r+=u-d}return o?e+r:new Gs(e+r,0,null)}touches(e,t){let o=0,r=fc(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?o:0);if(c>e)break;let d=this.ranges[l+s],u=c+d;if(e<=u&&l==r*3)return!0;o+=this.ranges[l+i]-d}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let i=this.ranges[r],l=i-(this.inverted?s:0),c=i+(this.inverted?0:s),d=this.ranges[r+t],u=this.ranges[r+o];e(l,l+d,c,c+u),s+=u-d}}invert(){return new Ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ue.empty:new Ue(e<0?[0,-e,0]:[0,0,e])}}Ue.empty=new Ue([]);class uo{constructor(e,t,o=0,r=e?e.length:0){this.mirror=t,this.from=o,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new uo(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,o=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?o+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=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,o=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?o-r-1:void 0)}}invert(){let e=new uo;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this._maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let r=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return o?e:new Gs(e,r,null)}}const Ys=Object.create(null);class Pe{getMap(){return Ue.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Ys[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Ys)throw new RangeError("Duplicate use of step JSON ID "+e);return Ys[e]=t,t.prototype.jsonID=e,t}}class ge{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ge(e,null)}static fail(e){return new ge(null,e)}static fromReplace(e,t,o,r){try{return ge.ok(e.replace(t,o,r))}catch(s){if(s instanceof Xo)return ge.fail(s.message);throw s}}}function Xs(n,e,t){let o=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(Xs(s.content,e,s))),s.isInline&&(s=e(s,t,r)),o.push(s)}return I.fromArray(o)}class zt extends Pe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),r=o.node(o.sharedDepth(this.to)),s=new z(Xs(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),r),t.openStart,t.openEnd);return ge.fromReplace(e,this.from,this.to,s)}invert(){return new tt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new zt(t.pos,o.pos,this.mark)}merge(e){return e instanceof zt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new zt(t.from,t.to,e.markFromJSON(t.mark))}}Pe.jsonID("addMark",zt);class tt extends Pe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new z(Xs(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return ge.fromReplace(e,this.from,this.to,o)}invert(){return new zt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new tt(t.pos,o.pos,this.mark)}merge(e){return e instanceof tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new tt(t.from,t.to,e.markFromJSON(t.mark))}}Pe.jsonID("removeMark",tt);class Ft extends Pe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ge.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ge.fromReplace(e,this.pos,this.pos+1,new z(I.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(o))return new Ft(this.pos,t.marks[r]);return new Ft(this.pos,this.mark)}}return new hn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ft(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ft(t.pos,e.markFromJSON(t.mark))}}Pe.jsonID("addNodeMark",Ft);class hn extends Pe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ge.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ge.fromReplace(e,this.pos,this.pos+1,new z(I.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ft(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new hn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new hn(t.pos,e.markFromJSON(t.mark))}}Pe.jsonID("removeNodeMark",hn);class we extends Pe{constructor(e,t,o,r=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=r}apply(e){return this.structure&&Qs(e,this.from,this.to)?ge.fail("Structure replace would overwrite content"):ge.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new we(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new we(t.pos,Math.max(t.pos,o.pos),this.slice,this.structure)}merge(e){if(!(e instanceof we)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?z.empty:new z(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new we(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?z.empty:new z(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new we(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new we(t.from,t.to,z.fromJSON(e,t.slice),!!t.structure)}}Pe.jsonID("replace",we);class be extends Pe{constructor(e,t,o,r,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=r,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Qs(e,this.from,this.gapFrom)||Qs(e,this.gapTo,this.to)))return ge.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ge.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?ge.fromReplace(e,this.from,this.to,o):ge.fail("Content does not fit in gap")}getMap(){return new Ue([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new be(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||r<t.pos||s>o.pos?null:new be(t.pos,o.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new be(t.from,t.to,t.gapFrom,t.gapTo,z.fromJSON(e,t.slice),t.insert,!!t.structure)}}Pe.jsonID("replaceAround",be);function Qs(n,e,t){let o=n.resolve(e),r=t-e,s=o.depth;for(;r>0&&s>0&&o.indexAfter(s)==o.node(s).childCount;)s--,r--;if(r>0){let i=o.node(s).maybeChild(o.indexAfter(s));for(;r>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,r--}}return!1}function Um(n,e,t,o){let r=[],s=[],i,l;n.doc.nodesBetween(e,t,(c,d,u)=>{if(!c.isInline)return;let f=c.marks;if(!o.isInSet(f)&&u.type.allowsMarkType(o.type)){let p=Math.max(d,e),h=Math.min(d+c.nodeSize,t),m=o.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(m)||(i&&i.to==p&&i.mark.eq(f[g])?i.to=h:r.push(i=new tt(p,h,f[g])));l&&l.to==p?l.to=h:s.push(l=new zt(p,h,o))}}),r.forEach(c=>n.step(c)),s.forEach(c=>n.step(c))}function jm(n,e,t,o){let r=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let c=null;if(o instanceof tr){let d=i.marks,u;for(;u=o.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else o?o.isInSet(i.marks)&&(c=[o]):c=i.marks;if(c&&c.length){let d=Math.min(l+i.nodeSize,t);for(let u=0;u<c.length;u++){let f=c[u],p;for(let h=0;h<r.length;h++){let m=r[h];m.step==s-1&&f.eq(r[h].style)&&(p=m)}p?(p.to=d,p.step=s):r.push({style:f,from:Math.max(l,e),to:d,step:s})}}}),r.forEach(i=>n.step(new tt(i.from,i.to,i.style)))}function Zs(n,e,t,o=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let c=0;c<s.childCount;c++){let d=s.child(c),u=l+d.nodeSize,f=o.matchType(d.type);if(!f)i.push(new we(l,u,z.empty));else{o=f;for(let p=0;p<d.marks.length;p++)t.allowsMarkType(d.marks[p].type)||n.step(new tt(l,u,d.marks[p]));if(r&&d.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,m;for(;p=h.exec(d.text);)m||(m=new z(I.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),i.push(new we(l+p.index,l+p.index+p[0].length,m))}}l=u}if(!o.validEnd){let c=o.fillBefore(I.empty,!0);n.replace(l,l,new z(c,0,0))}for(let c=i.length-1;c>=0;c--)n.step(i[c])}function Wm(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Pn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth,r=0,s=0;;--o){let i=n.$from.node(o),l=n.$from.index(o)+r,c=n.$to.indexAfter(o)-s;if(o<n.depth&&i.canReplace(l,c,t))return o;if(o==0||i.type.spec.isolating||!Wm(i,l,c))break;l&&(r=1),c<i.childCount&&(s=1)}return null}function Km(n,e,t){let{$from:o,$to:r,depth:s}=e,i=o.before(s+1),l=r.after(s+1),c=i,d=l,u=I.empty,f=0;for(let m=s,g=!1;m>t;m--)g||o.index(m)>0?(g=!0,u=I.from(o.node(m).copy(u)),f++):c--;let p=I.empty,h=0;for(let m=s,g=!1;m>t;m--)g||r.after(m+1)<r.end(m)?(g=!0,p=I.from(r.node(m).copy(p)),h++):d++;n.step(new be(c,d,i,l,new z(u.append(p),f,h),u.size-f,!0))}function gc(n,e,t=null,o=n){let r=qm(n,e),s=r&&Jm(o,e);return s?r.map(yc).concat({type:e,attrs:t}).concat(s.map(yc)):null}function yc(n){return{type:n,attrs:null}}function qm(n,e){let{parent:t,startIndex:o,endIndex:r}=n,s=t.contentMatchAt(o).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(o,r,i)?s:null}function Jm(n,e){let{parent:t,startIndex:o,endIndex:r}=n,s=t.child(o),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let c=(i.length?i[i.length-1]:e).contentMatch;for(let d=o;c&&d<r;d++)c=c.matchType(t.child(d).type);return!c||!c.validEnd?null:i}function Gm(n,e,t){let o=I.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=I.from(t[i].type.create(t[i].attrs,o))}let r=e.start,s=e.end;n.step(new be(r,s,r,s,new z(o,0,0),t.length,!0))}function Ym(n,e,t,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let c=typeof r=="function"?r(i):r;if(i.isTextblock&&!i.hasMarkup(o,c)&&Xm(n.doc,n.mapping.slice(s).map(l),o)){let d=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",m=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!m?d=!1:!h&&m&&(d=!0)}d===!1&&wc(n,i,l,s),Zs(n,n.mapping.slice(s).map(l,1),o,void 0,d===null);let u=n.mapping.slice(s),f=u.map(l,1),p=u.map(l+i.nodeSize,1);return n.step(new be(f,p,f+1,p-1,new z(I.from(o.create(c,null,i.marks)),0,0),1,!0)),d===!0&&kc(n,i,l,s),!1}})}function kc(n,e,t,o){e.forEach((r,s)=>{if(r.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(r.text);){let c=n.mapping.slice(o).map(t+1+s+i.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function wc(n,e,t,o){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function Xm(n,e,t){let o=n.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,t)}function Qm(n,e,t,o,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(o,null,r||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new be(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new z(I.from(i),0,0),1,!0))}function vt(n,e,t=1,o){let r=n.resolve(e),s=r.depth-t,i=o&&o[o.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!i.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let d=r.depth-1,u=t-2;d>s;d--,u--){let f=r.node(d),p=r.index(d);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(p,f.childCount),m=o&&o[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=o&&o[u]||f;if(!f.canReplace(p+1,f.childCount)||!g.type.validContent(h))return!1}let l=r.indexAfter(s),c=o&&o[0];return r.node(s).canReplaceWith(l,l,c?c.type:r.node(s+1).type)}function Zm(n,e,t=1,o){let r=n.doc.resolve(e),s=I.empty,i=I.empty;for(let l=r.depth,c=r.depth-t,d=t-1;l>c;l--,d--){s=I.from(r.node(l).copy(s));let u=o&&o[d];i=I.from(u?u.type.create(u.attrs,i):r.node(l).copy(i))}n.step(new we(e,e,new z(s.append(i),t,t),!0))}function pn(n,e){let t=n.resolve(e),o=t.index();return bc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function eg(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),i=s.type==o?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function bc(n,e){return!!(n&&e&&!n.isLeaf&&eg(n,e))}function sr(n,e,t=-1){let o=n.resolve(e);for(let r=o.depth;;r--){let s,i,l=o.index(r);if(r==o.depth?(s=o.nodeBefore,i=o.nodeAfter):t>0?(s=o.node(r+1),l++,i=o.node(r).maybeChild(l)):(s=o.node(r).maybeChild(l-1),i=o.node(r+1)),s&&!s.isTextblock&&bc(s,i)&&o.node(r).canReplace(l,l+1))return e;if(r==0)break;e=t<0?o.before(r):o.after(r)}}function tg(n,e,t){let o=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(r&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(r);u&&!f?o=!1:!u&&f&&(o=!0)}let l=n.steps.length;if(o===!1){let u=n.doc.resolve(e+t);wc(n,u.node(),u.before(),l)}i.inlineContent&&Zs(n,e+t-1,i,s.node().contentMatchAt(s.index()),o==null);let c=n.mapping.slice(l),d=c.map(e-t);if(n.step(new we(d,c.map(e+t,-1),z.empty,!0)),o===!0){let u=n.doc.resolve(d);kc(n,u.node(),u.before(),n.steps.length)}return n}function ng(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let r=o.depth-1;r>=0;r--){let s=o.index(r);if(o.node(r).canReplaceWith(s,s,t))return o.before(r+1);if(s>0)return null}if(o.parentOffset==o.parent.content.size)for(let r=o.depth-1;r>=0;r--){let s=o.indexAfter(r);if(o.node(r).canReplaceWith(s,s,t))return o.after(r+1);if(s<o.node(r).childCount)return null}return null}function Cc(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,c=o.index(i)+(l>0?1:0),d=o.node(i),u=!1;if(s==1)u=d.canReplace(c,c,r);else{let f=d.contentMatchAt(c).findWrapping(r.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return l==0?o.pos:l<0?o.before(i+1):o.after(i+1)}return null}function ir(n,e,t=e,o=z.empty){if(e==t&&!o.size)return null;let r=n.resolve(e),s=n.resolve(t);return xc(r,s,o)?new we(e,t,o):new og(r,s,o).fit()}function xc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class og{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=I.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=I.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,o=this.$from,r=this.close(e<0?this.$to:o.doc.resolve(e));if(!r)return null;let s=this.placed,i=o.depth,l=r.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let c=new z(s,i,l);return e>-1?new be(o.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||o.pos!=this.$to.pos?new we(o.pos,r.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,r=this.unplaced.openEnd;o<e;o++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=o){e=o;break}t=s.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let r,s=null;o?(s=ei(this.unplaced.content,o-1).firstChild,r=s.content):r=this.unplaced.content;let i=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:d}=this.frontier[l],u,f=null;if(t==1&&(i?d.matchType(i.type)||(f=d.fillBefore(I.from(i),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:o,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=d.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:s,wrap:u};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,r=ei(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new z(e,t+1,Math.max(o,r.size+t>=e.size-o?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,r=ei(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new z(fo(e,t-1,1),t-1,s?t-1:o)}else this.unplaced=new z(fo(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let i=this.unplaced,l=o?o.content:i.content,c=i.openStart-e,d=0,u=[],{match:f,type:p}=this.frontier[t];if(r){for(let g=0;g<r.childCount;g++)u.push(r.child(g));f=f.matchFragment(r)}let h=l.size+e-(i.content.size-i.openEnd);for(;d<l.childCount;){let g=l.child(d),y=f.matchType(g.type);if(!y)break;d++,(d>1||c==0||g.content.size)&&(f=y,u.push(Sc(g.mark(p.allowedMarks(g.marks)),d==1?c:0,d==l.childCount?h:-1)))}let m=d==l.childCount;m||(h=-1),this.placed=ho(this.placed,t,I.from(u)),this.frontier[t].match=f,m&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let k=y.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),y=k.content}this.unplaced=m?e==0?z.empty:new z(fo(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new z(fo(i.content,e,d),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ti(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:o}=this.$to,r=this.$to.after(o);for(;o>1&&r==this.$to.end(--o);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=ti(e,t,r,o,s);if(i){for(let l=t-1;l>=0;l--){let{match:c,type:d}=this.frontier[l],u=ti(e,l,d,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=ho(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let r=e.node(o),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(o));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,o){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=ho(this.placed,this.depth,I.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(I.empty,!0);t.childCount&&(this.placed=ho(this.placed,this.frontier.length,t))}}function fo(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(fo(n.firstChild.content,e-1,t)))}function ho(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(ho(n.lastChild.content,e-1,t)))}function ei(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Sc(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Sc(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(I.empty,!0)))),n.copy(o)}function ti(n,e,t,o,r){let s=n.node(e),i=r?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=o.fillBefore(s.content,!0,i);return l&&!rg(t,s.content,i)?l:null}function rg(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function sg(n){return n.spec.defining||n.spec.definingForContent}function ig(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(xc(r,s,o))return n.step(new we(e,t,o));let i=vc(r,s);i[i.length-1]==0&&i.pop();let l=-(r.depth+1);i.unshift(l);for(let p=r.depth,h=r.pos-1;p>0;p--,h--){let m=r.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(p)>-1?l=p:r.before(p)==h&&i.splice(1,0,-p)}let c=i.indexOf(l),d=[],u=o.openStart;for(let p=o.content,h=0;;h++){let m=p.firstChild;if(d.push(m),h==o.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let h=d[p],m=sg(h.type);if(m&&!h.sameMarkup(r.node(Math.abs(l)-1)))u=p;else if(m||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+u+1)%(o.openStart+1),m=d[h];if(m)for(let g=0;g<i.length;g++){let y=i[(g+c)%i.length],k=!0;y<0&&(k=!1,y=-y);let b=r.node(y-1),C=r.index(y-1);if(b.canReplaceWith(C,C,m.type,m.marks))return n.replace(r.before(y),k?s.after(y):t,new z(Ec(o.content,0,o.openStart,h),h,o.openEnd))}}let f=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>f));p--){let h=i[p];h<0||(e=r.before(h),t=s.after(h))}}function Ec(n,e,t,o,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Ec(s.content,e+1,t,o,s)))}if(e>o){let s=r.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(I.empty,!0))}return n}function lg(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=ng(n.doc,e,o.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new z(I.from(o),0,0))}function ag(n,e,t){let o=n.doc.resolve(e),r=n.doc.resolve(t),s=vc(o,r);for(let i=0;i<s.length;i++){let l=s[i],c=i==s.length-1;if(c&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),r.end(l));if(l>0&&(c||o.node(l-1).canReplace(o.index(l-1),r.indexAfter(l-1))))return n.delete(o.before(l),r.after(l))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&r.end(i)-t!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function vc(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let r=o;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}class Dn extends Pe{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return ge.fail("No node at attribute step's position");let o=Object.create(null);for(let s in t.attrs)o[s]=t.attrs[s];o[this.attr]=this.value;let r=t.type.create(o,null,t.marks);return ge.fromReplace(e,this.pos,this.pos+1,new z(I.from(r),0,t.isLeaf?0:1))}getMap(){return Ue.empty}invert(e){return new Dn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Dn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Dn(t.pos,t.attr,t.value)}}Pe.jsonID("attr",Dn);class po extends Pe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return ge.ok(o)}getMap(){return Ue.empty}invert(e){return new po(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new po(t.attr,t.value)}}Pe.jsonID("docAttr",po);let _n=class extends Error{};_n=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},_n.prototype=Object.create(Error.prototype),_n.prototype.constructor=_n,_n.prototype.name="TransformError";class Mc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new uo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new _n(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 o=0;o<this.mapping.maps.length;o++){let r=this.mapping.maps[o];o&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((s,i,l,c)=>{e=Math.min(e,l),t=Math.max(t,c)})}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,o=z.empty){let r=ir(this.doc,e,t,o);return r&&this.step(r),this}replaceWith(e,t,o){return this.replace(e,t,new z(I.from(o),0,0))}delete(e,t){return this.replace(e,t,z.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return ig(this,e,t,o),this}replaceRangeWith(e,t,o){return lg(this,e,t,o),this}deleteRange(e,t){return ag(this,e,t),this}lift(e,t){return Km(this,e,t),this}join(e,t=1){return tg(this,e,t),this}wrap(e,t){return Gm(this,e,t),this}setBlockType(e,t=e,o,r=null){return Ym(this,e,t,o,r),this}setNodeMarkup(e,t,o=null,r){return Qm(this,e,t,o,r),this}setNodeAttribute(e,t,o){return this.step(new Dn(e,t,o)),this}setDocAttribute(e,t){return this.step(new po(e,t)),this}addNodeMark(e,t){return this.step(new Ft(e,t)),this}removeNodeMark(e,t){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t instanceof re)t.isInSet(o.marks)&&this.step(new hn(e,t));else{let r=o.marks,s,i=[];for(;s=t.isInSet(r);)i.push(new hn(e,s)),r=s.removeFromSet(r);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,o){return Zm(this,e,t,o),this}addMark(e,t,o){return Um(this,e,t,o),this}removeMark(e,t,o){return jm(this,e,t,o),this}clearIncompatible(e,t,o){return Zs(this,e,t,o),this}}const ni=Object.create(null);class Z{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new cg(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=z.empty){let o=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=o,o=o.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:c,$to:d}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(c.pos),u.map(d.pos),l?z.empty:t),l==0&&Ac(e,s,(o?o.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:l}=r[s],c=e.mapping.slice(o),d=c.map(i.pos),u=c.map(l.pos);s?e.deleteRange(d,u):(e.replaceRangeWith(d,u,t),Ac(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let r=e.parent.inlineContent?new Y(e):Ln(e.node(0),e.parent,e.pos,e.index(),t,o);if(r)return r;for(let s=e.depth-1;s>=0;s--){let i=t<0?Ln(e.node(0),e.node(s),e.before(s+1),e.index(s),t,o):Ln(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new je(e.node(0))}static atStart(e){return Ln(e,e,0,0,1)||new je(e)}static atEnd(e){return Ln(e,e,e.content.size,e.childCount,-1)||new je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=ni[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in ni)throw new RangeError("Duplicate use of selection JSON ID "+e);return ni[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Y.between(this.$anchor,this.$head).getBookmark()}}Z.prototype.visible=!0;class cg{constructor(e,t){this.$from=e,this.$to=t}}let Tc=!1;function Nc(n){!Tc&&!n.parent.inlineContent&&(Tc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Y extends Z{constructor(e,t=e){Nc(e),Nc(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return Z.near(o);let r=e.resolve(t.map(this.anchor));return new Y(r.parent.inlineContent?r:o,o)}replace(e,t=z.empty){if(super.replace(e,t),t==z.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof Y&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new lr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Y(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let r=e.resolve(t);return new this(r,o==t?r:e.resolve(o))}static between(e,t,o){let r=e.pos-t.pos;if((!o||r)&&(o=r>=0?1:-1),!t.parent.inlineContent){let s=Z.findFrom(t,o,!0)||Z.findFrom(t,-o,!0);if(s)t=s.$head;else return Z.near(t,o)}return e.parent.inlineContent||(r==0?e=t:(e=(Z.findFrom(e,-o,!0)||Z.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new Y(e,t)}}Z.jsonID("text",Y);class lr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lr(e.map(this.anchor),e.map(this.head))}resolve(e){return Y.between(e.resolve(this.anchor),e.resolve(this.head))}}class q extends Z{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return o?Z.near(s):new q(s)}content(){return new z(I.from(this.node),0,0)}eq(e){return e instanceof q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new oi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new q(e.resolve(t.anchor))}static create(e,t){return new q(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}q.prototype.visible=!1,Z.jsonID("node",q);class oi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new lr(o,o):new oi(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&q.isSelectable(o)?new q(t):Z.near(t)}}class je extends Z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=z.empty){if(t==z.empty){e.delete(0,e.doc.content.size);let o=Z.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new je(e)}map(e){return new je(e)}eq(e){return e instanceof je}getBookmark(){return dg}}Z.jsonID("all",je);const dg={map(){return this},resolve(n){return new je(n)}};function Ln(n,e,t,o,r,s=!1){if(e.inlineContent)return Y.create(n,t);for(let i=o-(r>0?0:1);r>0?i<e.childCount:i>=0;i+=r){let l=e.child(i);if(l.isAtom){if(!s&&q.isSelectable(l))return q.create(n,t-(r<0?l.nodeSize:0))}else{let c=Ln(n,l,t+r,r<0?l.childCount:0,r,s);if(c)return c}t+=l.nodeSize*r}return null}function Ac(n,e,t){let o=n.steps.length-1;if(o<e)return;let r=n.steps[o];if(!(r instanceof we||r instanceof be))return;let s=n.mapping.maps[o],i;s.forEach((l,c,d,u)=>{i==null&&(i=u)}),n.setSelection(Z.near(n.doc.resolve(i),t))}const Bc=1,ar=2,Ic=4;class ug extends Mc{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Bc)&~ar,this.storedMarks=null,this}get selectionSet(){return(this.updated&Bc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ar,this}ensureMarks(e){return re.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&ar)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ar,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||re.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),!e)return this.deleteRange(t,o);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,r.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(Z.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ic,this}get scrolledIntoView(){return(this.updated&Ic)>0}}function Oc(n,e){return!e||!n?n:n.bind(e)}class mo{constructor(e,t,o){this.name=e,this.init=Oc(t.init,o),this.apply=Oc(t.apply,o)}}const fg=[new mo("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new mo("selection",{init(n,e){return n.selection||Z.atStart(e.doc)},apply(n){return n.selection}}),new mo("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new mo("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ri{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fg.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new mo(o.key,o.spec.state,o))})}}class Vn{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 o=0;o<this.config.plugins.length;o++)if(o!=t){let r=this.config.plugins[o];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),r=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let c=r?r[i].n:0,d=r?r[i].state:this,u=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,d,o);if(u&&o.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(let f=0;f<this.config.plugins.length;f++)r.push(f<i?{state:o,n:t.length}:{state:this,n:0})}t.push(u),o=o.applyInner(u),s=!0}r&&(r[i]={state:o,n:t.length})}}if(!s)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Vn(this.config),o=this.config.fields;for(let r=0;r<o.length;r++){let s=o[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new ug(this)}static create(e){let t=new ri(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Vn(t);for(let r=0;r<t.fields.length;r++)o[t.fields[r].name]=t.fields[r].init(e,o);return o}reconfigure(e){let t=new ri(this.schema,e.plugins),o=t.fields,r=new Vn(t);for(let s=0;s<o.length;s++){let i=o[s].name;r[i]=this.hasOwnProperty(i)?this[i]:o[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[o],s=r.spec.state;s&&s.toJSON&&(t[o]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new ri(e.schema,e.plugins),s=new Vn(r);return r.fields.forEach(i=>{if(i.name=="doc")s.doc=St.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=Z.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let c=o[l],d=c.spec.state;if(c.key==i.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=d.fromJSON.call(c,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function Rc(n,e,t){for(let o in n){let r=n[o];r instanceof Function?r=r.bind(e):o=="handleDOMEvents"&&(r=Rc(r,e,{})),t[o]=r}return t}class fe{constructor(e){this.spec=e,this.props={},e.props&&Rc(e.props,this,this.props),this.key=e.key?e.key.key:Pc("plugin")}getState(e){return e[this.key]}}const si=Object.create(null);function Pc(n){return n in si?n+"$"+ ++si[n]:(si[n]=0,n+"$")}class Ce{constructor(e="key"){this.key=Pc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ii=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Dc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const _c=(n,e,t)=>{let o=Dc(n,t);if(!o)return!1;let r=li(o);if(!r){let i=o.blockRange(),l=i&&Pn(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(Wc(n,r,e,-1))return!0;if(o.parent.content.size==0&&($n(s,"end")||q.isSelectable(s)))for(let i=o.depth;;i--){let l=ir(n.doc,o.before(i),o.after(i),z.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection($n(s,"end")?Z.findFrom(c.doc.resolve(c.mapping.map(r.pos,-1)),-1):q.create(c.doc,r.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return s.isAtom&&r.depth==o.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1},hg=(n,e,t)=>{let o=Dc(n,t);if(!o)return!1;let r=li(o);return r?Lc(n,r,e):!1},pg=(n,e,t)=>{let o=$c(n,t);if(!o)return!1;let r=ai(o);return r?Lc(n,r,e):!1};function Lc(n,e,t){let o=e.nodeBefore,r=o,s=e.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let u=r.lastChild;if(!u)return!1;r=u}let i=e.nodeAfter,l=i,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let d=ir(n.doc,s,c,z.empty);if(!d||d.from!=s||d instanceof we&&d.slice.size>=c-s)return!1;if(t){let u=n.tr.step(d);u.setSelection(Y.create(u.doc,s)),t(u.scrollIntoView())}return!0}function $n(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}const Vc=(n,e,t)=>{let{$head:o,empty:r}=n.selection,s=o;if(!r)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;s=li(o)}let i=s&&s.nodeBefore;return!i||!q.isSelectable(i)?!1:(e&&e(n.tr.setSelection(q.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function li(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function $c(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const zc=(n,e,t)=>{let o=$c(n,t);if(!o)return!1;let r=ai(o);if(!r)return!1;let s=r.nodeAfter;if(Wc(n,r,e,1))return!0;if(o.parent.content.size==0&&($n(s,"start")||q.isSelectable(s))){let i=ir(n.doc,o.before(),o.after(),z.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection($n(s,"start")?Z.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):q.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==o.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},Fc=(n,e,t)=>{let{$head:o,empty:r}=n.selection,s=o;if(!r)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;s=ai(o)}let i=s&&s.nodeAfter;return!i||!q.isSelectable(i)?!1:(e&&e(n.tr.setSelection(q.create(n.doc,s.pos)).scrollIntoView()),!0)};function ai(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const mg=(n,e)=>{let t=n.selection,o=t instanceof q,r;if(o){if(t.node.isTextblock||!pn(n.doc,t.from))return!1;r=t.from}else if(r=sr(n.doc,t.from,-1),r==null)return!1;if(e){let s=n.tr.join(r);o&&s.setSelection(q.create(s.doc,r-n.doc.resolve(r).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},gg=(n,e)=>{let t=n.selection,o;if(t instanceof q){if(t.node.isTextblock||!pn(n.doc,t.to))return!1;o=t.to}else if(o=sr(n.doc,t.to,1),o==null)return!1;return e&&e(n.tr.join(o).scrollIntoView()),!0},yg=(n,e)=>{let{$from:t,$to:o}=n.selection,r=t.blockRange(o),s=r&&Pn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},Hc=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
6
|
-
`).scrollIntoView()),!0)};function ci(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const kg=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let r=t.node(-1),s=t.indexAfter(-1),i=ci(r.contentMatchAt(s));if(!i||!r.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,i.createAndFill());c.setSelection(Z.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Uc=(n,e)=>{let t=n.selection,{$from:o,$to:r}=t;if(t instanceof je||o.parent.inlineContent||r.parent.inlineContent)return!1;let s=ci(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(Y.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},jc=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(vt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let o=t.blockRange(),r=o&&Pn(o);return r==null?!1:(e&&e(n.tr.lift(o,r).scrollIntoView()),!0)};function wg(n){return(e,t)=>{let{$from:o,$to:r}=e.selection;if(e.selection instanceof q&&e.selection.node.isBlock)return!o.parentOffset||!vt(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let s=[],i,l,c=!1,d=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){c=o.end(h)==o.pos+(o.depth-h),d=o.start(h)==o.pos-(o.depth-h),l=ci(o.node(h-1).contentMatchAt(o.indexAfter(h-1))),s.unshift(c&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof Y||e.selection instanceof je)&&u.deleteSelection();let f=u.mapping.map(o.pos),p=vt(u.doc,f,s.length,s);if(p||(s[0]=l?{type:l}:null,p=vt(u.doc,f,s.length,s)),!p)return!1;if(u.split(f,s.length,s),!c&&d&&o.node(i).type!=l){let h=u.mapping.map(o.before(i)),m=u.doc.resolve(h);l&&o.node(i-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(o.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const bg=wg(),Cg=(n,e)=>{let{$from:t,to:o}=n.selection,r,s=t.sharedDepth(o);return s==0?!1:(r=t.before(s),e&&e(n.tr.setSelection(q.create(n.doc,r))),!0)};function xg(n,e,t){let o=e.nodeBefore,r=e.nodeAfter,s=e.index();return!o||!r||!o.type.compatibleContent(r.type)?!1:!o.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||pn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Wc(n,e,t,o){let r=e.nodeBefore,s=e.nodeAfter,i,l,c=r.type.spec.isolating||s.type.spec.isolating;if(!c&&xg(n,e,t))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(i=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,m=I.empty;for(let k=i.length-1;k>=0;k--)m=I.from(i[k].create(null,m));m=I.from(r.copy(m));let g=n.tr.step(new be(e.pos-1,h,e.pos,h,new z(m,1,0),i.length,!0)),y=g.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==r.type&&pn(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=s.type.spec.isolating||o>0&&c?null:Z.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),p=f&&Pn(f);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(f,p).scrollIntoView()),!0;if(d&&$n(s,"start",!0)&&$n(r,"end")){let h=r,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=s,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let k=I.empty;for(let C=m.length-1;C>=0;C--)k=I.from(m[C].copy(k));let b=n.tr.step(new be(e.pos-m.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new z(k,m.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Kc(n){return function(e,t){let o=e.selection,r=n<0?o.$from:o.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(Y.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}const Sg=Kc(-1),Eg=Kc(1);function vg(n,e=null){return function(t,o){let{$from:r,$to:s}=t.selection,i=r.blockRange(s),l=i&&gc(i,n,e);return l?(o&&o(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function qc(n,e=null){return function(t,o){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(c,d)=>{if(r)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)r=!0;else{let u=t.doc.resolve(d),f=u.index();r=u.parent.canReplaceWith(f,f+1,n)}})}if(!r)return!1;if(o){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[i];s.setBlockType(l,c,n,e)}o(s.scrollIntoView())}return!0}}function di(...n){return function(e,t,o){for(let r=0;r<n.length;r++)if(n[r](e,t,o))return!0;return!1}}di(ii,_c,Vc),di(ii,zc,Fc),di(Hc,Uc,jc,bg),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Mg(n,e=null){return function(t,o){let{$from:r,$to:s}=t.selection,i=r.blockRange(s);if(!i)return!1;let l=o?t.tr:null;return Tg(l,i,n,e)?(o&&o(l.scrollIntoView()),!0):!1}}function Tg(n,e,t,o=null){let r=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=i.resolve(e.start-2);s=new Zo(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Zo(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=gc(s,t,o,e);return l?(n&&Ng(n,e,l,r,t),!0):!1}function Ng(n,e,t,o,r){let s=I.empty;for(let u=t.length-1;u>=0;u--)s=I.from(t[u].type.create(t[u].attrs,s));n.step(new be(e.start-(o?2:0),e.end,e.start,e.end,new z(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==r&&(i=u+1);let l=t.length-i,c=e.start+t.length-(o?2:0),d=e.parent;for(let u=e.startIndex,f=e.endIndex,p=!0;u<f;u++,p=!1)!p&&vt(n.doc,c,l)&&(n.split(c,l),c+=2*l),c+=d.child(u).nodeSize;return n}function Ag(n){return function(e,t){let{$from:o,$to:r}=e.selection,s=o.blockRange(r,i=>i.childCount>0&&i.firstChild.type==n);return s?t?o.node(s.depth-1).type==n?Bg(e,t,n,s):Ig(e,t,s):!0:!1}}function Bg(n,e,t,o){let r=n.tr,s=o.end,i=o.$to.end(o.depth);s<i&&(r.step(new be(s-1,i,s,i,new z(I.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Zo(r.doc.resolve(o.$from.pos),r.doc.resolve(i),o.depth));const l=Pn(o);if(l==null)return!1;r.lift(o,l);let c=r.doc.resolve(r.mapping.map(s,-1)-1);return pn(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}function Ig(n,e,t){let o=n.tr,r=t.parent;for(let h=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)h-=r.child(m).nodeSize,o.delete(h-1,h+1);let s=o.doc.resolve(t.start),i=s.nodeAfter;if(o.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,c=t.endIndex==r.childCount,d=s.node(-1),u=s.index(-1);if(!d.canReplace(u+(l?0:1),u+1,i.content.append(c?I.empty:I.from(r))))return!1;let f=s.pos,p=f+i.nodeSize;return o.step(new be(f-(l?1:0),p+(c?1:0),f+1,p-1,new z((l?I.empty:I.from(r.copy(I.empty))).append(c?I.empty:I.from(r.copy(I.empty))),l?0:1,c?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Og(n){return function(e,t){let{$from:o,$to:r}=e.selection,s=o.blockRange(r,d=>d.childCount>0&&d.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,c=l.child(i-1);if(c.type!=n)return!1;if(t){let d=c.lastChild&&c.lastChild.type==l.type,u=I.from(d?n.create():null),f=new z(I.from(n.create(null,I.from(l.type.create(null,u)))),d?3:1,0),p=s.start,h=s.end;t(e.tr.step(new be(p-(d?3:1),h,p,h,f,1,!0)).scrollIntoView())}return!0}}const Te=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},zn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let ui=null;const Mt=function(n,e,t){let o=ui||(ui=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Rg=function(){ui=null},mn=function(n,e,t,o){return t&&(Jc(n,e,t,o,-1)||Jc(n,e,t,o,1))},Pg=/^(img|br|input|textarea|hr)$/i;function Jc(n,e,t,o,r){for(var s;;){if(n==t&&e==o)return!0;if(e==(r<0?0:Je(n))){let i=n.parentNode;if(!i||i.nodeType!=1||go(n)||Pg.test(n.nodeName)||n.contentEditable=="false")return!1;e=Te(n)+(r<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(r<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=r;else return!1;else n=i,e=r<0?Je(n):0}else return!1}}function Je(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Dg(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Je(n)}else if(n.parentNode&&!go(n))e=Te(n),n=n.parentNode;else return null}}function _g(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!go(n))e=Te(n)+1,n=n.parentNode;else return null}}function Lg(n,e,t){for(let o=e==0,r=e==Je(n);o||r;){if(n==t)return!0;let s=Te(n);if(n=n.parentNode,!n)return!1;o=o&&s==0,r=r&&s==Je(n)}}function go(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const cr=function(n){return n.focusNode&&mn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function gn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Vg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function $g(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(Je(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(Je(o.startContainer),o.startOffset)}}}const ut=typeof navigator<"u"?navigator:null,Gc=typeof document<"u"?document:null,Ht=ut&&ut.userAgent||"",fi=/Edge\/(\d+)/.exec(Ht),Yc=/MSIE \d/.exec(Ht),hi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Fe=!!(Yc||hi||fi),Ut=Yc?document.documentMode:hi?+hi[1]:fi?+fi[1]:0,Ge=!Fe&&/gecko\/(\d+)/i.test(Ht);Ge&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const pi=!Fe&&/Chrome\/(\d+)/.exec(Ht),Ne=!!pi,Xc=pi?+pi[1]:0,De=!Fe&&!!ut&&/Apple Computer/.test(ut.vendor),Fn=De&&(/Mobile\/\w+/.test(Ht)||!!ut&&ut.maxTouchPoints>2),Ye=Fn||(ut?/Mac/.test(ut.platform):!1),Qc=ut?/Win/.test(ut.platform):!1,Tt=/Android \d/.test(Ht),yo=!!Gc&&"webkitFontSmoothing"in Gc.documentElement.style,zg=yo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Fg(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Nt(n,e){return typeof n=="number"?n:n[e]}function Hg(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function Zc(n,e,t){let o=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=zn(i);continue}let l=i,c=l==s.body,d=c?Fg(s):Hg(l),u=0,f=0;if(e.top<d.top+Nt(o,"top")?f=-(d.top-e.top+Nt(r,"top")):e.bottom>d.bottom-Nt(o,"bottom")&&(f=e.bottom-e.top>d.bottom-d.top?e.top+Nt(r,"top")-d.top:e.bottom-d.bottom+Nt(r,"bottom")),e.left<d.left+Nt(o,"left")?u=-(d.left-e.left+Nt(r,"left")):e.right>d.right-Nt(o,"right")&&(u=e.right-d.right+Nt(r,"right")),u||f)if(c)s.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,m=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-m;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let p=c?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(p))break;i=p=="absolute"?i.offsetParent:zn(i)}}function Ug(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,r;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=t-20){o=l,r=c.top;break}}return{refDOM:o,refTop:r,stack:ed(n.dom)}}function ed(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=zn(o));return e}function jg({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;td(t,o==0?0:o-e)}function td(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:r,left:s}=n[t];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}let Hn=null;function Wg(n){if(n.setActive)return n.setActive();if(Hn)return n.focus(Hn);let e=ed(n);n.focus(Hn==null?{get preventScroll(){return Hn={preventScroll:!0},!0}}:void 0),Hn||(Hn=!1,td(e,0))}function nd(n,e){let t,o=2e8,r,s=0,i=e.top,l=e.top,c,d;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let p;if(u.nodeType==1)p=u.getClientRects();else if(u.nodeType==3)p=Mt(u).getClientRects();else continue;for(let h=0;h<p.length;h++){let m=p[h];if(m.top<=i&&m.bottom>=l){i=Math.max(m.bottom,i),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<o){t=u,o=g,r=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(s=f+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!c&&m.left<=e.left&&m.right>=e.left&&(c=u,d={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(s=f+1)}}return!t&&c&&(t=c,r=d,o=0),t&&t.nodeType==3?Kg(t,r):!t||o&&t.nodeType==1?{node:n,offset:s}:nd(t,r)}function Kg(n,e){let t=n.nodeValue.length,o=document.createRange(),r;for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let i=jt(o,1);if(i.top!=i.bottom&&mi(e,i)){r={node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)};break}}return o.detach(),r||{node:n,offset:0}}function mi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function qg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Jg(n,e,t){let{node:o,offset:r}=nd(e,t),s=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,r,s)}function Gg(n,e,t,o){let r=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&c.left>o.left||c.top>o.top?r=l.posBefore:(!i&&c.right<o.left||c.bottom<o.top)&&(r=l.posAfter),i=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?o.top<(c.top+c.bottom)/2:o.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function od(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let c=0;c<l.length;c++){let d=l[c];if(mi(e,d))return od(i,e,d)}}if((s=(s+1)%o)==r)break}return n}function Yg(n,e){let t=n.dom.ownerDocument,o,r=0,s=$g(t,e.left,e.top);s&&({node:o,offset:r}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let d=n.dom.getBoundingClientRect();if(!mi(e,d)||(i=od(n.dom,e,d),!i))return null}if(De)for(let d=i;o&&d;d=zn(d))d.draggable&&(o=void 0);if(i=qg(i,e),o){if(Ge&&o.nodeType==1&&(r=Math.min(r,o.childNodes.length),r<o.childNodes.length)){let u=o.childNodes[r],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let d;yo&&r&&o.nodeType==1&&(d=o.childNodes[r-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&r--,o==n.dom&&r==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||o.nodeType!=1||o.childNodes[r-1].nodeName!="BR")&&(l=Gg(n,o,r,e))}l==null&&(l=Jg(n,i,e));let c=n.docView.nearestDesc(i,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function rd(n){return n.top<n.bottom||n.left<n.right}function jt(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(rd(o))return o}return Array.prototype.find.call(t,rd)||n.getBoundingClientRect()}const Xg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function sd(n,e,t){let{node:o,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=yo||Ge;if(o.nodeType==3)if(i&&(Xg.test(o.nodeValue)||(t<0?!r:r==o.nodeValue.length))){let c=jt(Mt(o,r,r),t);if(Ge&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let d=jt(Mt(o,r-1,r-1),-1);if(d.top==c.top){let u=jt(Mt(o,r,r+1),-1);if(u.top!=c.top)return ko(u,u.left<d.left)}}return c}else{let c=r,d=r,u=t<0?1:-1;return t<0&&!r?(d++,u=-1):t>=0&&r==o.nodeValue.length?(c--,u=1):t<0?c--:d++,ko(jt(Mt(o,c,d),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==Je(o))){let c=o.childNodes[r-1];if(c.nodeType==1)return gi(c.getBoundingClientRect(),!1)}if(s==null&&r<Je(o)){let c=o.childNodes[r];if(c.nodeType==1)return gi(c.getBoundingClientRect(),!0)}return gi(o.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==Je(o))){let c=o.childNodes[r-1],d=c.nodeType==3?Mt(c,Je(c)-(i?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return ko(jt(d,1),!1)}if(s==null&&r<Je(o)){let c=o.childNodes[r];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?Mt(c,0,i?0:1):c.nodeType==1?c:null:null;if(d)return ko(jt(d,-1),!0)}return ko(jt(o.nodeType==3?Mt(o):o,-t),t>=0)}function ko(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function gi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function id(n,e,t){let o=n.state,r=n.root.activeElement;o!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),r!=n.dom&&r&&r.focus()}}function Qg(n,e,t){let o=e.selection,r=t=="up"?o.$from:o.$to;return id(n,e,()=>{let{node:s}=n.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=sd(n,r.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Mt(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;d<c.length;d++){let u=c[d];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const Zg=/[\u0590-\u08ac]/;function e0(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,s=!r,i=r==o.parent.content.size,l=n.domSelection();return l?!Zg.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:id(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),y=m&&!h.contains(m.nodeType==1?m:m.parentNode)||c==m&&d==g;try{l.collapse(u,f),c&&(c!=u||d!=f)&&l.extend&&l.extend(c,d)}catch{}return p!=null&&(l.caretBidiLevel=p),y}):o.pos==o.start()||o.pos==o.end()}let ld=null,ad=null,cd=!1;function t0(n,e,t){return ld==e&&ad==t?cd:(ld=e,ad=t,cd=t=="up"||t=="down"?Qg(n,e,t):e0(n,e,t))}const Xe=0,dd=1,yn=2,ft=3;class wo{constructor(e,t,o,r){this.parent=e,this.children=t,this.dom=o,this.contentDOM=r,this.dirty=Xe,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){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,o=this.posAtStart;;t++){let r=this.children[t];if(r==e)return o;o+=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,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>Te(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 s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),i;if(s&&(!t||s.node))if(o&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let r=this.children[t],s=o+r.size;if(o==e&&s!=o){for(;!r.border&&r.children.length;)for(let i=0;i<r.children.length;i++){let l=r.children[i];if(l.size){r=l;break}}return r}if(e<s)return r.descAt(e-o-r.border);o=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,r=0;for(let s=0;o<this.children.length;o++){let i=this.children[o],l=s+i.size;if(l>e||i instanceof hd){r=e-s;break}s=l}if(r)return this.children[o].domFromPos(r-this.children[o].border,t);for(let s;o&&!(s=this.children[o-1]).size&&s instanceof ud&&s.side>=0;o--);if(t<=0){let s,i=!0;for(;s=o?this.children[o-1]:null,!(!s||s.dom.parentNode==this.contentDOM);o--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Te(s.dom)+1:0}}else{let s,i=!0;for(;s=o<this.children.length?this.children[o]:null,!(!s||s.dom.parentNode==this.contentDOM);o++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Te(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let i=o,l=0;;l++){let c=this.children[l],d=i+c.size;if(r==-1&&e<=d){let u=i+c.border;if(e>=u&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=Te(p.dom)+1;break}e-=p.size}r==-1&&(r=0)}if(r>-1&&(d>t||l==this.children.length-1)){t=d;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Te(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=d}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,r=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(s>m&&i<y)return g.setSelection(e-m-g.border,t-m-g.border,o,r);m=y}let l=this.domFromPos(e,e?-1:1),c=t==e?l:this.domFromPos(t,t?-1:1),d=o.root.getSelection(),u=o.domSelectionRange(),f=!1;if((Ge||De)&&e==t){let{node:h,offset:m}=l;if(h.nodeType==3){if(f=!!(m&&h.nodeValue[m-1]==`
|
|
7
|
-
`),f&&m==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:Te(y)+1});break}let k=g.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let g=h.childNodes[m-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ge&&u.focusNode&&u.focusNode!=c.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(r=!0)}if(!(r||f&&De)&&mn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&mn(c.node,c.offset,u.focusNode,u.focusOffset))return;let p=!1;if((d.extend||e==t)&&!(f&&Ge)){d.collapse(l.node,l.offset);try{e!=t&&d.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>t){let m=l;l=c,c=m}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,r=0;r<this.children.length;r++){let s=this.children[r],i=o+s.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+s.border,c=i-s.border;if(e>=l&&t<=c){this.dirty=e==o||t==i?yn:dd,e==l&&t==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ft:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?yn:ft}o=i}this.dirty=yn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?yn:dd;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ud extends wo{constructor(e,t,o,r){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Xe&&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}}class n0 extends wo{constructor(e,t,o,r){super(e,[],t,null),this.textDOM=o,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class kn extends wo{constructor(e,t,o,r,s){super(e,[],o,r),this.mark=t,this.spec=s}static create(e,t,o,r){let s=r.nodeViews[t.type.name],i=s&&s(t,r,o);return(!i||!i.dom)&&(i=fn.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new kn(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ft||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ft&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xe){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Xe}}slice(e,t,o){let r=kn.create(this.parent,this.mark,!0,o),s=this.children,i=this.size;t<i&&(s=ki(s,t,i,o)),e>0&&(s=ki(s,0,e,o));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Wt extends wo{constructor(e,t,o,r,s,i,l,c,d){super(e,[],s,i),this.node=t,this.outerDeco=o,this.innerDeco=r,this.nodeDOM=l}static create(e,t,o,r,s,i){let l=s.nodeViews[t.type.name],c,d=l&&l(t,s,()=>{if(!c)return i;if(c.parent)return c.parent.posBeforeChild(c)},o,r),u=d&&d.dom,f=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=fn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=gd(u,o,t),d?c=new o0(e,t,o,r,u,f||null,p,d,s,i+1):t.isText?new dr(e,t,o,r,u,p,s):new Wt(e,t,o,r,u,f||null,p,s,i+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 o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>I.empty)}return e}matchesNode(e,t,o){return this.dirty==Xe&&e.eq(this.node)&&ur(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new s0(this,i&&i.node,e);a0(this.node,this.innerDeco,(d,u,f)=>{d.spec.marks?c.syncToMarks(d.spec.marks,o,e,u):d.type.side>=0&&!f&&c.syncToMarks(u==this.node.childCount?re.none:this.node.child(u).marks,o,e,u),c.placeWidget(d,e,r)},(d,u,f,p)=>{c.syncToMarks(d.marks,o,e,p);let h;c.findNodeMatch(d,u,f,p)||l&&e.state.selection.from>r&&e.state.selection.to<r+d.nodeSize&&(h=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(d,u,f,h,e)||c.updateNextNode(d,u,f,e,p,r)||c.addNode(d,u,f,e,r),r+=d.nodeSize}),c.syncToMarks([],o,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==yn)&&(i&&this.protectLocalComposition(e,i),pd(this.contentDOM,this.children,e),Fn&&c0(this.dom))}localCompositionInfo(e,t){let{from:o,to:r}=e.state.selection;if(!(e.state.selection instanceof Y)||o<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=d0(this.node.content,i,o-t,r-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new n0(this,s,t,r);e.input.compositionNodes.push(i),this.children=ki(this.children,o,o+r.length,e,i)}update(e,t,o,r){return this.dirty==ft||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,r),!0)}updateInner(e,t,o,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(ur(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=md(this.dom,this.nodeDOM,yi(this.outerDeco,this.node,t),yi(e,this.node,t)),this.dom!=o&&(o.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 fd(n,e,t,o,r){gd(o,e,n);let s=new Wt(void 0,n,e,t,o,o,o,r,0);return s.contentDOM&&s.updateChildren(r,0),s}class dr extends Wt{constructor(e,t,o,r,s,i,l){super(e,t,o,r,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,r){return this.dirty==ft||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xe||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=Xe,!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,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new dr(this.parent,r,this.outerDeco,this.innerDeco,s,s,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ft)}get domAtom(){return!1}isText(e){return this.node.text==e}}class hd extends wo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class o0 extends Wt{constructor(e,t,o,r,s,i,l,c,d,u){super(e,t,o,r,s,i,l,d,u),this.spec=c}update(e,t,o,r){if(this.dirty==ft)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,o);return s&&this.updateInner(e,t,o,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,r){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,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 pd(n,e,t){let o=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=yd(o),r=!0;o=o.nextSibling}else r=!0,n.insertBefore(l,o);if(i instanceof kn){let c=o?o.previousSibling:n.lastChild;pd(i.contentDOM,i.children,t),o=c?c.nextSibling:n.firstChild}}for(;o;)o=yd(o),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}const bo=function(n){n&&(this.nodeName=n)};bo.prototype=Object.create(null);const wn=[new bo];function yi(n,e,t){if(n.length==0)return wn;let o=t?wn[0]:new bo,r=[o];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&r.push(o=new bo(i.nodeName));for(let l in i){let c=i[l];c!=null&&(t&&r.length==1&&r.push(o=new bo(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+c:l=="style"?o.style=(o.style?o.style+";":"")+c:l!="nodeName"&&(o[l]=c))}}}return r}function md(n,e,t,o){if(t==wn&&o==wn)return e;let r=e;for(let s=0;s<o.length;s++){let i=o[s],l=t[s];if(s){let c;l&&l.nodeName==i.nodeName&&r!=n&&(c=r.parentNode)&&c.nodeName.toLowerCase()==i.nodeName||(c=document.createElement(i.nodeName),c.pmIsDeco=!0,c.appendChild(r),l=wn[0]),r=c}r0(r,l||wn[0],i)}return r}function r0(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.remove(o[s]);for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=o.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function gd(n,e,t){return md(n,n,wn,yi(e,t,n.nodeType!=1))}function ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function yd(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class s0{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=i0(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o,r){let s=0,i=this.stack.length>>1,l=Math.min(i,e.length);for(;s<l&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let c=-1,d=this.top.children.length;r<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let u=this.index;u<d;u++){let f=this.top.children[u];if(f.matchesMark(e[i])&&!this.isLocked(f.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=kn.create(this.top,e[i],t,o);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,o,r){let s=-1,i;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let d=this.top.children[l];if(d.matchesNode(e,t,o)&&!this.preMatch.matched.has(d)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,o,r,s){let i=this.top.children[r];return i.dirty==ft&&i.dom==i.contentDOM&&(i.dirty=yn),i.update(e,t,o,s)?(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 o=e.pmViewDesc;if(o){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==o)return r}return-1}e=t}}updateNextNode(e,t,o,r,s,i){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Wt){let d=this.preMatch.matched.get(c);if(d!=null&&d!=s)return!1;let u=c.dom,f,p=this.isLocked(u)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=ft&&ur(t,c.outerDeco));if(!p&&c.update(e,t,o,r))return this.destroyBetween(this.index,l),c.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(c,e,t,o,r,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=yn,f.updateChildren(r,i+1),f.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,r,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ur(o,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=Wt.create(this.top,t,o,r,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,t,o,r,s){let i=Wt.create(this.top,e,t,o,r,s);i.contentDOM&&i.updateChildren(r,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,o){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 s=new ud(this.top,e,t,o);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof kn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof dr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((De||Ne)&&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 o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let r=new hd(this.top,[],o,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function i0(n,e){let t=e,o=t.children.length,r=n.childCount,s=new Map,i=[];e:for(;r>0;){let l;for(;;)if(o){let d=t.children[o-1];if(d instanceof kn)t=d,o=d.children.length;else{l=d,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(r-1))break;--r,s.set(l,r),i.push(l)}}return{index:r,matched:s,matches:i.reverse()}}function l0(n,e){return n.type.side-e.type.side}function a0(n,e,t,o){let r=e.locals(n),s=0;if(r.length==0){for(let d=0;d<n.childCount;d++){let u=n.child(d);o(u,r,e.forChild(s,u),d),s+=u.nodeSize}return}let i=0,l=[],c=null;for(let d=0;;){let u,f;for(;i<r.length&&r[i].to==s;){let y=r[i++];y.widget&&(u?(f||(f=[u])).push(y):u=y)}if(u)if(f){f.sort(l0);for(let y=0;y<f.length;y++)t(f[y],d,!!c)}else t(u,d,!!c);let p,h;if(c)h=-1,p=c,c=null;else if(d<n.childCount)h=d,p=n.child(d++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;i<r.length&&r[i].from<=s&&r[i].to>s;)l.push(r[i++]);let m=s+p.nodeSize;if(p.isText){let y=m;i<r.length&&r[i].from<y&&(y=r[i].from);for(let k=0;k<l.length;k++)l[k].to<y&&(y=l[k].to);y<m&&(c=p.cut(y-s),p=p.cut(0,y-s),m=y,h=-1)}else for(;i<r.length&&r[i].to<m;)i++;let g=p.isInline&&!p.isLeaf?l.filter(y=>!y.inline):l.slice();o(p,g,e.forChild(s,p),h),s=m}}function c0(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function d0(n,e,t,o){for(let r=0,s=0;r<n.childCount&&s<=o;){let i=n.child(r++),l=s;if(s+=i.nodeSize,!i.isText)continue;let c=i.text;for(;r<n.childCount;){let d=n.child(r++);if(s+=d.nodeSize,!d.isText)break;c+=d.text}if(s>=t){if(s>=o&&c.slice(o-e.length-l,o-l)==e)return o-e.length;let d=l<o?c.lastIndexOf(e,o-l-1):-1;if(d>=0&&d+e.length+l>=t)return l+d;if(t==o&&c.length>=o+e.length-l&&c.slice(o-l,o-l+e.length)==e)return o}}return-1}function ki(n,e,t,o,r){let s=[];for(let i=0,l=0;i<n.length;i++){let c=n[i],d=l,u=l+=c.size;d>=t||u<=e?s.push(c):(d<e&&s.push(c.slice(0,e-d,o)),r&&(s.push(r),r=void 0),u>t&&s.push(c.slice(t-d,c.size,o)))}return s}function wi(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),c,d;if(cr(t)){for(c=i;r&&!r.node;)r=r.parent;let f=r.node;if(r&&f.isAtom&&q.isSelectable(f)&&r.parent&&!(f.isInline&&Lg(t.focusNode,t.focusOffset,r.dom))){let p=r.posBefore;d=new q(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,p=i;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;[c,i]=p==n.state.selection.anchor?[p,f]:[f,p],l=o.resolve(i)}else c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let u=o.resolve(c);if(!d){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;d=Ci(n,u,l,f)}return d}function kd(n){return n.editable?n.hasFocus():vd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function At(n,e=!1){let t=n.state.selection;if(xd(n,t),!!kd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Ne){let o=n.domSelectionRange(),r=n.domObserver.currentSelection;if(o.anchorNode&&r.anchorNode&&mn(o.anchorNode,o.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)f0(n);else{let{anchor:o,head:r}=t,s,i;wd&&!(t instanceof Y)&&(t.$from.parent.inlineContent||(s=bd(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=bd(n,t.to))),n.docView.setSelection(o,r,n,e),wd&&(s&&Cd(s),i&&Cd(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&u0(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const wd=De||Ne&&Xc<63;function bd(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),r=o<t.childNodes.length?t.childNodes[o]:null,s=o?t.childNodes[o-1]:null;if(De&&r&&r.contentEditable=="false")return bi(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return bi(r);if(s)return bi(s)}}function bi(n){return n.contentEditable="true",De&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Cd(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function u0(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!kd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function f0(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,o=t.nodeName=="IMG";o?e.collapse(t.parentNode,Te(t)+1):e.collapse(t,0),!o&&!n.state.selection.visible&&Fe&&Ut<=11&&(t.disabled=!0,t.disabled=!1)}function xd(n,e){if(e instanceof q){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Sd(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Sd(n)}function Sd(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ci(n,e,t,o){return n.someProp("createSelectionBetween",r=>r(n,e,t))||Y.between(e,t,o)}function Ed(n){return n.editable&&!n.hasFocus()?!1:vd(n)}function vd(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function h0(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return mn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function xi(n,e){let{$anchor:t,$head:o}=n.selection,r=e>0?t.max(o):t.min(o),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&Z.findFrom(s,e)}function Kt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Md(n,e,t){let o=n.state.selection;if(o instanceof Y)if(t.indexOf("s")>-1){let{$head:r}=o,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return Kt(n,new Y(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=xi(n.state,e);return r&&r instanceof q?Kt(n,r):!1}else if(!(Ye&&t.indexOf("m")>-1)){let r=o.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?q.isSelectable(s)?Kt(n,new q(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):yo?Kt(n,new Y(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(o instanceof q&&o.node.isInline)return Kt(n,new Y(e>0?o.$to:o.$from));{let r=xi(n.state,e);return r?Kt(n,r):!1}}}function fr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Co(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Un(n,e){return e<0?p0(n):m0(n)}function p0(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let r,s,i=!1;for(Ge&&t.nodeType==1&&o<fr(t)&&Co(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Co(l,-1))r=t,s=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(Td(t))break;{let l=t.previousSibling;for(;l&&Co(l,-1);)r=t.parentNode,s=Te(l),l=l.previousSibling;if(l)t=l,o=fr(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?Si(n,t,o):r&&Si(n,r,s)}function m0(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let r=fr(t),s,i;for(;;)if(o<r){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Co(l,1))s=t,i=++o;else break}else{if(Td(t))break;{let l=t.nextSibling;for(;l&&Co(l,1);)s=l.parentNode,i=Te(l)+1,l=l.nextSibling;if(l)t=l,o=0,r=fr(t);else{if(t=t.parentNode,t==n.dom)break;o=r=0}}}s&&Si(n,s,i)}function Td(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function g0(n,e){for(;n&&e==n.childNodes.length&&!go(n);)e=Te(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function y0(n,e){for(;n&&!e&&!go(n);)e=Te(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Si(n,e,t){if(e.nodeType!=3){let s,i;(i=g0(e,t))?(e=i,t=0):(s=y0(e,t))&&(e=s,t=s.nodeValue.length)}let o=n.domSelection();if(!o)return;if(cr(o)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),o.removeAllRanges(),o.addRange(s)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&At(n)},50)}function Nd(n,e){let t=n.state.doc.resolve(e);if(!(Ne||Qc)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ad(n,e,t){let o=n.state.selection;if(o instanceof Y&&!o.empty||t.indexOf("s")>-1||Ye&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=o;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=xi(n.state,e);if(i&&i instanceof q)return Kt(n,i)}if(!r.parent.inlineContent){let i=e<0?r:s,l=o instanceof je?Z.near(i,e):Z.findFrom(i,e);return l?Kt(n,l):!1}return!1}function Bd(n,e){if(!(n.state.selection instanceof Y))return!0;let{$head:t,$anchor:o,empty:r}=n.state.selection;if(!t.sameParent(o))return!0;if(!r)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function Id(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function k0(n){if(!De||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let o=e.firstChild;Id(n,o,"true"),setTimeout(()=>Id(n,o,"false"),20)}return!1}function w0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function b0(n,e){let t=e.keyCode,o=w0(e);if(t==8||Ye&&t==72&&o=="c")return Bd(n,-1)||Un(n,-1);if(t==46&&!e.shiftKey||Ye&&t==68&&o=="c")return Bd(n,1)||Un(n,1);if(t==13||t==27)return!0;if(t==37||Ye&&t==66&&o=="c"){let r=t==37?Nd(n,n.state.selection.from)=="ltr"?-1:1:-1;return Md(n,r,o)||Un(n,r)}else if(t==39||Ye&&t==70&&o=="c"){let r=t==39?Nd(n,n.state.selection.from)=="ltr"?1:-1:1;return Md(n,r,o)||Un(n,r)}else{if(t==38||Ye&&t==80&&o=="c")return Ad(n,-1,o)||Un(n,-1);if(t==40||Ye&&t==78&&o=="c")return k0(n)||Ad(n,1,o)||Un(n,1);if(o==(Ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ei(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&o.childCount==1&&o.firstChild.childCount==1;){r--,s--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||fn.fromSchema(n.state.schema),l=$d(),c=l.createElement("div");c.appendChild(i.serializeFragment(o,{document:l}));let d=c.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=Ld[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=l.createElement(u[h]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),f++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${r} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
8
|
-
|
|
9
|
-
`);return{dom:c,text:p,slice:e}}function
|
|
10
|
-
`))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",p=>p(e,r,o,n));if(f)l=f;else{let p=r.marks(),{schema:h}=n.state,m=fn.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(h.text(g,p)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=E0(t),yo&&v0(i);let d=i&&i.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Et.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(c||u),context:r,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!C0.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=M0(_d(l,+u[1],+u[2]),u[4]);else if(l=z.maxOpen(x0(l.content,r),!0),l.openStart||l.openEnd){let f=0,p=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=_d(l,f,p)}return n.someProp("transformPasted",f=>{l=f(l,n,c)}),l}const C0=/^(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 x0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let c=r.findWrapping(l.type),d;if(!c)return i=null;if(d=i.length&&s.length&&Pd(c,s,l,i[i.length-1],0))i[i.length-1]=d;else{i.length&&(i[i.length-1]=Dd(i[i.length-1],s.length));let u=Rd(l,c);i.push(u),r=r.matchType(u.type),s=c}}),i)return I.from(i)}return n}function Rd(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,I.from(n));return n}function Pd(n,e,t,o,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=Pd(n,e,t,o.lastChild,r+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(r==n.length-1?t.type:n[r+1]))return o.copy(o.content.append(I.from(Rd(t,n,r+1))))}}function Dd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Dd(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(I.empty,!0);return n.copy(t.append(o))}function vi(n,e,t,o,r,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),r<o-1&&(l=vi(l,e,t,o,r+1,s)),r>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(I.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function _d(n,e,t){return e<n.openStart&&(n=new z(vi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new z(vi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ld={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Vd=null;function $d(){return Vd||(Vd=document.implementation.createHTMLDocument("title"))}let Mi=null;function S0(n){let e=window.trustedTypes;return e?(Mi||(Mi=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Mi.createHTML(n)):n}function E0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=$d().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),r;if((r=o&&Ld[o[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=S0(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function v0(n){let e=n.querySelectorAll(Ne?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function M0(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let c=t.nodes[o[l]];if(!c||c.hasRequiredAttrs())break;r=I.from(c.create(o[l+1],r)),s++,i++}return new z(r,s,i)}const Ve={},$e={},T0={touchstart:!0,touchmove:!0};class N0{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 A0(n){for(let e in Ve){let t=Ve[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{I0(n,o)&&!Ni(n,o)&&(n.editable||!(o.type in $e))&&t(n,o)},T0[e]?{passive:!0}:void 0)}De&&n.dom.addEventListener("input",()=>null),Ti(n)}function qt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function B0(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ti(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Ni(n,o))})}function Ni(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function I0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function O0(n,e){!Ni(n,e)&&Ve[e.type]&&(n.editable||!(e.type in $e))&&Ve[e.type](n,e)}$e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Fd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Tt&&Ne&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Fn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",r=>r(n,gn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||b0(n,t)?t.preventDefault():qt(n,"key")},$e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},$e.keypress=(n,e)=>{let t=e;if(Fd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ye&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof Y)||!o.$from.sameParent(o.$to)){let r=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",i=>i(n,o.$from.pos,o.$to.pos,r,s))&&n.dispatch(s()),t.preventDefault()}};function hr(n){return{left:n.clientX,top:n.clientY}}function R0(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Ai(n,e,t,o,r){if(o==-1)return!1;let s=n.state.doc.resolve(o);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),r,!0):l(n,t,s.node(i),s.before(i),r,!1)))return!0;return!1}function jn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function P0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&q.isSelectable(o)?(jn(n,new q(t)),!0):!1}function D0(n,e){if(e==-1)return!1;let t=n.state.selection,o,r;t instanceof q&&(o=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(q.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(i);break}}return r!=null?(jn(n,q.create(n.state.doc,r)),!0):!1}function _0(n,e,t,o,r){return Ai(n,"handleClickOn",e,t,o)||n.someProp("handleClick",s=>s(n,e,o))||(r?D0(n,t):P0(n,t))}function L0(n,e,t,o){return Ai(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",r=>r(n,e,o))}function V0(n,e,t,o){return Ai(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",r=>r(n,e,o))||$0(n,t,o)}function $0(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(jn(n,Y.create(o,0,o.content.size)),!0):!1;let r=o.resolve(e);for(let s=r.depth+1;s>0;s--){let i=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(i.inlineContent)jn(n,Y.create(o,l+1,l+1+i.content.size));else if(q.isSelectable(i))jn(n,q.create(o,l));else continue;return!0}}function Bi(n){return pr(n)}const zd=Ye?"metaKey":"ctrlKey";Ve.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=Bi(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&R0(t,n.input.lastClick)&&!t[zd]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s,button:t.button};let i=n.posAtCoords(hr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new z0(n,i,t,!!o)):(s=="doubleClick"?L0:V0)(n,i.pos,i.inside,t)?t.preventDefault():qt(n,"pointer"))};class z0{constructor(e,t,o,r){this.view=e,this.pos=t,this.event=o,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!o[zd],this.allowDefault=o.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=r?null:o.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=e.state;(o.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof q&&d.from<=i&&d.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!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)),qt(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(()=>At(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(hr(e))),this.updateAllowDefault(e),this.allowDefault||!t?qt(this.view,"pointer"):_0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||De&&this.mightDrag&&!this.mightDrag.node.isAtom||Ne&&!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)?(jn(this.view,Z.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):qt(this.view,"pointer")}move(e){this.updateAllowDefault(e),qt(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)}}Ve.touchstart=n=>{n.input.lastTouch=Date.now(),Bi(n),qt(n,"pointer")},Ve.touchmove=n=>{n.input.lastTouch=Date.now(),qt(n,"pointer")},Ve.contextmenu=n=>Bi(n);function Fd(n,e){return n.composing?!0:De&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const F0=Tt?5e3:-1;$e.compositionstart=$e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof Y&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||Ne&&Qc&&H0(n)))n.markCursor=n.state.storedMarks||t.marks(),pr(n,!0),n.markCursor=null;else if(pr(n,!e.selection.empty),Ge&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let r=o.focusNode,s=o.focusOffset;r&&r.nodeType==1&&s!=0;){let i=s<0?r.lastChild:r.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else r=i,s=-1}}n.input.composing=!0}Hd(n,F0)};function H0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let o=e.childNodes[t];return o.nodeType==1&&o.contentEditable=="false"}$e.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Hd(n,20))};function Hd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>pr(n),e))}function Ud(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=j0());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function U0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Dg(e.focusNode,e.focusOffset),o=_g(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let r=o.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||o==s)return s;if(!r||!r.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function j0(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function pr(n,e=!1){if(!(Tt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ud(n),e||n.docView&&n.docView.dirty){let t=wi(n),o=n.state.selection;return t&&!t.eq(o)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function W0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const xo=Fe&&Ut<15||Fn&&zg<604;Ve.copy=$e.cut=(n,e)=>{let t=e,o=n.state.selection,r=t.type=="cut";if(o.empty)return;let s=xo?null:t.clipboardData,i=o.content(),{dom:l,text:c}=Ei(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):W0(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function K0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function q0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?So(n,o.value,null,r,e):So(n,o.textContent,o.innerHTML,r,e)},50)}function So(n,e,t,o,r){let s=Od(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,r,s||z.empty)))return!0;if(!s)return!1;let i=K0(s),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function jd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$e.paste=(n,e)=>{let t=e;if(n.composing&&!Tt)return;let o=xo?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&So(n,jd(o),o.getData("text/html"),r,t)?t.preventDefault():q0(n,t)};class Wd{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const J0=Ye?"altKey":"ctrlKey";function Kd(n,e){let t=n.someProp("dragCopies",o=>!o(e));return t??!e[J0]}Ve.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(hr(t)),i;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof q?r.to-1:r.to))){if(o&&o.mightDrag)i=q.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=q.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:c,text:d,slice:u}=Ei(n,l);(!t.dataTransfer.files.length||!Ne||Xc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(xo?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",xo||t.dataTransfer.setData("text/plain",d),n.dragging=new Wd(u,Kd(n,t),i)},Ve.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},$e.dragover=$e.dragenter=(n,e)=>e.preventDefault(),$e.drop=(n,e)=>{try{G0(n,e,n.dragging)}finally{n.dragging=null}};function G0(n,e,t){if(!e.dataTransfer)return;let o=n.posAtCoords(hr(e));if(!o)return;let r=n.state.doc.resolve(o.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=Od(n,jd(e.dataTransfer),xo?null:e.dataTransfer.getData("text/html"),!1,r);let i=!!(t&&Kd(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||z.empty,i))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Cc(n.state.doc,r.pos,s):r.pos;l==null&&(l=r.pos);let c=n.state.tr;if(i){let{node:h}=t;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(f))return;let p=c.doc.resolve(d);if(u&&q.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new q(p));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,k)=>h=k),c.setSelection(Ci(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}Ve.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&At(n)},20))},Ve.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Ve.beforeinput=(n,e)=>{if(Ne&&Tt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,gn(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in $e)Ve[n]=$e[n];function Eo(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class mr{constructor(e,t){this.toDOM=e,this.spec=t||bn,this.side=this.spec.side||0}map(e,t,o,r){let{pos:s,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new ze(s-o,s-o,this)}valid(){return!0}eq(e){return this==e||e instanceof mr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Eo(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Jt{constructor(e,t){this.attrs=e,this.spec=t||bn}map(e,t,o,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-o;return s>=i?null:new ze(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Jt&&Eo(this.attrs,e.attrs)&&Eo(this.spec,e.spec)}static is(e){return e.type instanceof Jt}destroy(){}}class Ii{constructor(e,t){this.attrs=e,this.spec=t||bn}map(e,t,o,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=s.pos?null:new ze(s.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(o)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof Ii&&Eo(this.attrs,e.attrs)&&Eo(this.spec,e.spec)}destroy(){}}class ze{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new ze(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new ze(e,e,new mr(t,o))}static inline(e,t,o,r){return new ze(e,t,new Jt(o,r))}static node(e,t,o,r){return new ze(e,t,new Ii(o,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Jt}get widget(){return this.type instanceof mr}}const Wn=[],bn={};class de{constructor(e,t){this.local=e.length?e:Wn,this.children=t.length?t:Wn}static create(e,t){return t.length?gr(t,e,0,bn):_e}find(e,t,o){let r=[];return this.findInner(e??0,t??1e9,r,0,o),r}findInner(e,t,o,r,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&o.push(l.copy(l.from+r,l.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,r+l,s)}}map(e,t,o){return this==_e||e.maps.length==0?this:this.mapInner(e,t,0,0,o||bn)}mapInner(e,t,o,r,s){let i;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,o,r);c&&c.type.valid(t,c)?(i||(i=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Y0(this.children,i||[],e,t,o,r,s):i?new de(i.sort(Cn),Wn):_e}add(e,t){return t.length?this==_e?de.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let r,s=0;e.forEach((l,c)=>{let d=c+o,u;if(u=Jd(t,l,d)){for(r||(r=this.children.slice());s<r.length&&r[s]<c;)s+=3;r[s]==c?r[s+2]=r[s+2].addInner(l,u,d+1):r.splice(s,0,c,c+l.nodeSize,gr(u,l,d+1,bn)),s+=3}});let i=qd(s?Gd(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new de(i.length?this.local.concat(i).sort(Cn):this.local,r||this.children)}remove(e){return e.length==0||this==_e?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,r=this.local;for(let s=0;s<o.length;s+=3){let i,l=o[s]+t,c=o[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<c&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;o==this.children&&(o=this.children.slice());let d=o[s+2].removeInner(i,l+1);d!=_e?o[s+2]=d:(o.splice(s,3),s-=3)}if(r.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<r.length;l++)r[l].eq(i,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return o==this.children&&r==this.local?this:r.length||o.length?new de(r,o):_e}forChild(e,t){if(this==_e)return this;if(t.isLeaf)return de.empty;let o,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<i&&c.to>s&&c.type instanceof Jt){let d=Math.max(s,c.from)-s,u=Math.min(i,c.to)-s;d<u&&(r||(r=[])).push(c.copy(d,u))}}if(r){let l=new de(r.sort(Cn),Wn);return o?new Gt([l,o]):l}return o||_e}eq(e){if(this==e)return!0;if(!(e instanceof de)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Oi(this.localsInner(e))}localsInner(e){if(this==_e)return Wn;if(e.inlineContent||!this.local.some(Jt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Jt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}de.empty=new de([],[]),de.removeOverlap=Oi;const _e=de.empty;class Gt{constructor(e){this.members=e}map(e,t){const o=this.members.map(r=>r.map(e,t,bn));return Gt.from(o)}forChild(e,t){if(t.isLeaf)return de.empty;let o=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=_e&&(s instanceof Gt?o=o.concat(s.members):o.push(s))}return Gt.from(o)}eq(e){if(!(e instanceof Gt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{o&&(t=t.slice(),o=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Oi(o?t:t.sort(Cn)):Wn}static from(e){switch(e.length){case 0:return _e;case 1:return e[0];default:return new Gt(e.every(t=>t instanceof de)?e:e.reduce((t,o)=>t.concat(o instanceof de?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Y0(n,e,t,o,r,s,i){let l=n.slice();for(let d=0,u=s;d<t.maps.length;d++){let f=0;t.maps[d].forEach((p,h,m,g)=>{let y=g-m-(h-p);for(let k=0;k<l.length;k+=3){let b=l[k+1];if(b<0||p>b+u-f)continue;let C=l[k]+u-f;h>=C?l[k+1]=p<=C?-2:-1:p>=u&&y&&(l[k]+=y,l[k+1]+=y)}f+=y}),u=t.maps[d].map(u,-1)}let c=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){c=!0,l[d+1]=-1;continue}let u=t.map(n[d]+s),f=u-r;if(f<0||f>=o.content.size){c=!0;continue}let p=t.map(n[d+1]+s,-1),h=p-r,{index:m,offset:g}=o.content.findIndex(f),y=o.maybeChild(m);if(y&&g==f&&g+y.nodeSize==h){let k=l[d+2].mapInner(t,y,u+1,n[d]+s+1,i);k!=_e?(l[d]=f,l[d+1]=h,l[d+2]=k):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=X0(l,n,e,t,r,s,i),u=gr(d,o,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let h=u.children[f];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new de(e.sort(Cn),l)}function qd(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let r=n[o];t.push(new ze(r.from+e,r.to+e,r.type))}return t}function X0(n,e,t,o,r,s,i){function l(c,d){for(let u=0;u<c.local.length;u++){let f=c.local[u].map(o,r,d);f?t.push(f):i.onRemove&&i.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)l(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&l(n[c+2],e[c]+s+1);return t}function Jd(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,r=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<o&&((r||(r=[])).push(i),n[s]=null);return r}function Gd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function gr(n,e,t,o){let r=[],s=!1;e.forEach((l,c)=>{let d=Jd(n,l,c+t);if(d){s=!0;let u=gr(d,l,t+c+1,o);u!=_e&&r.push(c,c+l.nodeSize,u)}});let i=qd(s?Gd(n):n,-t).sort(Cn);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||r.length?new de(i,r):_e}function Cn(n,e){return n.from-e.from||n.to-e.to}function Oi(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==o.from){s.to!=o.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,o.to),Yd(e,r+1,s.copy(o.to,s.to)));continue}else{s.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,s.from),Yd(e,r,o.copy(s.from,o.to)));break}}}return e}function Yd(n,e,t){for(;e<n.length&&Cn(t,n[e])>0;)e++;n.splice(e,0,t)}function Ri(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=_e&&e.push(o)}),n.cursorWrapper&&e.push(de.create(n.state.doc,[n.cursorWrapper.deco])),Gt.from(e)}const Q0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Z0=Fe&&Ut<=11;class e1{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class t1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new e1,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let r=0;r<o.length;r++)this.queue.push(o[r]);Fe&&Ut<=11&&o.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():De&&e.composing&&o.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Z0&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.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,Q0)),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(Ed(this.view)){if(this.suppressingSelectionUpdates)return At(this.view);if(Fe&&Ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&mn(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,o;for(let s=e.focusNode;s;s=zn(s))t.add(s);for(let s=e.anchorNode;s;s=zn(s))if(t.has(s)){o=s;break}let r=o&&this.view.docView.nearestDesc(o);if(r&&r.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))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 o=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Ed(e)&&!this.ignoreSelectionChange(o),s=-1,i=-1,l=!1,c=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],c);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(c.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(Ge&&c.length){let u=c.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,p]=u;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of u){let h=p.parentNode;h&&h.nodeName=="LI"&&(!f||r1(e,f)!=h)&&p.remove()}}}let d=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&cr(o)&&(d=wi(e))&&d.eq(Z.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,At(e),this.currentSelection.set(o),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,i),n1(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,s1(e,c)),this.handleDOMChange(s,i,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||At(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let r=e.previousSibling,s=e.nextSibling;if(Fe&&Ut<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:p}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p)}let i=r&&r.parentNode==e.target?Te(r)+1:0,l=o.localPosFromDOM(e.target,i,-1),c=s&&s.parentNode==e.target?Te(s):e.target.childNodes.length,d=o.localPosFromDOM(e.target,c,1);return{from:l,to:d}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Xd=new WeakMap,Qd=!1;function n1(n){if(!Xd.has(n)&&(Xd.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ge,Qd)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."),Qd=!0}}function Zd(n,e){let t=e.startContainer,o=e.startOffset,r=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return mn(i.node,i.offset,r,s)&&([t,o,r,s]=[r,s,t,o]),{anchorNode:t,anchorOffset:o,focusNode:r,focusOffset:s}}function o1(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Zd(n,r)}let t;function o(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?Zd(n,t):null}function r1(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function s1(n,e){var t;let{focusNode:o,focusOffset:r}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let i=s.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let l=i;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(s,l.firstChild),o==s&&n.domSelection().collapse(s,r)}else s.parentNode.removeChild(s)}}function i1(n,e,t){let{node:o,fromOffset:r,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),c=n.domSelectionRange(),d,u=c.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:c.anchorOffset}],cr(c)||d.push({node:c.focusNode,offset:c.focusOffset})),Ne&&n.input.lastKeyCode===8)for(let y=s;y>r;y--){let k=o.childNodes[y-1],b=k.pmViewDesc;if(k.nodeName=="BR"&&!b){s=y;break}if(!b||b.size)break}let f=n.state.doc,p=n.someProp("domParser")||Et.fromSchema(n.state.schema),h=f.resolve(i),m=null,g=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:r,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:l1,context:h});if(d&&d[0].pos!=null){let y=d[0].pos,k=d[1]&&d[1].pos;k==null&&(k=y),m={anchor:y+i,head:k+i}}return{doc:g,sel:m,from:i,to:l}}function l1(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(De&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||De&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const a1=/^(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 c1(n,e,t,o,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let S=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,v=wi(n,S);if(v&&!n.state.selection.eq(v)){if(Ne&&Tt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",B=>B(n,gn(13,"Enter"))))return;let T=n.state.tr.setSelection(v);S=="pointer"?T.setMeta("pointer",!0):S=="key"&&T.scrollIntoView(),s&&T.setMeta("composition",s),n.dispatch(T)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,d=i1(n,e,t),u=n.state.doc,f=u.slice(d.from,d.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=f1(f.content,d.doc.content,d.from,p,h);if(m&&n.input.domChangeCount++,(Fn&&n.input.lastIOSEnter>Date.now()-225||Tt)&&r.some(S=>S.nodeType==1&&!a1.test(S.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",S=>S(n,gn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof Y&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let S=eu(n,n.state.doc,d.sel);if(S&&!S.eq(n.state.selection)){let v=n.state.tr.setSelection(S);s&&v.setMeta("composition",s),n.dispatch(v)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof Y&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),Fe&&Ut<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>d.from&&d.doc.textBetween(m.start-d.from-1,m.start-d.from+1)==" "&&(m.start--,m.endA--,m.endB--);let g=d.doc.resolveNoCache(m.start-d.from),y=d.doc.resolveNoCache(m.endB-d.from),k=u.resolve(m.start),b=g.sameParent(y)&&g.parent.inlineContent&&k.end()>=m.endA;if((Fn&&n.input.lastIOSEnter>Date.now()-225&&(!b||r.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!b&&g.pos<d.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(d.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",S=>S(n,gn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&u1(u,m.start,m.endA,g,y)&&n.someProp("handleKeyDown",S=>S(n,gn(8,"Backspace")))){Tt&&Ne&&n.domObserver.suppressSelectionUpdates();return}Ne&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Tt&&!b&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,y=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(S){return S(n,gn(13,"Enter"))})},20));let C=m.start,x=m.endA,E=S=>{let v=S||n.state.tr.replace(C,x,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let T=eu(n,v.doc,d.sel);T&&!(Ne&&n.composing&&T.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(T.head==C||T.head==v.mapping.map(x)-1)||Fe&&T.empty&&T.head==C)&&v.setSelection(T)}return s&&v.setMeta("composition",s),v.scrollIntoView()},M;if(b)if(g.pos==y.pos){Fe&&Ut<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>At(n),20));let S=E(n.state.tr.delete(C,x)),v=u.resolve(m.start).marksAcross(u.resolve(m.endA));v&&S.ensureMarks(v),n.dispatch(S)}else if(m.endA==m.endB&&(M=d1(g.parent.content.cut(g.parentOffset,y.parentOffset),k.parent.content.cut(k.parentOffset,m.endA-k.start())))){let S=E(n.state.tr);M.type=="add"?S.addMark(C,x,M.mark):S.removeMark(C,x,M.mark),n.dispatch(S)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let S=g.parent.textBetween(g.parentOffset,y.parentOffset),v=()=>E(n.state.tr.insertText(S,C,x));n.someProp("handleTextInput",T=>T(n,C,x,S,v))||n.dispatch(v())}else n.dispatch(E());else n.dispatch(E())}function eu(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ci(n,e.resolve(t.anchor),e.resolve(t.head))}function d1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,r=t,s=o,i,l,c;for(let u=0;u<o.length;u++)r=o[u].removeFromSet(r);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],i="add",c=u=>u.mark(l.addToSet(u.marks));else if(r.length==0&&s.length==1)l=s[0],i="remove",c=u=>u.mark(l.removeFromSet(u.marks));else return null;let d=[];for(let u=0;u<e.childCount;u++)d.push(c(e.child(u)));if(I.from(d).eq(n))return{mark:l,type:i}}function u1(n,e,t,o,r){if(t-e<=r.pos-o.pos||Pi(o,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!o.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(Pi(s,!0,!0));return!i.parent.isTextblock||i.pos>t||Pi(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function Pi(n,e,t){let o=n.depth,r=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,r++,e=!1;if(t){let s=n.node(o).maybeChild(n.indexAfter(o));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function f1(n,e,t,o,r){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(r=="end"){let c=Math.max(0,s-Math.min(i,l));o-=i+c-s}if(i<s&&n.size<e.size){let c=o<=s&&o>=i?s-o:0;s-=c,s&&s<e.size&&tu(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-i),i=s}else if(l<s){let c=o<=s&&o>=l?s-o:0;s-=c,s&&s<n.size&&tu(n.textBetween(s-1,s+1))&&(s+=c?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function tu(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class nu{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 N0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(lu),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=su(this),ru(this),this.nodeViews=iu(this),this.docView=fd(this.state.doc,ou(this),Ri(this),this.dom,this),this.domObserver=new t1(this,(o,r,s,i)=>c1(this,o,r,s,i)),this.domObserver.start(),A0(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&&Ti(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(lu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let r=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Ud(this),i=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=iu(this);p1(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ti(this),this.editable=su(this),ru(this);let c=Ri(this),d=ou(this),u=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,d,c);(f||!e.selection.eq(r.selection))&&(i=!0);let p=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Ug(this);if(i){this.domObserver.stop();let h=f&&(Fe||Ne)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&h1(r.selection,e.selection);if(f){let m=Ne?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=U0(this)),(s||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=fd(e.doc,d,c,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&h0(this))?At(this,h):(xd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((o=this.dragging)===null||o===void 0)&&o.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&jg(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof q){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Zc(this,t.getBoundingClientRect(),e)}else Zc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,r=-1;if(this.state.doc.nodeAt(o.from)==o.node)r=o.from;else{let s=o.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==o.node&&(r=s)}this.dragging=new Wd(e.slice,e.move,r<0?void 0:q.create(this.state.doc,r))}someProp(e,t){let o=this._props&&this._props[e],r;if(o!=null&&(r=t?t(o):o))return r;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(Fe){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&&Wg(this.dom),At(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Yg(this,e)}coordsAtPos(e,t=1){return sd(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,o=-1){let r=this.docView.posFromDOM(e,t,o);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return t0(this,t||this.state,e)}pasteHTML(e,t){return So(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return So(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ei(this,e)}destroy(){this.docView&&(B0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ri(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Rg())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return O0(this,e)}domSelectionRange(){let e=this.domSelection();return e?De&&this.root.nodeType===11&&Vg(this.dom.ownerDocument)==this.dom&&o1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}nu.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function ou(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[ze.node(0,n.state.doc.content.size,e)]}function ru(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ze.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function su(n){return!n.someProp("editable",e=>e(n.state)===!1)}function h1(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function iu(n){let e=Object.create(null);function t(o){for(let r in o)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=o[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function p1(n,e){let t=0,o=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)o++;return t!=o}function lu(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Yt={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:"'"},yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},m1=typeof navigator<"u"&&/Mac/.test(navigator.platform),g1=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ae=0;Ae<10;Ae++)Yt[48+Ae]=Yt[96+Ae]=String(Ae);for(var Ae=1;Ae<=24;Ae++)Yt[Ae+111]="F"+Ae;for(var Ae=65;Ae<=90;Ae++)Yt[Ae]=String.fromCharCode(Ae+32),yr[Ae]=String.fromCharCode(Ae);for(var Di in Yt)yr.hasOwnProperty(Di)||(yr[Di]=Yt[Di]);function y1(n){var e=m1&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||g1&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?yr:Yt)[n.keyCode]||n.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}const k1=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),w1=typeof navigator<"u"&&/Win/.test(navigator.platform);function b1(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,r,s,i;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))k1?i=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(t="Alt-"+t),r&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function C1(n){let e=Object.create(null);for(let t in n)e[b1(t)]=n[t];return e}function _i(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function x1(n){return new fe({props:{handleKeyDown:au(n)}})}function au(n){let e=C1(n);return function(t,o){let r=y1(o),s,i=e[_i(r,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(o.shiftKey){let l=e[_i(r,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(w1&&o.ctrlKey&&o.altKey)&&(s=Yt[o.keyCode])&&s!=r){let l=e[_i(s,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var S1=Object.defineProperty,Li=(n,e)=>{for(var t in e)S1(n,t,{get:e[t],enumerable:!0})};function kr(n){const{state:e,transaction:t}=n;let{selection:o}=t,{doc:r}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return o},get doc(){return r},get tr(){return o=t.selection,r=t.doc,s=t.storedMarks,t}}}var wr=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:o}=e,{tr:r}=t,s=this.buildProps(r);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...d)=>{const u=l(...d)(s);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(r),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:o,state:r}=this,{view:s}=o,i=[],l=!!n,c=n||r.tr,d=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),i.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(t).map(([f,p])=>[f,(...m)=>{const g=this.buildProps(c,e),y=p(...m)(g);return i.push(y),u}])),run:d};return u}createCan(n){const{rawCommands:e,state:t}=this,o=!1,r=n||t.tr,s=this.buildProps(r,o);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...d)=>c(...d)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,o)}}buildProps(n,e=!0){const{rawCommands:t,editor:o,state:r}=this,{view:s}=o,i={tr:n,editor:o,view:s,state:kr({state:r,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)(i)]))}};return i}},cu={};Li(cu,{blur:()=>E1,clearContent:()=>v1,clearNodes:()=>M1,command:()=>T1,createParagraphNear:()=>N1,cut:()=>A1,deleteCurrentNode:()=>B1,deleteNode:()=>I1,deleteRange:()=>O1,deleteSelection:()=>R1,enter:()=>P1,exitCode:()=>D1,extendMarkRange:()=>_1,first:()=>L1,focus:()=>$1,forEach:()=>z1,insertContent:()=>F1,insertContentAt:()=>j1,joinBackward:()=>q1,joinDown:()=>K1,joinForward:()=>J1,joinItemBackward:()=>G1,joinItemForward:()=>Y1,joinTextblockBackward:()=>X1,joinTextblockForward:()=>Q1,joinUp:()=>W1,keyboardShortcut:()=>ey,lift:()=>ty,liftEmptyBlock:()=>ny,liftListItem:()=>oy,newlineInCode:()=>ry,resetAttributes:()=>sy,scrollIntoView:()=>iy,selectAll:()=>ly,selectNodeBackward:()=>ay,selectNodeForward:()=>cy,selectParentNode:()=>dy,selectTextblockEnd:()=>uy,selectTextblockStart:()=>fy,setContent:()=>hy,setMark:()=>By,setMeta:()=>Iy,setNode:()=>Oy,setNodeSelection:()=>Ry,setTextDirection:()=>Py,setTextSelection:()=>Dy,sinkListItem:()=>_y,splitBlock:()=>Ly,splitListItem:()=>Vy,toggleList:()=>$y,toggleMark:()=>zy,toggleNode:()=>Fy,toggleWrap:()=>Hy,undoInputRule:()=>Uy,unsetAllMarks:()=>jy,unsetMark:()=>Wy,unsetTextDirection:()=>Ky,updateAttributes:()=>qy,wrapIn:()=>Jy,wrapInList:()=>Gy});var E1=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),v1=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),M1=()=>({state:n,tr:e,dispatch:t})=>{const{selection:o}=e,{ranges:r}=o;return t&&r.forEach(({$from:s,$to:i})=>{n.doc.nodesBetween(s.pos,i.pos,(l,c)=>{if(l.type.isText)return;const{doc:d,mapping:u}=e,f=d.resolve(u.map(c)),p=d.resolve(u.map(c+l.nodeSize)),h=f.blockRange(p);if(!h)return;const m=Pn(h);if(l.type.isTextblock){const{defaultType:g}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},T1=n=>e=>n(e),N1=()=>({state:n,dispatch:e})=>Uc(n,e),A1=(n,e)=>({editor:t,tr:o})=>{const{state:r}=t,s=r.doc.slice(n.from,n.to);o.deleteRange(n.from,n.to);const i=o.mapping.map(e);return o.insert(i,s.content),o.setSelection(new Y(o.doc.resolve(Math.max(i-1,0)))),!0},B1=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,o=t.$anchor.node();if(o.content.size>0)return!1;const r=n.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===o.type){if(e){const l=r.before(s),c=r.after(s);n.delete(l,c).scrollIntoView()}return!0}return!1};function xe(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var I1=n=>({tr:e,state:t,dispatch:o})=>{const r=xe(n,t.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r){if(o){const c=s.before(i),d=s.after(i);e.delete(c,d).scrollIntoView()}return!0}return!1},O1=n=>({tr:e,dispatch:t})=>{const{from:o,to:r}=n;return t&&e.delete(o,r),!0},R1=()=>({state:n,dispatch:e})=>ii(n,e),P1=()=>({commands:n})=>n.keyboardShortcut("Enter"),D1=()=>({state:n,dispatch:e})=>kg(n,e);function Vi(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function br(n,e,t={strict:!0}){const o=Object.keys(e);return o.length?o.every(r=>t.strict?e[r]===n[r]:Vi(e[r])?e[r].test(n[r]):e[r]===n[r]):!0}function du(n,e,t={}){return n.find(o=>o.type===e&&br(Object.fromEntries(Object.keys(t).map(r=>[r,o.attrs[r]])),t))}function uu(n,e,t={}){return!!du(n,e,t)}function $i(n,e,t){var o;if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(u=>u.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(u=>u.type===e)||(t=t||((o=r.node.marks[0])==null?void 0:o.attrs),!du([...r.node.marks],e,t)))return;let i=r.index,l=n.start()+r.offset,c=i+1,d=l+r.node.nodeSize;for(;i>0&&uu([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;c<n.parent.childCount&&uu([...n.parent.child(c).marks],e,t);)d+=n.parent.child(c).nodeSize,c+=1;return{from:l,to:d}}function Bt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var _1=(n,e={})=>({tr:t,state:o,dispatch:r})=>{const s=Bt(n,o.schema),{doc:i,selection:l}=t,{$from:c,from:d,to:u}=l;if(r){const f=$i(c,s,e);if(f&&f.from<=d&&f.to>=u){const p=Y.create(i,f.from,f.to);t.setSelection(p)}}return!0},L1=n=>e=>{const t=typeof n=="function"?n(e):n;for(let o=0;o<t.length;o+=1)if(t[o](e))return!0;return!1};function fu(n){return n instanceof Y}function xn(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function hu(n,e=null){if(!e)return null;const t=Z.atStart(n),o=Z.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return o;const r=t.from,s=o.to;return e==="all"?Y.create(n,xn(0,r,s),xn(n.content.size,r,s)):Y.create(n,xn(e,r,s),xn(e,r,s))}function pu(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Cr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function V1(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var $1=(n=null,e={})=>({editor:t,view:o,tr:r,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{(Cr()||pu())&&o.dom.focus(),V1()&&!Cr()&&!pu()&&o.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(o.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(o.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!fu(t.state.selection))return i(),!0;const l=hu(r.doc,n)||t.state.selection,c=t.state.selection.eq(l);return s&&(c||r.setSelection(l),c&&r.storedMarks&&r.setStoredMarks(r.storedMarks),i()),!0},z1=(n,e)=>t=>n.every((o,r)=>e(o,{...t,index:r})),F1=(n,e)=>({tr:t,commands:o})=>o.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),mu=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const o=e[t];o.nodeType===3&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?n.removeChild(o):o.nodeType===1&&mu(o)}return n};function vo(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return mu(t)}function Mo(n,e,t){if(n instanceof St||n instanceof I)return n;t={slice:!0,parseOptions:{},...t};const o=typeof n=="object"&&n!==null,r=typeof n=="string";if(o)try{if(Array.isArray(n)&&n.length>0)return I.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Mo("",e,t)}if(r){if(t.errorOnInvalidContent){let i=!1,l="";const c=new ec({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(i=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Et.fromSchema(c).parseSlice(vo(n),t.parseOptions):Et.fromSchema(c).parse(vo(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Et.fromSchema(e);return t.slice?s.parseSlice(vo(n),t.parseOptions).content:s.parse(vo(n),t.parseOptions)}return Mo("",e,t)}function H1(n,e,t){const o=n.steps.length-1;if(o<e)return;const r=n.steps[o];if(!(r instanceof we||r instanceof be))return;const s=n.mapping.maps[o];let i=0;s.forEach((l,c,d,u)=>{i===0&&(i=u)}),n.setSelection(Z.near(n.doc.resolve(i),t))}var U1=n=>!("type"in n),j1=(n,e,t)=>({tr:o,dispatch:r,editor:s})=>{var i;if(r){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const c=y=>{s.emit("contentError",{editor:s,error:y,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Mo(e,s.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=Mo(e,s.schema,{parseOptions:d,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:s.options.enableContentCheck})}catch(y){return c(y),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},p=!0,h=!0;if((U1(l)?l:[l]).forEach(y=>{y.check(),p=p?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===f&&h){const{parent:y}=o.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,f+=1)}let g;if(p){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof I){let y="";e.forEach(k=>{k.text&&(y+=k.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;o.insertText(g,u,f)}else{g=l;const y=o.doc.resolve(u),k=y.node(),b=y.parentOffset===0,C=k.isText||k.isTextblock,x=k.content.size>0;b&&C&&x&&(u=Math.max(0,u-1)),o.replaceWith(u,f,g)}t.updateSelection&&H1(o,o.steps.length-1,-1),t.applyInputRules&&o.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&o.setMeta("applyPasteRules",{from:u,text:g})}return!0},W1=()=>({state:n,dispatch:e})=>mg(n,e),K1=()=>({state:n,dispatch:e})=>gg(n,e),q1=()=>({state:n,dispatch:e})=>_c(n,e),J1=()=>({state:n,dispatch:e})=>zc(n,e),G1=()=>({state:n,dispatch:e,tr:t})=>{try{const o=sr(n.doc,n.selection.$from.pos,-1);return o==null?!1:(t.join(o,2),e&&e(t),!0)}catch{return!1}},Y1=()=>({state:n,dispatch:e,tr:t})=>{try{const o=sr(n.doc,n.selection.$from.pos,1);return o==null?!1:(t.join(o,2),e&&e(t),!0)}catch{return!1}},X1=()=>({state:n,dispatch:e})=>hg(n,e),Q1=()=>({state:n,dispatch:e})=>pg(n,e);function gu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Z1(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let o,r,s,i;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))Cr()||gu()?i=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return o&&(t=`Alt-${t}`),r&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var ey=n=>({editor:e,view:t,tr:o,dispatch:r})=>{const s=Z1(n).split(/-(?!$)/),i=s.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,l))});return c==null||c.steps.forEach(d=>{const u=d.map(o.mapping);u&&r&&o.maybeStep(u)}),!0};function To(n,e,t={}){const{from:o,to:r,empty:s}=n.selection,i=e?xe(e,n.schema):null,l=[];n.doc.nodesBetween(o,r,(f,p)=>{if(f.isText)return;const h=Math.max(o,p),m=Math.min(r,p+f.nodeSize);l.push({node:f,from:h,to:m})});const c=r-o,d=l.filter(f=>i?i.name===f.node.type.name:!0).filter(f=>br(f.node.attrs,t,{strict:!1}));return s?!!d.length:d.reduce((f,p)=>f+p.to-p.from,0)>=c}var ty=(n,e={})=>({state:t,dispatch:o})=>{const r=xe(n,t.schema);return To(t,r,e)?yg(t,o):!1},ny=()=>({state:n,dispatch:e})=>jc(n,e),oy=n=>({state:e,dispatch:t})=>{const o=xe(n,e.schema);return Ag(o)(e,t)},ry=()=>({state:n,dispatch:e})=>Hc(n,e);function xr(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function yu(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((o,r)=>(t.includes(r)||(o[r]=n[r]),o),{})}var sy=(n,e)=>({tr:t,state:o,dispatch:r})=>{let s=null,i=null;const l=xr(typeof n=="string"?n:n.name,o.schema);if(!l)return!1;l==="node"&&(s=xe(n,o.schema)),l==="mark"&&(i=Bt(n,o.schema));let c=!1;return t.selection.ranges.forEach(d=>{o.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,f)=>{s&&s===u.type&&(c=!0,r&&t.setNodeMarkup(f,void 0,yu(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(p=>{i===p.type&&(c=!0,r&&t.addMark(f,f+u.nodeSize,i.create(yu(p.attrs,e))))})})}),c},iy=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),ly=()=>({tr:n,dispatch:e})=>{if(e){const t=new je(n.doc);n.setSelection(t)}return!0},ay=()=>({state:n,dispatch:e})=>Vc(n,e),cy=()=>({state:n,dispatch:e})=>Fc(n,e),dy=()=>({state:n,dispatch:e})=>Cg(n,e),uy=()=>({state:n,dispatch:e})=>Eg(n,e),fy=()=>({state:n,dispatch:e})=>Sg(n,e);function zi(n,e,t={},o={}){return Mo(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:o.errorOnInvalidContent})}var hy=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:o={}}={})=>({editor:r,tr:s,dispatch:i,commands:l})=>{const{doc:c}=s;if(o.preserveWhitespace!=="full"){const d=zi(n,r.schema,o,{errorOnInvalidContent:e??r.options.enableContentCheck});return i&&s.replaceWith(0,c.content.size,d).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:c.content.size},n,{parseOptions:o,errorOnInvalidContent:e??r.options.enableContentCheck})};function ku(n,e){const t=Bt(e,n.schema),{from:o,to:r,empty:s}=n.selection,i=[];s?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(o,r,c=>{i.push(...c.marks)});const l=i.find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function wu(n,e){const t=new Mc(n);return e.forEach(o=>{o.steps.forEach(r=>{t.step(r)})}),t}function py(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function my(n,e,t){const o=[];return n.nodesBetween(e.from,e.to,(r,s)=>{t(r)&&o.push({node:r,pos:s})}),o}function gy(n,e){for(let t=n.depth;t>0;t-=1){const o=n.node(t);if(e(o))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:o}}}function Fi(n){return e=>gy(e.$from,n)}function W(n,e,t){return n.config[e]===void 0&&n.parent?W(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?W(n.parent,e,t):null}):n.config[e]}function Hi(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},o=W(e,"addExtensions",t);return o?[e,...Hi(o())]:e}).flat(10)}function Sr(n,e){const t=fn.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function bu(n){return typeof n=="function"}function se(n,e=void 0,...t){return bu(n)?e?n.bind(e)(...t):n(...t):n}function yy(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Kn(n){const e=n.filter(r=>r.type==="extension"),t=n.filter(r=>r.type==="node"),o=n.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:o}}function Cu(n){const e=[],{nodeExtensions:t,markExtensions:o}=Kn(n),r=[...t,...o],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=t.filter(d=>d.name!=="text").map(d=>d.name),l=o.map(d=>d.name),c=[...i,...l];return n.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage,extensions:r},f=W(d,"addGlobalAttributes",u);if(!f)return;f().forEach(h=>{let m;Array.isArray(h.types)?m=h.types:h.types==="*"?m=c:h.types==="nodes"?m=i:h.types==="marks"?m=l:m=[],m.forEach(g=>{Object.entries(h.attributes).forEach(([y,k])=>{e.push({type:g,name:y,attribute:{...s,...k}})})})})}),r.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage},f=W(d,"addAttributes",u);if(!f)return;const p=f();Object.entries(p).forEach(([h,m])=>{const g={...s,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:d.name,name:h,attribute:g})})}),e}function Xt(...n){return n.filter(e=>!!e).reduce((e,t)=>{const o={...e};return Object.entries(t).forEach(([r,s])=>{if(!o[r]){o[r]=s;return}if(r==="class"){const l=s?String(s).split(" "):[],c=o[r]?o[r].split(" "):[],d=l.filter(u=>!c.includes(u));o[r]=[...c,...d].join(" ")}else if(r==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=o[r]?o[r].split(";").map(u=>u.trim()).filter(Boolean):[],d=new Map;c.forEach(u=>{const[f,p]=u.split(":").map(h=>h.trim());d.set(f,p)}),l.forEach(u=>{const[f,p]=u.split(":").map(h=>h.trim());d.set(f,p)}),o[r]=Array.from(d.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else o[r]=s}),o},{})}function Er(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,o)=>Xt(t,o),{})}function ky(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function xu(n,e){return"style"in n?n:{...n,getAttrs:t=>{const o=n.getAttrs?n.getAttrs(t):n.attrs;if(o===!1)return!1;const r=e.reduce((s,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):ky(t.getAttribute(i.name));return l==null?s:{...s,[i.name]:l}},{});return{...o,...r}}}}function Su(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&yy(t)?!1:t!=null))}function Eu(n){var e,t;const o={};return!((e=n==null?void 0:n.attribute)!=null&&e.isRequired)&&"default"in((n==null?void 0:n.attribute)||{})&&(o.default=n.attribute.default),((t=n==null?void 0:n.attribute)==null?void 0:t.validate)!==void 0&&(o.validate=n.attribute.validate),[n.name,o]}function vu(n,e){var t;const o=Cu(n),{nodeExtensions:r,markExtensions:s}=Kn(n),i=(t=r.find(d=>W(d,"topNode")))==null?void 0:t.name,l=Object.fromEntries(r.map(d=>{const u=o.filter(k=>k.type===d.name),f={name:d.name,options:d.options,storage:d.storage,editor:e},p=n.reduce((k,b)=>{const C=W(b,"extendNodeSchema",f);return{...k,...C?C(d):{}}},{}),h=Su({...p,content:se(W(d,"content",f)),marks:se(W(d,"marks",f)),group:se(W(d,"group",f)),inline:se(W(d,"inline",f)),atom:se(W(d,"atom",f)),selectable:se(W(d,"selectable",f)),draggable:se(W(d,"draggable",f)),code:se(W(d,"code",f)),whitespace:se(W(d,"whitespace",f)),linebreakReplacement:se(W(d,"linebreakReplacement",f)),defining:se(W(d,"defining",f)),isolating:se(W(d,"isolating",f)),attrs:Object.fromEntries(u.map(Eu))}),m=se(W(d,"parseHTML",f));m&&(h.parseDOM=m.map(k=>xu(k,u)));const g=W(d,"renderHTML",f);g&&(h.toDOM=k=>g({node:k,HTMLAttributes:Er(k,u)}));const y=W(d,"renderText",f);return y&&(h.toText=y),[d.name,h]})),c=Object.fromEntries(s.map(d=>{const u=o.filter(y=>y.type===d.name),f={name:d.name,options:d.options,storage:d.storage,editor:e},p=n.reduce((y,k)=>{const b=W(k,"extendMarkSchema",f);return{...y,...b?b(d):{}}},{}),h=Su({...p,inclusive:se(W(d,"inclusive",f)),excludes:se(W(d,"excludes",f)),group:se(W(d,"group",f)),spanning:se(W(d,"spanning",f)),code:se(W(d,"code",f)),attrs:Object.fromEntries(u.map(Eu))}),m=se(W(d,"parseHTML",f));m&&(h.parseDOM=m.map(y=>xu(y,u)));const g=W(d,"renderHTML",f);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Er(y,u)})),[d.name,h]}));return new ec({topNode:i,nodes:l,marks:c})}function wy(n){const e=n.filter((t,o)=>n.indexOf(t)!==o);return Array.from(new Set(e))}function No(n){return n.sort((t,o)=>{const r=W(t,"priority")||100,s=W(o,"priority")||100;return r>s?-1:r<s?1:0})}function Ui(n){const e=No(Hi(n)),t=wy(e.map(o=>o.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),e}function Mu(n,e){const t=Ui(n);return vu(t,e)}function qn(n,e){const t=Mu(e),o=St.fromJSON(t,n);return Sr(o.content,t)}function nt(n,e){const t=Mu(e),o=vo(n);return Et.fromSchema(t).parse(o).toJSON()}function Tu(n,e,t){const{from:o,to:r}=e,{blockSeparator:s=`
|
|
11
|
-
|
|
12
|
-
`,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(o,r,(c,d,u,f)=>{var p;c.isBlock&&d>o&&(l+=s);const h=i==null?void 0:i[c.type.name];if(h)return u&&(l+=h({node:c,pos:d,parent:u,index:f,range:e})),!1;c.isText&&(l+=(p=c==null?void 0:c.text)==null?void 0:p.slice(Math.max(o,d)-d,r-d))}),l}function by(n,e){const t={from:0,to:n.content.size};return Tu(n,t,e)}function Nu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Cy(n,e){const t=xe(e,n.schema),{from:o,to:r}=n.selection,s=[];n.doc.nodesBetween(o,r,l=>{s.push(l)});const i=s.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function Au(n,e){const t=xr(typeof e=="string"?e:e.name,n.schema);return t==="node"?Cy(n,e):t==="mark"?ku(n,e):{}}function xy(n,e=JSON.stringify){const t={};return n.filter(o=>{const r=e(o);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function Sy(n){const e=xy(n);return e.length===1?e:e.filter((t,o)=>!e.filter((s,i)=>i!==o).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Bu(n){const{mapping:e,steps:t}=n,o=[];return e.maps.forEach((r,s)=>{const i=[];if(r.ranges.length)r.forEach((l,c)=>{i.push({from:l,to:c})});else{const{from:l,to:c}=t[s];if(l===void 0||c===void 0)return;i.push({from:l,to:c})}i.forEach(({from:l,to:c})=>{const d=e.slice(s).map(l,-1),u=e.slice(s).map(c),f=e.invert().map(d,-1),p=e.invert().map(u);o.push({oldRange:{from:f,to:p},newRange:{from:d,to:u}})})}),Sy(o)}function ji(n,e,t){const o=[];return n===e?t.resolve(n).marks().forEach(r=>{const s=t.resolve(n),i=$i(s,r.type);i&&o.push({mark:r,...i})}):t.nodesBetween(n,e,(r,s)=>{!r||(r==null?void 0:r.nodeSize)===void 0||o.push(...r.marks.map(i=>({from:s,to:s+r.nodeSize,mark:i})))}),o}function Ao(n,e){return e.nodes[n]||e.marks[n]||null}function vr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([o])=>{const r=n.find(s=>s.type===e&&s.name===o);return r?r.attribute.keepOnSplit:!1}))}var Ey=(n,e=500)=>{let t="";const o=n.parentOffset;return n.parent.nodesBetween(Math.max(0,o-e),o,(r,s,i,l)=>{var c,d;const u=((d=(c=r.type.spec).toText)==null?void 0:d.call(c,{node:r,pos:s,parent:i,index:l}))||r.textContent||"%leaf%";t+=r.isAtom&&!r.isText?u:u.slice(0,Math.max(0,o-s))}),t};function Wi(n,e,t={}){const{empty:o,ranges:r}=n.selection,s=e?Bt(e,n.schema):null;if(o)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>br(f.attrs,t,{strict:!1}));let i=0;const l=[];if(r.forEach(({$from:f,$to:p})=>{const h=f.pos,m=p.pos;n.doc.nodesBetween(h,m,(g,y)=>{if(s&&g.inlineContent&&!g.type.allowsMarkType(s))return!1;if(!g.isText&&!g.marks.length)return;const k=Math.max(h,y),b=Math.min(m,y+g.nodeSize),C=b-k;i+=C,l.push(...g.marks.map(x=>({mark:x,from:k,to:b})))})}),i===0)return!1;const c=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>br(f.mark.attrs,t,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),d=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+d:c)>=i}function vy(n,e,t={}){if(!e)return To(n,null,t)||Wi(n,null,t);const o=xr(e,n.schema);return o==="node"?To(n,e,t):o==="mark"?Wi(n,e,t):!1}function Iu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ou(n,e){const{nodeExtensions:t}=Kn(e),o=t.find(i=>i.name===n);if(!o)return!1;const r={name:o.name,options:o.options,storage:o.storage},s=se(W(o,"group",r));return typeof s!="string"?!1:s.split(" ").includes("list")}function Mr(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var o;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((o=n.text)!=null?o:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let r=!0;return n.content.forEach(s=>{r!==!1&&(Mr(s,{ignoreWhitespace:t,checkChildren:e})||(r=!1))}),r}return!1}function My(n){return n instanceof q}var Ru=class dp{constructor(e){this.position=e}static fromJSON(e){return new dp(e.position)}toJSON(){return{position:this.position}}};function Ty(n,e){const t=e.mapping.mapResult(n.position);return{position:new Ru(t.pos),mapResult:t}}function Ny(n){return new Ru(n)}function Ay(n,e,t){var o;const{selection:r}=e;let s=null;if(fu(r)&&(s=r.$cursor),s){const l=(o=n.storedMarks)!=null?o:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(d=>d.type.excludes(t)))}const{ranges:i}=r;return i.some(({$from:l,$to:c})=>{let d=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,c.pos,(u,f,p)=>{if(d)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));d=h&&m}return!d}),d})}var By=(n,e={})=>({tr:t,state:o,dispatch:r})=>{const{selection:s}=t,{empty:i,ranges:l}=s,c=Bt(n,o.schema);if(r)if(i){const d=ku(o,c);t.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;o.doc.nodesBetween(u,f,(p,h)=>{const m=Math.max(h,u),g=Math.min(h+p.nodeSize,f);p.marks.find(k=>k.type===c)?p.marks.forEach(k=>{c===k.type&&t.addMark(m,g,c.create({...k.attrs,...e}))}):t.addMark(m,g,c.create(e))})});return Ay(o,t,c)},Iy=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Oy=(n,e={})=>({state:t,dispatch:o,chain:r})=>{const s=xe(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),s.isTextblock?r().command(({commands:l})=>qc(s,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>qc(s,{...i,...e})(l,o)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ry=n=>({tr:e,dispatch:t})=>{if(t){const{doc:o}=e,r=xn(n,0,o.content.size),s=q.create(o,r);e.setSelection(s)}return!0},Py=(n,e)=>({tr:t,state:o,dispatch:r})=>{const{selection:s}=o;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=s.from,l=s.to),r&&t.doc.nodesBetween(i,l,(c,d)=>{c.isText||t.setNodeMarkup(d,void 0,{...c.attrs,dir:n})}),!0},Dy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:o}=e,{from:r,to:s}=typeof n=="number"?{from:n,to:n}:n,i=Y.atStart(o).from,l=Y.atEnd(o).to,c=xn(r,i,l),d=xn(s,i,l),u=Y.create(o,c,d);e.setSelection(u)}return!0},_y=n=>({state:e,dispatch:t})=>{const o=xe(n,e.schema);return Og(o)(e,t)};function Pu(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const o=t.filter(r=>e==null?void 0:e.includes(r.type.name));n.tr.ensureMarks(o)}}var Ly=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:o,editor:r})=>{const{selection:s,doc:i}=e,{$from:l,$to:c}=s,d=r.extensionManager.attributes,u=vr(d,l.node().type.name,l.node().attrs);if(s instanceof q&&s.node.isBlock)return!l.parentOffset||!vt(i,l.pos)?!1:(o&&(n&&Pu(t,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:py(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=f&&p?[{type:p,attrs:u}]:void 0,m=vt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&vt(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(m=!0,h=p?[{type:p,attrs:u}]:void 0),o){if(m&&(s instanceof Y&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),p&&!f&&!l.parentOffset&&l.parent.type!==p)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}n&&Pu(t,r.extensionManager.splittableMarks),e.scrollIntoView()}return m},Vy=(n,e={})=>({tr:t,state:o,dispatch:r,editor:s})=>{var i;const l=xe(n,o.schema),{$from:c,$to:d}=o.selection,u=o.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(d))return!1;const f=c.node(-1);if(f.type!==l)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let k=I.empty;const b=c.index(-1)?1:c.index(-2)?2:3;for(let v=c.depth-b;v>=c.depth-3;v-=1)k=I.from(c.node(v).copy(k));const C=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,x={...vr(p,c.node().type.name,c.node().attrs),...e},E=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(x))||void 0;k=k.append(I.from(l.createAndFill(null,E)||void 0));const M=c.before(c.depth-(b-1));t.replace(M,c.after(-C),new z(k,4-b,0));let S=-1;t.doc.nodesBetween(M,t.doc.content.size,(v,T)=>{if(S>-1)return!1;v.isTextblock&&v.content.size===0&&(S=T+1)}),S>-1&&t.setSelection(Y.near(t.doc.resolve(S))),t.scrollIntoView()}return!0}const h=d.pos===c.end()?f.contentMatchAt(0).defaultType:null,m={...vr(p,f.type.name,f.attrs),...e},g={...vr(p,c.node().type.name,c.node().attrs),...e};t.delete(c.pos,d.pos);const y=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!vt(t.doc,c.pos,2))return!1;if(r){const{selection:k,storedMarks:b}=o,{splittableMarks:C}=s.extensionManager,x=b||k.$to.parentOffset&&k.$from.marks();if(t.split(c.pos,2,y).scrollIntoView(),!x||!r)return!0;const E=x.filter(M=>C.includes(M.type.name));t.ensureMarks(E)}return!0},Ki=(n,e)=>{const t=Fi(i=>i.type===e)(n.selection);if(!t)return!0;const o=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(o===void 0)return!0;const r=n.doc.nodeAt(o);return t.node.type===(r==null?void 0:r.type)&&pn(n.doc,t.pos)&&n.join(t.pos),!0},qi=(n,e)=>{const t=Fi(i=>i.type===e)(n.selection);if(!t)return!0;const o=n.doc.resolve(t.start).after(t.depth);if(o===void 0)return!0;const r=n.doc.nodeAt(o);return t.node.type===(r==null?void 0:r.type)&&pn(n.doc,o)&&n.join(o),!0},$y=(n,e,t,o={})=>({editor:r,tr:s,state:i,dispatch:l,chain:c,commands:d,can:u})=>{const{extensions:f,splittableMarks:p}=r.extensionManager,h=xe(n,i.schema),m=xe(e,i.schema),{selection:g,storedMarks:y}=i,{$from:k,$to:b}=g,C=k.blockRange(b),x=y||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const E=Fi(M=>Ou(M.type.name,f))(g);if(C.depth>=1&&E&&C.depth-E.depth<=1){if(E.node.type===h)return d.liftListItem(m);if(Ou(E.node.type.name,f)&&h.validContent(E.node.content)&&l)return c().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>Ki(s,h)).command(()=>qi(s,h)).run()}return!t||!x||!l?c().command(()=>u().wrapInList(h,o)?!0:d.clearNodes()).wrapInList(h,o).command(()=>Ki(s,h)).command(()=>qi(s,h)).run():c().command(()=>{const M=u().wrapInList(h,o),S=x.filter(v=>p.includes(v.type.name));return s.ensureMarks(S),M?!0:d.clearNodes()}).wrapInList(h,o).command(()=>Ki(s,h)).command(()=>qi(s,h)).run()},zy=(n,e={},t={})=>({state:o,commands:r})=>{const{extendEmptyMarkRange:s=!1}=t,i=Bt(n,o.schema);return Wi(o,i,e)?r.unsetMark(i,{extendEmptyMarkRange:s}):r.setMark(i,e)},Fy=(n,e,t={})=>({state:o,commands:r})=>{const s=xe(n,o.schema),i=xe(e,o.schema),l=To(o,s,t);let c;return o.selection.$anchor.sameParent(o.selection.$head)&&(c=o.selection.$anchor.parent.attrs),l?r.setNode(i,c):r.setNode(s,{...c,...t})},Hy=(n,e={})=>({state:t,commands:o})=>{const r=xe(n,t.schema);return To(t,r,e)?o.lift(r):o.wrapIn(r,e)},Uy=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let o=0;o<t.length;o+=1){const r=t[o];let s;if(r.spec.isInputRules&&(s=r.getState(n))){if(e){const i=n.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)i.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,c))}else i.delete(s.from,s.to)}return!0}}return!1},jy=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:o,ranges:r}=t;return o||e&&r.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},Wy=(n,e={})=>({tr:t,state:o,dispatch:r})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,c=Bt(n,o.schema),{$from:d,empty:u,ranges:f}=l;if(!r)return!0;if(u&&i){let{from:p,to:h}=l;const m=(s=d.marks().find(y=>y.type===c))==null?void 0:s.attrs,g=$i(d,c,m);g&&(p=g.from,h=g.to),t.removeMark(p,h,c)}else f.forEach(p=>{t.removeMark(p.$from.pos,p.$to.pos,c)});return t.removeStoredMark(c),!0},Ky=n=>({tr:e,state:t,dispatch:o})=>{const{selection:r}=t;let s,i;return typeof n=="number"?(s=n,i=n):n&&"from"in n&&"to"in n?(s=n.from,i=n.to):(s=r.from,i=r.to),o&&e.doc.nodesBetween(s,i,(l,c)=>{if(l.isText)return;const d={...l.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},qy=(n,e={})=>({tr:t,state:o,dispatch:r})=>{let s=null,i=null;const l=xr(typeof n=="string"?n:n.name,o.schema);if(!l)return!1;l==="node"&&(s=xe(n,o.schema)),l==="mark"&&(i=Bt(n,o.schema));let c=!1;return t.selection.ranges.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;let p,h,m,g;t.selection.empty?o.doc.nodesBetween(u,f,(y,k)=>{s&&s===y.type&&(c=!0,m=Math.max(k,u),g=Math.min(k+y.nodeSize,f),p=k,h=y)}):o.doc.nodesBetween(u,f,(y,k)=>{k<u&&s&&s===y.type&&(c=!0,m=Math.max(k,u),g=Math.min(k+y.nodeSize,f),p=k,h=y),k>=u&&k<=f&&(s&&s===y.type&&(c=!0,r&&t.setNodeMarkup(k,void 0,{...y.attrs,...e})),i&&y.marks.length&&y.marks.forEach(b=>{if(i===b.type&&(c=!0,r)){const C=Math.max(k,u),x=Math.min(k+y.nodeSize,f);t.addMark(C,x,i.create({...b.attrs,...e}))}}))}),h&&(p!==void 0&&r&&t.setNodeMarkup(p,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(y=>{i===y.type&&r&&t.addMark(m,g,i.create({...y.attrs,...e}))}))}),c},Jy=(n,e={})=>({state:t,dispatch:o})=>{const r=xe(n,t.schema);return vg(r,e)(t,o)},Gy=(n,e={})=>({state:t,dispatch:o})=>{const r=xe(n,t.schema);return Mg(r,e)(t,o)},Yy=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(o=>o.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(o=>o!==e):delete this.callbacks[n]),this}once(n,e){const t=(...o)=>{this.off(n,t),e.apply(this,o)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Xy=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Qy=(n,e)=>{if(Vi(e))return e.exec(n);const t=e(n);if(!t)return null;const o=[t.text];return o.index=t.index,o.input=n,o.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(t.replaceWith)),o};function Tr(n){var e;const{editor:t,from:o,to:r,text:s,rules:i,plugin:l}=n,{view:c}=t;if(c.composing)return!1;const d=c.state.doc.resolve(o);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let u=!1;const f=Ey(d)+s;return i.forEach(p=>{if(u)return;const h=Qy(f,p.find);if(!h)return;const m=c.state.tr,g=kr({state:c.state,transaction:m}),y={from:o-(h[0].length-s.length),to:r},{commands:k,chain:b,can:C}=new wr({editor:t,state:g});p.handler({state:g,range:y,match:h,commands:k,chain:b,can:C})===null||!m.steps.length||(p.undoable&&m.setMeta(l,{transform:m,from:o,to:r,text:s}),c.dispatch(m),u=!0)}),u}function Zy(n){const{editor:e,rules:t}=n,o=new fe({state:{init(){return null},apply(r,s,i){const l=r.getMeta(o);if(l)return l;const c=r.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=Sr(I.from(u),i.schema);const{from:f}=c,p=f+u.length;Tr({editor:e,from:f,to:p,text:u,rules:t,plugin:o})}),r.selectionSet||r.docChanged?null:s}},props:{handleTextInput(r,s,i,l){return Tr({editor:e,from:s,to:i,text:l,rules:t,plugin:o})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{const{$cursor:s}=r.state.selection;s&&Tr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:o})}),!1)},handleKeyDown(r,s){if(s.key!=="Enter")return!1;const{$cursor:i}=r.state.selection;return i?Tr({editor:e,from:i.pos,to:i.pos,text:`
|
|
13
|
-
`,rules:t,plugin:o}):!1}},isInputRules:!0});return o}function ek(n){return Object.prototype.toString.call(n).slice(8,-1)}function Nr(n){return ek(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Du(n,e){const t={...n};return Nr(n)&&Nr(e)&&Object.keys(e).forEach(o=>{Nr(e[o])&&Nr(n[o])?t[o]=Du(n[o],e[o]):t[o]=e[o]}),t}var Ji=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...se(W(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...se(W(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>Du(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},Jn=class up extends Ji{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new up(t)}static handleExit({editor:e,mark:t}){const{tr:o}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks();if(!!!i.find(d=>(d==null?void 0:d.type.name)===t.name))return!1;const c=i.find(d=>(d==null?void 0:d.type.name)===t.name);return c&&o.removeStoredMark(c),o.insertText(" ",r.pos),e.view.dispatch(o),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function tk(n){return typeof n=="number"}var nk=class{constructor(n){this.find=n.find,this.handler=n.handler}},ok=(n,e,t)=>{if(Vi(e))return[...n.matchAll(e)];const o=e(n,t);return o?o.map(r=>{const s=[r.text];return s.index=r.index,s.input=n,s.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(r.replaceWith)),s}):[]};function rk(n){const{editor:e,state:t,from:o,to:r,rule:s,pasteEvent:i,dropEvent:l}=n,{commands:c,chain:d,can:u}=new wr({editor:e,state:t}),f=[];return t.doc.nodesBetween(o,r,(h,m)=>{var g,y,k,b,C;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const x=(C=(b=(k=h.content)==null?void 0:k.size)!=null?b:h.nodeSize)!=null?C:0,E=Math.max(o,m),M=Math.min(r,m+x);if(E>=M)return;const S=h.isText?h.text||"":h.textBetween(E-m,M-m,void 0,"");ok(S,s.find,i).forEach(T=>{if(T.index===void 0)return;const B=E+T.index+1,P=B+T[0].length,O={from:t.tr.mapping.map(B),to:t.tr.mapping.map(P)},_=s.handler({state:t,range:O,match:T,commands:c,chain:d,can:u,pasteEvent:i,dropEvent:l});f.push(_)})}),f.every(h=>h!==null)}var Ar=null,sk=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function ik(n){const{editor:e,rules:t}=n;let o=null,r=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:u,from:f,to:p,rule:h,pasteEvt:m})=>{const g=u.tr,y=kr({state:u,transaction:g});if(!(!rk({editor:e,state:y,from:Math.max(f-1,0),to:p.b-1,rule:h,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new fe({view(f){const p=m=>{var g;o=(g=f.dom.parentElement)!=null&&g.contains(m.target)?f.dom.parentElement:null,o&&(Ar=e)},h=()=>{Ar&&(Ar=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(s=o===f.dom.parentElement,l=p,!s){const h=Ar;h!=null&&h.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(f,p)=>{var h;const m=(h=p.clipboardData)==null?void 0:h.getData("text/html");return i=p,r=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(f,p,h)=>{const m=f[0],g=m.getMeta("uiEvent")==="paste"&&!r,y=m.getMeta("uiEvent")==="drop"&&!s,k=m.getMeta("applyPasteRules"),b=!!k;if(!g&&!y&&!b)return;if(b){let{text:E}=k;typeof E=="string"?E=E:E=Sr(I.from(E),h.schema);const{from:M}=k,S=M+E.length,v=sk(E);return c({rule:u,state:h,from:M,to:{b:S},pasteEvt:v})}const C=p.doc.content.findDiffStart(h.doc.content),x=p.doc.content.findDiffEnd(h.doc.content);if(!(!tk(C)||!x||C===x.b))return c({rule:u,state:h,from:C,to:x,pasteEvt:i})}}))}var Br=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Ui(n),this.schema=vu(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ao(e.name,this.schema)},o=W(e,"addCommands",t);return o?{...n,...o()}:n},{})}get plugins(){const{editor:n}=this;return No([...this.extensions].reverse()).flatMap(o=>{const r={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:n,type:Ao(o.name,this.schema)},s=[],i=W(o,"addKeyboardShortcuts",r);let l={};if(o.type==="mark"&&W(o,"exitable",r)&&(l.ArrowRight=()=>Jn.handleExit({editor:n,mark:o})),i){const p=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:n})]));l={...l,...p}}const c=x1(l);s.push(c);const d=W(o,"addInputRules",r);if(Iu(o,n.options.enableInputRules)&&d){const p=d();if(p&&p.length){const h=Zy({editor:n,rules:p}),m=Array.isArray(h)?h:[h];s.push(...m)}}const u=W(o,"addPasteRules",r);if(Iu(o,n.options.enablePasteRules)&&u){const p=u();if(p&&p.length){const h=ik({editor:n,rules:p});s.push(...h)}}const f=W(o,"addProseMirrorPlugins",r);if(f){const p=f();s.push(...p)}return s})}get attributes(){return Cu(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=Kn(this.extensions);return Object.fromEntries(e.filter(t=>!!W(t,"addNodeView")).map(t=>{const o=this.attributes.filter(c=>c.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:xe(t.name,this.schema)},s=W(t,"addNodeView",r);if(!s)return[];const i=s();if(!i)return[];const l=(c,d,u,f,p)=>{const h=Er(c,o);return i({node:c,view:d,getPos:u,decorations:f,innerDecorations:p,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){const{editor:e}=this;return No([...this.extensions].reverse()).reduceRight((o,r)=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Ao(r.name,this.schema)},i=W(r,"dispatchTransaction",s);return i?l=>{i.call(s,{transaction:l,next:o})}:o},n)}transformPastedHTML(n){const{editor:e}=this;return No([...this.extensions]).reduce((o,r)=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Ao(r.name,this.schema)},i=W(r,"transformPastedHTML",s);return i?(l,c)=>{const d=o(l,c);return i.call(s,d)}:o},n||(o=>o))}get markViews(){const{editor:n}=this,{markExtensions:e}=Kn(this.extensions);return Object.fromEntries(e.filter(t=>!!W(t,"addMarkView")).map(t=>{const o=this.attributes.filter(l=>l.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Bt(t.name,this.schema)},s=W(t,"addMarkView",r);if(!s)return[];const i=(l,c,d)=>{const u=Er(l,o);return s()({mark:l,view:c,inline:d,editor:n,extension:t,HTMLAttributes:u,updateAttributes:f=>{bk(l,n,f)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ao(e.name,this.schema)};e.type==="mark"&&((t=se(W(e,"keepOnSplit",o)))==null||t)&&this.splittableMarks.push(e.name);const r=W(e,"onBeforeCreate",o),s=W(e,"onCreate",o),i=W(e,"onUpdate",o),l=W(e,"onSelectionUpdate",o),c=W(e,"onTransaction",o),d=W(e,"onFocus",o),u=W(e,"onBlur",o),f=W(e,"onDestroy",o);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};Br.resolve=Ui,Br.sort=No,Br.flatten=Hi;var lk={};Li(lk,{ClipboardTextSerializer:()=>_u,Commands:()=>Lu,Delete:()=>Vu,Drop:()=>$u,Editable:()=>zu,FocusEvents:()=>Hu,Keymap:()=>Uu,Paste:()=>ju,Tabindex:()=>Wu,TextDirection:()=>Ku,focusEventsPluginKey:()=>Fu});var ie=class fp extends Ji{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new fp(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},_u=ie.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new fe({key:new Ce("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:o,selection:r}=e,{ranges:s}=r,i=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),c=Nu(t);return Tu(o,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Lu=ie.create({name:"commands",addCommands(){return{...cu}}}),Vu=ie.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,o,r;const s=()=>{var i,l,c,d;if((d=(c=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,n))!=null?d:n.getMeta("y-sync$"))return;const u=wu(n.before,[n,...e]);Bu(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(m,g)=>{const y=g+m.nodeSize-2,k=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!k,editor:this.editor,transaction:n,combinedTransform:u})})});const p=u.mapping;u.steps.forEach((h,m)=>{var g,y;if(h instanceof tt){const k=p.slice(m).map(h.from,-1),b=p.slice(m).map(h.to),C=p.invert().map(k,-1),x=p.invert().map(b),E=(g=u.doc.nodeAt(k-1))==null?void 0:g.marks.some(S=>S.eq(h.mark)),M=(y=u.doc.nodeAt(b))==null?void 0:y.marks.some(S=>S.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:C,to:x},newRange:{from:k,to:b},partial:!!(M||E),editor:this.editor,transaction:n,combinedTransform:u})}})};(r=(o=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:o.async)==null||r?setTimeout(s,0):s()}}),$u=ie.create({name:"drop",addProseMirrorPlugins(){return[new fe({key:new Ce("tiptapDrop"),props:{handleDrop:(n,e,t,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:o})}}})]}}),zu=ie.create({name:"editable",addProseMirrorPlugins(){return[new fe({key:new Ce("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Fu=new Ce("focusEvents"),Hu=ie.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new fe({key:Fu,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const o=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,t)=>{n.isFocused=!1;const o=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),Uu=ie.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:u,$anchor:f}=c,{pos:p,parent:h}=f,m=f.parent.isTextblock&&p>0?l.doc.resolve(p-1):f,g=m.parent.type.spec.isolating,y=f.pos-f.parentOffset,k=g&&m.parent.childCount===1?y===f.pos:Z.atStart(d).from===p;return!u||!h.type.isTextblock||h.textContent.length||!k||k&&f.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),o={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...o},s={...o,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Cr()||gu()?s:r},addProseMirrorPlugins(){return[new fe({key:new Ce("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const o=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),r=n.some(g=>g.getMeta("preventClearDocument"));if(!o||r)return;const{empty:s,from:i,to:l}=e.selection,c=Z.atStart(e.doc).from,d=Z.atEnd(e.doc).to;if(s||!(i===c&&l===d)||!Mr(t.doc))return;const p=t.tr,h=kr({state:t,transaction:p}),{commands:m}=new wr({editor:this.editor,state:h});if(m.clearNodes(),!!p.steps.length)return p}})]}}),ju=ie.create({name:"paste",addProseMirrorPlugins(){return[new fe({key:new Ce("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Wu=ie.create({name:"tabindex",addProseMirrorPlugins(){return[new fe({key:new Ce("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ku=ie.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=Kn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const 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 fe({key:new Ce("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),ak=class Ko{constructor(e,t,o=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=o,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(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,o=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,o=this.to-1}this.editor.commands.insertContentAt({from:t,to:o},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Ko(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ko(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ko(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,o)=>{const r=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,i=t.isInline,l=this.pos+o+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!r&&!i&&c.depth<=this.depth)return;const d=new Ko(c,this.editor,r,r||i?t:null);r&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let o=null,r=this.parent;for(;r&&!o;){if(r.node.type.name===e)if(Object.keys(t).length>0){const s=r.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const c=i[l];if(s[c]!==t[c])break}}else o=r;r=r.parent}return o}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},o=!1){let r=[];if(!this.children||this.children.length===0)return r;const s=Object.keys(t);return this.children.forEach(i=>{o&&r.length>0||(i.node.type.name===e&&s.every(c=>t[c]===i.node.attrs[c])&&r.push(i),!(o&&r.length>0)&&(r=r.concat(i.querySelectorAll(e,t,o))))}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},ck=`.ProseMirror {
|
|
1
|
+
(function(R,Ve){typeof exports=="object"&&typeof module<"u"?Ve(exports,require("@woven-ecs/canvas-store"),require("@woven-canvas/plugin-arrows"),require("vue"),require("@woven-canvas/core"),require("@woven-canvas/math"),require("@woven-canvas/plugin-eraser"),require("@woven-canvas/plugin-pen"),require("@woven-canvas/plugin-canvas-controls"),require("@woven-canvas/plugin-tapes")):typeof define=="function"&&define.amd?define(["exports","@woven-ecs/canvas-store","@woven-canvas/plugin-arrows","vue","@woven-canvas/core","@woven-canvas/math","@woven-canvas/plugin-eraser","@woven-canvas/plugin-pen","@woven-canvas/plugin-canvas-controls","@woven-canvas/plugin-tapes"],Ve):(R=typeof globalThis<"u"?globalThis:R||self,Ve(R.Vue={},R.WovenEcsCanvasStore,R.WovenCanvasPluginArrows,R.Vue,R.WovenCanvasCore,R.WovenCanvasMath,R.WovenCanvasPluginEraser,R.WovenCanvasPluginPen,R.WovenCanvasPluginCanvasControls,R.WovenCanvasPluginTapes))})(this,function(R,Ve,te,a,k,ae,kr,wr,wi,ag){"use strict";const bi=[{kind:te.ArrowHeadKind.None,label:"None",gap:0,svg:""},{kind:te.ArrowHeadKind.V,label:"Arrow",gap:15,svg:'<polyline points="-10,-7 -1,0 -10,7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />'},{kind:te.ArrowHeadKind.Delta,label:"Triangle",gap:20,svg:'<polygon points="-1,0 -12,-7 -12,7" fill="currentColor" />'},{kind:te.ArrowHeadKind.Circle,label:"Circle",gap:0,svg:'<circle cx="-6" cy="0" r="6" fill="currentColor" />'},{kind:te.ArrowHeadKind.Diamond,label:"Diamond",gap:0,svg:'<polygon points="0,0 -7,-6 -14,0 -7,6" fill="currentColor" />'}];function Hn(n){return bi.find(e=>e.kind===n)}const gc=Symbol.for("__woven_canvas_dropdown_active__"),yc=Symbol.for("__woven_canvas_dropdown_level__"),kc=Symbol.for("__woven_canvas_floating_menu__"),Si=Symbol.for("__woven_canvas_toolbar__"),Se=Symbol.for("__woven_canvas__");function me(n,e){const t=a.inject(Se);if(!t)throw new Error("useComponent must be used within a WovenCanvas component");const o=a.shallowRef(null),r=t.getEditor();if(r){const i=r._getContext();k.hasComponent(i,n,e)&&(o.value=e.snapshot(i,n))}const s=t.subscribeComponent(n,e.name,i=>{o.value=i});return a.onUnmounted(()=>{s()}),o}const cg={key:0},dg=["x1","y1","x2","y2","stroke","stroke-width"],ug=["x1","y1","x2","y2","stroke","stroke-width"],fg=["points","fill"],hg=["cx","cy","r","fill"],pg=["points","fill"],mg=15,gg=2,Tt=a.defineComponent({__name:"ArrowHead",props:{position:{},direction:{},thickness:{},color:{},arrowThickness:{},kind:{}},setup(n){const e=n,t=a.computed(()=>{const l=Math.hypot(e.direction[0],e.direction[1]);if(l===0)return null;const c=(e.arrowThickness/gg)**.33,d=mg*c,u=[e.direction[0]/l,e.direction[1]/l],f=[-u[1],u[0]];return{unitDir:u,perpDir:f,size:d}}),o=a.computed(()=>{if(!t.value)return null;const{unitDir:l,perpDir:c,size:d}=t.value,u=d,f=d,p=[e.position[0]-l[0]*u+c[0]*(f/2),e.position[1]-l[1]*u+c[1]*(f/2)],h=[e.position[0]-l[0]*u-c[0]*(f/2),e.position[1]-l[1]*u-c[1]*(f/2)];return{p1:p,p2:h}}),r=a.computed(()=>{if(!t.value)return null;const{unitDir:l,perpDir:c,size:d}=t.value,u=d,f=d,p=[l[0]*(d*.4),l[1]*(d*.4)],h=[e.position[0]-l[0]*u+p[0],e.position[1]-l[1]*u+p[1]],m=[h[0]+c[0]*(f/2),h[1]+c[1]*(f/2)],g=[h[0]-c[0]*(f/2),h[1]-c[1]*(f/2)],y=[e.position[0]+p[0],e.position[1]+p[1]];return`${y[0]},${y[1]} ${m[0]},${m[1]} ${g[0]},${g[1]}`}),s=a.computed(()=>{if(!t.value)return null;const{unitDir:l,size:c}=t.value,d=c*.8,u=[l[0]*d,l[1]*d];return{center:[e.position[0]-l[0]*d+u[0],e.position[1]-l[1]*d+u[1]],radius:d}}),i=a.computed(()=>{if(!t.value)return null;const{unitDir:l,perpDir:c,size:d}=t.value,u=1.6*d,f=1.6*d,p=[l[0]*(d*.8),l[1]*(d*.8)],h=[e.position[0]-l[0]*(u/2)+p[0],e.position[1]-l[1]*(u/2)+p[1]],m=[e.position[0]-l[0]*u+p[0],e.position[1]-l[1]*u+p[1]],g=[h[0]+c[0]*(f/2),h[1]+c[1]*(f/2)],y=[h[0]-c[0]*(f/2),h[1]-c[1]*(f/2)],w=[e.position[0]+p[0],e.position[1]+p[1]];return`${w[0]},${w[1]} ${g[0]},${g[1]} ${m[0]},${m[1]} ${y[0]},${y[1]}`});return(l,c)=>t.value?(a.openBlock(),a.createElementBlock("g",cg,[n.kind===a.unref(te.ArrowHeadKind).V&&o.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createElementVNode("line",{x1:o.value.p1[0],y1:o.value.p1[1],x2:n.position[0],y2:n.position[1],stroke:n.color,"stroke-width":n.thickness,"stroke-linecap":"round"},null,8,dg),a.createElementVNode("line",{x1:o.value.p2[0],y1:o.value.p2[1],x2:n.position[0],y2:n.position[1],stroke:n.color,"stroke-width":n.thickness,"stroke-linecap":"round"},null,8,ug)],64)):n.kind===a.unref(te.ArrowHeadKind).Delta&&r.value?(a.openBlock(),a.createElementBlock("polygon",{key:1,points:r.value,fill:n.color},null,8,fg)):n.kind===a.unref(te.ArrowHeadKind).Circle&&s.value?(a.openBlock(),a.createElementBlock("circle",{key:2,cx:s.value.center[0],cy:s.value.center[1],r:s.value.radius,fill:n.color},null,8,hg)):n.kind===a.unref(te.ArrowHeadKind).Diamond&&i.value?(a.openBlock(),a.createElementBlock("polygon",{key:3,points:i.value,fill:n.color},null,8,pg)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0)}}),yg={class:"arrow-svg",preserveAspectRatio:"none"},kg=["d","stroke","stroke-width"],wg=["x1","y1","x2","y2","stroke","stroke-width"],bg=["d"],Sg=["x1","y1","x2","y2"],xg=a.defineComponent({__name:"ArcArrow",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=a.ref(0),r=a.ref(0),s=me(e.entityId,k.Color),i=me(e.entityId,te.ArcArrow);let l=null;a.onMounted(()=>{t.value&&(l=new ResizeObserver(()=>{t.value&&(o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),l.observe(t.value),o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),a.onUnmounted(()=>{l==null||l.disconnect()});const c=a.computed(()=>{if(!s.value)return"#000000";const x=s.value.red.toString(16).padStart(2,"0"),S=s.value.green.toString(16).padStart(2,"0"),E=s.value.blue.toString(16).padStart(2,"0");return`#${x}${S}${E}`}),d=a.computed(()=>{var x;return((x=i.value)==null?void 0:x.value[6])??2}),u=a.computed(()=>`${d.value}px`),f=a.computed(()=>e.hovered||e.selected),p=a.computed(()=>{if(!i.value)return!1;const x=i.value.value,S=ae.Arc.create(x[0],x[1],x[2],x[3],x[4],x[5],x[6]);return!ae.Arc.isCollinear(S)}),h=a.computed(()=>{if(!i.value)return null;const x=i.value.value,S=o.value,E=r.value;return ae.Arc.create(x[0]*S,x[1]*E,x[2]*S,x[3]*E,x[4]*S,x[5]*E,x[6])}),m=a.computed(()=>!h.value||!p.value?null:ae.Arc.compute(h.value)),g=a.computed(()=>{var F,z,J,j;if(!i.value||!h.value)return null;const x=h.value,S=i.value.startArrowHead,E=i.value.endArrowHead,M=ae.Arc.length(x);let C=i.value.trimStart;if((F=e.connector)!=null&&F.startBlock&&S!=="none"){const K=((z=Hn(S))==null?void 0:z.gap)??0,W=M>0?K/M:0;C+=W}let T=i.value.trimEnd;if((J=e.connector)!=null&&J.endBlock&&E!=="none"){const K=((j=Hn(E))==null?void 0:j.gap)??0,W=M>0?K/M:0;T+=W}const v=1-T,I=ae.Arc.parametricToPoint(x,C),B=ae.Arc.parametricToPoint(x,v),P=b(ae.Arc.directionAt(x,C)),V=ae.Arc.directionAt(x,v);return{start:I,end:B,startDir:P,endDir:V,tStart:C,tEnd:v,startHead:S,endHead:E}}),y=a.computed(()=>{if(!g.value||!m.value||!p.value)return"";const{start:x,end:S,tStart:E,tEnd:M}=g.value,{radius:C,clockwise:T,arcAngle:v}=m.value,B=v*(M-E)>Math.PI?1:0,P=T?0:1;return`M ${x[0]} ${x[1]} A ${C} ${C} 0 ${B} ${P} ${S[0]} ${S[1]}`}),w=a.computed(()=>!g.value||p.value?null:{x1:g.value.start[0],y1:g.value.start[1],x2:g.value.end[0],y2:g.value.end[1]});function b(x){return[-x[0],-x[1]]}return(x,S)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-arc-arrow"},[(a.openBlock(),a.createElementBlock("svg",yg,[p.value&&y.value?(a.openBlock(),a.createElementBlock("path",{key:0,d:y.value,stroke:c.value,fill:"none","stroke-width":u.value,"stroke-linecap":"round"},null,8,kg)):w.value?(a.openBlock(),a.createElementBlock("line",{key:1,x1:w.value.x1,y1:w.value.y1,x2:w.value.x2,y2:w.value.y2,stroke:c.value,fill:"none","stroke-width":u.value,"stroke-linecap":"round"},null,8,wg)):a.createCommentVNode("",!0),g.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[g.value.startHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:0,position:g.value.start,direction:g.value.startDir,thickness:u.value,"arrow-thickness":d.value,color:c.value,kind:g.value.startHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),g.value.endHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:1,position:g.value.end,direction:g.value.endDir,thickness:u.value,"arrow-thickness":d.value,color:c.value,kind:g.value.endHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),f.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[p.value&&y.value?(a.openBlock(),a.createElementBlock("path",{key:0,d:y.value,class:"highlight-overlay",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,bg)):w.value?(a.openBlock(),a.createElementBlock("line",{key:1,x1:w.value.x1,y1:w.value.y1,x2:w.value.x2,y2:w.value.y2,class:"highlight-overlay",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,Sg)):a.createCommentVNode("",!0),g.value.startHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:2,position:g.value.start,direction:g.value.startDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":d.value,color:"var(--wov-highlighted-block-outline-color)",kind:g.value.startHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0),g.value.endHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:3,position:g.value.end,direction:g.value.endDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":d.value,color:"var(--wov-highlighted-block-outline-color)",kind:g.value.endHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)]))],512))}}),pn=(n,e)=>{const t=n.__vccOpts||n;for(const[o,r]of e)t[o]=r;return t},wc=pn(xg,[["__scopeId","data-v-de24f4c2"]]),Cg={},Eg={class:"wov-arrow-handle"};function vg(n,e){return a.openBlock(),a.createElementBlock("div",Eg,[...e[0]||(e[0]=[a.createElementVNode("div",{class:"wov-arrow-handle-inner"},null,-1)])])}const bc=pn(Cg,[["render",vg]]),Tg={},Mg={class:"wov-arrow-terminal"};function Ag(n,e){return a.openBlock(),a.createElementBlock("div",Mg,[...e[0]||(e[0]=[a.createElementVNode("div",{class:"wov-arrow-terminal-ring"},[a.createElementVNode("div",{class:"wov-arrow-terminal-fill"})],-1)])])}const Sc=pn(Tg,[["render",Ag]]),Ng={class:"arrow-svg",preserveAspectRatio:"none"},Ig=["x1","y1","x2","y2"],Bg=["x1","y1","x2","y2","stroke","stroke-width"],Og=["x1","y1","x2","y2"],xc=pn(a.defineComponent({__name:"ElbowArrow",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=a.ref(0),r=a.ref(0),s=me(e.entityId,k.Color),i=me(e.entityId,te.ElbowArrow),l=a.computed(()=>e.hovered||e.selected);let c=null;a.onMounted(()=>{t.value&&(c=new ResizeObserver(()=>{t.value&&(o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),c.observe(t.value),o.value=t.value.clientWidth,r.value=t.value.clientHeight)}),a.onUnmounted(()=>{c==null||c.disconnect()});const d=a.computed(()=>{if(!s.value)return"#000000";const g=s.value.red.toString(16).padStart(2,"0"),y=s.value.green.toString(16).padStart(2,"0"),w=s.value.blue.toString(16).padStart(2,"0");return`#${g}${y}${w}`}),u=a.computed(()=>{var g;return((g=i.value)==null?void 0:g.thickness)??2}),f=a.computed(()=>`${u.value}px`),p=a.computed(()=>{if(!i.value)return[];const g=i.value,y=o.value,w=r.value,b=[];for(let x=0;x<g.pointCount;x++){const S=g.points[x*2]*y,E=g.points[x*2+1]*w;b.push([S,E])}return b}),h=a.computed(()=>{const g=p.value;if(g.length<2)return[];const y=[];for(let w=0;w<g.length-1;w++)y.push({start:g[w],end:g[w+1]});return y}),m=a.computed(()=>{var B,P,V,F;if(!i.value||p.value.length<2)return null;const g=i.value,y=[...p.value.map(z=>[...z])],w=g.startArrowHead,b=g.endArrowHead,x=[y[1][0]-y[0][0],y[1][1]-y[0][1]],S=[y[y.length-1][0]-y[y.length-2][0],y[y.length-1][1]-y[y.length-2][1]];let E=g.trimStart;if((B=e.connector)!=null&&B.startBlock&&w!=="none"){const z=Math.hypot(x[0],x[1]),J=((P=Hn(w))==null?void 0:P.gap)??0,j=z>0?J/z:0;E+=j}let M=g.trimEnd;if((V=e.connector)!=null&&V.endBlock&&b!=="none"){const z=Math.hypot(S[0],S[1]),J=((F=Hn(b))==null?void 0:F.gap)??0,j=z>0?J/z:0;M+=j}const C=y.length-1,T=[y[0][0]+(y[1][0]-y[0][0])*E,y[0][1]+(y[1][1]-y[0][1])*E],v=[y[C-1][0]+(y[C][0]-y[C-1][0])*(1-M),y[C-1][1]+(y[C][1]-y[C-1][1])*(1-M)];y[0]=T,y[C]=v;const I=[];for(let z=0;z<y.length-1;z++)I.push({start:y[z],end:y[z+1]});return ae.Vec2.scale(x,-1),{points:y,lines:I,startPos:y[0],endPos:y[y.length-1],startDir:x,endDir:S,startHead:w,endHead:b}});return(g,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-elbow-arrow"},[(a.openBlock(),a.createElementBlock("svg",Ng,[l.value&&h.value.length>0?(a.openBlock(!0),a.createElementBlock(a.Fragment,{key:0},a.renderList(h.value,(w,b)=>(a.openBlock(),a.createElementBlock("line",{key:"bg-"+b,x1:w.start[0],y1:w.start[1],x2:w.end[0],y2:w.end[1],class:"highlight-bg",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))","stroke-dasharray":"calc(12px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,Ig))),128)):a.createCommentVNode("",!0),m.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(m.value.lines,(w,b)=>(a.openBlock(),a.createElementBlock("line",{key:b,x1:w.start[0],y1:w.start[1],x2:w.end[0],y2:w.end[1],stroke:d.value,fill:"none","stroke-width":f.value,"stroke-linecap":"round"},null,8,Bg))),128)),m.value.startHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:0,position:m.value.startPos,direction:m.value.startDir,thickness:f.value,"arrow-thickness":u.value,color:d.value,kind:m.value.startHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),m.value.endHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:1,position:m.value.endPos,direction:m.value.endDir,thickness:f.value,"arrow-thickness":u.value,color:d.value,kind:m.value.endHead},null,8,["position","direction","thickness","arrow-thickness","color","kind"])):a.createCommentVNode("",!0),l.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(m.value.lines,(w,b)=>(a.openBlock(),a.createElementBlock("line",{key:"hl-"+b,x1:w.start[0],y1:w.start[1],x2:w.end[0],y2:w.end[1],class:"highlight-overlay",fill:"none",style:{"stroke-width":"calc(2px / var(--wov-zoom))"},"stroke-linecap":"round"},null,8,Og))),128)),m.value.startHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:0,position:m.value.startPos,direction:m.value.startDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":u.value,color:"var(--wov-highlighted-block-outline-color)",kind:m.value.startHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0),m.value.endHead!=="none"?(a.openBlock(),a.createBlock(Tt,{key:1,position:m.value.endPos,direction:m.value.endDir,thickness:"calc(2px / var(--wov-zoom))","arrow-thickness":u.value,color:"var(--wov-highlighted-block-outline-color)",kind:m.value.endHead},null,8,["position","direction","arrow-thickness","kind"])):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)]))],512))}}),[["__scopeId","data-v-fab98224"]]),_g={class:"wov-embed-block"},Rg={key:0,class:"wov-embed-placeholder"},Pg=["src","allow"],Cc=a.defineComponent({__name:"EmbedBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const t=me(n.entityId,k.Embed),o=a.computed(()=>t.value&&(t.value.embedUrl||t.value.url)||null),r=a.computed(()=>{if(!t.value)return"";switch(t.value.provider){case k.EmbedProvider.Youtube:return"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";case k.EmbedProvider.Spotify:return"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture";case k.EmbedProvider.GoogleMaps:return"fullscreen";case k.EmbedProvider.GoogleCalendar:return"fullscreen";case k.EmbedProvider.GoogleSlides:return"fullscreen";case k.EmbedProvider.Figma:return"fullscreen";default:return"fullscreen"}}),s=a.computed(()=>{if(!t.value)return"Embed";switch(t.value.provider){case k.EmbedProvider.Youtube:return"YouTube";case k.EmbedProvider.Spotify:return"Spotify";case k.EmbedProvider.GoogleMaps:return"Google Maps";case k.EmbedProvider.GoogleCalendar:return"Google Calendar";case k.EmbedProvider.GoogleSlides:return"Google Slides";case k.EmbedProvider.Figma:return"Figma";case k.EmbedProvider.GithubGist:return"GitHub Gist";case k.EmbedProvider.Tldraw:return"tldraw";default:return"Embed"}});return(i,l)=>(a.openBlock(),a.createElementBlock("div",_g,[o.value?(a.openBlock(),a.createElementBlock("iframe",{key:1,src:o.value,allow:r.value,allowfullscreen:"",frameborder:"0",class:"wov-embed-iframe",style:a.normalizeStyle({pointerEvents:n.edited?"auto":"none"})},null,12,Pg)):(a.openBlock(),a.createElementBlock("div",Rg,[a.createElementVNode("span",null,a.toDisplayString(s.value),1)]))]))}}),{PI:Dg}=Math,So=Dg+1e-4,Ec=.5,vc=[1,1];function Tc(n,e,t,o=r=>r){return n*o(.5-e*(.5-t))}const{min:xi}=Math;function Mc(n,e,t){let o=xi(1,e/t);return xi(1,n+(xi(1,1-o)-n)*(o*.275))}function Lg(n){return[-n[0],-n[1]]}function ft(n,e){return[n[0]+e[0],n[1]+e[1]]}function Ac(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function zt(n,e){return[n[0]-e[0],n[1]-e[1]]}function Ci(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Ft(n,e){return[n[0]*e,n[1]*e]}function Ei(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function Vg(n,e){return[n[0]/e,n[1]/e]}function Nc(n){return[n[1],-n[0]]}function vi(n,e){let t=e[0];return n[0]=e[1],n[1]=-t,n}function Ic(n,e){return n[0]*e[0]+n[1]*e[1]}function $g(n,e){return n[0]===e[0]&&n[1]===e[1]}function zg(n){return Math.hypot(n[0],n[1])}function Bc(n,e){let t=n[0]-e[0],o=n[1]-e[1];return t*t+o*o}function Oc(n){return Vg(n,zg(n))}function Fg(n,e){return Math.hypot(n[1]-e[1],n[0]-e[0])}function Ti(n,e,t){let o=Math.sin(t),r=Math.cos(t),s=n[0]-e[0],i=n[1]-e[1],l=s*r-i*o,c=s*o+i*r;return[l+e[0],c+e[1]]}function _c(n,e,t,o){let r=Math.sin(o),s=Math.cos(o),i=e[0]-t[0],l=e[1]-t[1],c=i*s-l*r,d=i*r+l*s;return n[0]=c+t[0],n[1]=d+t[1],n}function Rc(n,e,t){return ft(n,Ft(zt(e,n),t))}function Hg(n,e,t,o){let r=t[0]-e[0],s=t[1]-e[1];return n[0]=e[0]+r*o,n[1]=e[1]+s*o,n}function Pc(n,e,t){return ft(n,Ft(e,t))}const Me=[0,0],Ht=[0,0],jt=[0,0];function jg(n,e){let t=Pc(n,Oc(Nc(zt(n,ft(n,[1,1])))),-e),o=[],r=1/13;for(let s=r;s<=1;s+=r)o.push(Ti(t,n,So*2*s));return o}function Wg(n,e,t){let o=[],r=1/t;for(let s=r;s<=1;s+=r)o.push(Ti(e,n,So*s));return o}function Ug(n,e,t){let o=zt(e,t),r=Ft(o,.5),s=Ft(o,.51);return[zt(n,r),zt(n,s),ft(n,s),ft(n,r)]}function Kg(n,e,t,o){let r=[],s=Pc(n,e,t),i=1/o;for(let l=i;l<1;l+=i)r.push(Ti(s,n,So*3*l));return r}function qg(n,e,t){return[ft(n,Ft(e,t)),ft(n,Ft(e,t*.99)),zt(n,Ft(e,t*.99)),zt(n,Ft(e,t))]}function Dc(n,e,t){return n===!1||n===void 0?0:n===!0?Math.max(e,t):n}function Jg(n,e,t){return n.slice(0,10).reduce((o,r)=>{let s=r.pressure;return e&&(s=Mc(o,r.distance,t)),(o+s)/2},n[0].pressure)}function Gg(n,e={}){let{size:t=16,smoothing:o=.5,thinning:r=.5,simulatePressure:s=!0,easing:i=j=>j,start:l={},end:c={},last:d=!1}=e,{cap:u=!0,easing:f=j=>j*(2-j)}=l,{cap:p=!0,easing:h=j=>--j*j*j+1}=c;if(n.length===0||t<=0)return[];let m=n[n.length-1].runningLength,g=Dc(l.taper,t,m),y=Dc(c.taper,t,m),w=(t*o)**2,b=[],x=[],S=Jg(n,s,t),E=Tc(t,r,n[n.length-1].pressure,i),M,C=n[0].vector,T=n[0].point,v=T,I=T,B=v,P=!1;for(let j=0;j<n.length;j++){let{pressure:K}=n[j],{point:W,vector:X,distance:re,runningLength:ie}=n[j],be=j===n.length-1;if(!be&&m-ie<3)continue;r?(s&&(K=Mc(S,re,t)),E=Tc(t,r,K,i)):E=t/2,M===void 0&&(M=E);let se=ie<g?f(ie/g):1,ot=m-ie<y?h((m-ie)/y):1;E=Math.max(.01,E*Math.min(se,ot));let he=(be?n[j]:n[j+1]).vector,hn=be?1:Ic(X,he),yi=Ic(X,C)<0&&!P,bo=hn!==null&&hn<0;if(yi||bo){vi(Me,C),Ei(Me,Me,E);for(let Et=0;Et<=1;Et+=.07692307692307693)Ci(Ht,W,Me),_c(Ht,Ht,W,So*Et),I=[Ht[0],Ht[1]],b.push(I),Ac(jt,W,Me),_c(jt,jt,W,So*-Et),B=[jt[0],jt[1]],x.push(B);T=I,v=B,bo&&(P=!0);continue}if(P=!1,be){vi(Me,X),Ei(Me,Me,E),b.push(zt(W,Me)),x.push(ft(W,Me));continue}Hg(Me,he,X,hn),vi(Me,Me),Ei(Me,Me,E),Ci(Ht,W,Me),I=[Ht[0],Ht[1]],(j<=1||Bc(T,I)>w)&&(b.push(I),T=I),Ac(jt,W,Me),B=[jt[0],jt[1]],(j<=1||Bc(v,B)>w)&&(x.push(B),v=B),S=K,C=X}let V=[n[0].point[0],n[0].point[1]],F=n.length>1?[n[n.length-1].point[0],n[n.length-1].point[1]]:ft(n[0].point,[1,1]),z=[],J=[];if(n.length===1){if(!(g||y)||d)return jg(V,M||E)}else{g||y&&n.length===1||(u?z.push(...Wg(V,x[0],13)):z.push(...Ug(V,b[0],x[0])));let j=Nc(Lg(n[n.length-1].vector));y||g&&n.length===1?J.push(F):p?J.push(...Kg(F,j,E,29)):J.push(...qg(F,j,E))}return b.concat(J,x.reverse(),z)}const Lc=[0,0];function Vc(n){return n!=null&&n>=0}function Yg(n,e={}){var p;let{streamline:t=.5,size:o=16,last:r=!1}=e;if(n.length===0)return[];let s=.15+(1-t)*.85,i=Array.isArray(n[0])?n:n.map(({x:h,y:m,pressure:g=Ec})=>[h,m,g]);if(i.length===2){let h=i[1];i=i.slice(0,-1);for(let m=1;m<5;m++)i.push(Rc(i[0],h,m/4))}i.length===1&&(i=[...i,[...ft(i[0],vc),...i[0].slice(2)]]);let l=[{point:[i[0][0],i[0][1]],pressure:Vc(i[0][2])?i[0][2]:.25,vector:[...vc],distance:0,runningLength:0}],c=!1,d=0,u=l[0],f=i.length-1;for(let h=1;h<i.length;h++){let m=r&&h===f?[i[h][0],i[h][1]]:Rc(u.point,i[h],s);if($g(u.point,m))continue;let g=Fg(m,u.point);if(d+=g,h<f&&!c){if(d<o)continue;c=!0}Ci(Lc,u.point,m),u={point:m,pressure:Vc(i[h][2])?i[h][2]:Ec,vector:Oc(Lc),distance:g,runningLength:d},l.push(u)}return l[0].vector=((p=l[1])==null?void 0:p.vector)||[0,0],l}function Mi(n,e={}){return Gg(Yg(n,e),e)}const Xg={class:"wov-eraser-stroke"},Qg={preserveAspectRatio:"none"},Zg=["d"],ey="#88888833",$c=a.defineComponent({__name:"Eraser",props:{entityId:{}},setup(n){const e=n,t=me(e.entityId,kr.EraserStroke),o=me(e.entityId,k.Block),r=a.shallowRef("");function s(l,c){return(l+c)/2}function i(l,c,d,u,f,p){if(l<=4)return"";const h=[],m=Math.min(l,kr.POINTS_CAPACITY);for(let S=0;S<m;S++){const E=(c+S)%kr.POINTS_CAPACITY*2;h.push([d[E]-f,d[E+1]-p])}const g=Mi(h,{size:u,start:{taper:66,cap:!0}});if(g.length<3)return"";let y=g[0],w=g[1];const b=g[2];let x=`M${y[0].toFixed(2)},${y[1].toFixed(2)} Q${w[0].toFixed(2)},${w[1].toFixed(2)} ${s(w[0],b[0]).toFixed(2)},${s(w[1],b[1]).toFixed(2)} T`;for(let S=2;S<g.length-1;S++)y=g[S],w=g[S+1],x+=`${s(y[0],w[0]).toFixed(2)},${s(y[1],w[1]).toFixed(2)} `;return x+=`${w[0].toFixed(2)},${w[1].toFixed(2)} `,x+="Z",x}return a.watch([t,o],([l,c])=>{if(!l||!c){r.value="";return}const d=l.radius??8,[u,f]=c.position;r.value=i(l.pointCount,l.firstPointIndex,l.points,2*d,u,f)},{immediate:!0}),(l,c)=>(a.openBlock(),a.createElementBlock("div",Xg,[(a.openBlock(),a.createElementBlock("svg",Qg,[a.createElementVNode("path",{d:r.value,fill:ey},null,8,Zg)]))]))}}),ty={class:"wov-image-block"},ny={key:0,class:"wov-image-placeholder wov-image-loading"},oy={key:1,class:"wov-image-placeholder"},ry={key:2,class:"wov-image-placeholder wov-image-error"},sy=["src","alt"],zc=a.defineComponent({__name:"ImageBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},async setup(n){let e,t;const o=n,r=a.inject(Se);if(!r)throw new Error("ImageBlock must be used within a WovenCanvas component");const s=r,i=me(o.entityId,k.Asset),l=me(o.entityId,k.Image),c=s.getAssetManager(),d=a.computed(()=>{const b=i.value;return!(b!=null&&b.identifier)||b.uploadState!==k.UploadState.Pending&&b.uploadState!==k.UploadState.Uploading?!1:!(c!=null&&c.hasPendingUpload(b.identifier))}),u=i.value;let f=null;c&&(u!=null&&u.identifier)&&!d.value&&(f=([e,t]=a.withAsyncContext(()=>c.getDisplayUrl(u.identifier)),e=await e,t(),e));const p=a.ref(f),h=a.ref(!f),m=a.ref(!1);let g=!0;a.onUnmounted(()=>{g=!1});async function y(){const b=i.value;if(!b){h.value=!1;return}if(d.value){p.value=null,h.value=!0,m.value=!1;return}try{h.value=!0,m.value=!1;const x=await(c==null?void 0:c.getDisplayUrl(b.identifier));if(!g)return;x?(p.value=x,h.value=!1):b.uploadState===k.UploadState.Failed&&(m.value=!0,h.value=!1)}catch(x){if(!g)return;console.error("Failed to get display URL:",x),m.value=!0,h.value=!1}}a.watch(()=>i.value,()=>{y()},{immediate:!0}),a.onMounted(()=>{y()});const w=a.computed(()=>({width:"100%",height:"100%",objectFit:"fill"}));return(b,x)=>{var S;return a.openBlock(),a.createElementBlock("div",ty,[d.value?(a.openBlock(),a.createElementBlock("div",ny,[...x[0]||(x[0]=[a.createElementVNode("div",{class:"wov-image-spinner","aria-label":"Loading image"},null,-1)])])):h.value&&!p.value?(a.openBlock(),a.createElementBlock("div",oy)):m.value?(a.openBlock(),a.createElementBlock("div",ry,[...x[1]||(x[1]=[a.createElementVNode("span",null,"Failed to save image",-1)])])):p.value?(a.openBlock(),a.createElementBlock("img",{key:3,src:p.value,alt:((S=a.unref(l))==null?void 0:S.alt)||"",style:a.normalizeStyle(w.value),draggable:"false"},null,12,sy)):a.createCommentVNode("",!0)])}}}),iy=["data-complete"],ly={preserveAspectRatio:"none"},ay=["d","fill"],cy={key:0,class:"highlight",preserveAspectRatio:"none"},dy=["d"],Fc=pn(a.defineComponent({__name:"PenStroke",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=me(e.entityId,wr.PenStroke),o=me(e.entityId,k.Block),r=me(e.entityId,k.Color),s=a.shallowRef(""),i=a.shallowRef("");function l(f,p){return(f+p)/2}function c(f,p,h){if(p<=4||f.length<3){const b=h/2;return`M ${b},0 a ${b},${b} 0 1 0 0.0001 0`}let m=f[0],g=f[1];const y=f[2];let w=`M${m[0].toFixed(2)},${m[1].toFixed(2)} Q${g[0].toFixed(2)},${g[1].toFixed(2)} ${l(g[0],y[0]).toFixed(2)},${l(g[1],y[1]).toFixed(2)} T`;for(let b=2;b<f.length-1;b++)m=f[b],g=f[b+1],w+=`${l(m[0],g[0]).toFixed(2)},${l(m[1],g[1]).toFixed(2)} `;return w+=`${g[0].toFixed(2)},${g[1].toFixed(2)} `,w+="Z",w}a.watch([t,o],([f,p])=>{if(!f||!p){s.value="",i.value="";return}if(!f.originalWidth||!f.originalHeight){s.value="",i.value="";return}const h=p.size[0]/f.originalWidth,m=p.size[1]/f.originalHeight,g=[];for(let w=0;w<f.pointCount;w++){const b=f.points[w*2],x=f.points[w*2+1],S=(b-f.originalLeft)*h,E=(x-f.originalTop)*m;f.hasPressure?g.push([S,E,f.pressures[w]]):g.push([S,E])}const y=Mi(g,{last:f.isComplete,size:f.thickness,simulatePressure:!f.hasPressure});if(s.value=c(y,f.pointCount,f.thickness),f.isComplete){const w=g.length===1?f.thickness:1,b=Mi(g,{last:!0,size:w,simulatePressure:!f.hasPressure});i.value=c(b,f.pointCount,w)}},{immediate:!0});const d=a.computed(()=>r.value?`rgb(${r.value.red}, ${r.value.green}, ${r.value.blue})`:"#000000"),u=a.computed(()=>e.selected||e.hovered);return(f,p)=>{var h;return a.openBlock(),a.createElementBlock("div",{class:"wov-pen-stroke","data-complete":((h=a.unref(t))==null?void 0:h.isComplete)||void 0},[(a.openBlock(),a.createElementBlock("svg",ly,[a.createElementVNode("path",{d:s.value,fill:d.value},null,8,ay)])),u.value?(a.openBlock(),a.createElementBlock("svg",cy,[a.createElementVNode("path",{d:i.value,stroke:"var(--wov-highlighted-block-outline-color)",style:{"stroke-width":"calc(1px / var(--wov-zoom))"},fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,8,dy)])):a.createCommentVNode("",!0)],8,iy)}}}),[["__scopeId","data-v-73f3bc07"]]);function fe(){const n=a.inject(Se);if(!n)throw new Error("useEditorContext must be used within a WovenCanvas component");return{getEditor:()=>n.getEditor(),setDefaults:(e,t)=>n.setDefaults(e,t),getDefaults:e=>n.getDefaults(e),nextEditorTick(e){return new Promise(t=>{const o=n.getEditor();o&&o.nextTick(r=>{e==null||e(r),t(r)})})}}}const xo={rectangle:"M0,0 L100,0 L100,100 L0,100 Z",ellipse:"M50,0 A50,50 0 1,1 50,100 A50,50 0 1,1 50,0",triangle:"M50,0 L100,100 L0,100 Z",diamond:"M50,0 L100,50 L50,100 L0,50 Z",pentagon:"M50,0 L100,38.2 L80.9,100 L19.1,100 L0,38.2 Z",hexagon:"M50,0 L100,25 L100,75 L50,100 L0,75 L0,25 Z",star:"M50,0 L61.8,38.2 L100,38.2 L69.1,61.8 L80.9,100 L50,76.4 L19.1,100 L30.9,61.8 L0,38.2 L38.2,38.2 Z",heart:"M50,16 C44,7 37,0 26,0 11,0 0,12 0,28 0,60 16,65 50,100 84,65 100,60 100,28 100,12 89,0 74,0 63,0 56,7 50,16 Z",arrow:"M0,35 L60,35 L60,0 L100,50 L60,100 L60,65 L0,65 Z"};function Ae(n){this.content=n}Ae.prototype={constructor:Ae,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,r=o.find(n),s=o.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new Ae(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ae(t)},addToStart:function(n,e){return new Ae([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ae(t)},addBefore:function(n,e,t){var o=this.remove(e),r=o.content.slice(),s=o.find(n);return r.splice(s==-1?r.length:s,0,e,t),new Ae(r)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ae.from(n),n.size?new Ae(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ae.from(n),n.size?new Ae(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ae.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Ae.from=function(n){if(n instanceof Ae)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ae(e)};function Hc(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(o),s=e.child(o);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let i=0;r.text[i]==s.text[i];i++)t++;return t}if(r.content.size||s.content.size){let i=Hc(r.content,s.content,t+1);if(i!=null)return i}t+=r.nodeSize}}function jc(n,e,t,o){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:o};let i=n.child(--r),l=e.child(--s),c=i.nodeSize;if(i==l){t-=c,o-=c;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let d=0,u=Math.min(i.text.length,l.text.length);for(;d<u&&i.text[i.text.length-d-1]==l.text[l.text.length-d-1];)d++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let d=jc(i.content,l.content,t-1,o-1);if(d)return d}t-=c,o-=c}}class _{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,r=0,s){for(let i=0,l=0;l<t;i++){let c=this.content[i],d=l+c.nodeSize;if(d>e&&o(c,r+l,s||null,i)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),o,r+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,r){let s="",i=!0;return this.nodesBetween(e,t,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&o&&(i?i=!1:s+=o),s+=d},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(o)&&(r[r.length-1]=t.withText(t.text+o.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new _(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],r=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],c=i+l.nodeSize;c>e&&((i<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),r+=l.nodeSize),i=c}return new _(o,r)}cutByIndex(e,t){return e==t?_.empty:e==0&&t==this.content.length?this:new _(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-o.nodeSize;return r[e]=t,new _(r,s)}addToStart(e){return new _([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new _(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,o=0;t<this.content.length;t++){let r=this.content[t];e(r,o,t),o+=r.nodeSize}}findDiffStart(e,t=0){return Hc(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return jc(this,e,t,o)}findIndex(e){if(e==0)return br(0,e);if(e==this.size)return br(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,o=0;;t++){let r=this.child(t),s=o+r.nodeSize;if(s>=e)return s==e?br(t+1,s):br(t,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return _.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new _(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return _.empty;let t,o=0;for(let r=0;r<e.length;r++){let s=e[r];o+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new _(t||e,o)}static from(e){if(!e)return _.empty;if(e instanceof _)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new _([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}_.empty=new _([],0);const Ai={index:0,offset:0};function br(n,e){return Ai.index=n,Ai.offset=e,Ai}function Sr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let o=0;o<n.length;o++)if(!Sr(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Sr(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}let le=class pc{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!o&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),o=!0),t&&t.push(s)}}return t||(t=e.slice()),o||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&&Sr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=o.create(t.attrs);return o.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return pc.none;if(e instanceof pc)return[e];let t=e.slice();return t.sort((o,r)=>o.type.rank-r.type.rank),t}};le.none=[];class xr extends Error{}class H{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=Uc(this.content,e+this.openStart,t);return o&&new H(o,this.openStart,this.openEnd)}removeBetween(e,t){return new H(Wc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return H.empty;let o=t.openStart||0,r=t.openEnd||0;if(typeof o!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new H(_.fromJSON(e,t.content),o,r)}static maxOpen(e,t=!0){let o=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)o++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new H(e,o,r)}}H.empty=new H(_.empty,0,0);function Wc(n,e,t){let{index:o,offset:r}=n.findIndex(e),s=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(r==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,s.copy(Wc(s.content,e-r-1,t-r-1)))}function Uc(n,e,t,o){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r);if(s==e||i.isText)return o&&!o.canReplace(r,r,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Uc(i.content,e-s-1,t,i);return l&&n.replaceChild(r,i.copy(l))}function uy(n,e,t){if(t.openStart>n.depth)throw new xr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new xr("Inconsistent open depths");return Kc(n,e,t,0)}function Kc(n,e,t,o){let r=n.index(o),s=n.node(o);if(r==e.index(o)&&o<n.depth-t.openStart){let i=Kc(n,e,t,o+1);return s.copy(s.content.replaceChild(r,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return gn(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=fy(t,n);return gn(s,Jc(n,i,l,e,o))}else return gn(s,Cr(n,e,o))}function qc(n,e){if(!e.type.compatibleContent(n.type))throw new xr("Cannot join "+e.type.name+" onto "+n.type.name)}function Ni(n,e,t){let o=n.node(t);return qc(o,e.node(t)),o}function mn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Co(n,e,t,o){let r=(e||n).node(t),s=0,i=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(mn(n.nodeAfter,o),s++));for(let l=s;l<i;l++)mn(r.child(l),o);e&&e.depth==t&&e.textOffset&&mn(e.nodeBefore,o)}function gn(n,e){return n.type.checkContent(e),n.copy(e)}function Jc(n,e,t,o,r){let s=n.depth>r&&Ni(n,e,r+1),i=o.depth>r&&Ni(t,o,r+1),l=[];return Co(null,n,r,l),s&&i&&e.index(r)==t.index(r)?(qc(s,i),mn(gn(s,Jc(n,e,t,o,r+1)),l)):(s&&mn(gn(s,Cr(n,e,r+1)),l),Co(e,t,r,l),i&&mn(gn(i,Cr(t,o,r+1)),l)),Co(o,null,r,l),new _(l)}function Cr(n,e,t){let o=[];if(Co(null,n,t,o),n.depth>t){let r=Ni(n,e,t+1);mn(gn(r,Cr(n,e,t+1)),o)}return Co(e,null,t,o),new _(o)}function fy(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(_.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class Eo{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],r=e.child(t);return o?e.child(t).cut(o):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 o=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=o.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return le.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),r=e.maybeChild(t);if(!o){let l=o;o=r,r=l}let s=o.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!r||!s[i].isInSet(r.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!r||!o[s].isInSet(r.marks))&&(o=o[s--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Er(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],r=0,s=t;for(let i=e;;){let{index:l,offset:c}=i.content.findIndex(s),d=s-c;if(o.push(i,l,r+c),!d||(i=i.child(l),i.isText))break;s=d-1,r+=c+1}return new Eo(t,o,s)}static resolveCached(e,t){let o=Gc.get(e);if(o)for(let s=0;s<o.elts.length;s++){let i=o.elts[s];if(i.pos==t)return i}else Gc.set(e,o=new hy);let r=o.elts[o.i]=Eo.resolve(e,t);return o.i=(o.i+1)%py,r}}class hy{constructor(){this.elts=[],this.i=0}}const py=12,Gc=new WeakMap;class Er{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const my=Object.create(null);let Mt=class mc{constructor(e,t,o,r=le.none){this.type=e,this.attrs=t,this.marks=r,this.content=o||_.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,o,r=0){this.content.nodesBetween(e,t,o,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,o,r){return this.content.textBetween(e,t,o,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,o){return this.type==e&&Sr(this.attrs,t||e.defaultAttrs||my)&&le.sameSet(this.marks,o||le.none)}copy(e=null){return e==this.content?this:new mc(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new mc(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,o=!1){if(e==t)return H.empty;let r=this.resolve(e),s=this.resolve(t),i=o?0:r.sharedDepth(t),l=r.start(i),d=r.node(i).content.cut(r.pos-l,s.pos-l);return new H(d,r.depth-i,s.depth-i)}replace(e,t,o){return uy(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let r=this.content.child(t-1);return{node:r,index:t-1,offset:o-r.nodeSize}}resolve(e){return Eo.resolveCached(this,e)}resolveNoCache(e){return Eo.resolve(this,e)}rangeHasMark(e,t,o){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(o.isInSet(s.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()+")"),Yc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,o=_.empty,r=0,s=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,r,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=r;c<s;c++)if(!this.type.allowsMarks(o.child(c).marks))return!1;return!0}canReplaceWith(e,t,o,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(o),i=s&&s.matchFragment(this.content,t);return i?i.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=le.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let r=_.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,o);return s.type.checkAttrs(s.attrs),s}};Mt.prototype.text=void 0;class vr extends Mt{constructor(e,t,o,r){if(super(e,t,null,r),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Yc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Yc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class yn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new gy(e,t);if(o.next==null)return yn.empty;let r=Xc(o);o.next&&o.err("Unexpected trailing text");let s=Cy(xy(r));return Ey(s,o),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let r=this;for(let s=t;r&&s<o;s++)r=r.matchType(e.child(s).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 o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let r=[this];function s(i,l){let c=i.matchFragment(e,o);if(c&&(!t||c.validEnd))return _.from(l.map(d=>d.createAndFill()));for(let d=0;d<i.next.length;d++){let{type:u,next:f}=i.next[d];if(!(u.isText||u.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let p=s(f,l.concat(u));if(p)return p}}return null}return s(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let r=o.shift(),s=r.match;if(s.matchType(e)){let i=[];for(let l=r;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:c}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||c.validEnd)&&(o.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let r=0;r<o.next.length;r++)e.indexOf(o.next[r].next)==-1&&t(o.next[r].next)}return t(this),e.map((o,r)=>{let s=r+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)s+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return s}).join(`
|
|
2
|
+
`)}}yn.empty=new yn(!0);class gy{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Xc(n){let e=[];do e.push(yy(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function yy(n){let e=[];do e.push(ky(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ky(n){let e=Sy(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=wy(n,e);else break;return e}function Qc(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function wy(n,e){let t=Qc(n),o=t;return n.eat(",")&&(n.next!="}"?o=Qc(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function by(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let r=[];for(let s in t){let i=t[s];i.isInGroup(e)&&r.push(i)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function Sy(n){if(n.eat("(")){let e=Xc(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=by(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function xy(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,c){let d={term:c,to:l};return e[i].push(d),d}function r(i,l){i.forEach(c=>c.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((c,d)=>c.concat(s(d,l)),[]);if(i.type=="seq")for(let c=0;;c++){let d=s(i.exprs[c],l);if(c==i.exprs.length-1)return d;r(d,l=t())}else if(i.type=="star"){let c=t();return o(l,c),r(s(i.expr,c),c),[o(c)]}else if(i.type=="plus"){let c=t();return r(s(i.expr,l),c),r(s(i.expr,c),c),[o(c)]}else{if(i.type=="opt")return[o(l)].concat(s(i.expr,l));if(i.type=="range"){let c=l;for(let d=0;d<i.min;d++){let u=t();r(s(i.expr,c),u),c=u}if(i.max==-1)r(s(i.expr,c),c);else for(let d=i.min;d<i.max;d++){let u=t();o(c,u),r(s(i.expr,c),u),c=u}return[o(c)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Zc(n,e){return e-n}function ed(n,e){let t=[];return o(e),t.sort(Zc);function o(r){let s=n[r];if(s.length==1&&!s[0].term)return o(s[0].to);t.push(r);for(let i=0;i<s.length;i++){let{term:l,to:c}=s[i];!l&&t.indexOf(c)==-1&&o(c)}}}function Cy(n){let e=Object.create(null);return t(ed(n,0));function t(o){let r=[];o.forEach(i=>{n[i].forEach(({term:l,to:c})=>{if(!l)return;let d;for(let u=0;u<r.length;u++)r[u][0]==l&&(d=r[u][1]);ed(n,c).forEach(u=>{d||r.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let s=e[o.join(",")]=new yn(o.indexOf(n.length-1)>-1);for(let i=0;i<r.length;i++){let l=r[i][1].sort(Zc);s.next.push({type:r[i][0],next:e[l.join(",")]||t(l)})}return s}}function Ey(n,e){for(let t=0,o=[n];t<o.length;t++){let r=o[t],s=!r.validEnd,i=[];for(let l=0;l<r.next.length;l++){let{type:c,next:d}=r.next[l];i.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),o.indexOf(d)==-1&&o.push(d)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function td(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function nd(n,e){let t=Object.create(null);for(let o in n){let r=e&&e[o];if(r===void 0){let s=n[o];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=r}return t}function od(n,e,t,o){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function rd(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Ty(n,o,e[o]);return t}let sd=class og{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=rd(e,o.attrs),this.defaultAttrs=td(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==yn.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:nd(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Mt(this,this.computeAttrs(e),_.from(t),le.setFrom(o))}createChecked(e=null,t,o){return t=_.from(t),this.checkContent(t),new Mt(this,this.computeAttrs(e),t,le.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=_.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(_.empty,!0);return s?new Mt(this,e,t.append(s),le.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){od(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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:le.none:e}static compile(e,t){let o=Object.create(null);e.forEach((s,i)=>o[s]=new og(s,t,i));let r=t.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let s in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function vy(n,e,t){let o=t.split("|");return r=>{let s=r===null?"null":typeof r;if(o.indexOf(s)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${s}`)}}class Ty{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?vy(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Tr{constructor(e,t,o,r){this.name=e,this.rank=t,this.schema=o,this.spec=r,this.attrs=rd(e,r.attrs),this.excluded=null;let s=td(this.attrs);this.instance=s?new le(this,s):null}create(e=null){return!e&&this.instance?this.instance:new le(this,nd(this.attrs,e))}static compile(e,t){let o=Object.create(null),r=0;return e.forEach((s,i)=>o[s]=new Tr(s,r++,t,i)),o}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){od(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class id{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Ae.from(e.nodes),t.marks=Ae.from(e.marks||{}),this.nodes=sd.compile(this.spec.nodes,this),this.marks=Tr.compile(this.spec.marks,this);let o=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=o[i]||(o[i]=yn.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?ld(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:ld(this,i.split(" "))}this.nodeFromJSON=r=>Mt.fromJSON(this,r),this.markFromJSON=r=>le.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof sd){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,o,r)}text(e,t){let o=this.nodes.text;return new vr(o,o.defaultAttrs,e,le.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 new RangeError("Unknown node type: "+e);return t}}function ld(n,e){let t=[];for(let o=0;o<e.length;o++){let r=e[o],s=n.marks[r],i=s;if(s)t.push(s);else for(let l in n.marks){let c=n.marks[l];(r=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&t.push(i=c)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function My(n){return n.tag!=null}function Ay(n){return n.style!=null}class At{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(r=>{if(My(r))this.tags.push(r);else if(Ay(r)){let s=/[^=]*/.exec(r.style)[0];o.indexOf(s)<0&&o.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let o=new ud(this,t,!1);return o.addAll(e,le.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new ud(this,t,!0);return o.addAll(e,le.none,t.from,t.to),H.maxOpen(o.finish())}matchTag(e,t,o){for(let r=o?this.tags.indexOf(o)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(By(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,o,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let c=i.getAttrs(t);if(c===!1)continue;i.attrs=c||void 0}return i}}}static schemaRules(e){let t=[];function o(r){let s=r.priority==null?50:r.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(i=>{o(i=fd(i)),i.mark||i.ignore||i.clearMark||(i.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(i=>{o(i=fd(i)),i.node||i.ignore||i.mark||(i.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new At(e,At.schemaRules(e)))}}const ad={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},Ny={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cd={ol:!0,ul:!0},vo=1,Ii=2,To=4;function dd(n,e,t){return e!=null?(e?vo:0)|(e==="full"?Ii:0):n&&n.whitespace=="pre"?vo|Ii:t&~To}class Mr{constructor(e,t,o,r,s,i){this.type=e,this.attrs=t,this.marks=o,this.solid=r,this.options=i,this.content=[],this.activeMarks=le.none,this.match=s||(i&To?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(_.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,r;return(r=o.findWrapping(e.type))?(this.match=o,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&vo)){let o=this.content[this.content.length-1],r;if(o&&o.isText&&(r=/[ \t\r\n\u000c]+$/.exec(o.text))){let s=o;o.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=_.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(_.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&&!ad.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ud{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,i=dd(null,t.preserveWhitespace,0)|(o?To:0);r?s=new Mr(r.type,r.attrs,le.none,!0,t.topMatch||r.type.contentMatch,i):o?s=new Mr(null,null,le.none,!0,null,i):s=new Mr(e.schema.topNodeType,null,le.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,r=this.top,s=r.options&Ii?"full":this.localPreserveWS||(r.options&vo)>0,{schema:i}=this.parser;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s)if(s==="full")o=o.replace(/\r\n?/g,`
|
|
3
|
+
`);else if(i.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=o.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[c]&&this.insertNode(i.text(l[c]),t,!/\S/.test(l[c]));o=""}else o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(o=o.slice(1))}o&&this.insertNode(i.text(o),t,!/\S/.test(o)),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let r=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;cd.hasOwnProperty(i)&&this.parser.normalizeLists&&Iy(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,o));e:if(c?c.ignore:Ny.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let d,u=this.needsBlock;if(ad.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),d=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=c&&c.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),d&&this.sync(s),this.needsBlock=u}else{let d=this.readStyles(e,t);d&&this.addElementByRule(e,c,d,c.consuming===!1?l: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 o=e.style;if(o&&o.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],i=o.getPropertyValue(s);if(i)for(let l=void 0;;){let c=this.parser.matchStyle(s,i,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?t=t.filter(d=>!c.clearMark(d)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,o,r){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let c=this.enter(i,t.attrs||null,o,t.preserveWhitespace);c&&(s=!0,o=c)}else{let c=this.parser.schema.marks[t.mark];o=o.concat(c.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,o,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,o,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,o),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,o,r){let s=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=r==null?null:e.childNodes[r];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,o){let r,s;for(let i=this.open,l=0;i>=0;i--){let c=this.nodes[i],d=c.findWrapping(e);if(d&&(!r||r.length>d.length+l)&&(r=d,s=c,!d.length))break;if(c.solid){if(o)break;l+=2}}if(!r)return null;this.sync(s);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],null,t,!1);return t}insertNode(e,t,o){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t,o);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=le.none;for(let l of r.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):hd(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,o,r){let s=this.findPlace(e.create(t),o,!1);return s&&(s=this.enterInner(e,t,o,!0,r)),s}enterInner(e,t,o,r=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=dd(e,s,i.options);i.options&To&&i.content.length==0&&(l|=To);let c=le.none;return o=o.filter(d=>(i.type?i.type.allowsMarkType(d.type):hd(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Mr(e,t,c,r,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=vo)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let r=o.length-1;r>=0;r--)e+=o[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].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,o){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)&(o?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("/"),o=this.options.context,r=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),s=-(o?o.depth+1:0)+(r?0:1),i=(l,c)=>{for(;l>=0;l--){let d=t[l];if(d==""){if(l==t.length-1||l==0)continue;for(;c>=s;c--)if(i(l-1,c))return!0;return!1}else{let u=c>0||c==0&&r?this.nodes[c].type:o&&c>=s?o.node(c-s).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Iy(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&cd.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function By(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function fd(n){let e={};for(let t in n)e[t]=n[t];return e}function hd(n,e){let t=e.schema.nodes;for(let o in t){let r=t[o];if(!r.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:d,next:u}=l.edge(c);if(d==e||s.indexOf(u)<0&&i(u))return!0}};if(i(r.contentMatch))return!0}}class kn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Bi(t).createDocumentFragment());let r=o,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,c=0;for(;l<s.length&&c<i.marks.length;){let d=i.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(s[l][0])||d.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)r=s.pop()[1];for(;c<i.marks.length;){let d=i.marks[c++],u=this.serializeMark(d,i.isInline,t);u&&(s.push([d,r]),r.appendChild(u.dom),r=u.contentDOM||u.dom)}}r.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:r}=Ar(Bi(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(o),o=s.dom)}return o}serializeMark(e,t,o={}){let r=this.marks[e.type.name];return r&&Ar(Bi(o),r(e,t),null,e.attrs)}static renderSpec(e,t,o=null,r){return Ar(e,t,o,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new kn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=pd(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return pd(e.marks)}}function pd(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Bi(n){return n.document||window.document}const md=new WeakMap;function Oy(n){let e=md.get(n);return e===void 0&&md.set(n,e=_y(n)),e}function _y(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let r=0;r<o.length;r++)t(o[r]);else for(let r in o)t(o[r])}return t(n),e}function Ar(n,e,t,o){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(s=Oy(o))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=r.indexOf(" ");i>0&&(t=r.slice(0,i),r=r.slice(i+1));let l,c=t?n.createElementNS(t,r):n.createElement(r),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&c.style?c.style.cssText=d[f]:c.setAttribute(f,d[f])}}for(let f=u;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:h,contentDOM:m}=Ar(n,p,t,o);if(c.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:c,contentDOM:l}}const gd=65535,yd=Math.pow(2,16);function Ry(n,e){return n+e*yd}function kd(n){return n&gd}function Py(n){return(n-(n&gd))/yd}const wd=1,bd=2,Nr=4,Sd=8;class Oi{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Sd)>0}get deletedBefore(){return(this.delInfo&(wd|Nr))>0}get deletedAfter(){return(this.delInfo&(bd|Nr))>0}get deletedAcross(){return(this.delInfo&Nr)>0}}class Ue{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ue.empty)return Ue.empty}recover(e){let t=0,o=kd(e);if(!this.inverted)for(let r=0;r<o;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[o*3]+t+Py(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let r=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[l+s],u=this.ranges[l+i],f=c+d;if(e<=f){let p=d?e==c?-1:e==f?1:t:t,h=c+r+(p<0?0:u);if(o)return h;let m=e==(t<0?c:f)?null:Ry(l/3,e-c),g=e==c?bd:e==f?wd:Nr;return(t<0?e!=c:e!=f)&&(g|=Sd),new Oi(h,g,m)}r+=u-d}return o?e+r:new Oi(e+r,0,null)}touches(e,t){let o=0,r=kd(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?o:0);if(c>e)break;let d=this.ranges[l+s],u=c+d;if(e<=u&&l==r*3)return!0;o+=this.ranges[l+i]-d}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let i=this.ranges[r],l=i-(this.inverted?s:0),c=i+(this.inverted?0:s),d=this.ranges[r+t],u=this.ranges[r+o];e(l,l+d,c,c+u),s+=u-d}}invert(){return new Ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ue.empty:new Ue(e<0?[0,-e,0]:[0,0,e])}}Ue.empty=new Ue([]);class Mo{constructor(e,t,o=0,r=e?e.length:0){this.mirror=t,this.from=o,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Mo(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,o=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?o+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=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,o=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?o-r-1:void 0)}}invert(){let e=new Mo;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this._maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let r=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return o?e:new Oi(e,r,null)}}const _i=Object.create(null);class Pe{getMap(){return Ue.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=_i[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in _i)throw new RangeError("Duplicate use of step JSON ID "+e);return _i[e]=t,t.prototype.jsonID=e,t}}class we{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new we(e,null)}static fail(e){return new we(null,e)}static fromReplace(e,t,o,r){try{return we.ok(e.replace(t,o,r))}catch(s){if(s instanceof xr)return we.fail(s.message);throw s}}}function Ri(n,e,t){let o=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(Ri(s.content,e,s))),s.isInline&&(s=e(s,t,r)),o.push(s)}return _.fromArray(o)}class Wt extends Pe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),r=o.node(o.sharedDepth(this.to)),s=new H(Ri(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),r),t.openStart,t.openEnd);return we.fromReplace(e,this.from,this.to,s)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Wt(t.pos,o.pos,this.mark)}merge(e){return e instanceof Wt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Wt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Wt(t.from,t.to,e.markFromJSON(t.mark))}}Pe.jsonID("addMark",Wt);class rt extends Pe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new H(Ri(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return we.fromReplace(e,this.from,this.to,o)}invert(){return new Wt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new rt(t.pos,o.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(t.from,t.to,e.markFromJSON(t.mark))}}Pe.jsonID("removeMark",rt);class Ut extends Pe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return we.fromReplace(e,this.pos,this.pos+1,new H(_.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(o))return new Ut(this.pos,t.marks[r]);return new Ut(this.pos,this.mark)}}return new wn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ut(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ut(t.pos,e.markFromJSON(t.mark))}}Pe.jsonID("addNodeMark",Ut);class wn extends Pe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return we.fromReplace(e,this.pos,this.pos+1,new H(_.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ut(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new wn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new wn(t.pos,e.markFromJSON(t.mark))}}Pe.jsonID("removeNodeMark",wn);class xe extends Pe{constructor(e,t,o,r=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=r}apply(e){return this.structure&&Pi(e,this.from,this.to)?we.fail("Structure replace would overwrite content"):we.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new xe(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new xe(t.pos,Math.max(t.pos,o.pos),this.slice,this.structure)}merge(e){if(!(e instanceof xe)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?H.empty:new H(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new xe(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?H.empty:new H(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new xe(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new xe(t.from,t.to,H.fromJSON(e,t.slice),!!t.structure)}}Pe.jsonID("replace",xe);class Ce extends Pe{constructor(e,t,o,r,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=r,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Pi(e,this.from,this.gapFrom)||Pi(e,this.gapTo,this.to)))return we.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return we.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?we.fromReplace(e,this.from,this.to,o):we.fail("Content does not fit in gap")}getMap(){return new Ue([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ce(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||r<t.pos||s>o.pos?null:new Ce(t.pos,o.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ce(t.from,t.to,t.gapFrom,t.gapTo,H.fromJSON(e,t.slice),t.insert,!!t.structure)}}Pe.jsonID("replaceAround",Ce);function Pi(n,e,t){let o=n.resolve(e),r=t-e,s=o.depth;for(;r>0&&s>0&&o.indexAfter(s)==o.node(s).childCount;)s--,r--;if(r>0){let i=o.node(s).maybeChild(o.indexAfter(s));for(;r>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,r--}}return!1}function Dy(n,e,t,o){let r=[],s=[],i,l;n.doc.nodesBetween(e,t,(c,d,u)=>{if(!c.isInline)return;let f=c.marks;if(!o.isInSet(f)&&u.type.allowsMarkType(o.type)){let p=Math.max(d,e),h=Math.min(d+c.nodeSize,t),m=o.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(m)||(i&&i.to==p&&i.mark.eq(f[g])?i.to=h:r.push(i=new rt(p,h,f[g])));l&&l.to==p?l.to=h:s.push(l=new Wt(p,h,o))}}),r.forEach(c=>n.step(c)),s.forEach(c=>n.step(c))}function Ly(n,e,t,o){let r=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let c=null;if(o instanceof Tr){let d=i.marks,u;for(;u=o.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else o?o.isInSet(i.marks)&&(c=[o]):c=i.marks;if(c&&c.length){let d=Math.min(l+i.nodeSize,t);for(let u=0;u<c.length;u++){let f=c[u],p;for(let h=0;h<r.length;h++){let m=r[h];m.step==s-1&&f.eq(r[h].style)&&(p=m)}p?(p.to=d,p.step=s):r.push({style:f,from:Math.max(l,e),to:d,step:s})}}}),r.forEach(i=>n.step(new rt(i.from,i.to,i.style)))}function Di(n,e,t,o=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let c=0;c<s.childCount;c++){let d=s.child(c),u=l+d.nodeSize,f=o.matchType(d.type);if(!f)i.push(new xe(l,u,H.empty));else{o=f;for(let p=0;p<d.marks.length;p++)t.allowsMarkType(d.marks[p].type)||n.step(new rt(l,u,d.marks[p]));if(r&&d.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,m;for(;p=h.exec(d.text);)m||(m=new H(_.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),i.push(new xe(l+p.index,l+p.index+p[0].length,m))}}l=u}if(!o.validEnd){let c=o.fillBefore(_.empty,!0);n.replace(l,l,new H(c,0,0))}for(let c=i.length-1;c>=0;c--)n.step(i[c])}function Vy(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function jn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth,r=0,s=0;;--o){let i=n.$from.node(o),l=n.$from.index(o)+r,c=n.$to.indexAfter(o)-s;if(o<n.depth&&i.canReplace(l,c,t))return o;if(o==0||i.type.spec.isolating||!Vy(i,l,c))break;l&&(r=1),c<i.childCount&&(s=1)}return null}function $y(n,e,t){let{$from:o,$to:r,depth:s}=e,i=o.before(s+1),l=r.after(s+1),c=i,d=l,u=_.empty,f=0;for(let m=s,g=!1;m>t;m--)g||o.index(m)>0?(g=!0,u=_.from(o.node(m).copy(u)),f++):c--;let p=_.empty,h=0;for(let m=s,g=!1;m>t;m--)g||r.after(m+1)<r.end(m)?(g=!0,p=_.from(r.node(m).copy(p)),h++):d++;n.step(new Ce(c,d,i,l,new H(u.append(p),f,h),u.size-f,!0))}function xd(n,e,t=null,o=n){let r=zy(n,e),s=r&&Fy(o,e);return s?r.map(Cd).concat({type:e,attrs:t}).concat(s.map(Cd)):null}function Cd(n){return{type:n,attrs:null}}function zy(n,e){let{parent:t,startIndex:o,endIndex:r}=n,s=t.contentMatchAt(o).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(o,r,i)?s:null}function Fy(n,e){let{parent:t,startIndex:o,endIndex:r}=n,s=t.child(o),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let c=(i.length?i[i.length-1]:e).contentMatch;for(let d=o;c&&d<r;d++)c=c.matchType(t.child(d).type);return!c||!c.validEnd?null:i}function Hy(n,e,t){let o=_.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=_.from(t[i].type.create(t[i].attrs,o))}let r=e.start,s=e.end;n.step(new Ce(r,s,r,s,new H(o,0,0),t.length,!0))}function jy(n,e,t,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let c=typeof r=="function"?r(i):r;if(i.isTextblock&&!i.hasMarkup(o,c)&&Wy(n.doc,n.mapping.slice(s).map(l),o)){let d=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",m=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!m?d=!1:!h&&m&&(d=!0)}d===!1&&vd(n,i,l,s),Di(n,n.mapping.slice(s).map(l,1),o,void 0,d===null);let u=n.mapping.slice(s),f=u.map(l,1),p=u.map(l+i.nodeSize,1);return n.step(new Ce(f,p,f+1,p-1,new H(_.from(o.create(c,null,i.marks)),0,0),1,!0)),d===!0&&Ed(n,i,l,s),!1}})}function Ed(n,e,t,o){e.forEach((r,s)=>{if(r.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(r.text);){let c=n.mapping.slice(o).map(t+1+s+i.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function vd(n,e,t,o){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
5
|
+
`))}})}function Wy(n,e,t){let o=n.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,t)}function Uy(n,e,t,o,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(o,null,r||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ce(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new H(_.from(i),0,0),1,!0))}function Nt(n,e,t=1,o){let r=n.resolve(e),s=r.depth-t,i=o&&o[o.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!i.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let d=r.depth-1,u=t-2;d>s;d--,u--){let f=r.node(d),p=r.index(d);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(p,f.childCount),m=o&&o[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=o&&o[u]||f;if(!f.canReplace(p+1,f.childCount)||!g.type.validContent(h))return!1}let l=r.indexAfter(s),c=o&&o[0];return r.node(s).canReplaceWith(l,l,c?c.type:r.node(s+1).type)}function Ky(n,e,t=1,o){let r=n.doc.resolve(e),s=_.empty,i=_.empty;for(let l=r.depth,c=r.depth-t,d=t-1;l>c;l--,d--){s=_.from(r.node(l).copy(s));let u=o&&o[d];i=_.from(u?u.type.create(u.attrs,i):r.node(l).copy(i))}n.step(new xe(e,e,new H(s.append(i),t,t),!0))}function bn(n,e){let t=n.resolve(e),o=t.index();return Td(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function qy(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),i=s.type==o?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Td(n,e){return!!(n&&e&&!n.isLeaf&&qy(n,e))}function Ir(n,e,t=-1){let o=n.resolve(e);for(let r=o.depth;;r--){let s,i,l=o.index(r);if(r==o.depth?(s=o.nodeBefore,i=o.nodeAfter):t>0?(s=o.node(r+1),l++,i=o.node(r).maybeChild(l)):(s=o.node(r).maybeChild(l-1),i=o.node(r+1)),s&&!s.isTextblock&&Td(s,i)&&o.node(r).canReplace(l,l+1))return e;if(r==0)break;e=t<0?o.before(r):o.after(r)}}function Jy(n,e,t){let o=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(r&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(r);u&&!f?o=!1:!u&&f&&(o=!0)}let l=n.steps.length;if(o===!1){let u=n.doc.resolve(e+t);vd(n,u.node(),u.before(),l)}i.inlineContent&&Di(n,e+t-1,i,s.node().contentMatchAt(s.index()),o==null);let c=n.mapping.slice(l),d=c.map(e-t);if(n.step(new xe(d,c.map(e+t,-1),H.empty,!0)),o===!0){let u=n.doc.resolve(d);Ed(n,u.node(),u.before(),n.steps.length)}return n}function Gy(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let r=o.depth-1;r>=0;r--){let s=o.index(r);if(o.node(r).canReplaceWith(s,s,t))return o.before(r+1);if(s>0)return null}if(o.parentOffset==o.parent.content.size)for(let r=o.depth-1;r>=0;r--){let s=o.indexAfter(r);if(o.node(r).canReplaceWith(s,s,t))return o.after(r+1);if(s<o.node(r).childCount)return null}return null}function Md(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,c=o.index(i)+(l>0?1:0),d=o.node(i),u=!1;if(s==1)u=d.canReplace(c,c,r);else{let f=d.contentMatchAt(c).findWrapping(r.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return l==0?o.pos:l<0?o.before(i+1):o.after(i+1)}return null}function Br(n,e,t=e,o=H.empty){if(e==t&&!o.size)return null;let r=n.resolve(e),s=n.resolve(t);return Ad(r,s,o)?new xe(e,t,o):new Yy(r,s,o).fit()}function Ad(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Yy{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=_.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=_.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,o=this.$from,r=this.close(e<0?this.$to:o.doc.resolve(e));if(!r)return null;let s=this.placed,i=o.depth,l=r.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let c=new H(s,i,l);return e>-1?new Ce(o.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||o.pos!=this.$to.pos?new xe(o.pos,r.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,r=this.unplaced.openEnd;o<e;o++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=o){e=o;break}t=s.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let r,s=null;o?(s=Li(this.unplaced.content,o-1).firstChild,r=s.content):r=this.unplaced.content;let i=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:d}=this.frontier[l],u,f=null;if(t==1&&(i?d.matchType(i.type)||(f=d.fillBefore(_.from(i),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:o,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=d.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:s,wrap:u};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,r=Li(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new H(e,t+1,Math.max(o,r.size+t>=e.size-o?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,r=Li(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new H(Ao(e,t-1,1),t-1,s?t-1:o)}else this.unplaced=new H(Ao(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let i=this.unplaced,l=o?o.content:i.content,c=i.openStart-e,d=0,u=[],{match:f,type:p}=this.frontier[t];if(r){for(let g=0;g<r.childCount;g++)u.push(r.child(g));f=f.matchFragment(r)}let h=l.size+e-(i.content.size-i.openEnd);for(;d<l.childCount;){let g=l.child(d),y=f.matchType(g.type);if(!y)break;d++,(d>1||c==0||g.content.size)&&(f=y,u.push(Nd(g.mark(p.allowedMarks(g.marks)),d==1?c:0,d==l.childCount?h:-1)))}let m=d==l.childCount;m||(h=-1),this.placed=No(this.placed,t,_.from(u)),this.frontier[t].match=f,m&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let w=y.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),y=w.content}this.unplaced=m?e==0?H.empty:new H(Ao(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new H(Ao(i.content,e,d),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Vi(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:o}=this.$to,r=this.$to.after(o);for(;o>1&&r==this.$to.end(--o);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Vi(e,t,r,o,s);if(i){for(let l=t-1;l>=0;l--){let{match:c,type:d}=this.frontier[l],u=Vi(e,l,d,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=No(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let r=e.node(o),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(o));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,o){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=No(this.placed,this.depth,_.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(_.empty,!0);t.childCount&&(this.placed=No(this.placed,this.frontier.length,t))}}function Ao(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ao(n.firstChild.content,e-1,t)))}function No(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(No(n.lastChild.content,e-1,t)))}function Li(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Nd(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Nd(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(_.empty,!0)))),n.copy(o)}function Vi(n,e,t,o,r){let s=n.node(e),i=r?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=o.fillBefore(s.content,!0,i);return l&&!Xy(t,s.content,i)?l:null}function Xy(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Qy(n){return n.spec.defining||n.spec.definingForContent}function Zy(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(Ad(r,s,o))return n.step(new xe(e,t,o));let i=Bd(r,s);i[i.length-1]==0&&i.pop();let l=-(r.depth+1);i.unshift(l);for(let p=r.depth,h=r.pos-1;p>0;p--,h--){let m=r.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(p)>-1?l=p:r.before(p)==h&&i.splice(1,0,-p)}let c=i.indexOf(l),d=[],u=o.openStart;for(let p=o.content,h=0;;h++){let m=p.firstChild;if(d.push(m),h==o.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let h=d[p],m=Qy(h.type);if(m&&!h.sameMarkup(r.node(Math.abs(l)-1)))u=p;else if(m||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+u+1)%(o.openStart+1),m=d[h];if(m)for(let g=0;g<i.length;g++){let y=i[(g+c)%i.length],w=!0;y<0&&(w=!1,y=-y);let b=r.node(y-1),x=r.index(y-1);if(b.canReplaceWith(x,x,m.type,m.marks))return n.replace(r.before(y),w?s.after(y):t,new H(Id(o.content,0,o.openStart,h),h,o.openEnd))}}let f=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>f));p--){let h=i[p];h<0||(e=r.before(h),t=s.after(h))}}function Id(n,e,t,o,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Id(s.content,e+1,t,o,s)))}if(e>o){let s=r.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(_.empty,!0))}return n}function e0(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=Gy(n.doc,e,o.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new H(_.from(o),0,0))}function t0(n,e,t){let o=n.doc.resolve(e),r=n.doc.resolve(t),s=Bd(o,r);for(let i=0;i<s.length;i++){let l=s[i],c=i==s.length-1;if(c&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),r.end(l));if(l>0&&(c||o.node(l-1).canReplace(o.index(l-1),r.indexAfter(l-1))))return n.delete(o.before(l),r.after(l))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&r.end(i)-t!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function Bd(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let r=o;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}class Wn extends Pe{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at attribute step's position");let o=Object.create(null);for(let s in t.attrs)o[s]=t.attrs[s];o[this.attr]=this.value;let r=t.type.create(o,null,t.marks);return we.fromReplace(e,this.pos,this.pos+1,new H(_.from(r),0,t.isLeaf?0:1))}getMap(){return Ue.empty}invert(e){return new Wn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Wn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Wn(t.pos,t.attr,t.value)}}Pe.jsonID("attr",Wn);class Io extends Pe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return we.ok(o)}getMap(){return Ue.empty}invert(e){return new Io(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Io(t.attr,t.value)}}Pe.jsonID("docAttr",Io);let Un=class extends Error{};Un=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Un.prototype=Object.create(Error.prototype),Un.prototype.constructor=Un,Un.prototype.name="TransformError";class Od{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Mo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Un(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 o=0;o<this.mapping.maps.length;o++){let r=this.mapping.maps[o];o&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((s,i,l,c)=>{e=Math.min(e,l),t=Math.max(t,c)})}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,o=H.empty){let r=Br(this.doc,e,t,o);return r&&this.step(r),this}replaceWith(e,t,o){return this.replace(e,t,new H(_.from(o),0,0))}delete(e,t){return this.replace(e,t,H.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return Zy(this,e,t,o),this}replaceRangeWith(e,t,o){return e0(this,e,t,o),this}deleteRange(e,t){return t0(this,e,t),this}lift(e,t){return $y(this,e,t),this}join(e,t=1){return Jy(this,e,t),this}wrap(e,t){return Hy(this,e,t),this}setBlockType(e,t=e,o,r=null){return jy(this,e,t,o,r),this}setNodeMarkup(e,t,o=null,r){return Uy(this,e,t,o,r),this}setNodeAttribute(e,t,o){return this.step(new Wn(e,t,o)),this}setDocAttribute(e,t){return this.step(new Io(e,t)),this}addNodeMark(e,t){return this.step(new Ut(e,t)),this}removeNodeMark(e,t){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t instanceof le)t.isInSet(o.marks)&&this.step(new wn(e,t));else{let r=o.marks,s,i=[];for(;s=t.isInSet(r);)i.push(new wn(e,s)),r=s.removeFromSet(r);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,o){return Ky(this,e,t,o),this}addMark(e,t,o){return Dy(this,e,t,o),this}removeMark(e,t,o){return Ly(this,e,t,o),this}clearIncompatible(e,t,o){return Di(this,e,t,o),this}}const $i=Object.create(null);class ee{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new n0(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=H.empty){let o=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=o,o=o.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:c,$to:d}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(c.pos),u.map(d.pos),l?H.empty:t),l==0&&Pd(e,s,(o?o.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:l}=r[s],c=e.mapping.slice(o),d=c.map(i.pos),u=c.map(l.pos);s?e.deleteRange(d,u):(e.replaceRangeWith(d,u,t),Pd(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let r=e.parent.inlineContent?new Q(e):Kn(e.node(0),e.parent,e.pos,e.index(),t,o);if(r)return r;for(let s=e.depth-1;s>=0;s--){let i=t<0?Kn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,o):Kn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ke(e.node(0))}static atStart(e){return Kn(e,e,0,0,1)||new Ke(e)}static atEnd(e){return Kn(e,e,e.content.size,e.childCount,-1)||new Ke(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=$i[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in $i)throw new RangeError("Duplicate use of selection JSON ID "+e);return $i[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}ee.prototype.visible=!0;class n0{constructor(e,t){this.$from=e,this.$to=t}}let _d=!1;function Rd(n){!_d&&!n.parent.inlineContent&&(_d=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Q extends ee{constructor(e,t=e){Rd(e),Rd(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return ee.near(o);let r=e.resolve(t.map(this.anchor));return new Q(r.parent.inlineContent?r:o,o)}replace(e,t=H.empty){if(super.replace(e,t),t==H.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Or(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Q(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let r=e.resolve(t);return new this(r,o==t?r:e.resolve(o))}static between(e,t,o){let r=e.pos-t.pos;if((!o||r)&&(o=r>=0?1:-1),!t.parent.inlineContent){let s=ee.findFrom(t,o,!0)||ee.findFrom(t,-o,!0);if(s)t=s.$head;else return ee.near(t,o)}return e.parent.inlineContent||(r==0?e=t:(e=(ee.findFrom(e,-o,!0)||ee.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new Q(e,t)}}ee.jsonID("text",Q);class Or{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Or(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class G extends ee{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return o?ee.near(s):new G(s)}content(){return new H(_.from(this.node),0,0)}eq(e){return e instanceof G&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new zi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new G(e.resolve(t.anchor))}static create(e,t){return new G(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}G.prototype.visible=!1,ee.jsonID("node",G);class zi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Or(o,o):new zi(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&G.isSelectable(o)?new G(t):ee.near(t)}}class Ke extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=H.empty){if(t==H.empty){e.delete(0,e.doc.content.size);let o=ee.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ke(e)}map(e){return new Ke(e)}eq(e){return e instanceof Ke}getBookmark(){return o0}}ee.jsonID("all",Ke);const o0={map(){return this},resolve(n){return new Ke(n)}};function Kn(n,e,t,o,r,s=!1){if(e.inlineContent)return Q.create(n,t);for(let i=o-(r>0?0:1);r>0?i<e.childCount:i>=0;i+=r){let l=e.child(i);if(l.isAtom){if(!s&&G.isSelectable(l))return G.create(n,t-(r<0?l.nodeSize:0))}else{let c=Kn(n,l,t+r,r<0?l.childCount:0,r,s);if(c)return c}t+=l.nodeSize*r}return null}function Pd(n,e,t){let o=n.steps.length-1;if(o<e)return;let r=n.steps[o];if(!(r instanceof xe||r instanceof Ce))return;let s=n.mapping.maps[o],i;s.forEach((l,c,d,u)=>{i==null&&(i=u)}),n.setSelection(ee.near(n.doc.resolve(i),t))}const Dd=1,_r=2,Ld=4;class r0 extends Od{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Dd)&~_r,this.storedMarks=null,this}get selectionSet(){return(this.updated&Dd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_r,this}ensureMarks(e){return le.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&_r)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~_r,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||le.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),!e)return this.deleteRange(t,o);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,r.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(ee.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|=Ld,this}get scrolledIntoView(){return(this.updated&Ld)>0}}function Vd(n,e){return!e||!n?n:n.bind(e)}class Bo{constructor(e,t,o){this.name=e,this.init=Vd(t.init,o),this.apply=Vd(t.apply,o)}}const s0=[new Bo("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Bo("selection",{init(n,e){return n.selection||ee.atStart(e.doc)},apply(n){return n.selection}}),new Bo("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Bo("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Fi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=s0.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new Bo(o.key,o.spec.state,o))})}}class qn{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 o=0;o<this.config.plugins.length;o++)if(o!=t){let r=this.config.plugins[o];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),r=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let c=r?r[i].n:0,d=r?r[i].state:this,u=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,d,o);if(u&&o.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(let f=0;f<this.config.plugins.length;f++)r.push(f<i?{state:o,n:t.length}:{state:this,n:0})}t.push(u),o=o.applyInner(u),s=!0}r&&(r[i]={state:o,n:t.length})}}if(!s)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new qn(this.config),o=this.config.fields;for(let r=0;r<o.length;r++){let s=o[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new r0(this)}static create(e){let t=new Fi(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new qn(t);for(let r=0;r<t.fields.length;r++)o[t.fields[r].name]=t.fields[r].init(e,o);return o}reconfigure(e){let t=new Fi(this.schema,e.plugins),o=t.fields,r=new qn(t);for(let s=0;s<o.length;s++){let i=o[s].name;r[i]=this.hasOwnProperty(i)?this[i]:o[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[o],s=r.spec.state;s&&s.toJSON&&(t[o]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Fi(e.schema,e.plugins),s=new qn(r);return r.fields.forEach(i=>{if(i.name=="doc")s.doc=Mt.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=ee.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let c=o[l],d=c.spec.state;if(c.key==i.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=d.fromJSON.call(c,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function $d(n,e,t){for(let o in n){let r=n[o];r instanceof Function?r=r.bind(e):o=="handleDOMEvents"&&(r=$d(r,e,{})),t[o]=r}return t}class ge{constructor(e){this.spec=e,this.props={},e.props&&$d(e.props,this,this.props),this.key=e.key?e.key.key:zd("plugin")}getState(e){return e[this.key]}}const Hi=Object.create(null);function zd(n){return n in Hi?n+"$"+ ++Hi[n]:(Hi[n]=0,n+"$")}class Ee{constructor(e="key"){this.key=zd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ji=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Fd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Hd=(n,e,t)=>{let o=Fd(n,t);if(!o)return!1;let r=Wi(o);if(!r){let i=o.blockRange(),l=i&&jn(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(Xd(n,r,e,-1))return!0;if(o.parent.content.size==0&&(Jn(s,"end")||G.isSelectable(s)))for(let i=o.depth;;i--){let l=Br(n.doc,o.before(i),o.after(i),H.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Jn(s,"end")?ee.findFrom(c.doc.resolve(c.mapping.map(r.pos,-1)),-1):G.create(c.doc,r.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return s.isAtom&&r.depth==o.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1},i0=(n,e,t)=>{let o=Fd(n,t);if(!o)return!1;let r=Wi(o);return r?jd(n,r,e):!1},l0=(n,e,t)=>{let o=Ud(n,t);if(!o)return!1;let r=Ui(o);return r?jd(n,r,e):!1};function jd(n,e,t){let o=e.nodeBefore,r=o,s=e.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let u=r.lastChild;if(!u)return!1;r=u}let i=e.nodeAfter,l=i,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let d=Br(n.doc,s,c,H.empty);if(!d||d.from!=s||d instanceof xe&&d.slice.size>=c-s)return!1;if(t){let u=n.tr.step(d);u.setSelection(Q.create(u.doc,s)),t(u.scrollIntoView())}return!0}function Jn(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}const Wd=(n,e,t)=>{let{$head:o,empty:r}=n.selection,s=o;if(!r)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;s=Wi(o)}let i=s&&s.nodeBefore;return!i||!G.isSelectable(i)?!1:(e&&e(n.tr.setSelection(G.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function Wi(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ud(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Kd=(n,e,t)=>{let o=Ud(n,t);if(!o)return!1;let r=Ui(o);if(!r)return!1;let s=r.nodeAfter;if(Xd(n,r,e,1))return!0;if(o.parent.content.size==0&&(Jn(s,"start")||G.isSelectable(s))){let i=Br(n.doc,o.before(),o.after(),H.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(Jn(s,"start")?ee.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):G.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==o.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},qd=(n,e,t)=>{let{$head:o,empty:r}=n.selection,s=o;if(!r)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;s=Ui(o)}let i=s&&s.nodeAfter;return!i||!G.isSelectable(i)?!1:(e&&e(n.tr.setSelection(G.create(n.doc,s.pos)).scrollIntoView()),!0)};function Ui(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const a0=(n,e)=>{let t=n.selection,o=t instanceof G,r;if(o){if(t.node.isTextblock||!bn(n.doc,t.from))return!1;r=t.from}else if(r=Ir(n.doc,t.from,-1),r==null)return!1;if(e){let s=n.tr.join(r);o&&s.setSelection(G.create(s.doc,r-n.doc.resolve(r).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},c0=(n,e)=>{let t=n.selection,o;if(t instanceof G){if(t.node.isTextblock||!bn(n.doc,t.to))return!1;o=t.to}else if(o=Ir(n.doc,t.to,1),o==null)return!1;return e&&e(n.tr.join(o).scrollIntoView()),!0},d0=(n,e)=>{let{$from:t,$to:o}=n.selection,r=t.blockRange(o),s=r&&jn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},Jd=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
6
|
+
`).scrollIntoView()),!0)};function Ki(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const u0=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let r=t.node(-1),s=t.indexAfter(-1),i=Ki(r.contentMatchAt(s));if(!i||!r.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,i.createAndFill());c.setSelection(ee.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Gd=(n,e)=>{let t=n.selection,{$from:o,$to:r}=t;if(t instanceof Ke||o.parent.inlineContent||r.parent.inlineContent)return!1;let s=Ki(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(Q.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Yd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Nt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let o=t.blockRange(),r=o&&jn(o);return r==null?!1:(e&&e(n.tr.lift(o,r).scrollIntoView()),!0)};function f0(n){return(e,t)=>{let{$from:o,$to:r}=e.selection;if(e.selection instanceof G&&e.selection.node.isBlock)return!o.parentOffset||!Nt(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let s=[],i,l,c=!1,d=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){c=o.end(h)==o.pos+(o.depth-h),d=o.start(h)==o.pos-(o.depth-h),l=Ki(o.node(h-1).contentMatchAt(o.indexAfter(h-1))),s.unshift(c&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof Q||e.selection instanceof Ke)&&u.deleteSelection();let f=u.mapping.map(o.pos),p=Nt(u.doc,f,s.length,s);if(p||(s[0]=l?{type:l}:null,p=Nt(u.doc,f,s.length,s)),!p)return!1;if(u.split(f,s.length,s),!c&&d&&o.node(i).type!=l){let h=u.mapping.map(o.before(i)),m=u.doc.resolve(h);l&&o.node(i-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(o.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const h0=f0(),p0=(n,e)=>{let{$from:t,to:o}=n.selection,r,s=t.sharedDepth(o);return s==0?!1:(r=t.before(s),e&&e(n.tr.setSelection(G.create(n.doc,r))),!0)};function m0(n,e,t){let o=e.nodeBefore,r=e.nodeAfter,s=e.index();return!o||!r||!o.type.compatibleContent(r.type)?!1:!o.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||bn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Xd(n,e,t,o){let r=e.nodeBefore,s=e.nodeAfter,i,l,c=r.type.spec.isolating||s.type.spec.isolating;if(!c&&m0(n,e,t))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(i=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,m=_.empty;for(let w=i.length-1;w>=0;w--)m=_.from(i[w].create(null,m));m=_.from(r.copy(m));let g=n.tr.step(new Ce(e.pos-1,h,e.pos,h,new H(m,1,0),i.length,!0)),y=g.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==r.type&&bn(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=s.type.spec.isolating||o>0&&c?null:ee.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),p=f&&jn(f);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(f,p).scrollIntoView()),!0;if(d&&Jn(s,"start",!0)&&Jn(r,"end")){let h=r,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=s,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let w=_.empty;for(let x=m.length-1;x>=0;x--)w=_.from(m[x].copy(w));let b=n.tr.step(new Ce(e.pos-m.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new H(w,m.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Qd(n){return function(e,t){let o=e.selection,r=n<0?o.$from:o.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(Q.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}const g0=Qd(-1),y0=Qd(1);function k0(n,e=null){return function(t,o){let{$from:r,$to:s}=t.selection,i=r.blockRange(s),l=i&&xd(i,n,e);return l?(o&&o(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Zd(n,e=null){return function(t,o){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(c,d)=>{if(r)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)r=!0;else{let u=t.doc.resolve(d),f=u.index();r=u.parent.canReplaceWith(f,f+1,n)}})}if(!r)return!1;if(o){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[i];s.setBlockType(l,c,n,e)}o(s.scrollIntoView())}return!0}}function qi(...n){return function(e,t,o){for(let r=0;r<n.length;r++)if(n[r](e,t,o))return!0;return!1}}qi(ji,Hd,Wd),qi(ji,Kd,qd),qi(Jd,Gd,Yd,h0),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function w0(n,e=null){return function(t,o){let{$from:r,$to:s}=t.selection,i=r.blockRange(s);if(!i)return!1;let l=o?t.tr:null;return b0(l,i,n,e)?(o&&o(l.scrollIntoView()),!0):!1}}function b0(n,e,t,o=null){let r=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=i.resolve(e.start-2);s=new Er(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Er(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=xd(s,t,o,e);return l?(n&&S0(n,e,l,r,t),!0):!1}function S0(n,e,t,o,r){let s=_.empty;for(let u=t.length-1;u>=0;u--)s=_.from(t[u].type.create(t[u].attrs,s));n.step(new Ce(e.start-(o?2:0),e.end,e.start,e.end,new H(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==r&&(i=u+1);let l=t.length-i,c=e.start+t.length-(o?2:0),d=e.parent;for(let u=e.startIndex,f=e.endIndex,p=!0;u<f;u++,p=!1)!p&&Nt(n.doc,c,l)&&(n.split(c,l),c+=2*l),c+=d.child(u).nodeSize;return n}function x0(n){return function(e,t){let{$from:o,$to:r}=e.selection,s=o.blockRange(r,i=>i.childCount>0&&i.firstChild.type==n);return s?t?o.node(s.depth-1).type==n?C0(e,t,n,s):E0(e,t,s):!0:!1}}function C0(n,e,t,o){let r=n.tr,s=o.end,i=o.$to.end(o.depth);s<i&&(r.step(new Ce(s-1,i,s,i,new H(_.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Er(r.doc.resolve(o.$from.pos),r.doc.resolve(i),o.depth));const l=jn(o);if(l==null)return!1;r.lift(o,l);let c=r.doc.resolve(r.mapping.map(s,-1)-1);return bn(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}function E0(n,e,t){let o=n.tr,r=t.parent;for(let h=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)h-=r.child(m).nodeSize,o.delete(h-1,h+1);let s=o.doc.resolve(t.start),i=s.nodeAfter;if(o.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,c=t.endIndex==r.childCount,d=s.node(-1),u=s.index(-1);if(!d.canReplace(u+(l?0:1),u+1,i.content.append(c?_.empty:_.from(r))))return!1;let f=s.pos,p=f+i.nodeSize;return o.step(new Ce(f-(l?1:0),p+(c?1:0),f+1,p-1,new H((l?_.empty:_.from(r.copy(_.empty))).append(c?_.empty:_.from(r.copy(_.empty))),l?0:1,c?0:1),l?0:1)),e(o.scrollIntoView()),!0}function v0(n){return function(e,t){let{$from:o,$to:r}=e.selection,s=o.blockRange(r,d=>d.childCount>0&&d.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,c=l.child(i-1);if(c.type!=n)return!1;if(t){let d=c.lastChild&&c.lastChild.type==l.type,u=_.from(d?n.create():null),f=new H(_.from(n.create(null,_.from(l.type.create(null,u)))),d?3:1,0),p=s.start,h=s.end;t(e.tr.step(new Ce(p-(d?3:1),h,p,h,f,1,!0)).scrollIntoView())}return!0}}const Ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Gn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ji=null;const It=function(n,e,t){let o=Ji||(Ji=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},T0=function(){Ji=null},Sn=function(n,e,t,o){return t&&(eu(n,e,t,o,-1)||eu(n,e,t,o,1))},M0=/^(img|br|input|textarea|hr)$/i;function eu(n,e,t,o,r){for(var s;;){if(n==t&&e==o)return!0;if(e==(r<0?0:Ye(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Oo(n)||M0.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ne(n)+(r<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(r<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=r;else return!1;else n=i,e=r<0?Ye(n):0}else return!1}}function Ye(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function A0(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ye(n)}else if(n.parentNode&&!Oo(n))e=Ne(n),n=n.parentNode;else return null}}function N0(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Oo(n))e=Ne(n)+1,n=n.parentNode;else return null}}function I0(n,e,t){for(let o=e==0,r=e==Ye(n);o||r;){if(n==t)return!0;let s=Ne(n);if(n=n.parentNode,!n)return!1;o=o&&s==0,r=r&&s==Ye(n)}}function Oo(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Rr=function(n){return n.focusNode&&Sn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function xn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function B0(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function O0(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(Ye(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(Ye(o.startContainer),o.startOffset)}}}const ht=typeof navigator<"u"?navigator:null,tu=typeof document<"u"?document:null,Kt=ht&&ht.userAgent||"",Gi=/Edge\/(\d+)/.exec(Kt),nu=/MSIE \d/.exec(Kt),Yi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Kt),He=!!(nu||Yi||Gi),qt=nu?document.documentMode:Yi?+Yi[1]:Gi?+Gi[1]:0,Xe=!He&&/gecko\/(\d+)/i.test(Kt);Xe&&+(/Firefox\/(\d+)/.exec(Kt)||[0,0])[1];const Xi=!He&&/Chrome\/(\d+)/.exec(Kt),Ie=!!Xi,ou=Xi?+Xi[1]:0,De=!He&&!!ht&&/Apple Computer/.test(ht.vendor),Yn=De&&(/Mobile\/\w+/.test(Kt)||!!ht&&ht.maxTouchPoints>2),Qe=Yn||(ht?/Mac/.test(ht.platform):!1),ru=ht?/Win/.test(ht.platform):!1,Bt=/Android \d/.test(Kt),_o=!!tu&&"webkitFontSmoothing"in tu.documentElement.style,_0=_o?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function R0(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ot(n,e){return typeof n=="number"?n:n[e]}function P0(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function su(n,e,t){let o=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=Gn(i);continue}let l=i,c=l==s.body,d=c?R0(s):P0(l),u=0,f=0;if(e.top<d.top+Ot(o,"top")?f=-(d.top-e.top+Ot(r,"top")):e.bottom>d.bottom-Ot(o,"bottom")&&(f=e.bottom-e.top>d.bottom-d.top?e.top+Ot(r,"top")-d.top:e.bottom-d.bottom+Ot(r,"bottom")),e.left<d.left+Ot(o,"left")?u=-(d.left-e.left+Ot(r,"left")):e.right>d.right-Ot(o,"right")&&(u=e.right-d.right+Ot(r,"right")),u||f)if(c)s.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,m=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-m;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let p=c?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(p))break;i=p=="absolute"?i.offsetParent:Gn(i)}}function D0(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,r;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=t-20){o=l,r=c.top;break}}return{refDOM:o,refTop:r,stack:iu(n.dom)}}function iu(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Gn(o));return e}function L0({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;lu(t,o==0?0:o-e)}function lu(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:r,left:s}=n[t];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}let Xn=null;function V0(n){if(n.setActive)return n.setActive();if(Xn)return n.focus(Xn);let e=iu(n);n.focus(Xn==null?{get preventScroll(){return Xn={preventScroll:!0},!0}}:void 0),Xn||(Xn=!1,lu(e,0))}function au(n,e){let t,o=2e8,r,s=0,i=e.top,l=e.top,c,d;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let p;if(u.nodeType==1)p=u.getClientRects();else if(u.nodeType==3)p=It(u).getClientRects();else continue;for(let h=0;h<p.length;h++){let m=p[h];if(m.top<=i&&m.bottom>=l){i=Math.max(m.bottom,i),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<o){t=u,o=g,r=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(s=f+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!c&&m.left<=e.left&&m.right>=e.left&&(c=u,d={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(s=f+1)}}return!t&&c&&(t=c,r=d,o=0),t&&t.nodeType==3?$0(t,r):!t||o&&t.nodeType==1?{node:n,offset:s}:au(t,r)}function $0(n,e){let t=n.nodeValue.length,o=document.createRange(),r;for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let i=Jt(o,1);if(i.top!=i.bottom&&Qi(e,i)){r={node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)};break}}return o.detach(),r||{node:n,offset:0}}function Qi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function z0(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function F0(n,e,t){let{node:o,offset:r}=au(e,t),s=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,r,s)}function H0(n,e,t,o){let r=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&c.left>o.left||c.top>o.top?r=l.posBefore:(!i&&c.right<o.left||c.bottom<o.top)&&(r=l.posAfter),i=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?o.top<(c.top+c.bottom)/2:o.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function cu(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let c=0;c<l.length;c++){let d=l[c];if(Qi(e,d))return cu(i,e,d)}}if((s=(s+1)%o)==r)break}return n}function j0(n,e){let t=n.dom.ownerDocument,o,r=0,s=O0(t,e.left,e.top);s&&({node:o,offset:r}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let d=n.dom.getBoundingClientRect();if(!Qi(e,d)||(i=cu(n.dom,e,d),!i))return null}if(De)for(let d=i;o&&d;d=Gn(d))d.draggable&&(o=void 0);if(i=z0(i,e),o){if(Xe&&o.nodeType==1&&(r=Math.min(r,o.childNodes.length),r<o.childNodes.length)){let u=o.childNodes[r],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let d;_o&&r&&o.nodeType==1&&(d=o.childNodes[r-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&r--,o==n.dom&&r==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||o.nodeType!=1||o.childNodes[r-1].nodeName!="BR")&&(l=H0(n,o,r,e))}l==null&&(l=F0(n,i,e));let c=n.docView.nearestDesc(i,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function du(n){return n.top<n.bottom||n.left<n.right}function Jt(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(du(o))return o}return Array.prototype.find.call(t,du)||n.getBoundingClientRect()}const W0=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function uu(n,e,t){let{node:o,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=_o||Xe;if(o.nodeType==3)if(i&&(W0.test(o.nodeValue)||(t<0?!r:r==o.nodeValue.length))){let c=Jt(It(o,r,r),t);if(Xe&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let d=Jt(It(o,r-1,r-1),-1);if(d.top==c.top){let u=Jt(It(o,r,r+1),-1);if(u.top!=c.top)return Ro(u,u.left<d.left)}}return c}else{let c=r,d=r,u=t<0?1:-1;return t<0&&!r?(d++,u=-1):t>=0&&r==o.nodeValue.length?(c--,u=1):t<0?c--:d++,Ro(Jt(It(o,c,d),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==Ye(o))){let c=o.childNodes[r-1];if(c.nodeType==1)return Zi(c.getBoundingClientRect(),!1)}if(s==null&&r<Ye(o)){let c=o.childNodes[r];if(c.nodeType==1)return Zi(c.getBoundingClientRect(),!0)}return Zi(o.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==Ye(o))){let c=o.childNodes[r-1],d=c.nodeType==3?It(c,Ye(c)-(i?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return Ro(Jt(d,1),!1)}if(s==null&&r<Ye(o)){let c=o.childNodes[r];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?It(c,0,i?0:1):c.nodeType==1?c:null:null;if(d)return Ro(Jt(d,-1),!0)}return Ro(Jt(o.nodeType==3?It(o):o,-t),t>=0)}function Ro(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Zi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function fu(n,e,t){let o=n.state,r=n.root.activeElement;o!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),r!=n.dom&&r&&r.focus()}}function U0(n,e,t){let o=e.selection,r=t=="up"?o.$from:o.$to;return fu(n,e,()=>{let{node:s}=n.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=uu(n,r.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=It(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;d<c.length;d++){let u=c[d];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const K0=/[\u0590-\u08ac]/;function q0(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,s=!r,i=r==o.parent.content.size,l=n.domSelection();return l?!K0.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:fu(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),y=m&&!h.contains(m.nodeType==1?m:m.parentNode)||c==m&&d==g;try{l.collapse(u,f),c&&(c!=u||d!=f)&&l.extend&&l.extend(c,d)}catch{}return p!=null&&(l.caretBidiLevel=p),y}):o.pos==o.start()||o.pos==o.end()}let hu=null,pu=null,mu=!1;function J0(n,e,t){return hu==e&&pu==t?mu:(hu=e,pu=t,mu=t=="up"||t=="down"?U0(n,e,t):q0(n,e,t))}const Ze=0,gu=1,Cn=2,pt=3;class Po{constructor(e,t,o,r){this.parent=e,this.children=t,this.dom=o,this.contentDOM=r,this.dirty=Ze,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){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,o=this.posAtStart;;t++){let r=this.children[t];if(r==e)return o;o+=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,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>Ne(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 s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),i;if(s&&(!t||s.node))if(o&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let r=this.children[t],s=o+r.size;if(o==e&&s!=o){for(;!r.border&&r.children.length;)for(let i=0;i<r.children.length;i++){let l=r.children[i];if(l.size){r=l;break}}return r}if(e<s)return r.descAt(e-o-r.border);o=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,r=0;for(let s=0;o<this.children.length;o++){let i=this.children[o],l=s+i.size;if(l>e||i instanceof wu){r=e-s;break}s=l}if(r)return this.children[o].domFromPos(r-this.children[o].border,t);for(let s;o&&!(s=this.children[o-1]).size&&s instanceof yu&&s.side>=0;o--);if(t<=0){let s,i=!0;for(;s=o?this.children[o-1]:null,!(!s||s.dom.parentNode==this.contentDOM);o--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Ne(s.dom)+1:0}}else{let s,i=!0;for(;s=o<this.children.length?this.children[o]:null,!(!s||s.dom.parentNode==this.contentDOM);o++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Ne(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let i=o,l=0;;l++){let c=this.children[l],d=i+c.size;if(r==-1&&e<=d){let u=i+c.border;if(e>=u&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=Ne(p.dom)+1;break}e-=p.size}r==-1&&(r=0)}if(r>-1&&(d>t||l==this.children.length-1)){t=d;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Ne(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=d}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,r=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(s>m&&i<y)return g.setSelection(e-m-g.border,t-m-g.border,o,r);m=y}let l=this.domFromPos(e,e?-1:1),c=t==e?l:this.domFromPos(t,t?-1:1),d=o.root.getSelection(),u=o.domSelectionRange(),f=!1;if((Xe||De)&&e==t){let{node:h,offset:m}=l;if(h.nodeType==3){if(f=!!(m&&h.nodeValue[m-1]==`
|
|
7
|
+
`),f&&m==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:Ne(y)+1});break}let w=g.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let g=h.childNodes[m-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Xe&&u.focusNode&&u.focusNode!=c.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(r=!0)}if(!(r||f&&De)&&Sn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Sn(c.node,c.offset,u.focusNode,u.focusOffset))return;let p=!1;if((d.extend||e==t)&&!(f&&Xe)){d.collapse(l.node,l.offset);try{e!=t&&d.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>t){let m=l;l=c,c=m}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,r=0;r<this.children.length;r++){let s=this.children[r],i=o+s.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+s.border,c=i-s.border;if(e>=l&&t<=c){this.dirty=e==o||t==i?Cn:gu,e==l&&t==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=pt:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Cn:pt}o=i}this.dirty=Cn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Cn:gu;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class yu extends Po{constructor(e,t,o,r){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ze&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class G0 extends Po{constructor(e,t,o,r){super(e,[],t,null),this.textDOM=o,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class En extends Po{constructor(e,t,o,r,s){super(e,[],o,r),this.mark=t,this.spec=s}static create(e,t,o,r){let s=r.nodeViews[t.type.name],i=s&&s(t,r,o);return(!i||!i.dom)&&(i=kn.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new En(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&pt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=pt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ze){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Ze}}slice(e,t,o){let r=En.create(this.parent,this.mark,!0,o),s=this.children,i=this.size;t<i&&(s=tl(s,t,i,o)),e>0&&(s=tl(s,0,e,o));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Gt extends Po{constructor(e,t,o,r,s,i,l,c,d){super(e,[],s,i),this.node=t,this.outerDeco=o,this.innerDeco=r,this.nodeDOM=l}static create(e,t,o,r,s,i){let l=s.nodeViews[t.type.name],c,d=l&&l(t,s,()=>{if(!c)return i;if(c.parent)return c.parent.posBeforeChild(c)},o,r),u=d&&d.dom,f=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=kn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=xu(u,o,t),d?c=new Y0(e,t,o,r,u,f||null,p,d,s,i+1):t.isText?new Pr(e,t,o,r,u,p,s):new Gt(e,t,o,r,u,f||null,p,s,i+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 o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>_.empty)}return e}matchesNode(e,t,o){return this.dirty==Ze&&e.eq(this.node)&&Dr(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new Q0(this,i&&i.node,e);t1(this.node,this.innerDeco,(d,u,f)=>{d.spec.marks?c.syncToMarks(d.spec.marks,o,e,u):d.type.side>=0&&!f&&c.syncToMarks(u==this.node.childCount?le.none:this.node.child(u).marks,o,e,u),c.placeWidget(d,e,r)},(d,u,f,p)=>{c.syncToMarks(d.marks,o,e,p);let h;c.findNodeMatch(d,u,f,p)||l&&e.state.selection.from>r&&e.state.selection.to<r+d.nodeSize&&(h=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(d,u,f,h,e)||c.updateNextNode(d,u,f,e,p,r)||c.addNode(d,u,f,e,r),r+=d.nodeSize}),c.syncToMarks([],o,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Cn)&&(i&&this.protectLocalComposition(e,i),bu(this.contentDOM,this.children,e),Yn&&n1(this.dom))}localCompositionInfo(e,t){let{from:o,to:r}=e.state.selection;if(!(e.state.selection instanceof Q)||o<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=o1(this.node.content,i,o-t,r-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new G0(this,s,t,r);e.input.compositionNodes.push(i),this.children=tl(this.children,o,o+r.length,e,i)}update(e,t,o,r){return this.dirty==pt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,r),!0)}updateInner(e,t,o,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Ze}updateOuterDeco(e){if(Dr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=Su(this.dom,this.nodeDOM,el(this.outerDeco,this.node,t),el(e,this.node,t)),this.dom!=o&&(o.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 ku(n,e,t,o,r){xu(o,e,n);let s=new Gt(void 0,n,e,t,o,o,o,r,0);return s.contentDOM&&s.updateChildren(r,0),s}class Pr extends Gt{constructor(e,t,o,r,s,i,l){super(e,t,o,r,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,r){return this.dirty==pt||this.dirty!=Ze&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ze||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Ze,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new Pr(this.parent,r,this.outerDeco,this.innerDeco,s,s,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=pt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class wu extends Po{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ze&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Y0 extends Gt{constructor(e,t,o,r,s,i,l,c,d,u){super(e,t,o,r,s,i,l,d,u),this.spec=c}update(e,t,o,r){if(this.dirty==pt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,o);return s&&this.updateInner(e,t,o,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,r){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,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 bu(n,e,t){let o=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=Cu(o),r=!0;o=o.nextSibling}else r=!0,n.insertBefore(l,o);if(i instanceof En){let c=o?o.previousSibling:n.lastChild;bu(i.contentDOM,i.children,t),o=c?c.nextSibling:n.firstChild}}for(;o;)o=Cu(o),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}const Do=function(n){n&&(this.nodeName=n)};Do.prototype=Object.create(null);const vn=[new Do];function el(n,e,t){if(n.length==0)return vn;let o=t?vn[0]:new Do,r=[o];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&r.push(o=new Do(i.nodeName));for(let l in i){let c=i[l];c!=null&&(t&&r.length==1&&r.push(o=new Do(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+c:l=="style"?o.style=(o.style?o.style+";":"")+c:l!="nodeName"&&(o[l]=c))}}}return r}function Su(n,e,t,o){if(t==vn&&o==vn)return e;let r=e;for(let s=0;s<o.length;s++){let i=o[s],l=t[s];if(s){let c;l&&l.nodeName==i.nodeName&&r!=n&&(c=r.parentNode)&&c.nodeName.toLowerCase()==i.nodeName||(c=document.createElement(i.nodeName),c.pmIsDeco=!0,c.appendChild(r),l=vn[0]),r=c}X0(r,l||vn[0],i)}return r}function X0(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.remove(o[s]);for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=o.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function xu(n,e,t){return Su(n,n,vn,el(e,t,n.nodeType!=1))}function Dr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Cu(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Q0{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Z0(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o,r){let s=0,i=this.stack.length>>1,l=Math.min(i,e.length);for(;s<l&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=Ze,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let c=-1,d=this.top.children.length;r<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let u=this.index;u<d;u++){let f=this.top.children[u];if(f.matchesMark(e[i])&&!this.isLocked(f.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=En.create(this.top,e[i],t,o);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,o,r){let s=-1,i;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let d=this.top.children[l];if(d.matchesNode(e,t,o)&&!this.preMatch.matched.has(d)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,o,r,s){let i=this.top.children[r];return i.dirty==pt&&i.dom==i.contentDOM&&(i.dirty=Cn),i.update(e,t,o,s)?(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 o=e.pmViewDesc;if(o){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==o)return r}return-1}e=t}}updateNextNode(e,t,o,r,s,i){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Gt){let d=this.preMatch.matched.get(c);if(d!=null&&d!=s)return!1;let u=c.dom,f,p=this.isLocked(u)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=pt&&Dr(t,c.outerDeco));if(!p&&c.update(e,t,o,r))return this.destroyBetween(this.index,l),c.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(c,e,t,o,r,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Cn,f.updateChildren(r,i+1),f.dirty=Ze),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,r,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Dr(o,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=Gt.create(this.top,t,o,r,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,t,o,r,s){let i=Gt.create(this.top,e,t,o,r,s);i.contentDOM&&i.updateChildren(r,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,o){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 s=new yu(this.top,e,t,o);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof En;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Pr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((De||Ie)&&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 o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let r=new wu(this.top,[],o,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Z0(n,e){let t=e,o=t.children.length,r=n.childCount,s=new Map,i=[];e:for(;r>0;){let l;for(;;)if(o){let d=t.children[o-1];if(d instanceof En)t=d,o=d.children.length;else{l=d,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(r-1))break;--r,s.set(l,r),i.push(l)}}return{index:r,matched:s,matches:i.reverse()}}function e1(n,e){return n.type.side-e.type.side}function t1(n,e,t,o){let r=e.locals(n),s=0;if(r.length==0){for(let d=0;d<n.childCount;d++){let u=n.child(d);o(u,r,e.forChild(s,u),d),s+=u.nodeSize}return}let i=0,l=[],c=null;for(let d=0;;){let u,f;for(;i<r.length&&r[i].to==s;){let y=r[i++];y.widget&&(u?(f||(f=[u])).push(y):u=y)}if(u)if(f){f.sort(e1);for(let y=0;y<f.length;y++)t(f[y],d,!!c)}else t(u,d,!!c);let p,h;if(c)h=-1,p=c,c=null;else if(d<n.childCount)h=d,p=n.child(d++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;i<r.length&&r[i].from<=s&&r[i].to>s;)l.push(r[i++]);let m=s+p.nodeSize;if(p.isText){let y=m;i<r.length&&r[i].from<y&&(y=r[i].from);for(let w=0;w<l.length;w++)l[w].to<y&&(y=l[w].to);y<m&&(c=p.cut(y-s),p=p.cut(0,y-s),m=y,h=-1)}else for(;i<r.length&&r[i].to<m;)i++;let g=p.isInline&&!p.isLeaf?l.filter(y=>!y.inline):l.slice();o(p,g,e.forChild(s,p),h),s=m}}function n1(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function o1(n,e,t,o){for(let r=0,s=0;r<n.childCount&&s<=o;){let i=n.child(r++),l=s;if(s+=i.nodeSize,!i.isText)continue;let c=i.text;for(;r<n.childCount;){let d=n.child(r++);if(s+=d.nodeSize,!d.isText)break;c+=d.text}if(s>=t){if(s>=o&&c.slice(o-e.length-l,o-l)==e)return o-e.length;let d=l<o?c.lastIndexOf(e,o-l-1):-1;if(d>=0&&d+e.length+l>=t)return l+d;if(t==o&&c.length>=o+e.length-l&&c.slice(o-l,o-l+e.length)==e)return o}}return-1}function tl(n,e,t,o,r){let s=[];for(let i=0,l=0;i<n.length;i++){let c=n[i],d=l,u=l+=c.size;d>=t||u<=e?s.push(c):(d<e&&s.push(c.slice(0,e-d,o)),r&&(s.push(r),r=void 0),u>t&&s.push(c.slice(t-d,c.size,o)))}return s}function nl(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),c,d;if(Rr(t)){for(c=i;r&&!r.node;)r=r.parent;let f=r.node;if(r&&f.isAtom&&G.isSelectable(f)&&r.parent&&!(f.isInline&&I0(t.focusNode,t.focusOffset,r.dom))){let p=r.posBefore;d=new G(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,p=i;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;[c,i]=p==n.state.selection.anchor?[p,f]:[f,p],l=o.resolve(i)}else c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let u=o.resolve(c);if(!d){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;d=rl(n,u,l,f)}return d}function Eu(n){return n.editable?n.hasFocus():Bu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function _t(n,e=!1){let t=n.state.selection;if(Au(n,t),!!Eu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Ie){let o=n.domSelectionRange(),r=n.domObserver.currentSelection;if(o.anchorNode&&r.anchorNode&&Sn(o.anchorNode,o.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)s1(n);else{let{anchor:o,head:r}=t,s,i;vu&&!(t instanceof Q)&&(t.$from.parent.inlineContent||(s=Tu(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Tu(n,t.to))),n.docView.setSelection(o,r,n,e),vu&&(s&&Mu(s),i&&Mu(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&r1(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const vu=De||Ie&&ou<63;function Tu(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),r=o<t.childNodes.length?t.childNodes[o]:null,s=o?t.childNodes[o-1]:null;if(De&&r&&r.contentEditable=="false")return ol(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return ol(r);if(s)return ol(s)}}function ol(n){return n.contentEditable="true",De&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Mu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function r1(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Eu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function s1(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,o=t.nodeName=="IMG";o?e.collapse(t.parentNode,Ne(t)+1):e.collapse(t,0),!o&&!n.state.selection.visible&&He&&qt<=11&&(t.disabled=!0,t.disabled=!1)}function Au(n,e){if(e instanceof G){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Nu(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Nu(n)}function Nu(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function rl(n,e,t,o){return n.someProp("createSelectionBetween",r=>r(n,e,t))||Q.between(e,t,o)}function Iu(n){return n.editable&&!n.hasFocus()?!1:Bu(n)}function Bu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function i1(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Sn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function sl(n,e){let{$anchor:t,$head:o}=n.selection,r=e>0?t.max(o):t.min(o),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&ee.findFrom(s,e)}function Yt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ou(n,e,t){let o=n.state.selection;if(o instanceof Q)if(t.indexOf("s")>-1){let{$head:r}=o,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return Yt(n,new Q(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=sl(n.state,e);return r&&r instanceof G?Yt(n,r):!1}else if(!(Qe&&t.indexOf("m")>-1)){let r=o.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?G.isSelectable(s)?Yt(n,new G(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):_o?Yt(n,new Q(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(o instanceof G&&o.node.isInline)return Yt(n,new Q(e>0?o.$to:o.$from));{let r=sl(n.state,e);return r?Yt(n,r):!1}}}function Lr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Lo(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Qn(n,e){return e<0?l1(n):a1(n)}function l1(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let r,s,i=!1;for(Xe&&t.nodeType==1&&o<Lr(t)&&Lo(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Lo(l,-1))r=t,s=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(_u(t))break;{let l=t.previousSibling;for(;l&&Lo(l,-1);)r=t.parentNode,s=Ne(l),l=l.previousSibling;if(l)t=l,o=Lr(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?il(n,t,o):r&&il(n,r,s)}function a1(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let r=Lr(t),s,i;for(;;)if(o<r){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Lo(l,1))s=t,i=++o;else break}else{if(_u(t))break;{let l=t.nextSibling;for(;l&&Lo(l,1);)s=l.parentNode,i=Ne(l)+1,l=l.nextSibling;if(l)t=l,o=0,r=Lr(t);else{if(t=t.parentNode,t==n.dom)break;o=r=0}}}s&&il(n,s,i)}function _u(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function c1(n,e){for(;n&&e==n.childNodes.length&&!Oo(n);)e=Ne(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function d1(n,e){for(;n&&!e&&!Oo(n);)e=Ne(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function il(n,e,t){if(e.nodeType!=3){let s,i;(i=c1(e,t))?(e=i,t=0):(s=d1(e,t))&&(e=s,t=s.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Rr(o)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),o.removeAllRanges(),o.addRange(s)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&_t(n)},50)}function Ru(n,e){let t=n.state.doc.resolve(e);if(!(Ie||ru)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Pu(n,e,t){let o=n.state.selection;if(o instanceof Q&&!o.empty||t.indexOf("s")>-1||Qe&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=o;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=sl(n.state,e);if(i&&i instanceof G)return Yt(n,i)}if(!r.parent.inlineContent){let i=e<0?r:s,l=o instanceof Ke?ee.near(i,e):ee.findFrom(i,e);return l?Yt(n,l):!1}return!1}function Du(n,e){if(!(n.state.selection instanceof Q))return!0;let{$head:t,$anchor:o,empty:r}=n.state.selection;if(!t.sameParent(o))return!0;if(!r)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function Lu(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function u1(n){if(!De||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let o=e.firstChild;Lu(n,o,"true"),setTimeout(()=>Lu(n,o,"false"),20)}return!1}function f1(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function h1(n,e){let t=e.keyCode,o=f1(e);if(t==8||Qe&&t==72&&o=="c")return Du(n,-1)||Qn(n,-1);if(t==46&&!e.shiftKey||Qe&&t==68&&o=="c")return Du(n,1)||Qn(n,1);if(t==13||t==27)return!0;if(t==37||Qe&&t==66&&o=="c"){let r=t==37?Ru(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ou(n,r,o)||Qn(n,r)}else if(t==39||Qe&&t==70&&o=="c"){let r=t==39?Ru(n,n.state.selection.from)=="ltr"?1:-1:1;return Ou(n,r,o)||Qn(n,r)}else{if(t==38||Qe&&t==80&&o=="c")return Pu(n,-1,o)||Qn(n,-1);if(t==40||Qe&&t==78&&o=="c")return u1(n)||Pu(n,1,o)||Qn(n,1);if(o==(Qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ll(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&o.childCount==1&&o.firstChild.childCount==1;){r--,s--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||kn.fromSchema(n.state.schema),l=Uu(),c=l.createElement("div");c.appendChild(i.serializeFragment(o,{document:l}));let d=c.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=ju[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=l.createElement(u[h]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),f++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${r} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
8
|
+
|
|
9
|
+
`);return{dom:c,text:p,slice:e}}function Vu(n,e,t,o,r){let s=r.parent.type.spec.code,i,l;if(!t&&!e)return null;let c=!!e&&(o||s||!t);if(c){if(n.someProp("transformPastedText",p=>{e=p(e,s||o,n)}),s)return l=new H(_.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
10
|
+
`))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",p=>p(e,r,o,n));if(f)l=f;else{let p=r.marks(),{schema:h}=n.state,m=kn.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(h.text(g,p)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=y1(t),_o&&k1(i);let d=i&&i.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||At.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(c||u),context:r,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!p1.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=w1(Hu(l,+u[1],+u[2]),u[4]);else if(l=H.maxOpen(m1(l.content,r),!0),l.openStart||l.openEnd){let f=0,p=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=Hu(l,f,p)}return n.someProp("transformPasted",f=>{l=f(l,n,c)}),l}const p1=/^(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 m1(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let c=r.findWrapping(l.type),d;if(!c)return i=null;if(d=i.length&&s.length&&zu(c,s,l,i[i.length-1],0))i[i.length-1]=d;else{i.length&&(i[i.length-1]=Fu(i[i.length-1],s.length));let u=$u(l,c);i.push(u),r=r.matchType(u.type),s=c}}),i)return _.from(i)}return n}function $u(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,_.from(n));return n}function zu(n,e,t,o,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=zu(n,e,t,o.lastChild,r+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(r==n.length-1?t.type:n[r+1]))return o.copy(o.content.append(_.from($u(t,n,r+1))))}}function Fu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Fu(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(_.empty,!0);return n.copy(t.append(o))}function al(n,e,t,o,r,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),r<o-1&&(l=al(l,e,t,o,r+1,s)),r>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(_.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Hu(n,e,t){return e<n.openStart&&(n=new H(al(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new H(al(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ju={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Wu=null;function Uu(){return Wu||(Wu=document.implementation.createHTMLDocument("title"))}let cl=null;function g1(n){let e=window.trustedTypes;return e?(cl||(cl=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),cl.createHTML(n)):n}function y1(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Uu().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),r;if((r=o&&ju[o[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=g1(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function k1(n){let e=n.querySelectorAll(Ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function w1(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let c=t.nodes[o[l]];if(!c||c.hasRequiredAttrs())break;r=_.from(c.create(o[l+1],r)),s++,i++}return new H(r,s,i)}const $e={},ze={},b1={touchstart:!0,touchmove:!0};class S1{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 x1(n){for(let e in $e){let t=$e[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{E1(n,o)&&!ul(n,o)&&(n.editable||!(o.type in ze))&&t(n,o)},b1[e]?{passive:!0}:void 0)}De&&n.dom.addEventListener("input",()=>null),dl(n)}function Xt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function C1(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function dl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>ul(n,o))})}function ul(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function E1(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function v1(n,e){!ul(n,e)&&$e[e.type]&&(n.editable||!(e.type in ze))&&$e[e.type](n,e)}ze.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!qu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Bt&&Ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Yn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",r=>r(n,xn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||h1(n,t)?t.preventDefault():Xt(n,"key")},ze.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ze.keypress=(n,e)=>{let t=e;if(qu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Qe&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof Q)||!o.$from.sameParent(o.$to)){let r=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",i=>i(n,o.$from.pos,o.$to.pos,r,s))&&n.dispatch(s()),t.preventDefault()}};function Vr(n){return{left:n.clientX,top:n.clientY}}function T1(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function fl(n,e,t,o,r){if(o==-1)return!1;let s=n.state.doc.resolve(o);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),r,!0):l(n,t,s.node(i),s.before(i),r,!1)))return!0;return!1}function Zn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function M1(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&G.isSelectable(o)?(Zn(n,new G(t)),!0):!1}function A1(n,e){if(e==-1)return!1;let t=n.state.selection,o,r;t instanceof G&&(o=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(G.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(i);break}}return r!=null?(Zn(n,G.create(n.state.doc,r)),!0):!1}function N1(n,e,t,o,r){return fl(n,"handleClickOn",e,t,o)||n.someProp("handleClick",s=>s(n,e,o))||(r?A1(n,t):M1(n,t))}function I1(n,e,t,o){return fl(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",r=>r(n,e,o))}function B1(n,e,t,o){return fl(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",r=>r(n,e,o))||O1(n,t,o)}function O1(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(Zn(n,Q.create(o,0,o.content.size)),!0):!1;let r=o.resolve(e);for(let s=r.depth+1;s>0;s--){let i=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(i.inlineContent)Zn(n,Q.create(o,l+1,l+1+i.content.size));else if(G.isSelectable(i))Zn(n,G.create(o,l));else continue;return!0}}function hl(n){return $r(n)}const Ku=Qe?"metaKey":"ctrlKey";$e.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=hl(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&T1(t,n.input.lastClick)&&!t[Ku]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s,button:t.button};let i=n.posAtCoords(Vr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new _1(n,i,t,!!o)):(s=="doubleClick"?I1:B1)(n,i.pos,i.inside,t)?t.preventDefault():Xt(n,"pointer"))};class _1{constructor(e,t,o,r){this.view=e,this.pos=t,this.event=o,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!o[Ku],this.allowDefault=o.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=r?null:o.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=e.state;(o.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof G&&d.from<=i&&d.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xe&&!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)),Xt(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(()=>_t(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(Vr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Xt(this.view,"pointer"):N1(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||De&&this.mightDrag&&!this.mightDrag.node.isAtom||Ie&&!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)?(Zn(this.view,ee.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Xt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Xt(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)}}$e.touchstart=n=>{n.input.lastTouch=Date.now(),hl(n),Xt(n,"pointer")},$e.touchmove=n=>{n.input.lastTouch=Date.now(),Xt(n,"pointer")},$e.contextmenu=n=>hl(n);function qu(n,e){return n.composing?!0:De&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const R1=Bt?5e3:-1;ze.compositionstart=ze.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||Ie&&ru&&P1(n)))n.markCursor=n.state.storedMarks||t.marks(),$r(n,!0),n.markCursor=null;else if($r(n,!e.selection.empty),Xe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let r=o.focusNode,s=o.focusOffset;r&&r.nodeType==1&&s!=0;){let i=s<0?r.lastChild:r.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else r=i,s=-1}}n.input.composing=!0}Ju(n,R1)};function P1(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let o=e.childNodes[t];return o.nodeType==1&&o.contentEditable=="false"}ze.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ju(n,20))};function Ju(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>$r(n),e))}function Gu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=L1());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function D1(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=A0(e.focusNode,e.focusOffset),o=N0(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let r=o.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||o==s)return s;if(!r||!r.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function L1(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function $r(n,e=!1){if(!(Bt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Gu(n),e||n.docView&&n.docView.dirty){let t=nl(n),o=n.state.selection;return t&&!t.eq(o)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function V1(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Vo=He&&qt<15||Yn&&_0<604;$e.copy=ze.cut=(n,e)=>{let t=e,o=n.state.selection,r=t.type=="cut";if(o.empty)return;let s=Vo?null:t.clipboardData,i=o.content(),{dom:l,text:c}=ll(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):V1(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $1(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function z1(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?$o(n,o.value,null,r,e):$o(n,o.textContent,o.innerHTML,r,e)},50)}function $o(n,e,t,o,r){let s=Vu(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,r,s||H.empty)))return!0;if(!s)return!1;let i=$1(s),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Yu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ze.paste=(n,e)=>{let t=e;if(n.composing&&!Bt)return;let o=Vo?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&$o(n,Yu(o),o.getData("text/html"),r,t)?t.preventDefault():z1(n,t)};class Xu{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const F1=Qe?"altKey":"ctrlKey";function Qu(n,e){let t=n.someProp("dragCopies",o=>!o(e));return t??!e[F1]}$e.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(Vr(t)),i;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof G?r.to-1:r.to))){if(o&&o.mightDrag)i=G.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=G.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:c,text:d,slice:u}=ll(n,l);(!t.dataTransfer.files.length||!Ie||ou>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Vo?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",Vo||t.dataTransfer.setData("text/plain",d),n.dragging=new Xu(u,Qu(n,t),i)},$e.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ze.dragover=ze.dragenter=(n,e)=>e.preventDefault(),ze.drop=(n,e)=>{try{H1(n,e,n.dragging)}finally{n.dragging=null}};function H1(n,e,t){if(!e.dataTransfer)return;let o=n.posAtCoords(Vr(e));if(!o)return;let r=n.state.doc.resolve(o.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=Vu(n,Yu(e.dataTransfer),Vo?null:e.dataTransfer.getData("text/html"),!1,r);let i=!!(t&&Qu(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||H.empty,i))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Md(n.state.doc,r.pos,s):r.pos;l==null&&(l=r.pos);let c=n.state.tr;if(i){let{node:h}=t;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(f))return;let p=c.doc.resolve(d);if(u&&G.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new G(p));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,w)=>h=w),c.setSelection(rl(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}$e.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&_t(n)},20))},$e.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},$e.beforeinput=(n,e)=>{if(Ie&&Bt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,xn(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in ze)$e[n]=ze[n];function zo(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class zr{constructor(e,t){this.toDOM=e,this.spec=t||Tn,this.side=this.spec.side||0}map(e,t,o,r){let{pos:s,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Fe(s-o,s-o,this)}valid(){return!0}eq(e){return this==e||e instanceof zr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&zo(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Qt{constructor(e,t){this.attrs=e,this.spec=t||Tn}map(e,t,o,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-o;return s>=i?null:new Fe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Qt&&zo(this.attrs,e.attrs)&&zo(this.spec,e.spec)}static is(e){return e.type instanceof Qt}destroy(){}}class pl{constructor(e,t){this.attrs=e,this.spec=t||Tn}map(e,t,o,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=s.pos?null:new Fe(s.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(o)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof pl&&zo(this.attrs,e.attrs)&&zo(this.spec,e.spec)}destroy(){}}class Fe{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new Fe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new Fe(e,e,new zr(t,o))}static inline(e,t,o,r){return new Fe(e,t,new Qt(o,r))}static node(e,t,o,r){return new Fe(e,t,new pl(o,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Qt}get widget(){return this.type instanceof zr}}const eo=[],Tn={};class pe{constructor(e,t){this.local=e.length?e:eo,this.children=t.length?t:eo}static create(e,t){return t.length?Fr(t,e,0,Tn):Le}find(e,t,o){let r=[];return this.findInner(e??0,t??1e9,r,0,o),r}findInner(e,t,o,r,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&o.push(l.copy(l.from+r,l.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,r+l,s)}}map(e,t,o){return this==Le||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Tn)}mapInner(e,t,o,r,s){let i;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,o,r);c&&c.type.valid(t,c)?(i||(i=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?j1(this.children,i||[],e,t,o,r,s):i?new pe(i.sort(Mn),eo):Le}add(e,t){return t.length?this==Le?pe.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let r,s=0;e.forEach((l,c)=>{let d=c+o,u;if(u=ef(t,l,d)){for(r||(r=this.children.slice());s<r.length&&r[s]<c;)s+=3;r[s]==c?r[s+2]=r[s+2].addInner(l,u,d+1):r.splice(s,0,c,c+l.nodeSize,Fr(u,l,d+1,Tn)),s+=3}});let i=Zu(s?tf(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new pe(i.length?this.local.concat(i).sort(Mn):this.local,r||this.children)}remove(e){return e.length==0||this==Le?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,r=this.local;for(let s=0;s<o.length;s+=3){let i,l=o[s]+t,c=o[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<c&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;o==this.children&&(o=this.children.slice());let d=o[s+2].removeInner(i,l+1);d!=Le?o[s+2]=d:(o.splice(s,3),s-=3)}if(r.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<r.length;l++)r[l].eq(i,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return o==this.children&&r==this.local?this:r.length||o.length?new pe(r,o):Le}forChild(e,t){if(this==Le)return this;if(t.isLeaf)return pe.empty;let o,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<i&&c.to>s&&c.type instanceof Qt){let d=Math.max(s,c.from)-s,u=Math.min(i,c.to)-s;d<u&&(r||(r=[])).push(c.copy(d,u))}}if(r){let l=new pe(r.sort(Mn),eo);return o?new Zt([l,o]):l}return o||Le}eq(e){if(this==e)return!0;if(!(e instanceof pe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ml(this.localsInner(e))}localsInner(e){if(this==Le)return eo;if(e.inlineContent||!this.local.some(Qt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Qt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}pe.empty=new pe([],[]),pe.removeOverlap=ml;const Le=pe.empty;class Zt{constructor(e){this.members=e}map(e,t){const o=this.members.map(r=>r.map(e,t,Tn));return Zt.from(o)}forChild(e,t){if(t.isLeaf)return pe.empty;let o=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=Le&&(s instanceof Zt?o=o.concat(s.members):o.push(s))}return Zt.from(o)}eq(e){if(!(e instanceof Zt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{o&&(t=t.slice(),o=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ml(o?t:t.sort(Mn)):eo}static from(e){switch(e.length){case 0:return Le;case 1:return e[0];default:return new Zt(e.every(t=>t instanceof pe)?e:e.reduce((t,o)=>t.concat(o instanceof pe?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function j1(n,e,t,o,r,s,i){let l=n.slice();for(let d=0,u=s;d<t.maps.length;d++){let f=0;t.maps[d].forEach((p,h,m,g)=>{let y=g-m-(h-p);for(let w=0;w<l.length;w+=3){let b=l[w+1];if(b<0||p>b+u-f)continue;let x=l[w]+u-f;h>=x?l[w+1]=p<=x?-2:-1:p>=u&&y&&(l[w]+=y,l[w+1]+=y)}f+=y}),u=t.maps[d].map(u,-1)}let c=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){c=!0,l[d+1]=-1;continue}let u=t.map(n[d]+s),f=u-r;if(f<0||f>=o.content.size){c=!0;continue}let p=t.map(n[d+1]+s,-1),h=p-r,{index:m,offset:g}=o.content.findIndex(f),y=o.maybeChild(m);if(y&&g==f&&g+y.nodeSize==h){let w=l[d+2].mapInner(t,y,u+1,n[d]+s+1,i);w!=Le?(l[d]=f,l[d+1]=h,l[d+2]=w):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=W1(l,n,e,t,r,s,i),u=Fr(d,o,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let h=u.children[f];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new pe(e.sort(Mn),l)}function Zu(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let r=n[o];t.push(new Fe(r.from+e,r.to+e,r.type))}return t}function W1(n,e,t,o,r,s,i){function l(c,d){for(let u=0;u<c.local.length;u++){let f=c.local[u].map(o,r,d);f?t.push(f):i.onRemove&&i.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)l(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&l(n[c+2],e[c]+s+1);return t}function ef(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,r=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<o&&((r||(r=[])).push(i),n[s]=null);return r}function tf(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Fr(n,e,t,o){let r=[],s=!1;e.forEach((l,c)=>{let d=ef(n,l,c+t);if(d){s=!0;let u=Fr(d,l,t+c+1,o);u!=Le&&r.push(c,c+l.nodeSize,u)}});let i=Zu(s?tf(n):n,-t).sort(Mn);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||r.length?new pe(i,r):Le}function Mn(n,e){return n.from-e.from||n.to-e.to}function ml(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==o.from){s.to!=o.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,o.to),nf(e,r+1,s.copy(o.to,s.to)));continue}else{s.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,s.from),nf(e,r,o.copy(s.from,o.to)));break}}}return e}function nf(n,e,t){for(;e<n.length&&Mn(t,n[e])>0;)e++;n.splice(e,0,t)}function gl(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=Le&&e.push(o)}),n.cursorWrapper&&e.push(pe.create(n.state.doc,[n.cursorWrapper.deco])),Zt.from(e)}const U1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},K1=He&&qt<=11;class q1{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class J1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new q1,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let r=0;r<o.length;r++)this.queue.push(o[r]);He&&qt<=11&&o.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():De&&e.composing&&o.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),K1&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.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,U1)),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(Iu(this.view)){if(this.suppressingSelectionUpdates)return _t(this.view);if(He&&qt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Sn(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,o;for(let s=e.focusNode;s;s=Gn(s))t.add(s);for(let s=e.anchorNode;s;s=Gn(s))if(t.has(s)){o=s;break}let r=o&&this.view.docView.nearestDesc(o);if(r&&r.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))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 o=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Iu(e)&&!this.ignoreSelectionChange(o),s=-1,i=-1,l=!1,c=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],c);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(c.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(Xe&&c.length){let u=c.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,p]=u;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of u){let h=p.parentNode;h&&h.nodeName=="LI"&&(!f||X1(e,f)!=h)&&p.remove()}}}let d=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Rr(o)&&(d=nl(e))&&d.eq(ee.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,_t(e),this.currentSelection.set(o),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,i),G1(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Q1(e,c)),this.handleDOMChange(s,i,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||_t(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let r=e.previousSibling,s=e.nextSibling;if(He&&qt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:p}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p)}let i=r&&r.parentNode==e.target?Ne(r)+1:0,l=o.localPosFromDOM(e.target,i,-1),c=s&&s.parentNode==e.target?Ne(s):e.target.childNodes.length,d=o.localPosFromDOM(e.target,c,1);return{from:l,to:d}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let of=new WeakMap,rf=!1;function G1(n){if(!of.has(n)&&(of.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Xe,rf)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."),rf=!0}}function sf(n,e){let t=e.startContainer,o=e.startOffset,r=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Sn(i.node,i.offset,r,s)&&([t,o,r,s]=[r,s,t,o]),{anchorNode:t,anchorOffset:o,focusNode:r,focusOffset:s}}function Y1(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return sf(n,r)}let t;function o(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?sf(n,t):null}function X1(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function Q1(n,e){var t;let{focusNode:o,focusOffset:r}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let i=s.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let l=i;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(s,l.firstChild),o==s&&n.domSelection().collapse(s,r)}else s.parentNode.removeChild(s)}}function Z1(n,e,t){let{node:o,fromOffset:r,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),c=n.domSelectionRange(),d,u=c.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:c.anchorOffset}],Rr(c)||d.push({node:c.focusNode,offset:c.focusOffset})),Ie&&n.input.lastKeyCode===8)for(let y=s;y>r;y--){let w=o.childNodes[y-1],b=w.pmViewDesc;if(w.nodeName=="BR"&&!b){s=y;break}if(!b||b.size)break}let f=n.state.doc,p=n.someProp("domParser")||At.fromSchema(n.state.schema),h=f.resolve(i),m=null,g=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:r,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:ek,context:h});if(d&&d[0].pos!=null){let y=d[0].pos,w=d[1]&&d[1].pos;w==null&&(w=y),m={anchor:y+i,head:w+i}}return{doc:g,sel:m,from:i,to:l}}function ek(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(De&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||De&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const tk=/^(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 nk(n,e,t,o,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=nl(n,C);if(T&&!n.state.selection.eq(T)){if(Ie&&Bt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,xn(13,"Enter"))))return;let v=n.state.tr.setSelection(T);C=="pointer"?v.setMeta("pointer",!0):C=="key"&&v.scrollIntoView(),s&&v.setMeta("composition",s),n.dispatch(v)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,d=Z1(n,e,t),u=n.state.doc,f=u.slice(d.from,d.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=sk(f.content,d.doc.content,d.from,p,h);if(m&&n.input.domChangeCount++,(Yn&&n.input.lastIOSEnter>Date.now()-225||Bt)&&r.some(C=>C.nodeType==1&&!tk.test(C.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",C=>C(n,xn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof Q&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let C=lf(n,n.state.doc,d.sel);if(C&&!C.eq(n.state.selection)){let T=n.state.tr.setSelection(C);s&&T.setMeta("composition",s),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof Q&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),He&&qt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>d.from&&d.doc.textBetween(m.start-d.from-1,m.start-d.from+1)==" "&&(m.start--,m.endA--,m.endB--);let g=d.doc.resolveNoCache(m.start-d.from),y=d.doc.resolveNoCache(m.endB-d.from),w=u.resolve(m.start),b=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=m.endA;if((Yn&&n.input.lastIOSEnter>Date.now()-225&&(!b||r.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!b&&g.pos<d.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(d.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",C=>C(n,xn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&rk(u,m.start,m.endA,g,y)&&n.someProp("handleKeyDown",C=>C(n,xn(8,"Backspace")))){Bt&&Ie&&n.domObserver.suppressSelectionUpdates();return}Ie&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Bt&&!b&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,y=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,xn(13,"Enter"))})},20));let x=m.start,S=m.endA,E=C=>{let T=C||n.state.tr.replace(x,S,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let v=lf(n,T.doc,d.sel);v&&!(Ie&&n.composing&&v.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(v.head==x||v.head==T.mapping.map(S)-1)||He&&v.empty&&v.head==x)&&T.setSelection(v)}return s&&T.setMeta("composition",s),T.scrollIntoView()},M;if(b)if(g.pos==y.pos){He&&qt<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>_t(n),20));let C=E(n.state.tr.delete(x,S)),T=u.resolve(m.start).marksAcross(u.resolve(m.endA));T&&C.ensureMarks(T),n.dispatch(C)}else if(m.endA==m.endB&&(M=ok(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,m.endA-w.start())))){let C=E(n.state.tr);M.type=="add"?C.addMark(x,S,M.mark):C.removeMark(x,S,M.mark),n.dispatch(C)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let C=g.parent.textBetween(g.parentOffset,y.parentOffset),T=()=>E(n.state.tr.insertText(C,x,S));n.someProp("handleTextInput",v=>v(n,x,S,C,T))||n.dispatch(T())}else n.dispatch(E());else n.dispatch(E())}function lf(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:rl(n,e.resolve(t.anchor),e.resolve(t.head))}function ok(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,r=t,s=o,i,l,c;for(let u=0;u<o.length;u++)r=o[u].removeFromSet(r);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],i="add",c=u=>u.mark(l.addToSet(u.marks));else if(r.length==0&&s.length==1)l=s[0],i="remove",c=u=>u.mark(l.removeFromSet(u.marks));else return null;let d=[];for(let u=0;u<e.childCount;u++)d.push(c(e.child(u)));if(_.from(d).eq(n))return{mark:l,type:i}}function rk(n,e,t,o,r){if(t-e<=r.pos-o.pos||yl(o,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!o.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(yl(s,!0,!0));return!i.parent.isTextblock||i.pos>t||yl(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function yl(n,e,t){let o=n.depth,r=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,r++,e=!1;if(t){let s=n.node(o).maybeChild(n.indexAfter(o));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function sk(n,e,t,o,r){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(r=="end"){let c=Math.max(0,s-Math.min(i,l));o-=i+c-s}if(i<s&&n.size<e.size){let c=o<=s&&o>=i?s-o:0;s-=c,s&&s<e.size&&af(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-i),i=s}else if(l<s){let c=o<=s&&o>=l?s-o:0;s-=c,s&&s<n.size&&af(n.textBetween(s-1,s+1))&&(s+=c?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function af(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class cf{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 S1,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(pf),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=ff(this),uf(this),this.nodeViews=hf(this),this.docView=ku(this.state.doc,df(this),gl(this),this.dom,this),this.domObserver=new J1(this,(o,r,s,i)=>nk(this,o,r,s,i)),this.domObserver.start(),x1(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&&dl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(pf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let r=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Gu(this),i=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=hf(this);lk(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&dl(this),this.editable=ff(this),uf(this);let c=gl(this),d=df(this),u=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,d,c);(f||!e.selection.eq(r.selection))&&(i=!0);let p=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&D0(this);if(i){this.domObserver.stop();let h=f&&(He||Ie)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&ik(r.selection,e.selection);if(f){let m=Ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=D1(this)),(s||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=ku(e.doc,d,c,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&i1(this))?_t(this,h):(Au(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((o=this.dragging)===null||o===void 0)&&o.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&L0(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof G){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&su(this,t.getBoundingClientRect(),e)}else su(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,r=-1;if(this.state.doc.nodeAt(o.from)==o.node)r=o.from;else{let s=o.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==o.node&&(r=s)}this.dragging=new Xu(e.slice,e.move,r<0?void 0:G.create(this.state.doc,r))}someProp(e,t){let o=this._props&&this._props[e],r;if(o!=null&&(r=t?t(o):o))return r;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(He){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&&V0(this.dom),_t(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return j0(this,e)}coordsAtPos(e,t=1){return uu(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,o=-1){let r=this.docView.posFromDOM(e,t,o);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return J0(this,t||this.state,e)}pasteHTML(e,t){return $o(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return $o(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ll(this,e)}destroy(){this.docView&&(C1(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,T0())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return v1(this,e)}domSelectionRange(){let e=this.domSelection();return e?De&&this.root.nodeType===11&&B0(this.dom.ownerDocument)==this.dom&&Y1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}cf.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function df(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[Fe.node(0,n.state.doc.content.size,e)]}function uf(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Fe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ff(n){return!n.someProp("editable",e=>e(n.state)===!1)}function ik(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function hf(n){let e=Object.create(null);function t(o){for(let r in o)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=o[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lk(n,e){let t=0,o=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)o++;return t!=o}function pf(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var en={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:"'"},Hr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ak=typeof navigator<"u"&&/Mac/.test(navigator.platform),ck=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Be=0;Be<10;Be++)en[48+Be]=en[96+Be]=String(Be);for(var Be=1;Be<=24;Be++)en[Be+111]="F"+Be;for(var Be=65;Be<=90;Be++)en[Be]=String.fromCharCode(Be+32),Hr[Be]=String.fromCharCode(Be);for(var kl in en)Hr.hasOwnProperty(kl)||(Hr[kl]=en[kl]);function dk(n){var e=ak&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ck&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Hr:en)[n.keyCode]||n.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}const uk=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fk=typeof navigator<"u"&&/Win/.test(navigator.platform);function hk(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,r,s,i;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))uk?i=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(t="Alt-"+t),r&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function pk(n){let e=Object.create(null);for(let t in n)e[hk(t)]=n[t];return e}function wl(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function mk(n){return new ge({props:{handleKeyDown:mf(n)}})}function mf(n){let e=pk(n);return function(t,o){let r=dk(o),s,i=e[wl(r,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(o.shiftKey){let l=e[wl(r,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(fk&&o.ctrlKey&&o.altKey)&&(s=en[o.keyCode])&&s!=r){let l=e[wl(s,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var gk=Object.defineProperty,bl=(n,e)=>{for(var t in e)gk(n,t,{get:e[t],enumerable:!0})};function jr(n){const{state:e,transaction:t}=n;let{selection:o}=t,{doc:r}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return o},get doc(){return r},get tr(){return o=t.selection,r=t.doc,s=t.storedMarks,t}}}var Wr=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:o}=e,{tr:r}=t,s=this.buildProps(r);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...d)=>{const u=l(...d)(s);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(r),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:o,state:r}=this,{view:s}=o,i=[],l=!!n,c=n||r.tr,d=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),i.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(t).map(([f,p])=>[f,(...m)=>{const g=this.buildProps(c,e),y=p(...m)(g);return i.push(y),u}])),run:d};return u}createCan(n){const{rawCommands:e,state:t}=this,o=!1,r=n||t.tr,s=this.buildProps(r,o);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...d)=>c(...d)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,o)}}buildProps(n,e=!0){const{rawCommands:t,editor:o,state:r}=this,{view:s}=o,i={tr:n,editor:o,view:s,state:jr({state:r,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)(i)]))}};return i}},gf={};bl(gf,{blur:()=>yk,clearContent:()=>kk,clearNodes:()=>wk,command:()=>bk,createParagraphNear:()=>Sk,cut:()=>xk,deleteCurrentNode:()=>Ck,deleteNode:()=>Ek,deleteRange:()=>vk,deleteSelection:()=>Tk,enter:()=>Mk,exitCode:()=>Ak,extendMarkRange:()=>Nk,first:()=>Ik,focus:()=>Ok,forEach:()=>_k,insertContent:()=>Rk,insertContentAt:()=>Lk,joinBackward:()=>zk,joinDown:()=>$k,joinForward:()=>Fk,joinItemBackward:()=>Hk,joinItemForward:()=>jk,joinTextblockBackward:()=>Wk,joinTextblockForward:()=>Uk,joinUp:()=>Vk,keyboardShortcut:()=>qk,lift:()=>Jk,liftEmptyBlock:()=>Gk,liftListItem:()=>Yk,newlineInCode:()=>Xk,resetAttributes:()=>Qk,scrollIntoView:()=>Zk,selectAll:()=>ew,selectNodeBackward:()=>tw,selectNodeForward:()=>nw,selectParentNode:()=>ow,selectTextblockEnd:()=>rw,selectTextblockStart:()=>sw,setContent:()=>iw,setMark:()=>Cw,setMeta:()=>Ew,setNode:()=>vw,setNodeSelection:()=>Tw,setTextDirection:()=>Mw,setTextSelection:()=>Aw,sinkListItem:()=>Nw,splitBlock:()=>Iw,splitListItem:()=>Bw,toggleList:()=>Ow,toggleMark:()=>_w,toggleNode:()=>Rw,toggleWrap:()=>Pw,undoInputRule:()=>Dw,unsetAllMarks:()=>Lw,unsetMark:()=>Vw,unsetTextDirection:()=>$w,updateAttributes:()=>zw,wrapIn:()=>Fw,wrapInList:()=>Hw});var yk=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),kk=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),wk=()=>({state:n,tr:e,dispatch:t})=>{const{selection:o}=e,{ranges:r}=o;return t&&r.forEach(({$from:s,$to:i})=>{n.doc.nodesBetween(s.pos,i.pos,(l,c)=>{if(l.type.isText)return;const{doc:d,mapping:u}=e,f=d.resolve(u.map(c)),p=d.resolve(u.map(c+l.nodeSize)),h=f.blockRange(p);if(!h)return;const m=jn(h);if(l.type.isTextblock){const{defaultType:g}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},bk=n=>e=>n(e),Sk=()=>({state:n,dispatch:e})=>Gd(n,e),xk=(n,e)=>({editor:t,tr:o})=>{const{state:r}=t,s=r.doc.slice(n.from,n.to);o.deleteRange(n.from,n.to);const i=o.mapping.map(e);return o.insert(i,s.content),o.setSelection(new Q(o.doc.resolve(Math.max(i-1,0)))),!0},Ck=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,o=t.$anchor.node();if(o.content.size>0)return!1;const r=n.selection.$anchor;for(let s=r.depth;s>0;s-=1)if(r.node(s).type===o.type){if(e){const l=r.before(s),c=r.after(s);n.delete(l,c).scrollIntoView()}return!0}return!1};function ve(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var Ek=n=>({tr:e,state:t,dispatch:o})=>{const r=ve(n,t.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r){if(o){const c=s.before(i),d=s.after(i);e.delete(c,d).scrollIntoView()}return!0}return!1},vk=n=>({tr:e,dispatch:t})=>{const{from:o,to:r}=n;return t&&e.delete(o,r),!0},Tk=()=>({state:n,dispatch:e})=>ji(n,e),Mk=()=>({commands:n})=>n.keyboardShortcut("Enter"),Ak=()=>({state:n,dispatch:e})=>u0(n,e);function Sl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Ur(n,e,t={strict:!0}){const o=Object.keys(e);return o.length?o.every(r=>t.strict?e[r]===n[r]:Sl(e[r])?e[r].test(n[r]):e[r]===n[r]):!0}function yf(n,e,t={}){return n.find(o=>o.type===e&&Ur(Object.fromEntries(Object.keys(t).map(r=>[r,o.attrs[r]])),t))}function kf(n,e,t={}){return!!yf(n,e,t)}function xl(n,e,t){var o;if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(u=>u.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(u=>u.type===e)||(t=t||((o=r.node.marks[0])==null?void 0:o.attrs),!yf([...r.node.marks],e,t)))return;let i=r.index,l=n.start()+r.offset,c=i+1,d=l+r.node.nodeSize;for(;i>0&&kf([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;c<n.parent.childCount&&kf([...n.parent.child(c).marks],e,t);)d+=n.parent.child(c).nodeSize,c+=1;return{from:l,to:d}}function Rt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Nk=(n,e={})=>({tr:t,state:o,dispatch:r})=>{const s=Rt(n,o.schema),{doc:i,selection:l}=t,{$from:c,from:d,to:u}=l;if(r){const f=xl(c,s,e);if(f&&f.from<=d&&f.to>=u){const p=Q.create(i,f.from,f.to);t.setSelection(p)}}return!0},Ik=n=>e=>{const t=typeof n=="function"?n(e):n;for(let o=0;o<t.length;o+=1)if(t[o](e))return!0;return!1};function wf(n){return n instanceof Q}function An(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function bf(n,e=null){if(!e)return null;const t=ee.atStart(n),o=ee.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return o;const r=t.from,s=o.to;return e==="all"?Q.create(n,An(0,r,s),An(n.content.size,r,s)):Q.create(n,An(e,r,s),An(e,r,s))}function Sf(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Kr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Bk(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Ok=(n=null,e={})=>({editor:t,view:o,tr:r,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{(Kr()||Sf())&&o.dom.focus(),Bk()&&!Kr()&&!Sf()&&o.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(o.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(o.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!wf(t.state.selection))return i(),!0;const l=bf(r.doc,n)||t.state.selection,c=t.state.selection.eq(l);return s&&(c||r.setSelection(l),c&&r.storedMarks&&r.setStoredMarks(r.storedMarks),i()),!0},_k=(n,e)=>t=>n.every((o,r)=>e(o,{...t,index:r})),Rk=(n,e)=>({tr:t,commands:o})=>o.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),xf=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const o=e[t];o.nodeType===3&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?n.removeChild(o):o.nodeType===1&&xf(o)}return n};function Fo(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return xf(t)}function Ho(n,e,t){if(n instanceof Mt||n instanceof _)return n;t={slice:!0,parseOptions:{},...t};const o=typeof n=="object"&&n!==null,r=typeof n=="string";if(o)try{if(Array.isArray(n)&&n.length>0)return _.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Ho("",e,t)}if(r){if(t.errorOnInvalidContent){let i=!1,l="";const c=new id({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(i=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?At.fromSchema(c).parseSlice(Fo(n),t.parseOptions):At.fromSchema(c).parse(Fo(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=At.fromSchema(e);return t.slice?s.parseSlice(Fo(n),t.parseOptions).content:s.parse(Fo(n),t.parseOptions)}return Ho("",e,t)}function Pk(n,e,t){const o=n.steps.length-1;if(o<e)return;const r=n.steps[o];if(!(r instanceof xe||r instanceof Ce))return;const s=n.mapping.maps[o];let i=0;s.forEach((l,c,d,u)=>{i===0&&(i=u)}),n.setSelection(ee.near(n.doc.resolve(i),t))}var Dk=n=>!("type"in n),Lk=(n,e,t)=>({tr:o,dispatch:r,editor:s})=>{var i;if(r){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const c=y=>{s.emit("contentError",{editor:s,error:y,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Ho(e,s.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=Ho(e,s.schema,{parseOptions:d,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:s.options.enableContentCheck})}catch(y){return c(y),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},p=!0,h=!0;if((Dk(l)?l:[l]).forEach(y=>{y.check(),p=p?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===f&&h){const{parent:y}=o.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,f+=1)}let g;if(p){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof _){let y="";e.forEach(w=>{w.text&&(y+=w.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;o.insertText(g,u,f)}else{g=l;const y=o.doc.resolve(u),w=y.node(),b=y.parentOffset===0,x=w.isText||w.isTextblock,S=w.content.size>0;b&&x&&S&&(u=Math.max(0,u-1)),o.replaceWith(u,f,g)}t.updateSelection&&Pk(o,o.steps.length-1,-1),t.applyInputRules&&o.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&o.setMeta("applyPasteRules",{from:u,text:g})}return!0},Vk=()=>({state:n,dispatch:e})=>a0(n,e),$k=()=>({state:n,dispatch:e})=>c0(n,e),zk=()=>({state:n,dispatch:e})=>Hd(n,e),Fk=()=>({state:n,dispatch:e})=>Kd(n,e),Hk=()=>({state:n,dispatch:e,tr:t})=>{try{const o=Ir(n.doc,n.selection.$from.pos,-1);return o==null?!1:(t.join(o,2),e&&e(t),!0)}catch{return!1}},jk=()=>({state:n,dispatch:e,tr:t})=>{try{const o=Ir(n.doc,n.selection.$from.pos,1);return o==null?!1:(t.join(o,2),e&&e(t),!0)}catch{return!1}},Wk=()=>({state:n,dispatch:e})=>i0(n,e),Uk=()=>({state:n,dispatch:e})=>l0(n,e);function Cf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Kk(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let o,r,s,i;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))Kr()||Cf()?i=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return o&&(t=`Alt-${t}`),r&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var qk=n=>({editor:e,view:t,tr:o,dispatch:r})=>{const s=Kk(n).split(/-(?!$)/),i=s.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,l))});return c==null||c.steps.forEach(d=>{const u=d.map(o.mapping);u&&r&&o.maybeStep(u)}),!0};function jo(n,e,t={}){const{from:o,to:r,empty:s}=n.selection,i=e?ve(e,n.schema):null,l=[];n.doc.nodesBetween(o,r,(f,p)=>{if(f.isText)return;const h=Math.max(o,p),m=Math.min(r,p+f.nodeSize);l.push({node:f,from:h,to:m})});const c=r-o,d=l.filter(f=>i?i.name===f.node.type.name:!0).filter(f=>Ur(f.node.attrs,t,{strict:!1}));return s?!!d.length:d.reduce((f,p)=>f+p.to-p.from,0)>=c}var Jk=(n,e={})=>({state:t,dispatch:o})=>{const r=ve(n,t.schema);return jo(t,r,e)?d0(t,o):!1},Gk=()=>({state:n,dispatch:e})=>Yd(n,e),Yk=n=>({state:e,dispatch:t})=>{const o=ve(n,e.schema);return x0(o)(e,t)},Xk=()=>({state:n,dispatch:e})=>Jd(n,e);function qr(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Ef(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((o,r)=>(t.includes(r)||(o[r]=n[r]),o),{})}var Qk=(n,e)=>({tr:t,state:o,dispatch:r})=>{let s=null,i=null;const l=qr(typeof n=="string"?n:n.name,o.schema);if(!l)return!1;l==="node"&&(s=ve(n,o.schema)),l==="mark"&&(i=Rt(n,o.schema));let c=!1;return t.selection.ranges.forEach(d=>{o.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,f)=>{s&&s===u.type&&(c=!0,r&&t.setNodeMarkup(f,void 0,Ef(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(p=>{i===p.type&&(c=!0,r&&t.addMark(f,f+u.nodeSize,i.create(Ef(p.attrs,e))))})})}),c},Zk=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),ew=()=>({tr:n,dispatch:e})=>{if(e){const t=new Ke(n.doc);n.setSelection(t)}return!0},tw=()=>({state:n,dispatch:e})=>Wd(n,e),nw=()=>({state:n,dispatch:e})=>qd(n,e),ow=()=>({state:n,dispatch:e})=>p0(n,e),rw=()=>({state:n,dispatch:e})=>y0(n,e),sw=()=>({state:n,dispatch:e})=>g0(n,e);function Cl(n,e,t={},o={}){return Ho(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:o.errorOnInvalidContent})}var iw=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:o={}}={})=>({editor:r,tr:s,dispatch:i,commands:l})=>{const{doc:c}=s;if(o.preserveWhitespace!=="full"){const d=Cl(n,r.schema,o,{errorOnInvalidContent:e??r.options.enableContentCheck});return i&&s.replaceWith(0,c.content.size,d).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:c.content.size},n,{parseOptions:o,errorOnInvalidContent:e??r.options.enableContentCheck})};function vf(n,e){const t=Rt(e,n.schema),{from:o,to:r,empty:s}=n.selection,i=[];s?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(o,r,c=>{i.push(...c.marks)});const l=i.find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function Tf(n,e){const t=new Od(n);return e.forEach(o=>{o.steps.forEach(r=>{t.step(r)})}),t}function lw(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function aw(n,e,t){const o=[];return n.nodesBetween(e.from,e.to,(r,s)=>{t(r)&&o.push({node:r,pos:s})}),o}function cw(n,e){for(let t=n.depth;t>0;t-=1){const o=n.node(t);if(e(o))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:o}}}function El(n){return e=>cw(e.$from,n)}function q(n,e,t){return n.config[e]===void 0&&n.parent?q(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?q(n.parent,e,t):null}):n.config[e]}function vl(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},o=q(e,"addExtensions",t);return o?[e,...vl(o())]:e}).flat(10)}function Jr(n,e){const t=kn.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function Mf(n){return typeof n=="function"}function ce(n,e=void 0,...t){return Mf(n)?e?n.bind(e)(...t):n(...t):n}function dw(n={}){return Object.keys(n).length===0&&n.constructor===Object}function to(n){const e=n.filter(r=>r.type==="extension"),t=n.filter(r=>r.type==="node"),o=n.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:o}}function Af(n){const e=[],{nodeExtensions:t,markExtensions:o}=to(n),r=[...t,...o],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=t.filter(d=>d.name!=="text").map(d=>d.name),l=o.map(d=>d.name),c=[...i,...l];return n.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage,extensions:r},f=q(d,"addGlobalAttributes",u);if(!f)return;f().forEach(h=>{let m;Array.isArray(h.types)?m=h.types:h.types==="*"?m=c:h.types==="nodes"?m=i:h.types==="marks"?m=l:m=[],m.forEach(g=>{Object.entries(h.attributes).forEach(([y,w])=>{e.push({type:g,name:y,attribute:{...s,...w}})})})})}),r.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage},f=q(d,"addAttributes",u);if(!f)return;const p=f();Object.entries(p).forEach(([h,m])=>{const g={...s,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:d.name,name:h,attribute:g})})}),e}function tn(...n){return n.filter(e=>!!e).reduce((e,t)=>{const o={...e};return Object.entries(t).forEach(([r,s])=>{if(!o[r]){o[r]=s;return}if(r==="class"){const l=s?String(s).split(" "):[],c=o[r]?o[r].split(" "):[],d=l.filter(u=>!c.includes(u));o[r]=[...c,...d].join(" ")}else if(r==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=o[r]?o[r].split(";").map(u=>u.trim()).filter(Boolean):[],d=new Map;c.forEach(u=>{const[f,p]=u.split(":").map(h=>h.trim());d.set(f,p)}),l.forEach(u=>{const[f,p]=u.split(":").map(h=>h.trim());d.set(f,p)}),o[r]=Array.from(d.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else o[r]=s}),o},{})}function Gr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,o)=>tn(t,o),{})}function uw(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Nf(n,e){return"style"in n?n:{...n,getAttrs:t=>{const o=n.getAttrs?n.getAttrs(t):n.attrs;if(o===!1)return!1;const r=e.reduce((s,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):uw(t.getAttribute(i.name));return l==null?s:{...s,[i.name]:l}},{});return{...o,...r}}}}function If(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&dw(t)?!1:t!=null))}function Bf(n){var e,t;const o={};return!((e=n==null?void 0:n.attribute)!=null&&e.isRequired)&&"default"in((n==null?void 0:n.attribute)||{})&&(o.default=n.attribute.default),((t=n==null?void 0:n.attribute)==null?void 0:t.validate)!==void 0&&(o.validate=n.attribute.validate),[n.name,o]}function Of(n,e){var t;const o=Af(n),{nodeExtensions:r,markExtensions:s}=to(n),i=(t=r.find(d=>q(d,"topNode")))==null?void 0:t.name,l=Object.fromEntries(r.map(d=>{const u=o.filter(w=>w.type===d.name),f={name:d.name,options:d.options,storage:d.storage,editor:e},p=n.reduce((w,b)=>{const x=q(b,"extendNodeSchema",f);return{...w,...x?x(d):{}}},{}),h=If({...p,content:ce(q(d,"content",f)),marks:ce(q(d,"marks",f)),group:ce(q(d,"group",f)),inline:ce(q(d,"inline",f)),atom:ce(q(d,"atom",f)),selectable:ce(q(d,"selectable",f)),draggable:ce(q(d,"draggable",f)),code:ce(q(d,"code",f)),whitespace:ce(q(d,"whitespace",f)),linebreakReplacement:ce(q(d,"linebreakReplacement",f)),defining:ce(q(d,"defining",f)),isolating:ce(q(d,"isolating",f)),attrs:Object.fromEntries(u.map(Bf))}),m=ce(q(d,"parseHTML",f));m&&(h.parseDOM=m.map(w=>Nf(w,u)));const g=q(d,"renderHTML",f);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:Gr(w,u)}));const y=q(d,"renderText",f);return y&&(h.toText=y),[d.name,h]})),c=Object.fromEntries(s.map(d=>{const u=o.filter(y=>y.type===d.name),f={name:d.name,options:d.options,storage:d.storage,editor:e},p=n.reduce((y,w)=>{const b=q(w,"extendMarkSchema",f);return{...y,...b?b(d):{}}},{}),h=If({...p,inclusive:ce(q(d,"inclusive",f)),excludes:ce(q(d,"excludes",f)),group:ce(q(d,"group",f)),spanning:ce(q(d,"spanning",f)),code:ce(q(d,"code",f)),attrs:Object.fromEntries(u.map(Bf))}),m=ce(q(d,"parseHTML",f));m&&(h.parseDOM=m.map(y=>Nf(y,u)));const g=q(d,"renderHTML",f);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Gr(y,u)})),[d.name,h]}));return new id({topNode:i,nodes:l,marks:c})}function fw(n){const e=n.filter((t,o)=>n.indexOf(t)!==o);return Array.from(new Set(e))}function Wo(n){return n.sort((t,o)=>{const r=q(t,"priority")||100,s=q(o,"priority")||100;return r>s?-1:r<s?1:0})}function Tl(n){const e=Wo(vl(n)),t=fw(e.map(o=>o.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),e}function _f(n,e){const t=Tl(n);return Of(t,e)}function no(n,e){const t=_f(e),o=Mt.fromJSON(t,n);return Jr(o.content,t)}function st(n,e){const t=_f(e),o=Fo(n);return At.fromSchema(t).parse(o).toJSON()}function Rf(n,e,t){const{from:o,to:r}=e,{blockSeparator:s=`
|
|
11
|
+
|
|
12
|
+
`,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(o,r,(c,d,u,f)=>{var p;c.isBlock&&d>o&&(l+=s);const h=i==null?void 0:i[c.type.name];if(h)return u&&(l+=h({node:c,pos:d,parent:u,index:f,range:e})),!1;c.isText&&(l+=(p=c==null?void 0:c.text)==null?void 0:p.slice(Math.max(o,d)-d,r-d))}),l}function hw(n,e){const t={from:0,to:n.content.size};return Rf(n,t,e)}function Pf(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function pw(n,e){const t=ve(e,n.schema),{from:o,to:r}=n.selection,s=[];n.doc.nodesBetween(o,r,l=>{s.push(l)});const i=s.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function Df(n,e){const t=qr(typeof e=="string"?e:e.name,n.schema);return t==="node"?pw(n,e):t==="mark"?vf(n,e):{}}function mw(n,e=JSON.stringify){const t={};return n.filter(o=>{const r=e(o);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function gw(n){const e=mw(n);return e.length===1?e:e.filter((t,o)=>!e.filter((s,i)=>i!==o).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Lf(n){const{mapping:e,steps:t}=n,o=[];return e.maps.forEach((r,s)=>{const i=[];if(r.ranges.length)r.forEach((l,c)=>{i.push({from:l,to:c})});else{const{from:l,to:c}=t[s];if(l===void 0||c===void 0)return;i.push({from:l,to:c})}i.forEach(({from:l,to:c})=>{const d=e.slice(s).map(l,-1),u=e.slice(s).map(c),f=e.invert().map(d,-1),p=e.invert().map(u);o.push({oldRange:{from:f,to:p},newRange:{from:d,to:u}})})}),gw(o)}function Ml(n,e,t){const o=[];return n===e?t.resolve(n).marks().forEach(r=>{const s=t.resolve(n),i=xl(s,r.type);i&&o.push({mark:r,...i})}):t.nodesBetween(n,e,(r,s)=>{!r||(r==null?void 0:r.nodeSize)===void 0||o.push(...r.marks.map(i=>({from:s,to:s+r.nodeSize,mark:i})))}),o}function Uo(n,e){return e.nodes[n]||e.marks[n]||null}function Yr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([o])=>{const r=n.find(s=>s.type===e&&s.name===o);return r?r.attribute.keepOnSplit:!1}))}var yw=(n,e=500)=>{let t="";const o=n.parentOffset;return n.parent.nodesBetween(Math.max(0,o-e),o,(r,s,i,l)=>{var c,d;const u=((d=(c=r.type.spec).toText)==null?void 0:d.call(c,{node:r,pos:s,parent:i,index:l}))||r.textContent||"%leaf%";t+=r.isAtom&&!r.isText?u:u.slice(0,Math.max(0,o-s))}),t};function Al(n,e,t={}){const{empty:o,ranges:r}=n.selection,s=e?Rt(e,n.schema):null;if(o)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>Ur(f.attrs,t,{strict:!1}));let i=0;const l=[];if(r.forEach(({$from:f,$to:p})=>{const h=f.pos,m=p.pos;n.doc.nodesBetween(h,m,(g,y)=>{if(s&&g.inlineContent&&!g.type.allowsMarkType(s))return!1;if(!g.isText&&!g.marks.length)return;const w=Math.max(h,y),b=Math.min(m,y+g.nodeSize),x=b-w;i+=x,l.push(...g.marks.map(S=>({mark:S,from:w,to:b})))})}),i===0)return!1;const c=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>Ur(f.mark.attrs,t,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),d=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+d:c)>=i}function kw(n,e,t={}){if(!e)return jo(n,null,t)||Al(n,null,t);const o=qr(e,n.schema);return o==="node"?jo(n,e,t):o==="mark"?Al(n,e,t):!1}function Vf(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function $f(n,e){const{nodeExtensions:t}=to(e),o=t.find(i=>i.name===n);if(!o)return!1;const r={name:o.name,options:o.options,storage:o.storage},s=ce(q(o,"group",r));return typeof s!="string"?!1:s.split(" ").includes("list")}function Xr(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var o;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((o=n.text)!=null?o:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let r=!0;return n.content.forEach(s=>{r!==!1&&(Xr(s,{ignoreWhitespace:t,checkChildren:e})||(r=!1))}),r}return!1}function ww(n){return n instanceof G}var zf=class rg{constructor(e){this.position=e}static fromJSON(e){return new rg(e.position)}toJSON(){return{position:this.position}}};function bw(n,e){const t=e.mapping.mapResult(n.position);return{position:new zf(t.pos),mapResult:t}}function Sw(n){return new zf(n)}function xw(n,e,t){var o;const{selection:r}=e;let s=null;if(wf(r)&&(s=r.$cursor),s){const l=(o=n.storedMarks)!=null?o:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(d=>d.type.excludes(t)))}const{ranges:i}=r;return i.some(({$from:l,$to:c})=>{let d=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,c.pos,(u,f,p)=>{if(d)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));d=h&&m}return!d}),d})}var Cw=(n,e={})=>({tr:t,state:o,dispatch:r})=>{const{selection:s}=t,{empty:i,ranges:l}=s,c=Rt(n,o.schema);if(r)if(i){const d=vf(o,c);t.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;o.doc.nodesBetween(u,f,(p,h)=>{const m=Math.max(h,u),g=Math.min(h+p.nodeSize,f);p.marks.find(w=>w.type===c)?p.marks.forEach(w=>{c===w.type&&t.addMark(m,g,c.create({...w.attrs,...e}))}):t.addMark(m,g,c.create(e))})});return xw(o,t,c)},Ew=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),vw=(n,e={})=>({state:t,dispatch:o,chain:r})=>{const s=ve(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),s.isTextblock?r().command(({commands:l})=>Zd(s,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Zd(s,{...i,...e})(l,o)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Tw=n=>({tr:e,dispatch:t})=>{if(t){const{doc:o}=e,r=An(n,0,o.content.size),s=G.create(o,r);e.setSelection(s)}return!0},Mw=(n,e)=>({tr:t,state:o,dispatch:r})=>{const{selection:s}=o;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=s.from,l=s.to),r&&t.doc.nodesBetween(i,l,(c,d)=>{c.isText||t.setNodeMarkup(d,void 0,{...c.attrs,dir:n})}),!0},Aw=n=>({tr:e,dispatch:t})=>{if(t){const{doc:o}=e,{from:r,to:s}=typeof n=="number"?{from:n,to:n}:n,i=Q.atStart(o).from,l=Q.atEnd(o).to,c=An(r,i,l),d=An(s,i,l),u=Q.create(o,c,d);e.setSelection(u)}return!0},Nw=n=>({state:e,dispatch:t})=>{const o=ve(n,e.schema);return v0(o)(e,t)};function Ff(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const o=t.filter(r=>e==null?void 0:e.includes(r.type.name));n.tr.ensureMarks(o)}}var Iw=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:o,editor:r})=>{const{selection:s,doc:i}=e,{$from:l,$to:c}=s,d=r.extensionManager.attributes,u=Yr(d,l.node().type.name,l.node().attrs);if(s instanceof G&&s.node.isBlock)return!l.parentOffset||!Nt(i,l.pos)?!1:(o&&(n&&Ff(t,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:lw(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=f&&p?[{type:p,attrs:u}]:void 0,m=Nt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&Nt(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(m=!0,h=p?[{type:p,attrs:u}]:void 0),o){if(m&&(s instanceof Q&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),p&&!f&&!l.parentOffset&&l.parent.type!==p)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}n&&Ff(t,r.extensionManager.splittableMarks),e.scrollIntoView()}return m},Bw=(n,e={})=>({tr:t,state:o,dispatch:r,editor:s})=>{var i;const l=ve(n,o.schema),{$from:c,$to:d}=o.selection,u=o.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(d))return!1;const f=c.node(-1);if(f.type!==l)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let w=_.empty;const b=c.index(-1)?1:c.index(-2)?2:3;for(let T=c.depth-b;T>=c.depth-3;T-=1)w=_.from(c.node(T).copy(w));const x=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,S={...Yr(p,c.node().type.name,c.node().attrs),...e},E=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(S))||void 0;w=w.append(_.from(l.createAndFill(null,E)||void 0));const M=c.before(c.depth-(b-1));t.replace(M,c.after(-x),new H(w,4-b,0));let C=-1;t.doc.nodesBetween(M,t.doc.content.size,(T,v)=>{if(C>-1)return!1;T.isTextblock&&T.content.size===0&&(C=v+1)}),C>-1&&t.setSelection(Q.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const h=d.pos===c.end()?f.contentMatchAt(0).defaultType:null,m={...Yr(p,f.type.name,f.attrs),...e},g={...Yr(p,c.node().type.name,c.node().attrs),...e};t.delete(c.pos,d.pos);const y=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!Nt(t.doc,c.pos,2))return!1;if(r){const{selection:w,storedMarks:b}=o,{splittableMarks:x}=s.extensionManager,S=b||w.$to.parentOffset&&w.$from.marks();if(t.split(c.pos,2,y).scrollIntoView(),!S||!r)return!0;const E=S.filter(M=>x.includes(M.type.name));t.ensureMarks(E)}return!0},Nl=(n,e)=>{const t=El(i=>i.type===e)(n.selection);if(!t)return!0;const o=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(o===void 0)return!0;const r=n.doc.nodeAt(o);return t.node.type===(r==null?void 0:r.type)&&bn(n.doc,t.pos)&&n.join(t.pos),!0},Il=(n,e)=>{const t=El(i=>i.type===e)(n.selection);if(!t)return!0;const o=n.doc.resolve(t.start).after(t.depth);if(o===void 0)return!0;const r=n.doc.nodeAt(o);return t.node.type===(r==null?void 0:r.type)&&bn(n.doc,o)&&n.join(o),!0},Ow=(n,e,t,o={})=>({editor:r,tr:s,state:i,dispatch:l,chain:c,commands:d,can:u})=>{const{extensions:f,splittableMarks:p}=r.extensionManager,h=ve(n,i.schema),m=ve(e,i.schema),{selection:g,storedMarks:y}=i,{$from:w,$to:b}=g,x=w.blockRange(b),S=y||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;const E=El(M=>$f(M.type.name,f))(g);if(x.depth>=1&&E&&x.depth-E.depth<=1){if(E.node.type===h)return d.liftListItem(m);if($f(E.node.type.name,f)&&h.validContent(E.node.content)&&l)return c().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>Nl(s,h)).command(()=>Il(s,h)).run()}return!t||!S||!l?c().command(()=>u().wrapInList(h,o)?!0:d.clearNodes()).wrapInList(h,o).command(()=>Nl(s,h)).command(()=>Il(s,h)).run():c().command(()=>{const M=u().wrapInList(h,o),C=S.filter(T=>p.includes(T.type.name));return s.ensureMarks(C),M?!0:d.clearNodes()}).wrapInList(h,o).command(()=>Nl(s,h)).command(()=>Il(s,h)).run()},_w=(n,e={},t={})=>({state:o,commands:r})=>{const{extendEmptyMarkRange:s=!1}=t,i=Rt(n,o.schema);return Al(o,i,e)?r.unsetMark(i,{extendEmptyMarkRange:s}):r.setMark(i,e)},Rw=(n,e,t={})=>({state:o,commands:r})=>{const s=ve(n,o.schema),i=ve(e,o.schema),l=jo(o,s,t);let c;return o.selection.$anchor.sameParent(o.selection.$head)&&(c=o.selection.$anchor.parent.attrs),l?r.setNode(i,c):r.setNode(s,{...c,...t})},Pw=(n,e={})=>({state:t,commands:o})=>{const r=ve(n,t.schema);return jo(t,r,e)?o.lift(r):o.wrapIn(r,e)},Dw=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let o=0;o<t.length;o+=1){const r=t[o];let s;if(r.spec.isInputRules&&(s=r.getState(n))){if(e){const i=n.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)i.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,c))}else i.delete(s.from,s.to)}return!0}}return!1},Lw=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:o,ranges:r}=t;return o||e&&r.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},Vw=(n,e={})=>({tr:t,state:o,dispatch:r})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,c=Rt(n,o.schema),{$from:d,empty:u,ranges:f}=l;if(!r)return!0;if(u&&i){let{from:p,to:h}=l;const m=(s=d.marks().find(y=>y.type===c))==null?void 0:s.attrs,g=xl(d,c,m);g&&(p=g.from,h=g.to),t.removeMark(p,h,c)}else f.forEach(p=>{t.removeMark(p.$from.pos,p.$to.pos,c)});return t.removeStoredMark(c),!0},$w=n=>({tr:e,state:t,dispatch:o})=>{const{selection:r}=t;let s,i;return typeof n=="number"?(s=n,i=n):n&&"from"in n&&"to"in n?(s=n.from,i=n.to):(s=r.from,i=r.to),o&&e.doc.nodesBetween(s,i,(l,c)=>{if(l.isText)return;const d={...l.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},zw=(n,e={})=>({tr:t,state:o,dispatch:r})=>{let s=null,i=null;const l=qr(typeof n=="string"?n:n.name,o.schema);if(!l)return!1;l==="node"&&(s=ve(n,o.schema)),l==="mark"&&(i=Rt(n,o.schema));let c=!1;return t.selection.ranges.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;let p,h,m,g;t.selection.empty?o.doc.nodesBetween(u,f,(y,w)=>{s&&s===y.type&&(c=!0,m=Math.max(w,u),g=Math.min(w+y.nodeSize,f),p=w,h=y)}):o.doc.nodesBetween(u,f,(y,w)=>{w<u&&s&&s===y.type&&(c=!0,m=Math.max(w,u),g=Math.min(w+y.nodeSize,f),p=w,h=y),w>=u&&w<=f&&(s&&s===y.type&&(c=!0,r&&t.setNodeMarkup(w,void 0,{...y.attrs,...e})),i&&y.marks.length&&y.marks.forEach(b=>{if(i===b.type&&(c=!0,r)){const x=Math.max(w,u),S=Math.min(w+y.nodeSize,f);t.addMark(x,S,i.create({...b.attrs,...e}))}}))}),h&&(p!==void 0&&r&&t.setNodeMarkup(p,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(y=>{i===y.type&&r&&t.addMark(m,g,i.create({...y.attrs,...e}))}))}),c},Fw=(n,e={})=>({state:t,dispatch:o})=>{const r=ve(n,t.schema);return k0(r,e)(t,o)},Hw=(n,e={})=>({state:t,dispatch:o})=>{const r=ve(n,t.schema);return w0(r,e)(t,o)},jw=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(o=>o.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(o=>o!==e):delete this.callbacks[n]),this}once(n,e){const t=(...o)=>{this.off(n,t),e.apply(this,o)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ww=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Uw=(n,e)=>{if(Sl(e))return e.exec(n);const t=e(n);if(!t)return null;const o=[t.text];return o.index=t.index,o.input=n,o.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(t.replaceWith)),o};function Qr(n){var e;const{editor:t,from:o,to:r,text:s,rules:i,plugin:l}=n,{view:c}=t;if(c.composing)return!1;const d=c.state.doc.resolve(o);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let u=!1;const f=yw(d)+s;return i.forEach(p=>{if(u)return;const h=Uw(f,p.find);if(!h)return;const m=c.state.tr,g=jr({state:c.state,transaction:m}),y={from:o-(h[0].length-s.length),to:r},{commands:w,chain:b,can:x}=new Wr({editor:t,state:g});p.handler({state:g,range:y,match:h,commands:w,chain:b,can:x})===null||!m.steps.length||(p.undoable&&m.setMeta(l,{transform:m,from:o,to:r,text:s}),c.dispatch(m),u=!0)}),u}function Kw(n){const{editor:e,rules:t}=n,o=new ge({state:{init(){return null},apply(r,s,i){const l=r.getMeta(o);if(l)return l;const c=r.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=Jr(_.from(u),i.schema);const{from:f}=c,p=f+u.length;Qr({editor:e,from:f,to:p,text:u,rules:t,plugin:o})}),r.selectionSet||r.docChanged?null:s}},props:{handleTextInput(r,s,i,l){return Qr({editor:e,from:s,to:i,text:l,rules:t,plugin:o})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{const{$cursor:s}=r.state.selection;s&&Qr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:o})}),!1)},handleKeyDown(r,s){if(s.key!=="Enter")return!1;const{$cursor:i}=r.state.selection;return i?Qr({editor:e,from:i.pos,to:i.pos,text:`
|
|
13
|
+
`,rules:t,plugin:o}):!1}},isInputRules:!0});return o}function qw(n){return Object.prototype.toString.call(n).slice(8,-1)}function Zr(n){return qw(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Hf(n,e){const t={...n};return Zr(n)&&Zr(e)&&Object.keys(e).forEach(o=>{Zr(e[o])&&Zr(n[o])?t[o]=Hf(n[o],e[o]):t[o]=e[o]}),t}var Bl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...ce(q(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ce(q(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>Hf(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},oo=class sg extends Bl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new sg(t)}static handleExit({editor:e,mark:t}){const{tr:o}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks();if(!!!i.find(d=>(d==null?void 0:d.type.name)===t.name))return!1;const c=i.find(d=>(d==null?void 0:d.type.name)===t.name);return c&&o.removeStoredMark(c),o.insertText(" ",r.pos),e.view.dispatch(o),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Jw(n){return typeof n=="number"}var Gw=class{constructor(n){this.find=n.find,this.handler=n.handler}},Yw=(n,e,t)=>{if(Sl(e))return[...n.matchAll(e)];const o=e(n,t);return o?o.map(r=>{const s=[r.text];return s.index=r.index,s.input=n,s.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(r.replaceWith)),s}):[]};function Xw(n){const{editor:e,state:t,from:o,to:r,rule:s,pasteEvent:i,dropEvent:l}=n,{commands:c,chain:d,can:u}=new Wr({editor:e,state:t}),f=[];return t.doc.nodesBetween(o,r,(h,m)=>{var g,y,w,b,x;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const S=(x=(b=(w=h.content)==null?void 0:w.size)!=null?b:h.nodeSize)!=null?x:0,E=Math.max(o,m),M=Math.min(r,m+S);if(E>=M)return;const C=h.isText?h.text||"":h.textBetween(E-m,M-m,void 0,"");Yw(C,s.find,i).forEach(v=>{if(v.index===void 0)return;const I=E+v.index+1,B=I+v[0].length,P={from:t.tr.mapping.map(I),to:t.tr.mapping.map(B)},V=s.handler({state:t,range:P,match:v,commands:c,chain:d,can:u,pasteEvent:i,dropEvent:l});f.push(V)})}),f.every(h=>h!==null)}var es=null,Qw=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function Zw(n){const{editor:e,rules:t}=n;let o=null,r=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:u,from:f,to:p,rule:h,pasteEvt:m})=>{const g=u.tr,y=jr({state:u,transaction:g});if(!(!Xw({editor:e,state:y,from:Math.max(f-1,0),to:p.b-1,rule:h,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new ge({view(f){const p=m=>{var g;o=(g=f.dom.parentElement)!=null&&g.contains(m.target)?f.dom.parentElement:null,o&&(es=e)},h=()=>{es&&(es=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(s=o===f.dom.parentElement,l=p,!s){const h=es;h!=null&&h.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(f,p)=>{var h;const m=(h=p.clipboardData)==null?void 0:h.getData("text/html");return i=p,r=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(f,p,h)=>{const m=f[0],g=m.getMeta("uiEvent")==="paste"&&!r,y=m.getMeta("uiEvent")==="drop"&&!s,w=m.getMeta("applyPasteRules"),b=!!w;if(!g&&!y&&!b)return;if(b){let{text:E}=w;typeof E=="string"?E=E:E=Jr(_.from(E),h.schema);const{from:M}=w,C=M+E.length,T=Qw(E);return c({rule:u,state:h,from:M,to:{b:C},pasteEvt:T})}const x=p.doc.content.findDiffStart(h.doc.content),S=p.doc.content.findDiffEnd(h.doc.content);if(!(!Jw(x)||!S||x===S.b))return c({rule:u,state:h,from:x,to:S,pasteEvt:i})}}))}var ts=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Tl(n),this.schema=Of(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Uo(e.name,this.schema)},o=q(e,"addCommands",t);return o?{...n,...o()}:n},{})}get plugins(){const{editor:n}=this;return Wo([...this.extensions].reverse()).flatMap(o=>{const r={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:n,type:Uo(o.name,this.schema)},s=[],i=q(o,"addKeyboardShortcuts",r);let l={};if(o.type==="mark"&&q(o,"exitable",r)&&(l.ArrowRight=()=>oo.handleExit({editor:n,mark:o})),i){const p=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:n})]));l={...l,...p}}const c=mk(l);s.push(c);const d=q(o,"addInputRules",r);if(Vf(o,n.options.enableInputRules)&&d){const p=d();if(p&&p.length){const h=Kw({editor:n,rules:p}),m=Array.isArray(h)?h:[h];s.push(...m)}}const u=q(o,"addPasteRules",r);if(Vf(o,n.options.enablePasteRules)&&u){const p=u();if(p&&p.length){const h=Zw({editor:n,rules:p});s.push(...h)}}const f=q(o,"addProseMirrorPlugins",r);if(f){const p=f();s.push(...p)}return s})}get attributes(){return Af(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=to(this.extensions);return Object.fromEntries(e.filter(t=>!!q(t,"addNodeView")).map(t=>{const o=this.attributes.filter(c=>c.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ve(t.name,this.schema)},s=q(t,"addNodeView",r);if(!s)return[];const i=s();if(!i)return[];const l=(c,d,u,f,p)=>{const h=Gr(c,o);return i({node:c,view:d,getPos:u,decorations:f,innerDecorations:p,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){const{editor:e}=this;return Wo([...this.extensions].reverse()).reduceRight((o,r)=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Uo(r.name,this.schema)},i=q(r,"dispatchTransaction",s);return i?l=>{i.call(s,{transaction:l,next:o})}:o},n)}transformPastedHTML(n){const{editor:e}=this;return Wo([...this.extensions]).reduce((o,r)=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Uo(r.name,this.schema)},i=q(r,"transformPastedHTML",s);return i?(l,c)=>{const d=o(l,c);return i.call(s,d)}:o},n||(o=>o))}get markViews(){const{editor:n}=this,{markExtensions:e}=to(this.extensions);return Object.fromEntries(e.filter(t=>!!q(t,"addMarkView")).map(t=>{const o=this.attributes.filter(l=>l.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Rt(t.name,this.schema)},s=q(t,"addMarkView",r);if(!s)return[];const i=(l,c,d)=>{const u=Gr(l,o);return s()({mark:l,view:c,inline:d,editor:n,extension:t,HTMLAttributes:u,updateAttributes:f=>{hb(l,n,f)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Uo(e.name,this.schema)};e.type==="mark"&&((t=ce(q(e,"keepOnSplit",o)))==null||t)&&this.splittableMarks.push(e.name);const r=q(e,"onBeforeCreate",o),s=q(e,"onCreate",o),i=q(e,"onUpdate",o),l=q(e,"onSelectionUpdate",o),c=q(e,"onTransaction",o),d=q(e,"onFocus",o),u=q(e,"onBlur",o),f=q(e,"onDestroy",o);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};ts.resolve=Tl,ts.sort=Wo,ts.flatten=vl;var eb={};bl(eb,{ClipboardTextSerializer:()=>jf,Commands:()=>Wf,Delete:()=>Uf,Drop:()=>Kf,Editable:()=>qf,FocusEvents:()=>Gf,Keymap:()=>Yf,Paste:()=>Xf,Tabindex:()=>Qf,TextDirection:()=>Zf,focusEventsPluginKey:()=>Jf});var de=class ig extends Bl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new ig(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},jf=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ge({key:new Ee("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:o,selection:r}=e,{ranges:s}=r,i=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),c=Pf(t);return Rf(o,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Wf=de.create({name:"commands",addCommands(){return{...gf}}}),Uf=de.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,o,r;const s=()=>{var i,l,c,d;if((d=(c=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,n))!=null?d:n.getMeta("y-sync$"))return;const u=Tf(n.before,[n,...e]);Lf(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(m,g)=>{const y=g+m.nodeSize-2,w=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!w,editor:this.editor,transaction:n,combinedTransform:u})})});const p=u.mapping;u.steps.forEach((h,m)=>{var g,y;if(h instanceof rt){const w=p.slice(m).map(h.from,-1),b=p.slice(m).map(h.to),x=p.invert().map(w,-1),S=p.invert().map(b),E=(g=u.doc.nodeAt(w-1))==null?void 0:g.marks.some(C=>C.eq(h.mark)),M=(y=u.doc.nodeAt(b))==null?void 0:y.marks.some(C=>C.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:x,to:S},newRange:{from:w,to:b},partial:!!(M||E),editor:this.editor,transaction:n,combinedTransform:u})}})};(r=(o=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:o.async)==null||r?setTimeout(s,0):s()}}),Kf=de.create({name:"drop",addProseMirrorPlugins(){return[new ge({key:new Ee("tiptapDrop"),props:{handleDrop:(n,e,t,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:o})}}})]}}),qf=de.create({name:"editable",addProseMirrorPlugins(){return[new ge({key:new Ee("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Jf=new Ee("focusEvents"),Gf=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ge({key:Jf,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const o=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,t)=>{n.isFocused=!1;const o=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),Yf=de.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:u,$anchor:f}=c,{pos:p,parent:h}=f,m=f.parent.isTextblock&&p>0?l.doc.resolve(p-1):f,g=m.parent.type.spec.isolating,y=f.pos-f.parentOffset,w=g&&m.parent.childCount===1?y===f.pos:ee.atStart(d).from===p;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&f.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),o={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...o},s={...o,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Kr()||Cf()?s:r},addProseMirrorPlugins(){return[new ge({key:new Ee("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const o=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),r=n.some(g=>g.getMeta("preventClearDocument"));if(!o||r)return;const{empty:s,from:i,to:l}=e.selection,c=ee.atStart(e.doc).from,d=ee.atEnd(e.doc).to;if(s||!(i===c&&l===d)||!Xr(t.doc))return;const p=t.tr,h=jr({state:t,transaction:p}),{commands:m}=new Wr({editor:this.editor,state:h});if(m.clearNodes(),!!p.steps.length)return p}})]}}),Xf=de.create({name:"paste",addProseMirrorPlugins(){return[new ge({key:new Ee("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Qf=de.create({name:"tabindex",addProseMirrorPlugins(){return[new ge({key:new Ee("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Zf=de.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=to(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const 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 ge({key:new Ee("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),tb=class yr{constructor(e,t,o=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=o,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(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,o=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,o=this.to-1}this.editor.commands.insertContentAt({from:t,to:o},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new yr(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new yr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new yr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,o)=>{const r=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,i=t.isInline,l=this.pos+o+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!r&&!i&&c.depth<=this.depth)return;const d=new yr(c,this.editor,r,r||i?t:null);r&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let o=null,r=this.parent;for(;r&&!o;){if(r.node.type.name===e)if(Object.keys(t).length>0){const s=r.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const c=i[l];if(s[c]!==t[c])break}}else o=r;r=r.parent}return o}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},o=!1){let r=[];if(!this.children||this.children.length===0)return r;const s=Object.keys(t);return this.children.forEach(i=>{o&&r.length>0||(i.node.type.name===e&&s.every(c=>t[c]===i.node.attrs[c])&&r.push(i),!(o&&r.length>0)&&(r=r.concat(i.querySelectorAll(e,t,o))))}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},nb=`.ProseMirror {
|
|
14
14
|
position: relative;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -80,28 +80,30 @@ img.ProseMirror-separator {
|
|
|
80
80
|
|
|
81
81
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
82
82
|
display: block;
|
|
83
|
-
}`;function
|
|
83
|
+
}`;function ob(n,e,t){const o=document.querySelector("style[data-tiptap-style]");if(o!==null)return o;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(r),r}var rb=class extends jw{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!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:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:bw,createMappablePosition:Sw},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:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const t=this.createDoc(),o=bf(t,this.options.autofocus);this.editorState=qn.create({doc:t,schema:this.schema,selection:o||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>"u")throw new 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){const e=this.editorView.dom;e!=null&&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=ob(nb,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 new 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){const o=Mf(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:o});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let o=t;if([].concat(e).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;o=o.filter(l=>!l.key.startsWith(i))}),t.length===o.length)return;const r=this.state.reconfigure({plugins:o});return this.view.updateState(r),r}createExtensionManager(){var e,t;const r=[...this.options.enableCoreExtensions?[qf,jf.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)==null?void 0:e.clipboardTextSerializer)==null?void 0:t.blockSeparator}),Wf,Gf,Yf,Qf,Kf,Xf,Uf,Zf.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new ts(r,this)}createCommandManager(){this.commandManager=new Wr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Cl(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(o=>o.name!=="collaboration"),this.createExtensionManager()}}),e=Cl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){const{editorProps:t,enableExtensionDispatchTransaction:o}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),s=o?this.extensionManager.dispatchTransaction(r):r,i=t.transformPastedHTML,l=this.extensionManager.transformPastedHTML(i);this.editorView=new cf(e,{...t,attributes:{role:"textbox",...t==null?void 0:t.attributes},dispatchTransaction:s,transformPastedHTML:l,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const d=this.view.dom;d.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;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var f;return(f=this.capturedTransaction)==null?void 0:f.step(u)});return}const{state:t,transactions:o}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),s=o.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!s)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:o.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=o.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),d=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),d&&this.emit("blur",{editor:this,event:d.event,transaction:l}),!(e.getMeta("preventUpdate")||!o.some(u=>u.docChanged)||i.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:o.slice(1)})}getAttributes(e){return Df(this.state,e)}isActive(e,t){const o=typeof e=="string"?e:null,r=typeof e=="string"?t:e;return kw(this.state,o,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Jr(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
84
84
|
|
|
85
|
-
`,textSerializers:o={}}=e||{};return
|
|
85
|
+
`,textSerializers:o={}}=e||{};return hw(this.state.doc,{blockSeparator:t,textSerializers:{...Pf(this.schema),...o}})}get isEmpty(){return Xr(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,t;return(t=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?t:!0}$node(e,t){var o;return((o=this.$doc)==null?void 0:o.querySelector(e,t))||null}$nodes(e,t){var o;return((o=this.$doc)==null?void 0:o.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new tb(t,this)}get $doc(){return this.$pos(0)}};function ns(n){return new Ww({find:n.find,handler:({state:e,range:t,match:o})=>{const r=ce(n.getAttributes,void 0,o);if(r===!1||r===null)return null;const{tr:s}=e,i=o[o.length-1],l=o[0];if(i){const c=l.search(/\S/),d=t.from+l.indexOf(i),u=d+i.length;if(Ml(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>d).length)return null;u<t.to&&s.delete(u,t.to),d>t.from&&s.delete(t.from+c,d);const p=t.from+c+i.length;s.addMark(t.from+c,p,n.type.create(r||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}var sb={};bl(sb,{createAtomBlockMarkdownSpec:()=>ib,createBlockMarkdownSpec:()=>lb,createInlineMarkdownSpec:()=>db,parseAttributes:()=>Ol,parseIndentedBlocks:()=>ub,renderNestedMarkdownContent:()=>fb,serializeAttributes:()=>_l});function Ol(n){if(!(n!=null&&n.trim()))return{};const e={},t=[],o=n.replace(/["']([^"']*)["']/g,d=>(t.push(d),`__QUOTED_${t.length-1}__`)),r=o.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){const d=r.map(u=>u.trim().slice(1));e.class=d.join(" ")}const s=o.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(o.matchAll(i)).forEach(([,d,u])=>{var f;const p=parseInt(((f=u.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),h=t[p];h&&(e[d]=h.slice(1,-1))});const c=o.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 c&&c.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function _l(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(o=>e.push(`.${o}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,o])=>{t==="class"||t==="id"||(o===!0?e.push(t):o!==!1&&o!=null&&e.push(`${t}="${String(o)}"`))}),e.join(" ")}function ib(n){const{nodeName:e,name:t,parseAttributes:o=Ol,serializeAttributes:r=_l,defaultAttributes:s={},requiredAttributes:i=[],allowedAttributes:l}=n,c=t||e,d=u=>{if(!l)return u;const f={};return l.forEach(p=>{p in u&&(f[p]=u[p])}),f};return{parseMarkdown:(u,f)=>{const p={...s,...u.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(u){var f;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),h=(f=u.match(p))==null?void 0:f.index;return h!==void 0?h:-1},tokenize(u,f,p){const h=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",y=o(g);if(!i.find(b=>!(b in y)))return{type:e,raw:m[0],attributes:y}}},renderMarkdown:u=>{const f=d(u.attrs||{}),p=r(f),h=p?` {${p}}`:"";return`:::${c}${h} :::`}}}function lb(n){const{nodeName:e,name:t,getContent:o,parseAttributes:r=Ol,serializeAttributes:s=_l,defaultAttributes:i={},content:l="block",allowedAttributes:c}=n,d=t||e,u=f=>{if(!c)return f;const p={};return c.forEach(h=>{h in f&&(p[h]=f[h])}),p};return{parseMarkdown:(f,p)=>{let h;if(o){const g=o(f);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=p.parseChildren(f.tokens||[]):h=p.parseInline(f.tokens||[]);const m={...i,...f.attributes};return p.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(f){var p;const h=new RegExp(`^:::${d}`,"m"),m=(p=f.match(h))==null?void 0:p.index;return m!==void 0?m:-1},tokenize(f,p,h){var m;const g=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(g);if(!y)return;const[w,b=""]=y,x=r(b);let S=1;const E=w.length;let M="";const C=/^:::([\w-]*)(\s.*)?/gm,T=f.slice(E);for(C.lastIndex=0;;){const v=C.exec(T);if(v===null)break;const I=v.index,B=v[1];if(!((m=v[2])!=null&&m.endsWith(":::"))){if(B)S+=1;else if(S-=1,S===0){const P=T.slice(0,I);M=P.trim();const V=f.slice(0,E+I+v[0].length);let F=[];if(M)if(l==="block")for(F=h.blockTokens(P),F.forEach(z=>{z.text&&(!z.tokens||z.tokens.length===0)&&(z.tokens=h.inlineTokens(z.text))});F.length>0;){const z=F[F.length-1];if(z.type==="paragraph"&&(!z.text||z.text.trim()===""))F.pop();else break}else F=h.inlineTokens(M);return{type:e,raw:V,attributes:x,content:M,tokens:F}}}}}},renderMarkdown:(f,p)=>{const h=u(f.attrs||{}),m=s(h),g=m?` {${m}}`:"",y=p.renderChildren(f.content||[],`
|
|
86
86
|
|
|
87
87
|
`);return`:::${d}${g}
|
|
88
88
|
|
|
89
89
|
${y}
|
|
90
90
|
|
|
91
|
-
:::`}}}function
|
|
91
|
+
:::`}}}function ab(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let o=t.exec(n);for(;o!==null;){const[,r,s,i]=o;e[r]=s||i,o=t.exec(n)}return e}function cb(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function db(n){const{nodeName:e,name:t,getContent:o,parseAttributes:r=ab,serializeAttributes:s=cb,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:c}=n,d=t||e,u=p=>{if(!c)return p;const h={};return c.forEach(m=>{const g=typeof m=="string"?m:m.name,y=typeof m=="string"?void 0:m.skipIfDefault;if(g in p){const w=p[g];if(y!==void 0&&w===y)return;h[g]=w}}),h},f=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,h)=>{const m={...i,...p.attributes};if(l)return h.createNode(e,m);const g=o?o(p):p.content||"";return g?h.createNode(e,m,[h.createTextNode(g)]):h.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(p){const h=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),m=p.match(h),g=m==null?void 0:m.index;return g!==void 0?g:-1},tokenize(p,h,m){const g=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=p.match(g);if(!y)return;let w="",b="";if(l){const[,S]=y;b=S}else{const[,S,E]=y;b=S,w=E||""}const x=r(b.trim());return{type:e,raw:y[0],content:w.trim(),attributes:x}}},renderMarkdown:p=>{let h="";o?h=o(p):p.content&&p.content.length>0&&(h=p.content.filter(w=>w.type==="text").map(w=>w.text).join(""));const m=u(p.attrs||{}),g=s(m),y=g?` ${g}`:"";return l?`[${d}${y}]`:`[${d}${y}]${h}[/${d}]`}}}function ub(n,e,t){var o,r,s,i;const l=n.split(`
|
|
92
92
|
`),c=[];let d="",u=0;const f=e.baseIndentSize||2;for(;u<l.length;){const p=l[u],h=p.match(e.itemPattern);if(!h){if(c.length>0)break;if(p.trim()===""){u+=1,d=`${d}${p}
|
|
93
93
|
`;continue}else return}const m=e.extractItemData(h),{indentLevel:g,mainContent:y}=m;d=`${d}${p}
|
|
94
|
-
`;const
|
|
95
|
-
`,u+=1;continue}else break}if((((i=(s=E.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:i.length)||0)>g)
|
|
96
|
-
`,u+=1;else break}let b;const
|
|
97
|
-
`);E.trim()&&(e.customNestedParser?b=e.customNestedParser(E):b=t.blockTokens(E))}const
|
|
94
|
+
`;const w=[y];for(u+=1;u<l.length;){const E=l[u];if(E.trim()===""){const C=l.slice(u+1).findIndex(I=>I.trim()!=="");if(C===-1)break;if((((r=(o=l[u+1+C].match(/^(\s*)/))==null?void 0:o[1])==null?void 0:r.length)||0)>g){w.push(E),d=`${d}${E}
|
|
95
|
+
`,u+=1;continue}else break}if((((i=(s=E.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:i.length)||0)>g)w.push(E),d=`${d}${E}
|
|
96
|
+
`,u+=1;else break}let b;const x=w.slice(1);if(x.length>0){const E=x.map(M=>M.slice(g+f)).join(`
|
|
97
|
+
`);E.trim()&&(e.customNestedParser?b=e.customNestedParser(E):b=t.blockTokens(E))}const S=e.createToken(m,b);c.push(S)}if(c.length!==0)return{items:c,raw:d}}function fb(n,e,t,o){if(!n||!Array.isArray(n.content))return"";const r=typeof t=="function"?t(o):t,[s,...i]=n.content,l=e.renderChildren([s]),c=[`${r}${l}`];return i&&i.length>0&&i.forEach(d=>{const u=e.renderChildren([d]);if(u){const f=u.split(`
|
|
98
98
|
`).map(p=>p?e.indent(p):"").join(`
|
|
99
99
|
`);c.push(f)}}),c.join(`
|
|
100
|
-
`)}function
|
|
100
|
+
`)}function hb(n,e,t={}){const{state:o}=e,{doc:r,tr:s}=o,i=n;r.descendants((l,c)=>{const d=s.mapping.map(c),u=s.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(h=>{if(h!==i)return!1;f=h}),!f)return;let p=!1;if(Object.keys(t).forEach(h=>{t[h]!==f.attrs[h]&&(p=!0)}),p){const h=n.type.create({...n.attrs,...t});s.removeMark(d,u,n.type),s.addMark(d,u,h)}}),s.docChanged&&e.view.dispatch(s)}var Rl=class lg extends Bl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new lg(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Ko(n){return new Gw({find:n.find,handler:({state:e,range:t,match:o,pasteEvent:r})=>{const s=ce(n.getAttributes,void 0,o,r);if(s===!1||s===null)return null;const{tr:i}=e,l=o[o.length-1],c=o[0];let d=t.to;if(l){const u=c.search(/\S/),f=t.from+c.indexOf(l),p=f+l.length;if(Ml(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>f).length)return null;p<t.to&&i.delete(p,t.to),f>t.from&&i.delete(t.from+u,f),d=t.from+u+l.length,i.addMark(t.from+u,d,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function eh(n){return a.customRef((e,t)=>({get(){return e(),n},set(o){n=o,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}var pb=class extends rb{constructor(n={}){return super(n),this.contentComponent=null,this.appContext=null,this.reactiveState=eh(this.view.state),this.reactiveExtensionStorage=eh(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),a.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(n,e){const t=super.registerPlugin(n,e);return this.reactiveState&&(this.reactiveState.value=t),t}unregisterPlugin(n){const e=super.unregisterPlugin(n);return this.reactiveState&&e&&(this.reactiveState.value=e),e}},mb=a.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=a.ref(),t=a.getCurrentInstance();return a.watchEffect(()=>{const o=n.editor;o&&o.options.element&&e.value&&a.nextTick(()=>{var r;if(!e.value||!((r=o.view.dom)!=null&&r.parentNode))return;const s=a.unref(e.value);e.value.append(...o.view.dom.parentNode.childNodes),o.contentComponent=t.ctx._,t&&(o.appContext={...t.appContext,provides:t.provides}),o.setOptions({element:s}),o.createNodeViews()})}),a.onBeforeUnmount(()=>{const o=n.editor;o&&(o.contentComponent=null,o.appContext=null)}),{rootEl:e}},render(){return a.h("div",{ref:n=>{this.rootEl=n}})}});a.defineComponent({name:"NodeViewContent",props:{as:{type:String,default:"div"}},render(){return a.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}}),a.defineComponent({name:"NodeViewWrapper",props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var n,e;return a.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(n=this.$slots).default)==null?void 0:e.call(n))}}),a.defineComponent({name:"MarkViewContent",props:{as:{type:String,default:"span"}},render(){return a.h(this.as,{style:{whiteSpace:"inherit"},"data-mark-view-content":""})}});var gb=Rl.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
101
101
|
|
|
102
|
-
`):""}),Ju=Sk,Gu=" ",Ek=" ",vk=Xi.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Xt(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const o=e.parseInline(t);return o.length===1&&o[0].type==="text"&&(o[0].text===Gu||o[0].text===Ek)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,o)},renderMarkdown:(n,e)=>{if(!n)return"";const t=Array.isArray(n.content)?n.content:[];return t.length===0?Gu:e.renderChildren(t)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Yu=vk,Mk=Xi.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Xu=Mk,Qu=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...o}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,o,t]},Tk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Nk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ak=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Bk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ik=Jn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Qu("strong",{...Xt(this.options.HTMLAttributes,n),children:Qu("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ir({find:Tk,type:this.type}),Ir({find:Ak,type:this.type})]},addPasteRules(){return[Bo({find:Nk,type:this.type}),Bo({find:Bk,type:this.type})]}}),Zu=Ik,Ok=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Rk=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Pk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,_k=Jn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Xt(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ir({find:Ok,type:this.type}),Ir({find:Pk,type:this.type})]},addPasteRules(){return[Bo({find:Rk,type:this.type}),Bo({find:Dk,type:this.type})]}}),ef=_k,Lk=Jn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Xt(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!r)return;const s=r[2].trim();return{type:"underline",raw:r[0],text:s,tokens:t.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),tf=Lk;const Vk="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",$k="ελ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",Qi="numeric",Zi="ascii",el="alpha",Io="asciinumeric",Oo="alphanumeric",tl="domain",nf="emoji",zk="scheme",Fk="slashscheme",nl="whitespace";function Hk(n,e){return n in e||(e[n]=[]),e[n]}function Sn(n,e,t){e[Qi]&&(e[Io]=!0,e[Oo]=!0),e[Zi]&&(e[Io]=!0,e[el]=!0),e[Io]&&(e[Oo]=!0),e[el]&&(e[Oo]=!0),e[Oo]&&(e[tl]=!0),e[nf]&&(e[tl]=!0);for(const o in e){const r=Hk(o,t);r.indexOf(n)<0&&r.push(n)}}function Uk(n,e){const t={};for(const o in e)e[o].indexOf(n)>=0&&(t[o]=!0);return t}function He(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}He.groups={},He.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let o=0;o<e.jr.length;o++){const r=e.jr[o][0],s=e.jr[o][1];if(s&&r.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,o){for(let r=0;r<n.length;r++)this.tt(n[r],e,t,o)},tr(n,e,t,o){o=o||He.groups;let r;return e&&e.j?r=e:(r=new He(e),t&&o&&Sn(e,t,o)),this.jr.push([n,r]),r},ts(n,e,t,o){let r=this;const s=n.length;if(!s)return r;for(let i=0;i<s-1;i++)r=r.tt(n[i]);return r.tt(n[s-1],e,t,o)},tt(n,e,t,o){o=o||He.groups;const r=this;if(e&&e.j)return r.j[n]=e,e;const s=e;let i,l=r.go(n);if(l?(i=new He,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new He,s){if(o)if(i.t&&typeof i.t=="string"){const c=Object.assign(Uk(i.t,o),t);Sn(s,c,o)}else t&&Sn(s,t,o);i.t=s}return r.j[n]=i,i}};const X=(n,e,t,o,r)=>n.ta(e,t,o,r),he=(n,e,t,o,r)=>n.tr(e,t,o,r),of=(n,e,t,o,r)=>n.ts(e,t,o,r),D=(n,e,t,o,r)=>n.tt(e,t,o,r),It="WORD",ol="UWORD",rf="ASCIINUMERICAL",sf="ALPHANUMERICAL",Ro="LOCALHOST",rl="TLD",sl="UTLD",Or="SCHEME",Gn="SLASH_SCHEME",il="NUM",ll="WS",al="NL",Po="OPENBRACE",Do="CLOSEBRACE",Rr="OPENBRACKET",Pr="CLOSEBRACKET",Dr="OPENPAREN",_r="CLOSEPAREN",Lr="OPENANGLEBRACKET",Vr="CLOSEANGLEBRACKET",$r="FULLWIDTHLEFTPAREN",zr="FULLWIDTHRIGHTPAREN",Fr="LEFTCORNERBRACKET",Hr="RIGHTCORNERBRACKET",Ur="LEFTWHITECORNERBRACKET",jr="RIGHTWHITECORNERBRACKET",Wr="FULLWIDTHLESSTHAN",Kr="FULLWIDTHGREATERTHAN",qr="AMPERSAND",Jr="APOSTROPHE",Gr="ASTERISK",Qt="AT",Yr="BACKSLASH",Xr="BACKTICK",Qr="CARET",Zt="COLON",cl="COMMA",Zr="DOLLAR",ht="DOT",es="EQUALS",dl="EXCLAMATION",Qe="HYPHEN",_o="PERCENT",ts="PIPE",ns="PLUS",rs="POUND",Lo="QUERY",ul="QUOTE",lf="FULLWIDTHMIDDLEDOT",fl="SEMI",pt="SLASH",Vo="TILDE",ss="UNDERSCORE",af="EMOJI",is="SYM";var cf=Object.freeze({__proto__:null,ALPHANUMERICAL:sf,AMPERSAND:qr,APOSTROPHE:Jr,ASCIINUMERICAL:rf,ASTERISK:Gr,AT:Qt,BACKSLASH:Yr,BACKTICK:Xr,CARET:Qr,CLOSEANGLEBRACKET:Vr,CLOSEBRACE:Do,CLOSEBRACKET:Pr,CLOSEPAREN:_r,COLON:Zt,COMMA:cl,DOLLAR:Zr,DOT:ht,EMOJI:af,EQUALS:es,EXCLAMATION:dl,FULLWIDTHGREATERTHAN:Kr,FULLWIDTHLEFTPAREN:$r,FULLWIDTHLESSTHAN:Wr,FULLWIDTHMIDDLEDOT:lf,FULLWIDTHRIGHTPAREN:zr,HYPHEN:Qe,LEFTCORNERBRACKET:Fr,LEFTWHITECORNERBRACKET:Ur,LOCALHOST:Ro,NL:al,NUM:il,OPENANGLEBRACKET:Lr,OPENBRACE:Po,OPENBRACKET:Rr,OPENPAREN:Dr,PERCENT:_o,PIPE:ts,PLUS:ns,POUND:rs,QUERY:Lo,QUOTE:ul,RIGHTCORNERBRACKET:Hr,RIGHTWHITECORNERBRACKET:jr,SCHEME:Or,SEMI:fl,SLASH:pt,SLASH_SCHEME:Gn,SYM:is,TILDE:Vo,TLD:rl,UNDERSCORE:ss,UTLD:sl,UWORD:ol,WORD:It,WS:ll});const Ot=/[a-z]/,$o=new RegExp("\\p{L}","u"),hl=new RegExp("\\p{Emoji}","u"),Rt=/\d/,pl=/\s/,df="\r",ml=`
|
|
103
|
-
`,
|
|
102
|
+
`):""}),th=gb,nh=" ",yb=" ",kb=Rl.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",tn(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const o=e.parseInline(t);return o.length===1&&o[0].type==="text"&&(o[0].text===nh||o[0].text===yb)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,o)},renderMarkdown:(n,e)=>{if(!n)return"";const t=Array.isArray(n.content)?n.content:[];return t.length===0?nh:e.renderChildren(t)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),oh=kb,wb=Rl.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),rh=wb,sh=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...o}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,o,t]},bb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Sb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,xb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Cb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Eb=oo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return sh("strong",{...tn(this.options.HTMLAttributes,n),children:sh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ns({find:bb,type:this.type}),ns({find:xb,type:this.type})]},addPasteRules(){return[Ko({find:Sb,type:this.type}),Ko({find:Cb,type:this.type})]}}),ih=Eb,vb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Tb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Mb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ab=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Nb=oo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",tn(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ns({find:vb,type:this.type}),ns({find:Mb,type:this.type})]},addPasteRules(){return[Ko({find:Tb,type:this.type}),Ko({find:Ab,type:this.type})]}}),lh=Nb,Ib=oo.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",tn(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!r)return;const s=r[2].trim();return{type:"underline",raw:r[0],text:s,tokens:t.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),ah=Ib;const Bb="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Ob="ελ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",Pl="numeric",Dl="ascii",Ll="alpha",qo="asciinumeric",Jo="alphanumeric",Vl="domain",ch="emoji",_b="scheme",Rb="slashscheme",$l="whitespace";function Pb(n,e){return n in e||(e[n]=[]),e[n]}function Nn(n,e,t){e[Pl]&&(e[qo]=!0,e[Jo]=!0),e[Dl]&&(e[qo]=!0,e[Ll]=!0),e[qo]&&(e[Jo]=!0),e[Ll]&&(e[Jo]=!0),e[Jo]&&(e[Vl]=!0),e[ch]&&(e[Vl]=!0);for(const o in e){const r=Pb(o,t);r.indexOf(n)<0&&r.push(n)}}function Db(n,e){const t={};for(const o in e)e[o].indexOf(n)>=0&&(t[o]=!0);return t}function je(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}je.groups={},je.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let o=0;o<e.jr.length;o++){const r=e.jr[o][0],s=e.jr[o][1];if(s&&r.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,o){for(let r=0;r<n.length;r++)this.tt(n[r],e,t,o)},tr(n,e,t,o){o=o||je.groups;let r;return e&&e.j?r=e:(r=new je(e),t&&o&&Nn(e,t,o)),this.jr.push([n,r]),r},ts(n,e,t,o){let r=this;const s=n.length;if(!s)return r;for(let i=0;i<s-1;i++)r=r.tt(n[i]);return r.tt(n[s-1],e,t,o)},tt(n,e,t,o){o=o||je.groups;const r=this;if(e&&e.j)return r.j[n]=e,e;const s=e;let i,l=r.go(n);if(l?(i=new je,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new je,s){if(o)if(i.t&&typeof i.t=="string"){const c=Object.assign(Db(i.t,o),t);Nn(s,c,o)}else t&&Nn(s,t,o);i.t=s}return r.j[n]=i,i}};const Z=(n,e,t,o,r)=>n.ta(e,t,o,r),ye=(n,e,t,o,r)=>n.tr(e,t,o,r),dh=(n,e,t,o,r)=>n.ts(e,t,o,r),D=(n,e,t,o,r)=>n.tt(e,t,o,r),Pt="WORD",zl="UWORD",uh="ASCIINUMERICAL",fh="ALPHANUMERICAL",Go="LOCALHOST",Fl="TLD",Hl="UTLD",rs="SCHEME",ro="SLASH_SCHEME",jl="NUM",Wl="WS",Ul="NL",Yo="OPENBRACE",Xo="CLOSEBRACE",ss="OPENBRACKET",is="CLOSEBRACKET",ls="OPENPAREN",as="CLOSEPAREN",cs="OPENANGLEBRACKET",ds="CLOSEANGLEBRACKET",us="FULLWIDTHLEFTPAREN",fs="FULLWIDTHRIGHTPAREN",hs="LEFTCORNERBRACKET",ps="RIGHTCORNERBRACKET",ms="LEFTWHITECORNERBRACKET",gs="RIGHTWHITECORNERBRACKET",ys="FULLWIDTHLESSTHAN",ks="FULLWIDTHGREATERTHAN",ws="AMPERSAND",bs="APOSTROPHE",Ss="ASTERISK",nn="AT",xs="BACKSLASH",Cs="BACKTICK",Es="CARET",on="COLON",Kl="COMMA",vs="DOLLAR",mt="DOT",Ts="EQUALS",ql="EXCLAMATION",et="HYPHEN",Qo="PERCENT",Ms="PIPE",As="PLUS",Ns="POUND",Zo="QUERY",Jl="QUOTE",hh="FULLWIDTHMIDDLEDOT",Gl="SEMI",gt="SLASH",er="TILDE",Is="UNDERSCORE",ph="EMOJI",Bs="SYM";var mh=Object.freeze({__proto__:null,ALPHANUMERICAL:fh,AMPERSAND:ws,APOSTROPHE:bs,ASCIINUMERICAL:uh,ASTERISK:Ss,AT:nn,BACKSLASH:xs,BACKTICK:Cs,CARET:Es,CLOSEANGLEBRACKET:ds,CLOSEBRACE:Xo,CLOSEBRACKET:is,CLOSEPAREN:as,COLON:on,COMMA:Kl,DOLLAR:vs,DOT:mt,EMOJI:ph,EQUALS:Ts,EXCLAMATION:ql,FULLWIDTHGREATERTHAN:ks,FULLWIDTHLEFTPAREN:us,FULLWIDTHLESSTHAN:ys,FULLWIDTHMIDDLEDOT:hh,FULLWIDTHRIGHTPAREN:fs,HYPHEN:et,LEFTCORNERBRACKET:hs,LEFTWHITECORNERBRACKET:ms,LOCALHOST:Go,NL:Ul,NUM:jl,OPENANGLEBRACKET:cs,OPENBRACE:Yo,OPENBRACKET:ss,OPENPAREN:ls,PERCENT:Qo,PIPE:Ms,PLUS:As,POUND:Ns,QUERY:Zo,QUOTE:Jl,RIGHTCORNERBRACKET:ps,RIGHTWHITECORNERBRACKET:gs,SCHEME:rs,SEMI:Gl,SLASH:gt,SLASH_SCHEME:ro,SYM:Bs,TILDE:er,TLD:Fl,UNDERSCORE:Is,UTLD:Hl,UWORD:zl,WORD:Pt,WS:Wl});const Dt=/[a-z]/,tr=new RegExp("\\p{L}","u"),Yl=new RegExp("\\p{Emoji}","u"),Lt=/\d/,Xl=/\s/,gh="\r",Ql=`
|
|
103
|
+
`,Lb="️",Vb="",Zl="";let Os=null,_s=null;function $b(n=[]){const e={};je.groups=e;const t=new je;Os==null&&(Os=kh(Bb)),_s==null&&(_s=kh(Ob)),D(t,"'",bs),D(t,"{",Yo),D(t,"}",Xo),D(t,"[",ss),D(t,"]",is),D(t,"(",ls),D(t,")",as),D(t,"<",cs),D(t,">",ds),D(t,"(",us),D(t,")",fs),D(t,"「",hs),D(t,"」",ps),D(t,"『",ms),D(t,"』",gs),D(t,"<",ys),D(t,">",ks),D(t,"&",ws),D(t,"*",Ss),D(t,"@",nn),D(t,"`",Cs),D(t,"^",Es),D(t,":",on),D(t,",",Kl),D(t,"$",vs),D(t,".",mt),D(t,"=",Ts),D(t,"!",ql),D(t,"-",et),D(t,"%",Qo),D(t,"|",Ms),D(t,"+",As),D(t,"#",Ns),D(t,"?",Zo),D(t,'"',Jl),D(t,"/",gt),D(t,";",Gl),D(t,"~",er),D(t,"_",Is),D(t,"\\",xs),D(t,"・",hh);const o=ye(t,Lt,jl,{[Pl]:!0});ye(o,Lt,o);const r=ye(o,Dt,uh,{[qo]:!0}),s=ye(o,tr,fh,{[Jo]:!0}),i=ye(t,Dt,Pt,{[Dl]:!0});ye(i,Lt,r),ye(i,Dt,i),ye(r,Lt,r),ye(r,Dt,r);const l=ye(t,tr,zl,{[Ll]:!0});ye(l,Dt),ye(l,Lt,s),ye(l,tr,l),ye(s,Lt,s),ye(s,Dt),ye(s,tr,s);const c=D(t,Ql,Ul,{[$l]:!0}),d=D(t,gh,Wl,{[$l]:!0}),u=ye(t,Xl,Wl,{[$l]:!0});D(t,Zl,u),D(d,Ql,c),D(d,Zl,u),ye(d,Xl,u),D(u,gh),D(u,Ql),ye(u,Xl,u),D(u,Zl,u);const f=ye(t,Yl,ph,{[ch]:!0});D(f,"#"),ye(f,Yl,f),D(f,Lb,f);const p=D(f,Vb);D(p,"#"),ye(p,Yl,f);const h=[[Dt,i],[Lt,r]],m=[[Dt,null],[tr,l],[Lt,s]];for(let g=0;g<Os.length;g++)rn(t,Os[g],Fl,Pt,h);for(let g=0;g<_s.length;g++)rn(t,_s[g],Hl,zl,m);Nn(Fl,{tld:!0,ascii:!0},e),Nn(Hl,{utld:!0,alpha:!0},e),rn(t,"file",rs,Pt,h),rn(t,"mailto",rs,Pt,h),rn(t,"http",ro,Pt,h),rn(t,"https",ro,Pt,h),rn(t,"ftp",ro,Pt,h),rn(t,"ftps",ro,Pt,h),Nn(rs,{scheme:!0,ascii:!0},e),Nn(ro,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],b=n[g][1]?{[_b]:!0}:{[Rb]:!0};y.indexOf("-")>=0?b[Vl]=!0:Dt.test(y)?Lt.test(y)?b[qo]=!0:b[Dl]=!0:b[Pl]=!0,dh(t,y,y,b)}return dh(t,"localhost",Go,{ascii:!0}),t.jd=new je(Bs),{start:t,tokens:Object.assign({groups:e},mh)}}function yh(n,e){const t=zb(e.replace(/[A-Z]/g,l=>l.toLowerCase())),o=t.length,r=[];let s=0,i=0;for(;i<o;){let l=n,c=null,d=0,u=null,f=-1,p=-1;for(;i<o&&(c=l.go(t[i]));)l=c,l.accepts()?(f=0,p=0,u=l):f>=0&&(f+=t[i].length,p++),d+=t[i].length,s+=t[i].length,i++;s-=f,i-=p,d-=f,r.push({t:u.t,v:e.slice(s-d,s),s:s-d,e:s})}return r}function zb(n){const e=[],t=n.length;let o=0;for(;o<t;){let r=n.charCodeAt(o),s,i=r<55296||r>56319||o+1===t||(s=n.charCodeAt(o+1))<56320||s>57343?n[o]:n.slice(o,o+2);e.push(i),o+=i.length}return e}function rn(n,e,t,o,r){let s;const i=e.length;for(let l=0;l<i-1;l++){const c=e[l];n.j[c]?s=n.j[c]:(s=new je(o),s.jr=r.slice(),n.j[c]=s),n=s}return s=new je(t),s.jr=r.slice(),n.j[e[i-1]]=s,s}function kh(n){const e=[],t=[];let o=0,r="0123456789";for(;o<n.length;){let s=0;for(;r.indexOf(n[o+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let i=parseInt(n.substring(o,o+s),10);i>0;i--)t.pop();o+=s}else t.push(n[o]),o++}return e}const nr={defaultProtocol:"http",events:null,format:wh,formatHref:wh,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ea(n,e=null){let t=Object.assign({},nr);n&&(t=Object.assign(t,n instanceof ea?n.o:n));const o=t.ignoreTags,r=[];for(let s=0;s<o.length;s++)r.push(o[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=r}ea.prototype={o:nr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const o=e!=null;let r=this.o[n];return r&&(typeof r=="object"?(r=t.t in r?r[t.t]:nr[n],typeof r=="function"&&o&&(r=r(e,t))):typeof r=="function"&&o&&(r=r(e,t.t,t)),r)},getObj(n,e,t){let o=this.o[n];return typeof o=="function"&&e!=null&&(o=o(e,t.t,t)),o},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function wh(n){return n}function bh(n,e){this.t="token",this.v=n,this.tk=e}bh.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),o=n.get("format",e,this);return t&&o.length>t?o.substring(0,t)+"…":o},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=nr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),o=n.get("formatHref",t,this),r=n.get("tagName",t,e),s=this.toFormattedString(n),i={},l=n.get("className",t,e),c=n.get("target",t,e),d=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return i.href=o,l&&(i.class=l),c&&(i.target=c),d&&(i.rel=d),u&&Object.assign(i,u),{tagName:r,attributes:i,content:s,eventListeners:f}}};function Rs(n,e){class t extends bh{constructor(r,s){super(r,s),this.t=n}}for(const o in e)t.prototype[o]=e[o];return t.t=n,t}const Sh=Rs("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),xh=Rs("text"),Fb=Rs("nl"),Ps=Rs("url",{isLink:!0,toHref(n=nr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Go&&n[1].t===on}}),tt=n=>new je(n);function Hb({groups:n}){const e=n.domain.concat([ws,Ss,nn,xs,Cs,Es,vs,Ts,et,jl,Qo,Ms,As,Ns,gt,Bs,er,Is]),t=[bs,on,Kl,mt,ql,Qo,Zo,Jl,Gl,cs,ds,Yo,Xo,is,ss,ls,as,us,fs,hs,ps,ms,gs,ys,ks],o=[ws,bs,Ss,xs,Cs,Es,vs,Ts,et,Yo,Xo,Qo,Ms,As,Ns,Zo,gt,Bs,er,Is],r=tt(),s=D(r,er);Z(s,o,s),Z(s,n.domain,s);const i=tt(),l=tt(),c=tt();Z(r,n.domain,i),Z(r,n.scheme,l),Z(r,n.slashscheme,c),Z(i,o,s),Z(i,n.domain,i);const d=D(i,nn);D(s,nn,d),D(l,nn,d),D(c,nn,d);const u=D(s,mt);Z(u,o,s),Z(u,n.domain,s);const f=tt();Z(d,n.domain,f),Z(f,n.domain,f);const p=D(f,mt);Z(p,n.domain,f);const h=tt(Sh);Z(p,n.tld,h),Z(p,n.utld,h),D(d,Go,h);const m=D(f,et);D(m,et,m),Z(m,n.domain,f),Z(h,n.domain,f),D(h,mt,p),D(h,et,m);const g=D(h,on);Z(g,n.numeric,Sh);const y=D(i,et),w=D(i,mt);D(y,et,y),Z(y,n.domain,i),Z(w,o,s),Z(w,n.domain,i);const b=tt(Ps);Z(w,n.tld,b),Z(w,n.utld,b),Z(b,n.domain,i),Z(b,o,s),D(b,mt,w),D(b,et,y),D(b,nn,d);const x=D(b,on),S=tt(Ps);Z(x,n.numeric,S);const E=tt(Ps),M=tt();Z(E,e,E),Z(E,t,M),Z(M,e,E),Z(M,t,M),D(b,gt,E),D(S,gt,E);const C=D(l,on),T=D(c,on),v=D(T,gt),I=D(v,gt);Z(l,n.domain,i),D(l,mt,w),D(l,et,y),Z(c,n.domain,i),D(c,mt,w),D(c,et,y),Z(C,n.domain,E),D(C,gt,E),D(C,Zo,E),Z(I,n.domain,E),Z(I,e,E),D(I,gt,E);const B=[[Yo,Xo],[ss,is],[ls,as],[cs,ds],[us,fs],[hs,ps],[ms,gs],[ys,ks]];for(let P=0;P<B.length;P++){const[V,F]=B[P],z=D(E,V);D(M,V,z),D(z,F,E);const J=tt(Ps);Z(z,e,J);const j=tt();Z(z,t),Z(J,e,J),Z(J,t,j),Z(j,e,J),Z(j,t,j),D(J,F,E),D(j,F,E)}return D(r,Go,b),D(r,Ul,Fb),{start:r,tokens:mh}}function jb(n,e,t){let o=t.length,r=0,s=[],i=[];for(;r<o;){let l=n,c=null,d=null,u=0,f=null,p=-1;for(;r<o&&!(c=l.go(t[r].t));)i.push(t[r++]);for(;r<o&&(d=c||l.go(t[r].t));)c=null,l=d,l.accepts()?(p=0,f=l):p>=0&&p++,r++,u++;if(p<0)r-=u,r<o&&(i.push(t[r]),r++);else{i.length>0&&(s.push(ta(xh,e,i)),i=[]),r-=p,u-=p;const h=f.t,m=t.slice(r-u,r);s.push(ta(h,e,m))}}return i.length>0&&s.push(ta(xh,e,i)),s}function ta(n,e,t){const o=t[0].s,r=t[t.length-1].e,s=e.slice(o,r);return new n(s,t)}const Wb=typeof console<"u"&&console&&console.warn||(()=>{}),Ub="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ue={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Kb(){return je.groups={},ue.scanner=null,ue.parser=null,ue.tokenQueue=[],ue.pluginQueue=[],ue.customSchemes=[],ue.initialized=!1,ue}function Ch(n,e=!1){if(ue.initialized&&Wb(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Ub}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
104
104
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
105
105
|
2. Cannot start or end with "-"
|
|
106
|
-
3. "-" cannot repeat`);le.customSchemes.push([n,e])}function ew(){le.scanner=Kk(le.customSchemes);for(let n=0;n<le.tokenQueue.length;n++)le.tokenQueue[n][1]({scanner:le.scanner});le.parser=Gk(le.scanner.tokens);for(let n=0;n<le.pluginQueue.length;n++)le.pluginQueue[n][1]({scanner:le.scanner,parser:le.parser});return le.initialized=!0,le}function wl(n){return le.initialized||ew(),Yk(le.parser.start,n,uf(le.scanner.start,n))}wl.scan=uf;function kf(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const o=new yl(t),r=wl(n),s=[];for(let i=0;i<r.length;i++){const l=r[i];l.isLink&&(!e||l.t===e)&&o.check(l)&&s.push(l.toFormattedObject(o))}return s}var bl="[\0- -\u2029 ]",tw=new RegExp(bl),nw=new RegExp(`${bl}$`),ow=new RegExp(bl,"g");function rw(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function sw(n){return new fe({key:new Ce("autolink"),appendTransaction:(e,t,o)=>{const r=e.some(d=>d.docChanged)&&!t.doc.eq(o.doc),s=e.some(d=>d.getMeta("preventAutolink"));if(!r||s)return;const{tr:i}=o,l=wu(t.doc,[...e]);if(Bu(l).forEach(({newRange:d})=>{const u=my(o.doc,d,h=>h.isTextblock);let f,p;if(u.length>1)f=u[0],p=o.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const h=o.doc.textBetween(d.from,d.to," "," ");if(!nw.test(h))return;f=u[0],p=o.doc.textBetween(f.pos,d.to,void 0," ")}if(f&&p){const h=p.split(tw).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=f.pos+p.lastIndexOf(m);if(!m)return!1;const y=wl(m).map(k=>k.toObject(n.defaultProtocol));if(!rw(y))return!1;y.filter(k=>k.isLink).map(k=>({...k,from:g+k.start+1,to:g+k.end+1})).filter(k=>o.schema.marks.code?!o.doc.rangeHasMark(k.from,k.to,o.schema.marks.code):!0).filter(k=>n.validate(k.value)).filter(k=>n.shouldAutoLink(k.value)).forEach(k=>{ji(k.from,k.to,o.doc).some(b=>b.mark.type===n.type)||i.addMark(k.from,k.to,n.type.create({href:k.href}))})}}),!!i.steps.length)return i}})}function iw(n){return new fe({key:new Ce("handleClickLink"),props:{handleClick:(e,t,o)=>{var r,s;if(o.button!==0||!e.editable)return!1;let i=null;if(o.target instanceof HTMLAnchorElement)i=o.target;else{const c=o.target;if(!c)return!1;const d=n.editor.view.dom;i=c.closest("a"),i&&!d.contains(i)&&(i=null)}if(!i)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const c=Au(e.state,n.type.name),d=(r=i.href)!=null?r:c.href,u=(s=i.target)!=null?s:c.target;d&&(window.open(d,u),l=!0)}return l}}})}function lw(n){return new fe({key:new Ce("handlePasteLink"),props:{handlePaste:(e,t,o)=>{const{shouldAutoLink:r}=n,{state:s}=e,{selection:i}=s,{empty:l}=i;if(l)return!1;let c="";o.content.forEach(u=>{c+=u.textContent});const d=kf(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||r!==void 0&&!r(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function En(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(o=>{const r=typeof o=="string"?o:o.scheme;r&&t.push(r)}),!n||n.replace(ow,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var aw=Jn.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(n=>{if(typeof n=="string"){yf(n);return}yf(n.scheme,n.optionalSlashes)})},onDestroy(){Zk()},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:(n,e)=>!!En(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const r=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!En(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!En(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Xt(this.options.HTMLAttributes,n),0]:["a",Xt(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,o,r,s;const i=(o=(t=n.attrs)==null?void 0:t.href)!=null?o:"",l=(s=(r=n.attrs)==null?void 0:r.title)!=null?s:"",c=e.renderChildren(n);return l?`[${c}](${i} "${l}")`:`[${c}](${i})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:o=>!!En(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:o=>!!En(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Bo({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:o}=this.options,r=kf(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!En(i,t),protocols:t,defaultProtocol:o}));r.length&&r.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(sw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:o=>this.options.isAllowedUri(o,{defaultValidate:r=>!!En(r,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(iw({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(lw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),wf=aw,cw=ie.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),bf=cw,dw=20,Cf=(n,e=0)=>{const t=[];return!n.children.length||e>dw||Array.from(n.children).forEach(o=>{o.tagName==="SPAN"?t.push(o):o.children.length&&t.push(...Cf(o,e+1))}),t},uw=n=>{if(!n.children.length)return;const e=Cf(n);e&&e.forEach(t=>{var o,r;const s=t.getAttribute("style"),i=(r=(o=t.parentElement)==null?void 0:o.closest("span"))==null?void 0:r.getAttribute("style");t.setAttribute("style",`${i};${s}`)})},Cl=Jn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&uw(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",Xt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,o)=>{if(t.isTextblock)return!0;t.marks.filter(r=>r.type===this.type).some(r=>Object.values(r.attrs).some(s=>!!s))||n.removeMark(o,o+t.nodeSize,this.type)}),!0}}}}),fw=ie.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="background-color")return l.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),xf=ie.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="color")return l.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),hw=ie.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),pw=ie.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),mw=ie.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});ie.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(fw.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push(xf.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(hw.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(pw.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(mw.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(Cl.configure(this.options.textStyle)),n}});var Sf=xf;function gw(n={}){return new fe({view(e){return new yw(e,n)}})}class yw{constructor(e,t){var o;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(o=t.width)!==null&&o!==void 0?o:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let s=i=>{this[r](i)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}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,o,r=this.editorView.dom,s=r.getBoundingClientRect(),i=s.width/r.offsetWidth,l=s.height/r.offsetHeight;if(t){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=f?m.bottom:m.top;f&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;o={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!o){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*i;o={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.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 d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,h=f.height/c.offsetHeight;d=f.left-c.scrollLeft*p,u=f.top-c.scrollTop*h}this.element.style.left=(o.left-d)/i+"px",this.element.style.top=(o.top-u)/l+"px",this.element.style.width=(o.right-o.left)/i+"px",this.element.style.height=(o.bottom-o.top)/l+"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}),o=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=o&&o.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Cc(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class pe extends Z{constructor(e){super(e,e)}map(e,t){let o=e.resolve(t.map(this.head));return pe.valid(o)?new pe(o):Z.near(o)}content(){return z.empty}eq(e){return e instanceof pe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new pe(e.resolve(t.pos))}getBookmark(){return new xl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!kw(e)||!ww(e))return!1;let o=t.type.spec.allowGapCursor;if(o!=null)return o;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,o=!1){e:for(;;){if(!o&&pe.valid(e))return e;let r=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;r+=t;let c=e.doc.resolve(r);if(pe.valid(c))return c}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!q.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),o=!1;continue e}break}s=i,r+=t;let l=e.doc.resolve(r);if(pe.valid(l))return l}return null}}}pe.prototype.visible=!1,pe.findFrom=pe.findGapCursorFrom,Z.jsonID("gapcursor",pe);class xl{constructor(e){this.pos=e}map(e){return new xl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return pe.valid(t)?new pe(t):Z.near(t)}}function Ef(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function kw(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),o=n.node(e);if(t==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||Ef(r.type))return!0;if(r.inlineContent)return!1}}return!0}function ww(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),o=n.node(e);if(t==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||Ef(r.type))return!0;if(r.inlineContent)return!1}}return!0}function bw(){return new fe({props:{decorations:Ew,createSelectionBetween(n,e,t){return e.pos==t.pos&&pe.valid(t)?new pe(t):null},handleClick:xw,handleKeyDown:Cw,handleDOMEvents:{beforeinput:Sw}}})}const Cw=au({ArrowLeft:us("horiz",-1),ArrowRight:us("horiz",1),ArrowUp:us("vert",-1),ArrowDown:us("vert",1)});function us(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,s){let i=o.selection,l=e>0?i.$to:i.$from,c=i.empty;if(i instanceof Y){if(!s.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=o.doc.resolve(e>0?l.after():l.before())}let d=pe.findGapCursorFrom(l,e,c);return d?(r&&r(o.tr.setSelection(new pe(d))),!0):!1}}function xw(n,e,t){if(!n||!n.editable)return!1;let o=n.state.doc.resolve(e);if(!pe.valid(o))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&q.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new pe(o))),!0)}function Sw(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof pe))return!1;let{$from:t}=n.state.selection,o=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!o)return!1;let r=I.empty;for(let i=o.length-1;i>=0;i--)r=I.from(o[i].createAndFill(null,r));let s=n.state.tr.replace(t.pos,t.pos,new z(r,0,0));return s.setSelection(Y.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Ew(n){if(!(n.selection instanceof pe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",de.create(n.doc,[ze.widget(n.selection.head,e,{key:"gapcursor"})])}var fs=200,Se=function(){};Se.prototype.append=function(e){return e.length?(e=Se.from(e),!this.length&&e||e.length<fs&&this.leafAppend(e)||this.length<fs&&e.leafPrepend(this)||this.appendInner(e)):this},Se.prototype.prepend=function(e){return e.length?Se.from(e).append(this):this},Se.prototype.appendInner=function(e){return new vw(this,e)},Se.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Se.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Se.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Se.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},Se.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var r=[];return this.forEach(function(s,i){return r.push(e(s,i))},t,o),r},Se.from=function(e){return e instanceof Se?e:e&&e.length?new vf(e):Se.empty};var vf=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,i,l){for(var c=s;c<i;c++)if(r(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,l){for(var c=s-1;c>=i;c--)if(r(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=fs)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=fs)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Se);Se.empty=new vf([]);var vw=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,r,s,i){var l=this.left.length;if(r<l&&this.left.forEachInner(o,r,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(o,Math.max(r-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,r,s,i){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(o,r-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(o,Math.min(r,l),s,i)===!1)return!1},e.prototype.sliceInner=function(o,r){if(o==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(o,r):o>=s?this.right.slice(o-s,r-s):this.left.slice(o,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(o){var r=this.right.leafAppend(o);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(o){var r=this.left.leafPrepend(o);if(r)return new e(r,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Se);const Mw=500;class ot{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let r,s;t&&(r=this.remapping(o,this.items.length),s=r.maps.length);let i=e.tr,l,c,d=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){r||(r=this.remapping(o,p+1),s=r.maps.length),s--,u.push(f);return}if(r){u.push(new mt(f.map));let h=f.step.map(r.slice(s)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],d.push(new mt(m,void 0,void 0,d.length+u.length))),s--,m&&r.appendMap(m,s)}else i.maybeStep(f.step);if(f.selection)return l=r?f.selection.map(r.slice(s)):f.selection,c=new ot(this.items.slice(0,o).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:i,selection:l}}addTransform(e,t,o,r){let s=[],i=this.eventCount,l=this.items,c=!r&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new mt(e.mapping.maps[u],f,t),h;(h=c&&c.merge(p))&&(p=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(p),t&&(i++,t=void 0),r||(c=p)}let d=i-o.depth;return d>Nw&&(l=Tw(l,d),i-=d),new ot(l.append(s),i)}remapping(e,t){let o=new uo;return this.items.forEach((r,s)=>{let i=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?o.maps.length-r.mirrorOffset:void 0;o.appendMap(r.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new ot(this.items.append(e.map(t=>new mt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],r=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},r);let c=t;this.items.forEach(p=>{let h=s.getMirror(--c);if(h==null)return;i=Math.min(i,h);let m=s.maps[h];if(p.step){let g=e.steps[h].invert(e.docs[h]),y=p.selection&&p.selection.map(s.slice(c+1,h));y&&l++,o.push(new mt(m,g,y))}else o.push(new mt(m))},r);let d=[];for(let p=t;p<i;p++)d.push(new mt(s.maps[p]));let u=this.items.slice(0,r).append(d).append(o),f=new ot(u,l);return f.emptyItemCount()>Mw&&(f=f.compress(this.items.length-o.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,r=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)r.push(i),i.selection&&s++;else if(i.step){let c=i.step.map(t.slice(o)),d=c&&c.getMap();if(o--,d&&t.appendMap(d,o),c){let u=i.selection&&i.selection.map(t.slice(o));u&&s++;let f=new mt(d.invert(),c,u),p,h=r.length-1;(p=r.length&&r[h].merge(f))?r[h]=p:r.push(f)}}else i.map&&o--},this.items.length,0),new ot(Se.from(r.reverse()),s)}}ot.empty=new ot(Se.empty,0);function Tw(n,e){let t;return n.forEach((o,r)=>{if(o.selection&&e--==0)return t=r,!1}),n.slice(t)}class mt{constructor(e,t,o,r){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new mt(t.getMap().invert(),t,this.selection)}}}class tn{constructor(e,t,o,r,s){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=r,this.prevComposition=s}}const Nw=20;function Aw(n,e,t,o){let r=t.getMeta(vn),s;if(r)return r.historyState;t.getMeta(Ow)&&(n=new tn(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(vn))return i.getMeta(vn).redo?new tn(n.done.addTransform(t,void 0,o,hs(e)),n.undone,Mf(t.mapping.maps),n.prevTime,n.prevComposition):new tn(n.done,n.undone.addTransform(t,void 0,o,hs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Bw(t,n.prevRanges)),d=i?Sl(n.prevRanges,t.mapping):Mf(t.mapping.maps);return new tn(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,hs(e)),ot.empty,d,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new tn(n.done.rebased(t,s),n.undone.rebased(t,s),Sl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new tn(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Sl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Bw(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,r)=>{for(let s=0;s<e.length;s+=2)o<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function Mf(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,r,s,i)=>e.push(s,i));return e}function Sl(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let r=e.map(n[o],1),s=e.map(n[o+1],-1);r<=s&&t.push(r,s)}return t}function Iw(n,e,t){let o=hs(e),r=vn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,o);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,o),c=new tn(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(vn,{redo:t,historyState:c})}let El=!1,Tf=null;function hs(n){let e=n.plugins;if(Tf!=e){El=!1,Tf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){El=!0;break}}return El}const vn=new Ce("history"),Ow=new Ce("closeHistory");function Rw(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new fe({key:vn,state:{init(){return new tn(ot.empty,ot.empty,null,0,-1)},apply(e,t,o){return Aw(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,r=o=="historyUndo"?Af:o=="historyRedo"?Bf:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Nf(n,e){return(t,o)=>{let r=vn.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(o){let s=Iw(r,t,n);s&&o(e?s.scrollIntoView():s)}return!0}}const Af=Nf(!1,!0),Bf=Nf(!0,!0);ie.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const o=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(o)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new fe({key:new Ce("characterCount"),appendTransaction:(e,t,o)=>{if(n)return;const r=this.options.limit;if(r==null||r===0){n=!0;return}const s=this.storage.characters({node:o.doc});if(s>r){const i=s-r,l=0,c=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const d=o.tr.deleteRange(l,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const o=this.options.limit;if(!e.docChanged||o===0||o===null||o===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=o||r>o&&s>o&&s<=r)return!0;if(r>o&&s>o&&s>r||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-o,d=l-c,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>o)}})]}}),ie.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[gw(this.options)]}}),ie.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fe({key:new Ce("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:o}=this.editor,{anchor:r}=e,s=[];if(!t||!o)return de.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(c.isText)return;if(!(r>=d&&r<=d+c.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((c,d)=>{if(c.isText||!(r>=d&&r<=d+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(ze.node(d,d+c.nodeSize,{class:this.options.className}))}),de.create(n,s)}}})]}}),ie.create({name:"gapCursor",addProseMirrorPlugins(){return[bw()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=se(W(n,"allowGapCursor",t)))!=null?e:null}}});var If="placeholder";function Pw(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}ie.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:If,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${Pw(this.options.dataAttribute)}`:`data-${If}`;return[new fe({key:new Ce("placeholder"),props:{decorations:({doc:e,selection:t})=>{const o=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!o)return null;const i=this.editor.isEmpty;return e.descendants((l,c)=>{const d=r>=c&&r<=c+l.nodeSize,u=!l.isLeaf&&Mr(l);if((d||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=ze.node(c,c+l.nodeSize,{class:f.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:d}):this.options.placeholder});s.push(p)}return this.options.includeChildren}),de.create(e,s)}}})]}}),ie.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new fe({key:new Ce("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||My(t.selection)||n.view.dragging?null:de.create(t.doc,[ze.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Of({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}ie.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new Ce(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",o=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(t).includes(r.name));return[new fe({key:e,appendTransaction:(r,s,i)=>{const{doc:l,tr:c,schema:d}=i,u=e.getState(i),f=l.content.size,p=d.nodes[t];if(u)return c.insert(f,p.create())},state:{init:(r,s)=>{const i=s.tr.doc.lastChild;return!Of({node:i,types:o})},apply:(r,s)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return s;const i=r.doc.lastChild;return!Of({node:i,types:o})}}})]}});var Dw=ie.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Af(n,e),redo:()=>({state:n,dispatch:e})=>Bf(n,e)}},addProseMirrorPlugins(){return[Rw(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()}}});const Yn="editing",vl=50,ps=1e3,ms=Le.defineCanvasSingleton({name:"blockPlacementState"},{editedCheckpoint:w.field.string().default("").max(36)}),_w=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),Fo=Le.defineCanvasSingleton({name:"doubleClickState"},{snapshot:w.field.string().max(1024).default(_w),lastClickTime:w.field.float64().default(0),lastClickWorldX:w.field.float64().default(0),lastClickWorldY:w.field.float64().default(0)}),Rf=w.defineQuery(n=>n.with(w.Edited));function Lw(n){var e;if(!n)return null;try{const t=JSON.parse(n);return(e=t.block)!=null&&e.tag?t:(console.warn("Block snapshot missing required tag:",t),null)}catch{return console.warn("Invalid block snapshot JSON:",n),null}}function Ml(n,e,t){const o=w.getBlockDef(n,e.block.tag);if(!o)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const r=e.block.size??[100,100],s=[t[0]-r[0]/2,t[1]-r[1]/2];w.Grid.snapPosition(n,s);const[i,l]=s,c=e.block.rank??w.RankBounds.genNext(n),d=w.createEntity(n);"synced"in e||w.addComponent(n,d,w.Synced,{id:crypto.randomUUID()});const u=Object.assign({},e.block,{position:[i,l],size:r,rank:c});w.addComponent(n,d,w.Block,u);for(const f of o.components)if(!(f.name in e))w.addComponent(n,d,f);else{const p=e[f.name];w.addComponent(n,d,f,p)}return d}function Pf(n,e,t,o,r){const s=Ml(n,e,t),{sessionId:i}=w.getResources(n);w.addComponent(n,s,w.Held,{sessionId:i});const l=w.Block.read(n,s);if(w.canBlockEdit(n,e.block.tag)&&(w.addComponent(n,s,te.EditAfterPlacing,{}),r==="placement")){const{store:f}=w.getPluginResources(n,Yn),p=f.createCheckpoint();if(p){const h=ms.write(n);h.editedCheckpoint=p}}const c=te.SelectionStateSingleton.write(n);c.state=r==="dragOut"?te.SelectionState.Dragging:te.SelectionState.Pointing,c.dragStart=t,c.draggedEntity=s,c.draggedEntityStart=l.position,c.pointingStartClient=o,c.pointingStartWorld=t,c.isCloning=!1;const d=w.Controls.write(n);d.leftMouseTool="select",d.heldSnapshot="";const u=w.Cursor.write(n);u.cursorKind="select",u.rotation=0}function Vw(n){const e=ms.read(n);if(e.editedCheckpoint){const t=e.editedCheckpoint;ms.write(n).editedCheckpoint="";const{store:o}=w.getPluginResources(n,Yn);o.onSettled(()=>o.squashToCheckpoint(t),{frames:5})}}const $w=w.defineEditorSystem({phase:"capture"},n=>{Rf.removed(n).length>0&&Rf.current(n).length===0&&Vw(n);const e=w.Controls.read(n);if(!e.heldSnapshot)return;const t=w.getPointerInput(n,[w.PointerButton.Left]);if(t.length===0)return;const o=Lw(e.heldSnapshot);if(!o)return;if(e.leftMouseTool==="drag-out"){const s=t.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;Pf(n,o,s.worldPosition,s.screenPosition,"dragOut")}else{const s=t.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;Pf(n,o,s.worldPosition,s.screenPosition,"placement")}});function zw(n){return n.trimEnd().split(/\r?\n/).map(e=>`<p>${e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")||""}</p>`).join("")}function Df(n){if(n.startsWith("#"))return n.toUpperCase();const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const t=parseInt(e[1],10).toString(16).padStart(2,"0"),o=parseInt(e[2],10).toString(16).padStart(2,"0"),r=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${t}${o}${r}`.toUpperCase()}return n}function Ho(n){const e=Math.round(n.red),t=Math.round(n.green),o=Math.round(n.blue),r=Math.round(n.alpha);return r<255?"#"+[e,t,o,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,t,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function Tl(n){n=n.replace(/^#/,"");let e,t,o,r=255;if(n.length===6)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16);else if(n.length===8)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);else return null;return{red:e,green:t,blue:o,alpha:r}}function _f(n){const e=Tl(n);if(!e)return{h:0,s:100,v:100,a:255};const t=e.red/255,o=e.green/255,r=e.blue/255,s=Math.max(t,o,r),i=Math.min(t,o,r),l=s-i;let c=0;const d=s===0?0:l/s*100,u=s*100;if(l!==0)switch(s){case t:c=((o-r)/l+(o<r?6:0))*60;break;case o:c=((r-t)/l+2)*60;break;case r:c=((t-o)/l+4)*60;break}return{h:c,s:d,v:u,a:e.alpha}}function Lf(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const p=h=>Math.round(h*255).toString(16).padStart(2,"0");return`#${p(r)}${p(s)}${p(i)}`}function Vf(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const p=m=>Math.round(m*255).toString(16).padStart(2,"0"),h=Math.round(n.a).toString(16).padStart(2,"0");return n.a<255?`#${p(r)}${p(s)}${p(i)}${h}`:`#${p(r)}${p(s)}${p(i)}`}const Be=a.shallowRef(null),Nl=a.shallowRef(null),Al=a.shallowRef(null),gt=a.ref(0);function Mn(){const n={hasEditor:a.computed(()=>Be.value!==null),isBold:a.computed(()=>{var s;return gt.value,((s=Be.value)==null?void 0:s.isActive("bold"))??!1}),isItalic:a.computed(()=>{var s;return gt.value,((s=Be.value)==null?void 0:s.isActive("italic"))??!1}),isUnderline:a.computed(()=>{var s;return gt.value,((s=Be.value)==null?void 0:s.isActive("underline"))??!1}),alignment:a.computed(()=>{gt.value;const s=Be.value;return s?s.isActive({textAlign:"center"})?"center":s.isActive({textAlign:"right"})?"right":s.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:a.computed(()=>{gt.value;const s=Be.value;if(!s)return null;const l=s.getAttributes("textStyle").color??null;return l?Df(l):null}),linkHref:a.computed(()=>{gt.value;const s=Be.value;return s?s.getAttributes("link").href??null:null})},e={toggleBold(){const s=Be.value;if(!s)return;const{from:i,to:l}=s.state.selection,c=i===l;let d=s.chain().focus();c&&(d=d.selectAll()),d=d.toggleBold(),c&&(d=d.setTextSelection(l)),d.run()},toggleItalic(){const s=Be.value;if(!s)return;const{from:i,to:l}=s.state.selection,c=i===l;let d=s.chain().focus();c&&(d=d.selectAll()),d=d.toggleItalic(),c&&(d=d.setTextSelection(l)),d.run()},toggleUnderline(){const s=Be.value;if(!s)return;const{from:i,to:l}=s.state.selection,c=i===l;let d=s.chain().focus();c&&(d=d.selectAll()),d=d.toggleUnderline(),c&&(d=d.setTextSelection(l)),d.run()},setAlignment(s){const i=Be.value;i&&i.chain().selectAll().setTextAlign(s).run()},setColor(s){const i=Be.value;if(!i)return;const{from:l,to:c}=i.state.selection;l===c?i.chain().focus().selectAll().setColor(s).setTextSelection(c).run():i.chain().focus().setColor(s).run()},setLink(s){const i=Be.value;if(!i)return;const{from:l,to:c}=i.state.selection;l===c?i.chain().focus().selectAll().setLink({href:s}).setTextSelection(c).run():i.chain().focus().setLink({href:s}).run()},removeLink(){const s=Be.value;if(!s)return;const{from:i,to:l}=s.state.selection;i===l?s.chain().focus().selectAll().unsetLink().setTextSelection(l).run():s.chain().focus().unsetLink().run()}};function t(s,i,l){Be.value=s,Al.value=i,Nl.value=l,s.on("selectionUpdate",()=>{gt.value++}),s.on("transaction",()=>{gt.value++})}function o(){Be.value=null,Al.value=null,Nl.value=null}function r(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{gt.value++})})}return{editor:Be,blockElement:Nl,textElement:Al,state:n,commands:e,updateCounter:gt,register:t,unregister:o,repositionMenu:r}}const $f=1,zf="Synced",Ff="application/x-woven-canvas",Hf=w.defineQuery(n=>n.with(w.Block,te.Selected));function Fw(n){const e=[...Hf.current(n)];if(e.length===0)return null;const{componentsById:t}=w.getResources(n),o=new Map([...t].filter(([,c])=>c.sync==="document")),r=w.Synced._getComponentId(n),s=[],i=ae.Aabb.zero();let l=!1;for(const c of e){const d={};w.hasComponent(n,c,w.Synced)&&(d[zf]=w.Synced.snapshot(n,c));for(const u of n.entityBuffer.getComponentIds(c)){if(u===r)continue;const f=o.get(u);if(f){const p=f.snapshot(n,c),h=Uw(n,f.schema,p);d[f.name]=h}}if(s.push(d),w.hasComponent(n,c,w.Aabb)){const{value:u}=w.Aabb.read(n,c);l?ae.Aabb.union(i,u):(ae.Aabb.copy(i,u),l=!0)}}return{version:$f,center:ae.Aabb.center(i),entities:s}}function Hw(n,e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||t.version!==$f||!Array.isArray(t.entities)||t.entities.length===0)return null;const{componentsByName:o}=w.getResources(n),r=w.Synced._getComponentId(n),s=[];for(const i of t.entities){const l=new Map;for(const[c,d]of Object.entries(i)){if(c===zf){l.set(r,d);continue}const u=o.get(c);u&&u.sync==="document"&&l.set(u._getComponentId(n),d)}s.push(l)}return{entities:s,center:t.center}}function Uw(n,e,t){var r;const o={...t};for(const[s,i]of Object.entries(e))if(((r=i==null?void 0:i.def)==null?void 0:r.type)==="ref"){const l=t[s];o[s]=l!=null&&w.hasComponent(n,l,w.Synced)?w.Synced.read(n,l).id:null}return o}function jw(n){var t;const e=[];for(const[o,r]of Object.entries(n))((t=r==null?void 0:r.def)==null?void 0:t.type)==="ref"&&e.push(o);return e}function Ww(n,e,t,o,r){var i;const s=t.write(n,e);for(const[l,c]of Object.entries(t.schema))if(((i=c==null?void 0:c.def)==null?void 0:i.type)==="ref"){const d=o[l];d!=null&&(s[l]=r.get(d)??null)}}function Kw(n,e,t,o){if(e.length===0)return;const{componentsById:r}=w.getResources(n),s=new Map([...r].filter(([,p])=>p.sync==="document")),i=w.Synced._getComponentId(n),l=w.Block._getComponentId(n);let c;{const p=w.Camera.getWorldCenter(n);c=ae.Vec2.clone(p),ae.Vec2.sub(c,t),w.Grid.snapPosition(n,c)}const d=[...e].sort((p,h)=>{var y,k;const m=((y=p.get(l))==null?void 0:y.rank)??"",g=((k=h.get(l))==null?void 0:k.rank)??"";return m<g?-1:m>g?1:0});te.deselectAll(n);const u=new Map,f=[];for(const p of d){const h=w.createEntity(n),m=p.get(i);m!=null&&m.id&&u.set(m.id,h),w.addComponent(n,h,w.Synced,{id:crypto.randomUUID()});for(const[g,y]of p){if(g===i)continue;const k=s.get(g);if(!k)continue;const b={...y};if(g===l){const x=ae.Vec2.clone(b.position);ae.Vec2.add(x,c),b.position=x,b.rank=w.RankBounds.genNext(n)}const C=jw(k.schema);if(C.length>0){for(const x of C)delete b[x];f.push({entityId:h,componentDef:k,componentData:y})}w.addComponent(n,h,k,b)}te.selectBlock(n,h)}for(const{entityId:p,componentDef:h,componentData:m}of f)Ww(n,p,h,m,u)}function qw(n,e,t,o){const r=w.Text.default(),s=document.createElement("div");if(s.style.position="absolute",s.style.visibility="hidden",s.style.fontFamily=r.fontFamily,s.style.fontSize=`${r.fontSizePx}px`,s.style.lineHeight=`${r.lineHeight}`,s.style.letterSpacing=`${r.letterSpacingEm}em`,s.style.width="fit-content",s.style.wordBreak="break-word",s.style.minWidth="2px",e){const c=o/t,d=Math.min(ps,c/2);s.style.maxWidth=`${d}px`,s.style.whiteSpace="pre-wrap"}else s.style.whiteSpace="pre";s.classList.add("wov-editable-text"),s.innerHTML=n,document.body.appendChild(s);const i=s.offsetWidth,l=s.offsetHeight;return document.body.removeChild(s),{width:i,height:l}}function Jw(n,e={}){const t=e.enabled??!0,o=e.canPasteTextAsBlock??!0;if(!t)return;const{getEditor:r,nextEditorTick:s}=ce(),i=a.inject(ke),l=Mn();let c=null;a.watch(()=>l.editor.value,h=>{if(!h||!c)return;const{plainText:m,html:g}=c;c=null;const y=new DataTransfer;y.setData("text/plain",m),g&&y.setData("text/html",g);const k=new ClipboardEvent("paste",{clipboardData:y,bubbles:!0,cancelable:!0});h.view.dom.dispatchEvent(k),s(b=>{te.DeselectAll.spawn(b)})});function d(h){if(l.editor.value||!h.clipboardData)return!1;const m=r();if(!m)return!1;const g=m._getContext(),y=Fw(g);return y?(h.clipboardData.setData(Ff,JSON.stringify(y)),h.clipboardData.setData("text/plain",`${y.entities.length} block${y.entities.length===1?"":"s"}`),h.preventDefault(),!0):!1}function u(h){d(h)}function f(h){d(h)&&s(m=>{for(const g of Hf.current(m))w.removeEntity(m,g)})}async function p(h){var P,O,_,$;if(l.editor.value)return;const m=document.activeElement;if(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement||m!=null&&m.isContentEditable)return;const g=((P=h.clipboardData)==null?void 0:P.getData(Ff))??"",y=((O=h.clipboardData)==null?void 0:O.getData("text/html"))??"",k=((_=h.clipboardData)==null?void 0:_.getData("text/plain"))??"";if(g){h.preventDefault();const F=await s(),J=Hw(F,g);J&&Kw(F,J.entities,J.center);return}if(!o||!k.trim())return;const b=await s();c={plainText:k,html:y};const C=w.Mouse.read(b),x=w.Camera.read(b),E=[x.left+C.position[0]/x.zoom,x.top+C.position[1]/x.zoom],M=zw(k),S=k.length>vl,v=(($=n.value)==null?void 0:$.clientWidth)??ps,T=qw(M,S,x.zoom,v),B=Ml(b,{block:{tag:"text",size:[T.width,T.height]},text:{constrainWidth:S,fontSizePx:24,...i.getDefaults("text")}},E);w.canBlockEdit(b,"text")&&w.addComponent(b,B,te.EditAfterPlacing,{}),te.SelectBlock.spawn(b,{entityId:B,deselectOthers:!0})}a.onMounted(()=>{const h=n.value;h&&(h.addEventListener("paste",p),h.addEventListener("copy",u),h.addEventListener("cut",f))}),a.onUnmounted(()=>{const h=n.value;h&&(h.removeEventListener("paste",p),h.removeEventListener("copy",u),h.removeEventListener("cut",f))})}function Pt(n,e){const t=a.inject(ke);if(!t)throw new Error("useComponents must be used within a WovenCanvas component");const o=a.shallowRef(new Map),r=new Map;function s(l){if(r.has(l))return;const c=t.getEditor();if(c){const u=c._getContext();if(w.hasComponent(u,l,e)){const f=new Map(o.value);f.set(l,e.snapshot(u,l)),o.value=f}else{const f=new Map(o.value);f.set(l,null),o.value=f}}const d=t.subscribeComponent(l,e.name,u=>{const f=new Map(o.value);f.set(l,u),o.value=f});r.set(l,d)}function i(l){const c=r.get(l);if(c){c(),r.delete(l);const d=new Map(o.value);d.delete(l),o.value=d}}return a.watch(()=>a.toValue(n),(l,c)=>{const d=new Set(l),u=new Set(c??[]);for(const f of u)d.has(f)||i(f);for(const f of d)u.has(f)||s(f)},{immediate:!0}),a.onUnmounted(()=>{for(const l of r.values())l();r.clear()}),o}function Uf(){const n=a.inject(ke);if(!n)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=ce();function t(s){return new Promise((i,l)=>{const c=new window.Image;c.onload=()=>{i({width:c.naturalWidth,height:c.naturalHeight}),URL.revokeObjectURL(c.src)},c.onerror=()=>{l(new Error("Failed to load image")),URL.revokeObjectURL(c.src)},c.src=URL.createObjectURL(s)})}async function o(s,i,l,c={}){const{maxSize:d=400}=c,u=await t(s),f=await e(),p=Math.min(1,d/Math.max(u.width,u.height));let h=Math.round(u.width*p),m=Math.round(u.height*p);const g=w.Grid.read(f);g.enabled&&(h=Math.max(g.colWidth,Math.round(h/g.colWidth)*g.colWidth),m=Math.max(g.rowHeight,Math.round(m/g.rowHeight)*g.rowHeight));const y=w.createEntity(f);w.addComponent(f,y,w.Block);const k=w.Block.write(f,y);k.tag="image",k.position[0]=i-h/2,k.position[1]=l-m/2,k.size[0]=h,k.size[1]=m,w.Grid.snapPosition(f,k.position);const b=crypto.randomUUID();w.addComponent(f,y,w.Asset);const C=w.Asset.write(f,y);C.identifier=b,C.uploadState=w.UploadState.Pending,w.addComponent(f,y,w.Image);const x=w.Image.write(f,y);return x.width=u.width,x.height=u.height,x.alt=s.name,w.addComponent(f,y,Le.Synced,{id:crypto.randomUUID()}),(n==null?void 0:n.getAssetManager())&&r(y,b,s),y}async function r(s,i,l){const c=n==null?void 0:n.getAssetManager();if(c)try{await c.upload(i,l,{filename:l.name,mimeType:l.type});const d=await e(),u=w.Asset.write(d,s);u.uploadState=w.UploadState.Complete}catch{const d=await e(),u=w.Asset.write(d,s);u.uploadState=w.UploadState.Failed}}return{getImageDimensions:t,createImageBlock:o}}const Gw=w.defineQuery(n=>n.with(w.Block,w.Edited,w.Text));function Yw(n){const e=typeof window<"u"?window.visualViewport:null;if(!e)return;const t=Mn();let o=null,r=!1;const s=40,i=.2;function l(){return e?window.innerHeight-e.height>window.innerHeight*i:!1}function c(){if(e){if(!l()){if(o&&r){const d=o;o=null,r=!1,n(u=>{const f=w.Camera.write(u);f.left=d.left,f.top=d.top}),t.repositionMenu()}return}n(d=>{const f=Gw.current(d)[Symbol.iterator]().next().value;if(!f)return;const p=w.Block.read(d,f),h=w.Camera.read(d);if(!p||!h)return;const m=h.zoom,g=(p.position[1]-h.top)*m,y=(p.position[1]+p.size[1]-h.top)*m,k=e.height,b=e.offsetTop,C=b,x=b+k;if(y+s<=x&&g>=C)return;o||(o={left:h.left,top:h.top});const E=p.position[1]+p.size[1]/2,M=b+k/2,S=E-M/m,v=w.Camera.write(d);v.top=S,r=!0,t.repositionMenu()})}}e.addEventListener("resize",c),a.onUnmounted(()=>{if(e.removeEventListener("resize",c),o&&r){const d=o;o=null,r=!1,n(u=>{const f=w.Camera.write(u);f.left=d.left,f.top=d.top})}})}function jf(n){const e=a.inject(ke);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const t=a.shallowRef([]),o=w.defineQuery(f=>f.with(...n)),r=new Map;let s=!1;function i(f){const p=e.getEditor();if(!p)return{refs:{},unsubscribes:[]};const h=p._getContext(),m={},g=[];for(const y of n){const k=a.shallowRef(y.snapshot(h,f));m[y.name]=k;const b=e.subscribeComponent(f,y.name,C=>{k.value=C});g.push(b)}return{refs:m,unsubscribes:g}}function l(f){const p=r.get(f);if(p){for(const h of p.unsubscribes)h();r.delete(f)}}function c(){const f=[];for(const[p,h]of r)f.push({entityId:p,...h.refs});return f}function d(f){if(!s){const g=o.current(f);for(const y of g)r.set(y,i(y));t.value=c(),s=!0;return}const p=o.added(f),h=o.removed(f);let m=!1;for(const g of h)l(g),m=!0;for(const g of p)r.has(g)||(r.set(g,i(g)),m=!0);m&&(t.value=c())}const u=e.registerTickCallback(d);return a.onUnmounted(()=>{u();for(const f of r.keys())l(f)}),t}function Ie(n){const e=a.inject(ke);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const t=a.shallowRef(n.default()),o=e.getEditor();if(o){const i=o._getContext();t.value=n.snapshot(i)}const r=e.subscribeSingleton(n.name,i=>{t.value=i??{}});let s=null;return o||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const l=i._getContext();t.value=n.snapshot(l),s==null||s(),s=null}})),a.onUnmounted(()=>{r(),s==null||s()}),t}function Bl(n,e,t){if(!n.closest(".wov-block")){const h=n.getBoundingClientRect();return{width:h.width,height:h.height,left:0,top:0}}const r=n.getBoundingClientRect(),s=t.value.left,i=t.value.top,l=new DOMPoint(r.left+r.width/2-s,r.top+r.height/2-i),c=e.value.zoom,d=new DOMMatrix;d.translateSelf(-e.value.left*c,-e.value.top*c),d.scaleSelf(c,c),d.invertSelf();const u=d.transformPoint(l),f=n.offsetWidth,p=n.offsetHeight;return{width:f,height:p,left:u.x-f/2,top:u.y-p/2}}const Oe=[Ju,Yu,Xu,Cl,Sf,Zu,ef,tf,wf.configure({openOnClick:!1}),bf.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function Xw(n){return n.type==="text"&&typeof n.text=="string"}function yt(n,e){if(Xw(n)){e(n);return}if(n.content)for(const t of n.content)yt(t,e)}function Il(n,e){if(n.type==="paragraph"){e(n);return}if(n.content)for(const t of n.content)Il(t,e)}function Qw(n,e){var t;return((t=n.marks)==null?void 0:t.some(o=>o.type===e))??!1}function Zw(n){var o,r;const e=(o=n.marks)==null?void 0:o.find(s=>s.type==="textStyle"),t=((r=e==null?void 0:e.attrs)==null?void 0:r.color)??null;return t?Df(t):null}function eb(n,e){if(!n.trim())return!1;const t=nt(n,Oe);let o=!1,r=!0,s=0;return yt(t,i=>{s++,Qw(i,e)?o=!0:r=!1}),s===0?!1:r?!0:o?null:!1}function tb(n){if(!n.trim())return"left";const e=nt(n,Oe);let t="left";return Il(e,o=>{var s;const r=(s=o.attrs)==null?void 0:s.textAlign;r&&(t=r)}),t}function nb(n){if(!n.trim())return null;const e=nt(n,Oe);let t=null;return yt(e,o=>{t===null&&(t=Zw(o))}),t}function Ol(n,e){if(!n.trim())return n;const t=nt(n,Oe);return yt(t,o=>{const r=o.marks??[];r.findIndex(i=>i.type===e)===-1&&(o.marks=[...r,{type:e}])}),qn(t,Oe)}function Rl(n,e){if(!n.trim())return n;const t=nt(n,Oe);return yt(t,o=>{const r=o.marks??[];o.marks=r.filter(s=>s.type!==e)}),qn(t,Oe)}function ob(n,e){if(!n.trim())return n;const t=nt(n,Oe);return Il(t,o=>{o.attrs={...o.attrs,textAlign:e}}),qn(t,Oe)}function rb(n,e){if(!n.trim())return n;const t=nt(n,Oe);return yt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="textStyle");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,color:e}},o.marks=r):o.marks=[...r,{type:"textStyle",attrs:{color:e}}]}),qn(t,Oe)}function sb(n){if(!n.trim())return null;const e=nt(n,Oe);let t=null;return yt(e,o=>{var r,s;if(t===null){const i=(r=o.marks)==null?void 0:r.find(l=>l.type==="link");(s=i==null?void 0:i.attrs)!=null&&s.href&&(t=i.attrs.href)}}),t}function ib(n,e){if(!n.trim())return n;const t=nt(n,Oe);return yt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="link");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,href:e}},o.marks=r):o.marks=[...r,{type:"link",attrs:{href:e,target:"_blank",rel:"noopener noreferrer"}}]}),qn(t,Oe)}function lb(n){if(!n.trim())return n;const e=nt(n,Oe);return yt(e,t=>{const o=t.marks??[];t.marks=o.filter(r=>r.type!=="link")}),qn(e,Oe)}function Wf(n){const e=document.querySelector(`[data-entity-id="${n}"]`);if(!e)return null;const t=e.firstElementChild;return t||e.querySelector(".wov-editable-text")}function Kf(n,e,t,o){var c;const r=n.cloneNode(!0);r.style.position="absolute",r.style.visibility="hidden",r.style.pointerEvents="none",r.style.top="0",r.style.left="0";const s=r.classList.contains("wov-editable-text")?r:r.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${o.fontSizePx}px`,s.style.fontFamily=o.fontFamily,s.style.lineHeight=String(o.lineHeight),s.style.letterSpacing=`${o.letterSpacingEm}em`);const i=r.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=o.content:s?s.innerHTML=o.content:r.innerHTML=o.content,(c=n.parentElement)==null||c.appendChild(r);const l=Bl(r,e,t);return r.remove(),l}function qf(n){const{nextEditorTick:e}=ce(),t=a.inject(ke),o=Pt(n,w.Text),r=Ie(w.Camera),s=Ie(w.Screen),i=Mn(),l={hasTextEntities:a.computed(()=>{for(const h of o.value.values())if(h)return!0;return!1}),hasTextContent:a.computed(()=>{for(const h of o.value.values()){if(!h)continue;const m=h.content?nt(h.content,Oe):null;if(m){let g=!1;if(yt(m,y=>{var k;(k=y.text)!=null&&k.trim()&&(g=!0)}),g)return!0}}return!1}),isBold:a.computed(()=>c("bold")),isItalic:a.computed(()=>c("italic")),isUnderline:a.computed(()=>c("underline")),alignment:a.computed(()=>{let h=null;for(const m of o.value.values()){if(!m)continue;const g=tb(m.content);if(h===null)h=g;else if(h!==g)return null}return h??"left"}),color:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values()){if(!g)continue;const y=nb(g.content);if(!m)h=y,m=!0;else if(h!==y)return null}return h}),fontSize:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values())if(g){if(!m)h=g.fontSizePx,m=!0;else if(h!==g.fontSizePx)return null}return h}),fontFamily:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values())if(g){if(!m)h=g.fontFamily,m=!0;else if(h!==g.fontFamily)return null}return h}),linkHref:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values()){if(!g)continue;const y=sb(g.content);if(!m)h=y,m=!0;else if(h!==y)return null}return h})};function c(h){let m=null,g=!1;for(const y of o.value.values()){if(!y)continue;const k=eb(y.content,h);if(!g)m=k,g=!0;else if(m!==k)return null}return m}const d={toggleBold(){f(h=>l.isBold.value?Rl(h,"bold"):Ol(h,"bold"))},toggleItalic(){f(h=>l.isItalic.value?Rl(h,"italic"):Ol(h,"italic"))},toggleUnderline(){f(h=>l.isUnderline.value?Rl(h,"underline"):Ol(h,"underline"))},setAlignment(h){p(m=>ob(m,h))},setColor(h){p(m=>rb(m,h))},setFontSize(h){u(m=>({...m,fontSizePx:h}),m=>{m.fontSizePx=h})},setFontFamily(h){t.setDefaults("text",{fontFamily:h}),u(m=>({...m,fontFamily:h}),m=>{m.fontFamily=h})},setTextStyle(h){const m={};h.fontFamily!==void 0&&(m.fontFamily=h.fontFamily),h.fontSizePx!==void 0&&(m.fontSizePx=h.fontSizePx),h.lineHeight!==void 0&&(m.lineHeight=h.lineHeight),h.letterSpacingEm!==void 0&&(m.letterSpacingEm=h.letterSpacingEm),Object.keys(m).length>0&&t.setDefaults("text",m),u(g=>({...g,fontFamily:h.fontFamily??g.fontFamily,fontSizePx:h.fontSizePx??g.fontSizePx,lineHeight:h.lineHeight??g.lineHeight,letterSpacingEm:h.letterSpacingEm??g.letterSpacingEm}),g=>{h.fontFamily!==void 0&&(g.fontFamily=h.fontFamily),h.fontSizePx!==void 0&&(g.fontSizePx=h.fontSizePx),h.lineHeight!==void 0&&(g.lineHeight=h.lineHeight),h.letterSpacingEm!==void 0&&(g.letterSpacingEm=h.letterSpacingEm)})},setLink(h){p(m=>ib(m,h))},removeLink(){p(h=>lb(h))}};function u(h,m){const g=a.toValue(n),y=[];for(const k of g){const b=o.value.get(k);if(!b)continue;const C=Wf(k);if(C){const x=Kf(C,r,s,h(b));y.push({entityId:k,...x})}}e(k=>{for(const b of g)m(w.Text.write(k,b));for(const{entityId:b,width:C,height:x,left:E,top:M}of y){const S=w.Block.write(k,b);S.size=[C,x],S.position=[E,M]}a.nextTick(()=>{var b;i.updateCounter.value++,(b=i.editor.value)==null||b.commands.focus()})})}function f(h){const m=a.toValue(n),g=[];for(const y of m){const k=o.value.get(y);if(!k)continue;const b=h(k.content),C=Wf(y);if(C){const x=Kf(C,r,s,{...k,content:b});g.push({entityId:y,content:b,...x})}else g.push({entityId:y,content:b,width:0,height:0,left:0,top:0})}e(y=>{for(const{entityId:k,content:b,width:C,height:x,left:E,top:M}of g){const S=w.Text.write(y,k);if(S.content=b,C>0&&x>0){const v=w.Block.write(y,k);v.size=[C,x],v.position=[E,M]}}})}function p(h){const m=a.toValue(n);e(g=>{for(const y of m){const k=w.Text.write(g,y);k.content=h(k.content)}})}return{state:l,commands:d}}function rt(n){const e=Mn(),t=qf(n),o=e.state.hasEditor;return{state:a.reactive({hasTextToFormat:a.computed(()=>o.value||t.state.hasTextEntities.value),hasEditor:o,hasTextContent:a.computed(()=>t.state.hasTextContent.value),showTextMenuButtons:a.computed(()=>o.value||t.state.hasTextContent.value),isBold:a.computed(()=>o.value?e.state.isBold.value:t.state.isBold.value===!0),isItalic:a.computed(()=>o.value?e.state.isItalic.value:t.state.isItalic.value===!0),isUnderline:a.computed(()=>o.value?e.state.isUnderline.value:t.state.isUnderline.value===!0),alignment:a.computed(()=>o.value?e.state.alignment.value:t.state.alignment.value??"left"),color:a.computed(()=>o.value?e.state.color.value:t.state.color.value),fontSize:a.computed(()=>t.state.fontSize.value),fontFamily:a.computed(()=>t.state.fontFamily.value),linkHref:a.computed(()=>o.value?e.state.linkHref.value:t.state.linkHref.value)}),commands:{toggleBold(){o.value?e.commands.toggleBold():t.commands.toggleBold()},toggleItalic(){o.value?e.commands.toggleItalic():t.commands.toggleItalic()},toggleUnderline(){o.value?e.commands.toggleUnderline():t.commands.toggleUnderline()},setAlignment(i){o.value?e.commands.setAlignment(i):t.commands.setAlignment(i)},setColor(i){o.value?e.commands.setColor(i):t.commands.setColor(i)},setFontSize(i){t.commands.setFontSize(i)},setFontFamily(i){t.commands.setFontFamily(i)},setTextStyle(i){t.commands.setTextStyle(i)},setLink(i){o.value?e.commands.setLink(i):t.commands.setLink(i)},removeLink(){o.value?e.commands.removeLink():t.commands.removeLink()}}}}function Pl(n){const e=Ie(w.Camera),t=Ie(w.Screen),o=Ie(te.TransformBoxStateSingleton),r=Ie(te.SelectionStateSingleton),{nextEditorTick:s}=ce();let i=!1,l=null;function c(u,f){const{entityId:p}=a.toValue(n.blockData),h=a.toValue(n.minWidth)??0,m=a.toValue(n.minHeight)??0,g=Math.max(f.width,h),y=Math.max(f.height,m),k=w.Block.read(u,p),b=Math.abs(k.size[0]-g)>.5,C=Math.abs(k.size[1]-y)>.5;if(!b&&!C)return;const x=w.Block.write(u,p);x.size=[g,y],x.position=[f.left,f.top],o.value.transformBoxId!==null&&te.UpdateTransformBox.spawn(u,{transformBoxId:o.value.transformBoxId})}a.watch(()=>r.value,()=>{s(u=>{const f=ab(u);if(i&&!f){const p=n.containerRef.value;if(!p)return;l=Bl(p,e,t),c(u,l),l=null}i=f})},{flush:"sync"});function d(u){const{content:f,...p}=u;s(h=>{const{entityId:m}=a.toValue(n.blockData);if(w.Text.read(h,m).content!==f){const y=w.Text.write(h,m);y.content=f}c(h,p)})}return{handleEditEnd:d}}function ab(n){const e=te.SelectionStateSingleton.read(n);return e.state===te.SelectionState.Dragging&&e.draggedEntity!==null&&w.hasComponent(n,e.draggedEntity,te.TransformHandle)&&te.TransformHandle.read(n,e.draggedEntity).kind===te.TransformHandleKind.Stretch}function gs(){const n=a.inject(Vs);if(!n)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:n.activeTool,heldTool:n.heldTool,setTool:n.setTool,dragOutTool:n.dragOutTool,onToolPointerDown:n.onToolPointerDown,onToolPointerUp:n.onToolPointerUp,isActive:e=>a.computed(()=>n.activeTool.value===e)}}const cb=500,db=1500;function Jf(){const n=a.ref(null),e=a.ref(!1),t=a.ref(!1);let o=null,r=null;function s(){o&&(clearTimeout(o),o=null),r&&(clearTimeout(r),r=null)}function i(d,u){s(),n.value={text:d,anchor:u},t.value?e.value=!0:o=setTimeout(()=>{e.value=!0,t.value=!0,o=null},cb)}function l(){s(),e.value=!1,n.value=null,t.value&&(r=setTimeout(()=>{t.value=!1,r=null},db))}function c(){s(),e.value=!1,n.value=null,t.value=!1}return{activeTooltip:a.readonly(n),isVisible:a.readonly(e),isWarmedUp:a.readonly(t),show:i,hide:l,reset:c}}function Dt(){const n=a.inject(fa);if(!n)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return n}const ub={key:1},fb=["innerHTML"],ys=a.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(n,{expose:e,emit:t}){var S;const o=n,r=t,s=me(o.entityId,w.Text),i=Ie(w.Camera),l=Ie(w.Screen),c=Mn(),{nextEditorTick:d}=ce(),u=Ie(w.Mouse),f=a.ref(null);e({editableTextRef:f});const p=a.ref(((S=s.value)==null?void 0:S.content)??""),h=a.shallowRef(null);async function m(){var F,J;f.value&&(f.value.style.opacity="0");const v=await d(),T=w.Block.read(v,o.entityId),B=(((F=l.value)==null?void 0:F.width)??ps)/(((J=i.value)==null?void 0:J.zoom)??1),P=Math.min(ps,B/2),O=Math.max(T.size[0],P),_=w.Block.write(v,o.entityId);_.size=[O,T.size[1]];const $=w.Text.write(v,o.entityId);$.constrainWidth=!0,w.ResetKeyboard.spawn(v),requestAnimationFrame(()=>{f.value&&(f.value.style.opacity=""),requestAnimationFrame(()=>{c.updateCounter.value++})})}function g(v,T){var $,F,J;const B=s.value;if(!B)return!1;const P=(($=T.clipboardData)==null?void 0:$.getData("text/html"))??"",O=((F=T.clipboardData)==null?void 0:F.getData("text/plain"))??"";if(!/<[^>]+data-pm-slice=/.test(P)){T.preventDefault();const K=O.trimEnd().split(/\r?\n/).map(U=>({type:"paragraph",content:U?[{type:"text",text:U}]:[]}));return(J=h.value)==null||J.commands.insertContent(K),!B.constrainWidth&&O.length>vl&&m(),!0}return!B.constrainWidth&&O.length>vl&&m(),!1}function y(){var v,T;return new Ck({extensions:[Ju,Yu,Xu,Cl,Sf,Zu,ef,tf,wf.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),bf.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((v=s.value)==null?void 0:v.defaultAlignment)??"left"}),Dw],content:((T=s.value)==null?void 0:T.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:g}})}a.watch(()=>o.edited,async v=>{if(v&&f.value){if(h.value=y(),await k(h.value),!o.blockElement)return;c.register(h.value,f.value,o.blockElement)}else h.value&&(c.unregister(),b(h.value),h.value.destroy(),h.value=null)},{immediate:!0});async function k(v){var O;const T=(O=u.value)==null?void 0:O.position,B=l.value;await a.nextTick(),await new Promise(_=>requestAnimationFrame(_));const P=f.value;if(T&&B&&P){const _=T[0]+B.left,$=T[1]+B.top,F=v.view.posAtCoords({left:_,top:$});if(F){v.chain().focus().setTextSelection(F.pos).run();return}}v.commands.focus("start")}function b(v){let T=v.getHTML();const P=T.replace(/<[^>]*>/g,"").trim().length>0;P||(T=""),p.value=T,d(O=>{var K,U;const _=w.getBlockDef(O,o.block.tag);if(!P&&((K=_.editOptions)!=null&&K.removeWhenTextEmpty)){w.removeEntity(O,o.entityId);return}const $=(U=f.value)==null?void 0:U.closest(".wov-block"),F=($==null?void 0:$.firstElementChild)??f.value;if(!F){console.warn("EditableText: no element to measure");return}const J=Bl(F,i,l);r("editEnd",{content:T,...J})})}a.watch(()=>{var v;return(v=s.value)==null?void 0:v.content},v=>{v!==void 0&&(h.value?h.value.getHTML()!==v&&h.value.commands.setContent(v,{emitUpdate:!1}):p.value=v)});const C=a.computed(()=>{const v=s.value;if(!v)return{};const[T,B]=o.block.flip,P=T?-1:1,O=B?-1:1,_=T||B;return{fontFamily:v.fontFamily,fontSize:`${v.fontSizePx}px`,lineHeight:v.lineHeight,letterSpacing:`${v.letterSpacingEm}em`,width:v.constrainWidth?"100%":"fit-content",whiteSpace:v.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:o.edited?"auto":"none",userSelect:o.edited?"auto":"none",transform:_?`scale(${P}, ${O})`:void 0}});function x(v){v.key==="Control"||v.key==="Meta"||v.stopPropagation()}function E(v){o.edited&&v.stopPropagation()}function M(v){if(o.edited)return;const T=v.target.closest("a");if(!T)return;const B=T.getAttribute("href");B&&(v.preventDefault(),v.stopPropagation(),window.open(B,"_blank","noopener,noreferrer"))}return a.onUnmounted(()=>{h.value&&(c.unregister(),h.value.destroy(),h.value=null)}),(v,T)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:a.normalizeStyle(C.value),onKeydown:x,onPointerdown:E,onPointermove:E,onPointerup:E,onClick:M},[h.value?(a.openBlock(),a.createBlock(a.unref(xk),{key:0,editor:h.value},null,8,["editor"])):(a.openBlock(),a.createElementBlock("div",ub,[a.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:p.value},null,8,fb)]))],36))}}),hb={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},pb=["d","fill","stroke","stroke-width","stroke-dasharray"],Gf=a.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=me(e.entityId,w.Shape),o=me(e.entityId,w.VerticalAlign),r=a.ref(null),s={[w.VerticalAlignment.Top]:"flex-start",[w.VerticalAlignment.Center]:"center",[w.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>t.value?`rgba(${t.value.fillRed}, ${t.value.fillGreen}, ${t.value.fillBlue}, ${(t.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),l=a.computed(()=>t.value?t.value.strokeKind===w.StrokeKind.None?"none":`rgba(${t.value.strokeRed}, ${t.value.strokeGreen}, ${t.value.strokeBlue}, ${t.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),c=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeWidth)??2}),d=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeKind)??w.StrokeKind.Solid}),u=a.computed(()=>{var g;return so[((g=t.value)==null?void 0:g.kind)??"rectangle"]??so.rectangle}),f=a.computed(()=>{const g=c.value;switch(d.value){case w.StrokeKind.Dashed:return`${g*3} ${g*3}`;case w.StrokeKind.None:return"";default:return""}}),p=a.computed(()=>{var g;return{overflow:e.edited?"visible":"hidden",alignItems:s[((g=o.value)==null?void 0:g.value)??w.VerticalAlignment.Top]}}),{nextEditorTick:h}=ce();function m(g){h(y=>{if(w.Text.read(y,e.entityId).content===g.content)return;const b=w.Text.write(y,e.entityId);b.content=g.content})}return(g,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-shape-block"},[(a.openBlock(),a.createElementBlock("svg",hb,[a.createElementVNode("path",{d:u.value,fill:i.value,stroke:l.value,"stroke-width":c.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,pb)])),a.createElementVNode("div",{class:"wov-shape-content",style:a.normalizeStyle(p.value)},[a.createVNode(ys,a.mergeProps(e,{"block-element":r.value,onEditEnd:m}),null,16,["block-element"])],4)],512))}}),mb={class:"wov-tape-block"},gb={key:0,class:"wov-tape-placeholder"},Yf=a.defineComponent({__name:"TapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},async setup(n){let e,t;const o=n,r=a.inject(ke);if(!r)throw new Error("TapeBlock must be used within a WovenCanvas component");const s=r,i=me(o.entityId,w.Asset),l=s.getAssetManager(),c=i.value;let d=null;l&&(c!=null&&c.identifier)&&(d=([e,t]=a.withAsyncContext(()=>l.getDisplayUrl(c.identifier)),e=await e,t(),e));const u=a.ref(d),f=a.ref(!d),p=a.ref(!1);let h=!0;a.onUnmounted(()=>{h=!1});async function m(){const g=s.getAssetManager();if(!g)return;const y=i.value;if(!y||!y.identifier){f.value=!1;return}try{f.value=!0,p.value=!1;const k=await g.getDisplayUrl(y.identifier);if(!h)return;k?(u.value=k,f.value=!1):y.uploadState===w.UploadState.Failed&&(p.value=!0,f.value=!1)}catch(k){if(!h)return;console.error("Failed to get tape display URL:",k),p.value=!0,f.value=!1}}return a.watch(()=>i.value,()=>{m()},{immediate:!0}),a.onMounted(()=>{m()}),(g,y)=>(a.openBlock(),a.createElementBlock("div",mb,[f.value&&!u.value?(a.openBlock(),a.createElementBlock("div",gb)):u.value?(a.openBlock(),a.createElementBlock("div",{key:1,class:"wov-tape-image",style:a.normalizeStyle({backgroundImage:`url(${u.value})`})},null,4)):a.createCommentVNode("",!0)]))}}),yb=["data-text-empty"],Xf=a.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=me(e.entityId,w.Text),r=a.computed(()=>{var d;return(((d=o.value)==null?void 0:d.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),s=a.computed(()=>{var l;return((l=o.value)==null?void 0:l.constrainWidth)??!1}),{handleEditEnd:i}=Pl({blockData:e,containerRef:t});return(l,c)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-text-block","data-text-empty":r.value||void 0,style:a.normalizeStyle({width:s.value?"100%":"fit-content"})},[a.createVNode(ys,a.mergeProps(e,{"block-element":t.value,onEditEnd:a.unref(i)}),null,16,["block-element","onEditEnd"])],12,yb))}}),ks=Math.min,Tn=Math.max,ws=Math.round,bs=Math.floor,kt=n=>({x:n,y:n}),kb={left:"right",right:"left",bottom:"top",top:"bottom"},wb={start:"end",end:"start"};function Qf(n,e,t){return Tn(n,ks(e,t))}function Cs(n,e){return typeof n=="function"?n(e):n}function Nn(n){return n.split("-")[0]}function xs(n){return n.split("-")[1]}function Zf(n){return n==="x"?"y":"x"}function eh(n){return n==="y"?"height":"width"}const bb=new Set(["top","bottom"]);function nn(n){return bb.has(Nn(n))?"y":"x"}function th(n){return Zf(nn(n))}function Cb(n,e,t){t===void 0&&(t=!1);const o=xs(n),r=th(n),s=eh(r);let i=r==="x"?o===(t?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=Ss(i)),[i,Ss(i)]}function xb(n){const e=Ss(n);return[Dl(n),e,Dl(e)]}function Dl(n){return n.replace(/start|end/g,e=>wb[e])}const nh=["left","right"],oh=["right","left"],Sb=["top","bottom"],Eb=["bottom","top"];function vb(n,e,t){switch(n){case"top":case"bottom":return t?e?oh:nh:e?nh:oh;case"left":case"right":return e?Sb:Eb;default:return[]}}function Mb(n,e,t,o){const r=xs(n);let s=vb(Nn(n),t==="start",o);return r&&(s=s.map(i=>i+"-"+r),e&&(s=s.concat(s.map(Dl)))),s}function Ss(n){return n.replace(/left|right|bottom|top/g,e=>kb[e])}function Tb(n){return{top:0,right:0,bottom:0,left:0,...n}}function Nb(n){return typeof n!="number"?Tb(n):{top:n,right:n,bottom:n,left:n}}function Es(n){const{x:e,y:t,width:o,height:r}=n;return{width:o,height:r,top:t,left:e,right:e+o,bottom:t+r,x:e,y:t}}function rh(n,e,t){let{reference:o,floating:r}=n;const s=nn(e),i=th(e),l=eh(i),c=Nn(e),d=s==="y",u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,p=o[l]/2-r[l]/2;let h;switch(c){case"top":h={x:u,y:o.y-r.height};break;case"bottom":h={x:u,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:f};break;case"left":h={x:o.x-r.width,y:f};break;default:h={x:o.x,y:o.y}}switch(xs(e)){case"start":h[i]-=p*(t&&d?-1:1);break;case"end":h[i]+=p*(t&&d?-1:1);break}return h}async function Ab(n,e){var t;e===void 0&&(e={});const{x:o,y:r,platform:s,rects:i,elements:l,strategy:c}=n,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=Cs(e,n),m=Nb(h),y=l[p?f==="floating"?"reference":"floating":f],k=Es(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(y)))==null||t?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),b=f==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},E=Es(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:C,strategy:c}):b);return{top:(k.top-E.top+m.top)/x.y,bottom:(E.bottom-k.bottom+m.bottom)/x.y,left:(k.left-E.left+m.left)/x.x,right:(E.right-k.right+m.right)/x.x}}const Bb=async(n,e,t)=>{const{placement:o="bottom",strategy:r="absolute",middleware:s=[],platform:i}=t,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let d=await i.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:f}=rh(d,o,c),p=o,h={},m=0;for(let y=0;y<l.length;y++){var g;const{name:k,fn:b}=l[y],{x:C,y:x,data:E,reset:M}=await b({x:u,y:f,initialPlacement:o,placement:p,strategy:r,middlewareData:h,rects:d,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:Ab},elements:{reference:n,floating:e}});u=C??u,f=x??f,h={...h,[k]:{...h[k],...E}},M&&m<=50&&(m++,typeof M=="object"&&(M.placement&&(p=M.placement),M.rects&&(d=M.rects===!0?await i.getElementRects({reference:n,floating:e,strategy:r}):M.rects),{x:u,y:f}=rh(d,p,c)),y=-1)}return{x:u,y:f,placement:p,strategy:r,middlewareData:h}},Ib=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,o;const{placement:r,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=Cs(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const k=Nn(r),b=nn(l),C=Nn(l)===l,x=await(c.isRTL==null?void 0:c.isRTL(d.floating)),E=p||(C||!g?[Ss(l)]:xb(l)),M=m!=="none";!p&&M&&E.push(...Mb(l,g,m,x));const S=[l,...E],v=await c.detectOverflow(e,y),T=[];let B=((o=s.flip)==null?void 0:o.overflows)||[];if(u&&T.push(v[k]),f){const $=Cb(r,i,x);T.push(v[$[0]],v[$[1]])}if(B=[...B,{placement:r,overflows:T}],!T.every($=>$<=0)){var P,O;const $=(((P=s.flip)==null?void 0:P.index)||0)+1,F=S[$];if(F&&(!(f==="alignment"?b!==nn(F):!1)||B.every(U=>nn(U.placement)===b?U.overflows[0]>0:!0)))return{data:{index:$,overflows:B},reset:{placement:F}};let J=(O=B.filter(K=>K.overflows[0]<=0).sort((K,U)=>K.overflows[1]-U.overflows[1])[0])==null?void 0:O.placement;if(!J)switch(h){case"bestFit":{var _;const K=(_=B.filter(U=>{if(M){const j=nn(U.placement);return j===b||j==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(j=>j>0).reduce((j,Q)=>j+Q,0)]).sort((U,j)=>U[1]-j[1])[0])==null?void 0:_[0];K&&(J=K);break}case"initialPlacement":J=l;break}if(r!==J)return{reset:{placement:J}}}return{}}}},Ob=new Set(["left","top"]);async function Rb(n,e){const{placement:t,platform:o,elements:r}=n,s=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Nn(t),l=xs(t),c=nn(t)==="y",d=Ob.has(i)?-1:1,u=s&&c?-1:1,f=Cs(e,n);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof m=="number"&&(h=l==="end"?m*-1:m),c?{x:h*u,y:p*d}:{x:p*d,y:h*u}}const Pb=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,o;const{x:r,y:s,placement:i,middlewareData:l}=e,c=await Rb(e,n);return i===((t=l.offset)==null?void 0:t.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:i}}}}},Db=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:o,placement:r,platform:s}=e,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:k=>{let{x:b,y:C}=k;return{x:b,y:C}}},...d}=Cs(n,e),u={x:t,y:o},f=await s.detectOverflow(e,d),p=nn(Nn(r)),h=Zf(p);let m=u[h],g=u[p];if(i){const k=h==="y"?"top":"left",b=h==="y"?"bottom":"right",C=m+f[k],x=m-f[b];m=Qf(C,m,x)}if(l){const k=p==="y"?"top":"left",b=p==="y"?"bottom":"right",C=g+f[k],x=g-f[b];g=Qf(C,g,x)}const y=c.fn({...e,[h]:m,[p]:g});return{...y,data:{x:y.x-t,y:y.y-o,enabled:{[h]:i,[p]:l}}}}}};function vs(){return typeof window<"u"}function An(n){return _l(n)?(n.nodeName||"").toLowerCase():"#document"}function We(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function wt(n){var e;return(e=(_l(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function _l(n){return vs()?n instanceof Node||n instanceof We(n).Node:!1}function st(n){return vs()?n instanceof Element||n instanceof We(n).Element:!1}function bt(n){return vs()?n instanceof HTMLElement||n instanceof We(n).HTMLElement:!1}function sh(n){return!vs()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof We(n).ShadowRoot}const _b=new Set(["inline","contents"]);function Uo(n){const{overflow:e,overflowX:t,overflowY:o,display:r}=it(n);return/auto|scroll|overlay|hidden|clip/.test(e+o+t)&&!_b.has(r)}const Lb=new Set(["table","td","th"]);function Vb(n){return Lb.has(An(n))}const $b=[":popover-open",":modal"];function Ms(n){return $b.some(e=>{try{return n.matches(e)}catch{return!1}})}const zb=["transform","translate","scale","rotate","perspective"],Fb=["transform","translate","scale","rotate","perspective","filter"],Hb=["paint","layout","strict","content"];function Ll(n){const e=Vl(),t=st(n)?it(n):n;return zb.some(o=>t[o]?t[o]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||Fb.some(o=>(t.willChange||"").includes(o))||Hb.some(o=>(t.contain||"").includes(o))}function Ub(n){let e=on(n);for(;bt(e)&&!Xn(e);){if(Ll(e))return e;if(Ms(e))return null;e=on(e)}return null}function Vl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jb=new Set(["html","body","#document"]);function Xn(n){return jb.has(An(n))}function it(n){return We(n).getComputedStyle(n)}function Ts(n){return st(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function on(n){if(An(n)==="html")return n;const e=n.assignedSlot||n.parentNode||sh(n)&&n.host||wt(n);return sh(e)?e.host:e}function ih(n){const e=on(n);return Xn(e)?n.ownerDocument?n.ownerDocument.body:n.body:bt(e)&&Uo(e)?e:ih(e)}function jo(n,e,t){var o;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=ih(n),s=r===((o=n.ownerDocument)==null?void 0:o.body),i=We(r);if(s){const l=$l(i);return e.concat(i,i.visualViewport||[],Uo(r)?r:[],l&&t?jo(l):[])}return e.concat(r,jo(r,[],t))}function $l(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function lh(n){const e=it(n);let t=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=bt(n),s=r?n.offsetWidth:t,i=r?n.offsetHeight:o,l=ws(t)!==s||ws(o)!==i;return l&&(t=s,o=i),{width:t,height:o,$:l}}function zl(n){return st(n)?n:n.contextElement}function Qn(n){const e=zl(n);if(!bt(e))return kt(1);const t=e.getBoundingClientRect(),{width:o,height:r,$:s}=lh(e);let i=(s?ws(t.width):t.width)/o,l=(s?ws(t.height):t.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Wb=kt(0);function ah(n){const e=We(n);return!Vl()||!e.visualViewport?Wb:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Kb(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==We(n)?!1:e}function Bn(n,e,t,o){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=zl(n);let i=kt(1);e&&(o?st(o)&&(i=Qn(o)):i=Qn(n));const l=Kb(s,t,o)?ah(s):kt(0);let c=(r.left+l.x)/i.x,d=(r.top+l.y)/i.y,u=r.width/i.x,f=r.height/i.y;if(s){const p=We(s),h=o&&st(o)?We(o):o;let m=p,g=$l(m);for(;g&&o&&h!==m;){const y=Qn(g),k=g.getBoundingClientRect(),b=it(g),C=k.left+(g.clientLeft+parseFloat(b.paddingLeft))*y.x,x=k.top+(g.clientTop+parseFloat(b.paddingTop))*y.y;c*=y.x,d*=y.y,u*=y.x,f*=y.y,c+=C,d+=x,m=We(g),g=$l(m)}}return Es({width:u,height:f,x:c,y:d})}function Ns(n,e){const t=Ts(n).scrollLeft;return e?e.left+t:Bn(wt(n)).left+t}function ch(n,e){const t=n.getBoundingClientRect(),o=t.left+e.scrollLeft-Ns(n,t),r=t.top+e.scrollTop;return{x:o,y:r}}function qb(n){let{elements:e,rect:t,offsetParent:o,strategy:r}=n;const s=r==="fixed",i=wt(o),l=e?Ms(e.floating):!1;if(o===i||l&&s)return t;let c={scrollLeft:0,scrollTop:0},d=kt(1);const u=kt(0),f=bt(o);if((f||!f&&!s)&&((An(o)!=="body"||Uo(i))&&(c=Ts(o)),bt(o))){const h=Bn(o);d=Qn(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const p=i&&!f&&!s?ch(i,c):kt(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-c.scrollLeft*d.x+u.x+p.x,y:t.y*d.y-c.scrollTop*d.y+u.y+p.y}}function Jb(n){return Array.from(n.getClientRects())}function Gb(n){const e=wt(n),t=Ts(n),o=n.ownerDocument.body,r=Tn(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=Tn(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let i=-t.scrollLeft+Ns(n);const l=-t.scrollTop;return it(o).direction==="rtl"&&(i+=Tn(e.clientWidth,o.clientWidth)-r),{width:r,height:s,x:i,y:l}}const dh=25;function Yb(n,e){const t=We(n),o=wt(n),r=t.visualViewport;let s=o.clientWidth,i=o.clientHeight,l=0,c=0;if(r){s=r.width,i=r.height;const u=Vl();(!u||u&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}const d=Ns(o);if(d<=0){const u=o.ownerDocument,f=u.body,p=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(o.clientWidth-f.clientWidth-h);m<=dh&&(s-=m)}else d<=dh&&(s+=d);return{width:s,height:i,x:l,y:c}}const Xb=new Set(["absolute","fixed"]);function Qb(n,e){const t=Bn(n,!0,e==="fixed"),o=t.top+n.clientTop,r=t.left+n.clientLeft,s=bt(n)?Qn(n):kt(1),i=n.clientWidth*s.x,l=n.clientHeight*s.y,c=r*s.x,d=o*s.y;return{width:i,height:l,x:c,y:d}}function uh(n,e,t){let o;if(e==="viewport")o=Yb(n,t);else if(e==="document")o=Gb(wt(n));else if(st(e))o=Qb(e,t);else{const r=ah(n);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Es(o)}function fh(n,e){const t=on(n);return t===e||!st(t)||Xn(t)?!1:it(t).position==="fixed"||fh(t,e)}function Zb(n,e){const t=e.get(n);if(t)return t;let o=jo(n,[],!1).filter(l=>st(l)&&An(l)!=="body"),r=null;const s=it(n).position==="fixed";let i=s?on(n):n;for(;st(i)&&!Xn(i);){const l=it(i),c=Ll(i);!c&&l.position==="fixed"&&(r=null),(s?!c&&!r:!c&&l.position==="static"&&!!r&&Xb.has(r.position)||Uo(i)&&!c&&fh(n,i))?o=o.filter(u=>u!==i):r=l,i=on(i)}return e.set(n,o),o}function e2(n){let{element:e,boundary:t,rootBoundary:o,strategy:r}=n;const i=[...t==="clippingAncestors"?Ms(e)?[]:Zb(e,this._c):[].concat(t),o],l=i[0],c=i.reduce((d,u)=>{const f=uh(e,u,r);return d.top=Tn(f.top,d.top),d.right=ks(f.right,d.right),d.bottom=ks(f.bottom,d.bottom),d.left=Tn(f.left,d.left),d},uh(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function t2(n){const{width:e,height:t}=lh(n);return{width:e,height:t}}function n2(n,e,t){const o=bt(e),r=wt(e),s=t==="fixed",i=Bn(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=kt(0);function d(){c.x=Ns(r)}if(o||!o&&!s)if((An(e)!=="body"||Uo(r))&&(l=Ts(e)),o){const h=Bn(e,!0,s,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop}else r&&d();s&&!o&&r&&d();const u=r&&!o&&!s?ch(r,l):kt(0),f=i.left+l.scrollLeft-c.x-u.x,p=i.top+l.scrollTop-c.y-u.y;return{x:f,y:p,width:i.width,height:i.height}}function Fl(n){return it(n).position==="static"}function hh(n,e){if(!bt(n)||it(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return wt(n)===t&&(t=t.ownerDocument.body),t}function ph(n,e){const t=We(n);if(Ms(n))return t;if(!bt(n)){let r=on(n);for(;r&&!Xn(r);){if(st(r)&&!Fl(r))return r;r=on(r)}return t}let o=hh(n,e);for(;o&&Vb(o)&&Fl(o);)o=hh(o,e);return o&&Xn(o)&&Fl(o)&&!Ll(o)?t:o||Ub(n)||t}const o2=async function(n){const e=this.getOffsetParent||ph,t=this.getDimensions,o=await t(n.floating);return{reference:n2(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function r2(n){return it(n).direction==="rtl"}const s2={convertOffsetParentRelativeRectToViewportRelativeRect:qb,getDocumentElement:wt,getClippingRect:e2,getOffsetParent:ph,getElementRects:o2,getClientRects:Jb,getDimensions:t2,getScale:Qn,isElement:st,isRTL:r2};function mh(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function i2(n,e){let t=null,o;const r=wt(n);function s(){var l;clearTimeout(o),(l=t)==null||l.disconnect(),t=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=n.getBoundingClientRect(),{left:u,top:f,width:p,height:h}=d;if(l||e(),!p||!h)return;const m=bs(f),g=bs(r.clientWidth-(u+p)),y=bs(r.clientHeight-(f+h)),k=bs(u),C={rootMargin:-m+"px "+-g+"px "+-y+"px "+-k+"px",threshold:Tn(0,ks(1,c))||1};let x=!0;function E(M){const S=M[0].intersectionRatio;if(S!==c){if(!x)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!mh(d,n.getBoundingClientRect())&&i(),x=!1}try{t=new IntersectionObserver(E,{...C,root:r.ownerDocument})}catch{t=new IntersectionObserver(E,C)}t.observe(n)}return i(!0),s}function As(n,e,t,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,d=zl(n),u=r||s?[...d?jo(d):[],...jo(e)]:[];u.forEach(k=>{r&&k.addEventListener("scroll",t,{passive:!0}),s&&k.addEventListener("resize",t)});const f=d&&l?i2(d,t):null;let p=-1,h=null;i&&(h=new ResizeObserver(k=>{let[b]=k;b&&b.target===d&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=h)==null||C.observe(e)})),t()}),d&&!c&&h.observe(d),h.observe(e));let m,g=c?Bn(n):null;c&&y();function y(){const k=Bn(n);g&&!mh(g,k)&&t(),g=k,m=requestAnimationFrame(y)}return t(),()=>{var k;u.forEach(b=>{r&&b.removeEventListener("scroll",t),s&&b.removeEventListener("resize",t)}),f==null||f(),(k=h)==null||k.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const Zn=Pb,eo=Db,to=Ib,l2=(n,e,t)=>{const o=new Map,r={platform:s2,...t},s={...r.platform,_c:o};return Bb(n,e,{...r,platform:s})};function a2(n){return n!=null&&typeof n=="object"&&"$el"in n}function gh(n){if(a2(n)){const e=n.$el;return _l(e)&&An(e)==="#comment"?null:e}return n}function Wo(n){return typeof n=="function"?n():a.unref(n)}function yh(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function kh(n,e){const t=yh(n);return Math.round(e*t)/t}function no(n,e,t){t===void 0&&(t={});const o=t.whileElementsMounted,r=a.computed(()=>{var S;return(S=Wo(t.open))!=null?S:!0}),s=a.computed(()=>Wo(t.middleware)),i=a.computed(()=>{var S;return(S=Wo(t.placement))!=null?S:"bottom"}),l=a.computed(()=>{var S;return(S=Wo(t.strategy))!=null?S:"absolute"}),c=a.computed(()=>{var S;return(S=Wo(t.transform))!=null?S:!0}),d=a.computed(()=>gh(n.value)),u=a.computed(()=>gh(e.value)),f=a.ref(0),p=a.ref(0),h=a.ref(l.value),m=a.ref(i.value),g=a.shallowRef({}),y=a.ref(!1),k=a.computed(()=>{const S={position:h.value,left:"0",top:"0"};if(!u.value)return S;const v=kh(u.value,f.value),T=kh(u.value,p.value);return c.value?{...S,transform:"translate("+v+"px, "+T+"px)",...yh(u.value)>=1.5&&{willChange:"transform"}}:{position:h.value,left:v+"px",top:T+"px"}});let b;function C(){if(d.value==null||u.value==null)return;const S=r.value;l2(d.value,u.value,{middleware:s.value,placement:i.value,strategy:l.value}).then(v=>{f.value=v.x,p.value=v.y,h.value=v.strategy,m.value=v.placement,g.value=v.middlewareData,y.value=S!==!1})}function x(){typeof b=="function"&&(b(),b=void 0)}function E(){if(x(),o===void 0){C();return}if(d.value!=null&&u.value!=null){b=o(d.value,u.value,C);return}}function M(){r.value||(y.value=!1)}return a.watch([s,i,l,r],C,{flush:"sync"}),a.watch([d,u],E,{flush:"sync"}),a.watch(r,M,{flush:"sync"}),a.getCurrentScope()&&a.onScopeDispose(x),{x:a.shallowReadonly(f),y:a.shallowReadonly(p),strategy:a.shallowReadonly(h),placement:a.shallowReadonly(m),middlewareData:a.shallowReadonly(g),isPositioned:a.shallowReadonly(y),floatingStyles:k,update:C}}const c2=["menu-open"],Ke=a.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(n,{emit:e}){const t=n,o=e,r=a.inject("containerRef"),s=a.inject(ca,null),i=a.inject(da,0),l=Math.random().toString(36).slice(2);a.provide(da,i+1);const{show:c,hide:d}=Dt(),u=a.ref(!1);s&&a.watch(()=>s.value.get(i),C=>{C!==void 0&&C!==l&&u.value&&(u.value=!1)});const f=a.ref(null),p=a.ref(null),{floatingStyles:h}=no(f,p,{placement:t.placement,middleware:[Zn(t.offsetPx),to(),eo({padding:8})],whileElementsMounted:As});function m(){t.disabled||(u.value=!u.value)}function g(){u.value=!1}function y(C){var v,T,B;const x=C.target,E=(v=f.value)==null?void 0:v.contains(x),M=(T=p.value)==null?void 0:T.contains(x),S=(B=x.closest)==null?void 0:B.call(x,".wov-menu-dropdown");!E&&!M&&!S&&g()}function k(){t.title&&f.value&&!u.value&&c(t.title,f.value)}function b(){d()}return a.watch(u,C=>{C?(d(),document.addEventListener("click",y,!0),s&&(s.value.set(i,l),s.value=new Map(s.value)),o("open")):(document.removeEventListener("click",y,!0),(s==null?void 0:s.value.get(i))===l&&(s.value.delete(i),s.value=new Map(s.value)),o("close"))}),a.onUnmounted(()=>{document.removeEventListener("click",y,!0)}),(C,x)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:a.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:x[0]||(x[0]=a.withModifiers(()=>{},["prevent"])),onClick:m,onMouseenter:k,onMouseleave:b},[a.renderSlot(C.$slots,"button",{isOpen:u.value})],42,c2),a.unref(r)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(r)},[u.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"wov-menu-dropdown",style:a.normalizeStyle(a.unref(h))},[a.renderSlot(C.$slots,"dropdown",{close:g})],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),d2={},u2={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function f2(n,e){return a.openBlock(),a.createElementBlock("svg",u2,[...e[0]||(e[0]=[a.createElementVNode("path",{d:"M233.4 278.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 210.7 86.6 41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"},null,-1)])])}const qe=an(d2,[["render",f2]]),h2={class:"wov-menu-button"},p2=["innerHTML"],m2=["onClick"],g2=["innerHTML"],Hl=a.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(n){const e=n,{nextEditorTick:t}=ce(),o=a.shallowRef(null),r=a.computed(()=>{const l=o.value??(e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V);return Rn(l)});t(l=>{let c=null;for(const d of e.entityIds){if(w.hasComponent(l,d,ee.ElbowArrow)){const u=ee.ElbowArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V;return}}if(w.hasComponent(l,d,ee.ArcArrow)){const u=ee.ArcArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V;return}}}o.value=c});function s(l){o.value=l,t(c=>{for(const d of e.entityIds){if(w.hasComponent(c,d,ee.ElbowArrow)){const u=ee.ElbowArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}if(w.hasComponent(c,d,ee.ArcArrow)){const u=ee.ArcArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}}})}function i(l){if(!l)return"";const c=e.side==="start";return`<line x1="${c?8:4}" y1="12" x2="${c?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${c?4:20}, 12) scale(${c?"-0.8, 0.8":"0.8"})`}">${l.svg}</g>`}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:n.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:a.withCtx(()=>[a.createElementVNode("div",h2,[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(r.value)},null,8,p2)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(a.unref(Ls),d=>(a.openBlock(),a.createElementBlock("button",{key:d.kind,class:a.normalizeClass(["wov-menu-option",{"is-active":o.value===d.kind}]),onClick:u=>s(d.kind)},[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(d)},null,8,g2))],10,m2))),128))]),_:1},8,["title"]))}}),y2={class:"wov-menu-button"},k2=["onClick"],wh=a.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],t=n,{nextEditorTick:o}=ce(),r=a.shallowRef(null);o(i=>{let l=null;for(const c of t.entityIds){if(w.hasComponent(i,c,ee.ElbowArrow)){const d=ee.ElbowArrow.read(i,c);if(l===null)l=d.thickness;else if(d.thickness!==l){r.value=null;return}}if(w.hasComponent(i,c,ee.ArcArrow)){const d=ee.ArcArrow.getThickness(i,c);if(l===null)l=d;else if(d!==l){r.value=null;return}}}r.value=l});function s(i){r.value=i,o(l=>{for(const c of t.entityIds){if(w.hasComponent(l,c,ee.ElbowArrow)){const d=ee.ElbowArrow.write(l,c);d.thickness=i}w.hasComponent(l,c,ee.ArcArrow)&&ee.ArcArrow.setThickness(l,c,i)}})}return(i,l)=>(a.openBlock(),a.createBlock(Ke,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",y2,[l[0]||(l[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,c=>a.createElementVNode("button",{key:c.value,class:a.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":r.value===c.value}]),onClick:d=>s(c.value)},a.toDisplayString(c.label),11,k2)),64))]),_:1}))}}),w2=["value"],b2=a.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(t.modelValue??"");a.watch(()=>t.modelValue,u=>{u&&u!==r.value&&(r.value=u)});function s(u){const f=u.startsWith("#")?u:`#${u}`;return/^#[0-9A-Fa-f]{6}$/.test(f)}function i(u){return(u.startsWith("#")?u:`#${u}`).toLowerCase()}function l(u){let p=u.target.value;if((p.length===6||p.length===7)&&s(p)){const h=i(p);r.value=h,o("update:modelValue",h)}}function c(u){const p=u.target.value;if(p&&s(p)){const h=i(p);r.value=h,o("update:modelValue",h)}else t.modelValue&&(r.value=t.modelValue)}function d(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,p=f.value;if(p&&s(p)){const h=i(p);r.value=h,o("update:modelValue",h),setTimeout(()=>f.select())}}}return(u,f)=>(a.openBlock(),a.createElementBlock("input",{id:"wov-color-input",class:"wov-color-input",type:"text",size:"1","aria-label":"Hex color value",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",value:r.value,onInput:l,onChange:c,onKeydown:d},null,40,w2))}}),C2={class:"wov-color-picker"},x2={class:"wov-color-picker-area"},S2={class:"wov-color-picker-selector-gradient"},E2="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",bh=a.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),s=a.ref(null),i=a.ref(null),l=a.ref({x:100,y:0}),c=a.ref(0),d=a.ref(0),u=a.ref(!1),f=a.computed(()=>{var M,S;return u.value||((M=r.value)==null?void 0:M.isDragging)||((S=s.value)==null?void 0:S.isDragging)}),p=a.computed(()=>({h:c.value/100*360,s:l.value.x,v:100-l.value.y,a:(100-d.value)/100*255})),h=a.computed(()=>Lf({h:p.value.h,s:100,v:100})),m=a.computed(()=>Lf({h:p.value.h,s:p.value.s,v:p.value.v})),g=a.computed(()=>t.withOpacity?Vf(p.value):m.value),y=a.computed(()=>`linear-gradient(to top, transparent 0%, ${m.value} 100%)`);function k(M){if(M){const S=_f(M);l.value={x:S.s,y:100-S.v},c.value=S.h/360*100,d.value=100-S.a/255*100}}function b(M){k(M),o("update:modelValue",t.withOpacity?Vf(_f(M)):M)}k(t.modelValue),a.watch(()=>t.modelValue,M=>{f.value||k(M)}),a.watch([l,c,d],()=>{f.value&&o("update:modelValue",g.value)});function C(M){u.value=!0,x(M),window.addEventListener("pointermove",x),window.addEventListener("pointerup",E)}function x(M){if(!i.value)return;const S=i.value.getBoundingClientRect(),v=Math.max(0,Math.min(100,(M.clientX-S.left)/S.width*100)),T=Math.max(0,Math.min(100,(M.clientY-S.top)/S.height*100));l.value={x:v,y:T}}function E(){u.value=!1,window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",E)}return(M,S)=>{const v=a.resolveComponent("ColorSlider");return a.openBlock(),a.createElementBlock("div",C2,[a.createVNode(b2,{modelValue:g.value,"onUpdate:modelValue":b},null,8,["modelValue"]),a.createElementVNode("div",x2,[a.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:a.normalizeStyle({backgroundColor:h.value}),onPointerdown:a.withModifiers(C,["prevent"])},[a.createElementVNode("div",S2,[a.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:a.normalizeStyle({left:`${l.value.x}%`,top:`${l.value.y}%`,backgroundColor:m.value})},null,4)])],36),a.createVNode(v,{ref_key:"hueSliderRef",ref:r,modelValue:c.value,"onUpdate:modelValue":S[0]||(S[0]=T=>c.value=T),thumbColor:h.value,background:E2},null,8,["modelValue","thumbColor"]),n.withOpacity?(a.openBlock(),a.createBlock(v,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:d.value,"onUpdate:modelValue":S[1]||(S[1]=T=>d.value=T),thumbColor:m.value,background:y.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):a.createCommentVNode("",!0)])])}}}),v2={class:"wov-color-bubbles-container"},M2={key:1,class:"wov-color-bubbles"},T2=["onClick"],Bs=a.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(n,{emit:e}){const t=n,o=e,r=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=a.computed(()=>{const m=t.palette??r,g=t.withPicker,y=m.length%2===1;return g&&!y||!g&&y?m.slice(0,-1):m}),i=a.ref(!1),l=a.ref(t.currentColor??"#ff0000");function c(m,g){const y=k=>{const b=k.replace(/^#/,"").toLowerCase();return b.length===6?`${b}ff`:b};return y(m)===y(g)}function d(m){return t.hideHighlight||!t.currentColor?!1:c(t.currentColor,m)}function u(){return t.hideHighlight||!t.currentColor?!1:!s.value.some(m=>c(t.currentColor,m))}function f(m){const g=Tl(m);g&&o("change",g)}function p(){!i.value&&t.currentColor&&(l.value=t.currentColor),i.value=!i.value,o("picker-open",i.value)}function h(m){l.value=m;const g=Tl(m);g&&o("change",g)}return(m,g)=>(a.openBlock(),a.createElementBlock("div",v2,[i.value?(a.openBlock(),a.createBlock(bh,{key:0,modelValue:l.value,"onUpdate:modelValue":[g[0]||(g[0]=y=>l.value=y),h],withOpacity:n.withOpacity},null,8,["modelValue","withOpacity"])):(a.openBlock(),a.createElementBlock("div",M2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,y=>(a.openBlock(),a.createElementBlock("div",{key:y,class:a.normalizeClass(["wov-color-bubble",{selected:d(y)}]),style:a.normalizeStyle({backgroundColor:y}),onMousedown:g[1]||(g[1]=a.withModifiers(()=>{},["prevent"])),onClick:k=>f(y)},null,46,T2))),128)),n.withPicker?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:g[2]||(g[2]=a.withModifiers(()=>{},["prevent"])),onClick:p},null,34)):a.createCommentVNode("",!0)]))]))}}),N2={class:"wov-color-button"},Ch=a.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=ce(),o=Pt(()=>e.entityIds,w.Color),r=a.computed(()=>{const d=new Set;for(const u of o.value.values())if(u){const f=Ho(u);d.add(f)}return Array.from(d)}),s=a.computed(()=>r.value.length>1),i=a.computed(()=>r.value[0]??null),l=a.computed(()=>{if(r.value.length===0)return{backgroundColor:"#000"};if(r.value.length>=2){const d=r.value[0],u=r.value[1];return{background:`linear-gradient(45deg, ${d} 0%, ${d} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:r.value[0]}});function c(d){const u=Ho(d);t(f=>{for(const p of e.entityIds)w.Color.fromHex(f,p,u)})}return(d,u)=>(a.openBlock(),a.createBlock(Ke,{title:"Color"},{button:a.withCtx(()=>[a.createElementVNode("div",N2,[a.createElementVNode("div",{class:"wov-color-swatch",style:a.normalizeStyle(l.value)},null,4),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(Bs,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:c},null,8,["currentColor","hideHighlight"])]),_:1}))}}),In=a.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),{show:s,hide:i}=Dt();function l(u){o("click",u)}function c(){t.title&&r.value&&s(t.title,r.value)}function d(){i()}return(u,f)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:"wov-menu-button",onClick:l,onMouseenter:c,onMouseleave:d},[a.renderSlot(u.$slots,"default")],544))}}),Ul=a.defineComponent({__name:"MenuTooltip",setup(n){const{activeTooltip:e,isVisible:t}=Dt(),o=a.inject("containerRef"),r=a.ref(null),s=a.computed(()=>{var c;return((c=e.value)==null?void 0:c.anchor)??null}),{floatingStyles:i}=no(s,r,{placement:"top",middleware:[Zn(8),to({fallbackPlacements:["bottom"]}),eo({padding:8})]}),l=a.computed(()=>{var c;return t.value&&((c=e.value)==null?void 0:c.text)});return(c,d)=>a.unref(o)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(o)},[a.createVNode(a.Transition,{name:"wov-tooltip-fade"},{default:a.withCtx(()=>{var u;return[l.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:r,class:"wov-menu-tooltip",style:a.normalizeStyle(a.unref(i))},a.toDisplayString((u=a.unref(e))==null?void 0:u.text),5)):a.createCommentVNode("",!0)]}),_:1})],8,["to"])):a.createCommentVNode("",!0)}}),A2={class:"wov-menu-button"},B2=["onClick"],xh=a.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],t=n,{nextEditorTick:o}=ce(),r=Pt(()=>t.entityIds,Jo.PenStroke),s=a.computed(()=>{let l=null;for(const c of r.value.values())if(c){if(l===null)l=c.thickness;else if(c.thickness!==l)return null}return l});function i(l){o(c=>{for(const d of t.entityIds){const u=Jo.PenStroke.write(c,d);u.thickness=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",A2,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("button",{key:d.value,class:a.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===d.value}]),onClick:u=>i(d.value)},a.toDisplayString(d.label),11,B2)),64))]),_:1}))}}),I2={class:"wov-fill-color-button"},O2={class:"wov-fill-dropdown"},R2={key:0,class:"wov-fill-mode-section"},P2=["title","onClick"],D2={viewBox:"0 0 24 24",fill:"none"},_2=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],Sh=a.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=ce(),o=Pt(()=>e.entityIds,w.Shape),r=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=a.computed(()=>{const h=o.value.values().next().value,m=(h==null?void 0:h.fillAlpha)??255;return m===0?"none":m<200?"faded":"solid"}),i=a.computed(()=>{const h=new Set;for(const m of o.value.values())if(m){const g=m.fillAlpha??255;g===0?h.add("none"):g<200?h.add("faded"):h.add("solid")}return h.size>1});function l(h){t(m=>{for(const g of e.entityIds){const y=w.Shape.write(m,g);y.fillAlpha=h}})}const c=a.computed(()=>{const h=new Set;for(const m of o.value.values())if(m){const g=Ho({red:m.fillRed,green:m.fillGreen,blue:m.fillBlue,alpha:m.fillAlpha??255});h.add(g)}return Array.from(h)}),d=a.computed(()=>c.value.length>1),u=a.computed(()=>c.value[0]??"#4a90d9");function f(h){t(m=>{for(const g of e.entityIds){const y=w.Shape.write(m,g);y.fillRed=h.red,y.fillGreen=h.green,y.fillBlue=h.blue,y.fillAlpha=h.alpha}})}const p=a.ref(!1);return(h,m)=>(a.openBlock(),a.createBlock(Ke,{title:"Fill Color"},{button:a.withCtx(()=>[a.createElementVNode("div",I2,[m[1]||(m[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M5.879,2.625L14.121,2.625C15.906,2.625 17.375,4.094 17.375,5.879L17.375,14.121C17.375,15.906 15.906,17.375 14.121,17.375L5.88,17.375C4.095,17.375 2.626,15.906 2.626,14.121L2.626,5.88C2.626,4.095 4.095,2.626 5.88,2.626L5.879,2.625Z","stroke-width":"1.25"}),a.createElementVNode("path",{d:"M2.779,14.655L14.543,2.871M10.238,17.308L17.318,10.229M2.876,9.577L9.853,2.6M5.397,17.239L17.16,5.476","stroke-width":"1.25"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",O2,[p.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",R2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,g=>a.createElementVNode("button",{key:g.mode,class:a.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&g.mode===s.value}]),title:g.label,onClick:y=>l(g.alpha)},[(a.openBlock(),a.createElementBlock("svg",D2,[a.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:g.mode==="none"?"none":"currentColor","fill-opacity":g.mode==="faded"?.4:1,stroke:g.mode==="none"?"currentColor":"none","stroke-width":g.mode==="none"?1.5:0,"stroke-dasharray":g.mode==="none"?"3 3":""},null,8,_2)])),a.createElementVNode("span",null,a.toDisplayString(g.label),1)],10,P2)),64))])),a.createVNode(Bs,{currentColor:u.value,hideHighlight:d.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:m[0]||(m[0]=g=>p.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),L2={class:"wov-shape-kind-button"},V2={class:"wov-shape-kind-dropdown"},$2=["onClick"],z2={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},F2=["d"],Eh=a.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=ce(),o=Pt(()=>e.entityIds,w.Shape),r=a.computed(()=>{const c=o.value.values().next().value;return(c==null?void 0:c.kind)??"rectangle"}),s=a.computed(()=>{const c=new Set;for(const d of o.value.values())d&&c.add(d.kind);return c.size>1}),i=a.computed(()=>Object.keys(so).map(c=>({kind:c,label:c.charAt(0).toUpperCase()+c.slice(1)})));function l(c){t(d=>{for(const u of e.entityIds){const f=w.Shape.write(d,u);f.kind=c}})}return(c,d)=>(a.openBlock(),a.createBlock(Ke,{title:"Shape Type"},{button:a.withCtx(()=>[a.createElementVNode("div",L2,[d[0]||(d[0]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),a.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",V2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,u=>(a.openBlock(),a.createElementBlock("button",{key:u.kind,class:a.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===r.value}]),onClick:f=>l(u.kind)},[(a.openBlock(),a.createElementBlock("svg",z2,[a.createElementVNode("path",{d:a.unref(so)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,F2)])),a.createElementVNode("span",null,a.toDisplayString(u.label),1)],10,$2))),128))])]),_:1}))}}),H2={class:"wov-stroke-style-section"},U2=["title","onClick"],j2={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},W2=["stroke-dasharray","stroke-opacity"],K2=a.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(n,{emit:e}){const t=e,o=[{kind:w.StrokeKind.Solid,label:"Solid"},{kind:w.StrokeKind.Dashed,label:"Dashed"},{kind:w.StrokeKind.None,label:"None"}];function r(i){switch(i){case w.StrokeKind.Dashed:return"6 6";case w.StrokeKind.None:return"";default:return""}}function s(i){t("change",i)}return(i,l)=>(a.openBlock(),a.createElementBlock("div",H2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(o,c=>a.createElementVNode("button",{key:c.kind,class:a.normalizeClass(["wov-stroke-style-option",{"is-active":!n.hasMultipleStyles&&c.kind===n.currentStyle}]),title:c.label,onClick:d=>s(c.kind)},[(a.openBlock(),a.createElementBlock("svg",j2,[a.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":r(c.kind),"stroke-opacity":c.kind===a.unref(w.StrokeKind).None?.3:1},null,8,W2)])),a.createElementVNode("span",null,a.toDisplayString(c.label),1)],10,U2)),64))]))}}),q2={class:"wov-stroke-color-button"},J2={class:"wov-stroke-dropdown"},G2={key:1,class:"wov-stroke-divider"},vh=a.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=ce(),o=Pt(()=>e.entityIds,w.Shape),r=a.ref(!1),s=a.computed(()=>{const p=new Set;for(const h of o.value.values())if(h){const m=Ho({red:h.strokeRed,green:h.strokeGreen,blue:h.strokeBlue,alpha:255});p.add(m)}return Array.from(p)}),i=a.computed(()=>s.value.length>1),l=a.computed(()=>s.value[0]??"#000000"),c=a.computed(()=>{const p=o.value.values().next().value;return(p==null?void 0:p.strokeKind)??w.StrokeKind.Solid}),d=a.computed(()=>{const p=new Set;for(const h of o.value.values())h&&p.add(h.strokeKind);return p.size>1});function u(p){t(h=>{for(const m of e.entityIds){const g=w.Shape.write(h,m);g.strokeRed=p.red,g.strokeGreen=p.green,g.strokeBlue=p.blue}})}function f(p){t(h=>{for(const m of e.entityIds){const g=w.Shape.write(h,m);g.strokeKind=p}})}return(p,h)=>(a.openBlock(),a.createBlock(Ke,{title:"Stroke Color"},{button:a.withCtx(()=>[a.createElementVNode("div",q2,[h[1]||(h[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43","stroke-width":"1.25"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",J2,[r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createBlock(K2,{key:0,currentStyle:c.value,hasMultipleStyles:d.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",G2)),a.createVNode(Bs,{currentColor:l.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:h[0]||(h[0]=m=>r.value=m)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),Y2={class:"wov-tape-image-button"},X2={class:"wov-tape-image-bubbles"},Q2=["onClick"],Mh=a.defineComponent({__name:"TapeImageButton",props:{entityIds:{}},setup(n){const e=[{name:"Masking Tape",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media"},{name:"Transparent",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F522899b7-0ae9-4303-bdca-71105d835210.png?generation=1715183195130528&alt=media"},{name:"Arabic",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F3658d208-67e9-48a4-865b-44842187b523.png?generation=1715183192038109&alt=media"},{name:"Balloons",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7d836c56-ae9a-44e6-a624-e6a49286dcde.png?generation=1715183193267076&alt=media"},{name:"Flowers",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2Fc1a1b89a-543f-4817-8afa-76544e94d776.png?generation=1715183194007112&alt=media"}],t=n,{nextEditorTick:o}=ce(),r=Pt(()=>t.entityIds,w.Asset),s=a.computed(()=>{for(const l of r.value.values())if(l!=null&&l.identifier)return l.identifier;return null});function i(l){o(c=>{for(const d of t.entityIds){const u=w.Asset.write(c,d);u.identifier=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:"Tape Style"},{button:a.withCtx(()=>[a.createElementVNode("div",Y2,[a.createElementVNode("div",{class:"wov-tape-image-swatch",style:a.normalizeStyle(s.value?{backgroundImage:`url(${s.value})`}:{})},null,4),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",X2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("div",{key:d.url,class:a.normalizeClass(["wov-tape-image-bubble",{selected:s.value===d.url}]),style:a.normalizeStyle({backgroundImage:`url(${d.url})`}),onMousedown:c[0]||(c[0]=a.withModifiers(()=>{},["prevent"])),onClick:u=>i(d.url)},null,46,Q2)),64))])]),_:1}))}}),Z2={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},eC={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},tC={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},nC={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},jl=a.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=[w.TextAlignment.Left,w.TextAlignment.Center,w.TextAlignment.Right,w.TextAlignment.Justify];function s(){const i=r.indexOf(t.alignment),l=r[(i+1)%r.length];o.setAlignment(l)}return(i,l)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(In,{key:0,title:"Text Align",onClick:s},{default:a.withCtx(()=>[a.unref(t).alignment===a.unref(w.TextAlignment).Left?(a.openBlock(),a.createElementBlock("svg",Z2,[...l[0]||(l[0]=[a.createElementVNode("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):a.unref(t).alignment===a.unref(w.TextAlignment).Center?(a.openBlock(),a.createElementBlock("svg",eC,[...l[1]||(l[1]=[a.createElementVNode("path",{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},null,-1)])])):a.unref(t).alignment===a.unref(w.TextAlignment).Right?(a.openBlock(),a.createElementBlock("svg",tC,[...l[2]||(l[2]=[a.createElementVNode("path",{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",nC,[...l[3]||(l[3]=[a.createElementVNode("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),Wl=a.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(In,{key:0,title:"Bold",class:a.normalizeClass({"wov-active":a.unref(t).isBold}),onClick:a.unref(o).toggleBold},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}});function oC(n,e){return a.getCurrentScope()?(a.onScopeDispose(n,e),!0):!1}const rC=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const sC=Object.prototype.toString,iC=n=>sC.call(n)==="[object Object]",Is=()=>{};function Os(n){return Array.isArray(n)?n:[n]}function lC(n){return a.getCurrentInstance()}function aC(n,e=!0,t){lC()?a.onMounted(n,t):e?n():a.nextTick(n)}function cC(n,e,t){return a.watch(n,e,{...t,immediate:!0})}const Rs=rC?window:void 0;function lt(n){var e;const t=a.toValue(n);return(e=t==null?void 0:t.$el)!==null&&e!==void 0?e:t}function Kl(...n){const e=(o,r,s,i)=>(o.addEventListener(r,s,i),()=>o.removeEventListener(r,s,i)),t=a.computed(()=>{const o=Os(a.toValue(n[0])).filter(r=>r!=null);return o.every(r=>typeof r!="string")?o:void 0});return cC(()=>{var o,r;return[(o=(r=t.value)===null||r===void 0?void 0:r.map(s=>lt(s)))!==null&&o!==void 0?o:[Rs].filter(s=>s!=null),Os(a.toValue(t.value?n[1]:n[0])),Os(a.unref(t.value?n[2]:n[1])),a.toValue(t.value?n[3]:n[2])]},([o,r,s,i],l,c)=>{if(!(o!=null&&o.length)||!(r!=null&&r.length)||!(s!=null&&s.length))return;const d=iC(i)?{...i}:i,u=o.flatMap(f=>r.flatMap(p=>s.map(h=>e(f,p,h,d))));c(()=>{u.forEach(f=>f())})},{flush:"post"})}function dC(n,e,t={}){const{window:o=Rs,ignore:r=[],capture:s=!0,detectIframe:i=!1,controls:l=!1}=t;if(!o)return l?{stop:Is,cancel:Is,trigger:Is}:Is;let c=!0;const d=y=>a.toValue(r).some(k=>{if(typeof k=="string")return Array.from(o.document.querySelectorAll(k)).some(b=>b===y.target||y.composedPath().includes(b));{const b=lt(k);return b&&(y.target===b||y.composedPath().includes(b))}});function u(y){const k=a.toValue(y);return k&&k.$.subTree.shapeFlag===16}function f(y,k){const b=a.toValue(y),C=b.$.subTree&&b.$.subTree.children;return C==null||!Array.isArray(C)?!1:C.some(x=>x.el===k.target||k.composedPath().includes(x.el))}const p=y=>{const k=lt(n);if(y.target!=null&&!(!(k instanceof Element)&&u(n)&&f(n,y))&&!(!k||k===y.target||y.composedPath().includes(k))){if("detail"in y&&y.detail===0&&(c=!d(y)),!c){c=!0;return}e(y)}};let h=!1;const m=[Kl(o,"click",y=>{h||(h=!0,setTimeout(()=>{h=!1},0),p(y))},{passive:!0,capture:s}),Kl(o,"pointerdown",y=>{const k=lt(n);c=!d(y)&&!!(k&&!y.composedPath().includes(k))},{passive:!0}),i&&Kl(o,"blur",y=>{setTimeout(()=>{var k;const b=lt(n);((k=o.document.activeElement)===null||k===void 0?void 0:k.tagName)==="IFRAME"&&!(b!=null&&b.contains(o.document.activeElement))&&e(y)},0)},{passive:!0})].filter(Boolean),g=()=>m.forEach(y=>y());return l?{stop:g,cancel:()=>{c=!1},trigger:y=>{c=!0,p(y),c=!1}}:g}function uC(){const n=a.shallowRef(!1),e=a.getCurrentInstance();return e&&a.onMounted(()=>{n.value=!0},e),n}function fC(n){const e=uC();return a.computed(()=>(e.value,!!n()))}function hC(n,e,t={}){const{window:o=Rs,...r}=t;let s;const i=fC(()=>o&&"ResizeObserver"in o),l=()=>{s&&(s.disconnect(),s=void 0)},c=a.watch(a.computed(()=>{const u=a.toValue(n);return Array.isArray(u)?u.map(f=>lt(f)):[lt(u)]}),u=>{if(l(),i.value&&o){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,r)}},{immediate:!0,flush:"post"}),d=()=>{l(),c()};return oC(d),{isSupported:i,stop:d}}function Th(n,e={width:0,height:0},t={}){const{window:o=Rs,box:r="content-box"}=t,s=a.computed(()=>{var f;return(f=lt(n))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=a.shallowRef(e.width),l=a.shallowRef(e.height),{stop:c}=hC(n,([f])=>{const p=r==="border-box"?f.borderBoxSize:r==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(o&&s.value){const h=lt(n);if(h){const m=h.getBoundingClientRect();i.value=m.width,l.value=m.height}}else if(p){const h=Os(p);i.value=h.reduce((m,{inlineSize:g})=>m+g,0),l.value=h.reduce((m,{blockSize:g})=>m+g,0)}else i.value=f.contentRect.width,l.value=f.contentRect.height},t);aC(()=>{const f=lt(n);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,l.value="offsetHeight"in f?f.offsetHeight:e.height)});const d=a.watch(()=>lt(n),f=>{i.value=f?e.width:0,l.value=f?e.height:0});function u(){c(),d()}return{width:i,height:l,stop:u}}function Nh(){const n=a.inject(ke);if(!n)throw new Error("useFonts must be used within a WovenCanvas component");return a.computed(()=>{const e=n.getEditor();return e?e.fonts.filter(t=>t.selectable):[]})}const pC={class:"wov-font-family-button"},mC={class:"wov-font-family-label"},gC={class:"wov-font-list"},yC=["onClick"],kC=["src","alt"],ql=a.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=Nh(),s=a.computed(()=>r.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=a.computed(()=>t.fontFamily),l=a.computed(()=>{const u=i.value;if(u===null)return"Mixed";const f=s.value.find(p=>p.name===u);return(f==null?void 0:f.displayName)??u});function c(u){o.setFontFamily(u)}function d(u){u.stopPropagation()}return(u,f)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Font Family"},{button:a.withCtx(()=>[a.createElementVNode("div",pC,[a.createElementVNode("span",mC,a.toDisplayString(l.value),1),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-family-menu",onWheel:d,onClick:f[0]||(f[0]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",gC,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,p=>(a.openBlock(),a.createElementBlock("div",{key:p.name,class:a.normalizeClass(["wov-font-item",{active:i.value===p.name}]),onClick:h=>c(p.name)},[p.previewImage?(a.openBlock(),a.createElementBlock("img",{key:0,class:"wov-font-preview",src:p.previewImage,alt:p.name},null,8,kC)):(a.openBlock(),a.createElementBlock("span",{key:1,class:"wov-font-name",style:a.normalizeStyle({fontFamily:p.name})},a.toDisplayString(p.displayName),5))],10,yC))),128))])],32)]),_:1})):a.createCommentVNode("",!0)}}),wC={class:"wov-font-size-button"},bC={class:"wov-font-size-label"},CC=["onClick"],xC={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},SC={class:"wov-input-container"},EC=["value"],Jl=a.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=[{label:"Small",value:16,displayValue:10},{label:"Medium",value:24,displayValue:12},{label:"Large",value:40,displayValue:16},{label:"Huge",value:96,displayValue:20}],s=a.computed(()=>t.fontSize),i=a.computed(()=>{const p=s.value;if(p===null)return"Mixed";const h=r.find(m=>m.value===p);return h?h.label:`${+p.toFixed(1)} px`}),l=a.computed(()=>{const p=s.value;return p===null?"":String(+p.toFixed(1))});function c(p){o.setFontSize(p)}function d(p){const h=p.target,m=Number.parseFloat(h.value);!Number.isNaN(m)&&m>0&&c(m)}function u(p){p.key==="Enter"&&p.target.blur()}function f(p){p.stopPropagation()}return(p,h)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Font Size"},{button:a.withCtx(()=>[a.createElementVNode("div",wC,[a.createElementVNode("span",bC,a.toDisplayString(i.value),1),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:h[0]||(h[0]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,m=>a.createElementVNode("div",{key:m.value,class:a.normalizeClass(["wov-font-size-option",{active:s.value===m.value}]),onClick:g=>c(m.value)},[s.value===m.value?(a.openBlock(),a.createElementBlock("svg",xC,[...h[1]||(h[1]=[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},null,-1)])])):a.createCommentVNode("",!0),a.createElementVNode("span",{class:"wov-option-label",style:a.normalizeStyle({fontSize:`${m.displayValue}px`})},a.toDisplayString(m.label),5)],10,CC)),64)),h[3]||(h[3]=a.createElementVNode("div",{class:"wov-separator"},null,-1)),a.createElementVNode("div",SC,[a.createElementVNode("input",{class:"wov-custom-input",value:l.value,onInput:d,onKeydown:u,placeholder:"Custom size"},null,40,EC),h[2]||(h[2]=a.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):a.createCommentVNode("",!0)}}),Gl=a.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(In,{key:0,title:"Italic",class:a.normalizeClass({"wov-active":a.unref(t).isItalic}),onClick:a.unref(o).toggleItalic},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),Yl=a.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(In,{key:0,title:"Underline",class:a.normalizeClass({"wov-active":a.unref(t).isUnderline}),onClick:a.unref(o).toggleUnderline},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),vC={class:"wov-link-input-container"},MC=["onKeydown"],Xl=a.defineComponent({__name:"TextLinkButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=a.ref(!1),s=a.ref(""),i=a.ref(null),l=a.ref(null),c=a.ref(null),d=a.inject("containerRef"),{floatingStyles:u}=no(l,c,{placement:"top",middleware:[Zn(8),to(),eo({padding:8})],whileElementsMounted:As});function f(){s.value=t.linkHref??"",r.value=!0,a.nextTick(()=>{var g,y;(g=i.value)==null||g.focus(),(y=i.value)==null||y.select()})}function p(){const g=s.value.trim();g?o.setLink(g):o.removeLink(),r.value=!1}function h(){o.removeLink(),s.value="",r.value=!1}function m(g){var k,b;const y=g.target;!((k=l.value)!=null&&k.contains(y))&&!((b=c.value)!=null&&b.contains(y))&&(r.value=!1)}return a.watch(r,g=>{g?document.addEventListener("click",m,!0):document.removeEventListener("click",m,!0)}),(g,y)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:l},[a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(In,{key:0,title:"Link",class:a.normalizeClass({"wov-active":a.unref(t).linkHref!==null}),onClick:f},{default:a.withCtx(()=>[...y[3]||(y[3]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 7-34.4-7.4-44.6s-34.4-7-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372.1 74 321.1 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.8l-1.1 1.6c-10.3 14.4-7 34.4 7.4 44.6s34.4 7 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})],-1)])]),_:1},8,["class"])):a.createCommentVNode("",!0)],512),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[r.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:c,class:"wov-link-input-dropdown",style:a.normalizeStyle(a.unref(u)),onKeydown:y[2]||(y[2]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",vC,[a.withDirectives(a.createElementVNode("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":y[0]||(y[0]=k=>s.value=k),class:"wov-link-input",placeholder:"Paste or type URL",onKeydown:[a.withKeys(a.withModifiers(p,["prevent"]),["enter"]),y[1]||(y[1]=a.withKeys(a.withModifiers(k=>r.value=!1,["prevent"]),["esc"]))]},null,40,MC),[[a.vModelText,s.value]]),s.value||a.unref(t).linkHref?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-link-action-button",title:"Remove link",onClick:h},[...y[4]||(y[4]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 12.5 32.8 0 45.3s32.8 12.5 45.3 0L237.3 256 342.6 150.6z"})],-1)])])):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-link-action-button",title:"Apply link",onClick:p},[...y[5]||(y[5]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})],-1)])])])],36)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),TC={class:"wov-text-color-button"},NC={class:"wov-text-icon-container"},Ql=a.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=a.computed(()=>t.color??"#000000"),s=a.computed(()=>({backgroundColor:r.value}));function i(l){o.setColor(Ho(l))}return(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Text Color"},{button:a.withCtx(()=>[a.createElementVNode("div",TC,[a.createElementVNode("div",NC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createElementVNode("div",{class:"wov-color-underline",style:a.normalizeStyle(s.value)},null,4)]),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(Bs,{currentColor:r.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):a.createCommentVNode("",!0)}}),AC={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-start-icon lucide-align-vertical-justify-start"},BC={key:1,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-center-icon lucide-align-vertical-justify-center"},IC={key:2,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-end-icon lucide-align-vertical-justify-end"},Ah=a.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=ce(),{state:o}=rt(()=>e.entityIds),r=[w.VerticalAlignment.Top,w.VerticalAlignment.Center,w.VerticalAlignment.Bottom],s=Pt(()=>e.entityIds,w.VerticalAlign),i=a.computed(()=>{let c=null;for(const d of s.value.values()){const u=(d==null?void 0:d.value)??w.VerticalAlignment.Top;if(c===null)c=u;else if(c!==u)return null}return c});function l(){const c=i.value??w.VerticalAlignment.Top,d=r.indexOf(c),u=r[(d+1)%r.length];t(f=>{for(const p of e.entityIds){const h=w.VerticalAlign.write(f,p);h.value=u}})}return(c,d)=>a.unref(o).showTextMenuButtons?(a.openBlock(),a.createBlock(In,{key:0,title:"Vertical Align",onClick:l},{default:a.withCtx(()=>[i.value===a.unref(w.VerticalAlignment).Top||i.value===null?(a.openBlock(),a.createElementBlock("svg",AC,[...d[0]||(d[0]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===a.unref(w.VerticalAlignment).Center?(a.openBlock(),a.createElementBlock("svg",BC,[...d[1]||(d[1]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",IC,[...d[2]||(d[2]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),OC={class:"wov-text-group-button"},RC={class:"wov-text-group-dropdown"},PC={class:"wov-text-group-row wov-text-group-row-full"},DC={class:"wov-text-group-row"},_C=a.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(n){const e=n,{state:t}=rt(()=>e.entityIds),o=a.inject("containerRef"),{width:r}=Th(o),s=a.computed(()=>r.value>0&&r.value<600),i=a.ref(new Map);return a.provide(ca,i),(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[s.value?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Text Formatting",placement:"top"},{button:a.withCtx(()=>[a.createElementVNode("div",OC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",RC,[a.createElementVNode("div",PC,[a.createVNode(ql,{entityIds:n.entityIds},null,8,["entityIds"]),c[1]||(c[1]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(Jl,{entityIds:n.entityIds},null,8,["entityIds"])]),a.createElementVNode("div",DC,[a.createVNode(Wl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Gl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Yl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Xl,{entityIds:n.entityIds},null,8,["entityIds"]),c[2]||(c[2]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(Ql,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(jl,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Ah,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)])])]),_:1})):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createVNode(ql,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Jl,{entityIds:n.entityIds},null,8,["entityIds"]),c[3]||(c[3]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Wl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Gl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Yl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Xl,{entityIds:n.entityIds},null,8,["entityIds"]),c[4]||(c[4]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Ql,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(jl,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Ah,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)],64))],64)):a.createCommentVNode("",!0)}}),Bh=a.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(n){const e=n,t={kind:"none",color:"#f4f4f4",strokeColor:"#a1a1a1",subdivisionStep:5},o=a.computed(()=>({...t,...e.background})),r=Ie(w.Camera),s=Ie(w.Grid),i=a.inject("containerRef"),l=a.ref({width:0,height:0});let c=null;const d=a.ref(null);let u=null;typeof document<"u"&&(u=document.createElement("canvas"));function f(b,C,x,E){const M=E/2;b.beginPath(),b.arc(C,x,M,0,Math.PI*2),b.fill()}function p(b,C,x){if(!u)return null;const E=x.dotSize??2,M=b*x.subdivisionStep,S=C*x.subdivisionStep;if(M<=0||S<=0)return null;u.width=M,u.height=S;const v=u.getContext("2d");if(!v)return null;if(v.clearRect(0,0,M,S),v.fillStyle=x.strokeColor,x.subdivisionStep===1)f(v,M/2,S/2,E);else for(let T=0;T<x.subdivisionStep;T++)for(let B=0;B<x.subdivisionStep;B++){const P=(T+.5)*(M/x.subdivisionStep),O=(B+.5)*(S/x.subdivisionStep),$=T===0&&B===0?2*E:E;f(v,P,O,$)}return v.createPattern(u,"repeat")}function h(b,C,x,E,M,S){b.lineWidth=S,b.beginPath(),b.moveTo(C,x),b.lineTo(E,M),b.stroke()}function m(b,C,x){if(!u)return null;const E=x.gridSize??1,M=b*x.subdivisionStep,S=C*x.subdivisionStep;if(M<=0||S<=0)return null;u.width=M,u.height=S;const v=u.getContext("2d");if(!v)return null;if(v.clearRect(0,0,M,S),v.strokeStyle=x.strokeColor,x.subdivisionStep===1)h(v,0,0,M,0,E),h(v,0,0,0,S,E);else{const T=M/x.subdivisionStep,B=S/x.subdivisionStep;for(let P=0;P<=x.subdivisionStep;P++){const O=P*T,_=P%x.subdivisionStep===0;h(v,O,0,O,S,_?3*E:E)}for(let P=0;P<=x.subdivisionStep;P++){const O=P*B,_=P%x.subdivisionStep===0;h(v,0,O,M,O,_?3*E:E)}}return v.createPattern(u,"repeat")}function g(b){let C=s.value.colWidth,x=s.value.rowHeight;const E=o.value.subdivisionStep,M=l.value.width,S=l.value.height,v=r.value.left,T=r.value.top,B=v+M/r.value.zoom,P=T+S/r.value.zoom;let O=C*E,_=x*E,$=0,F=0,J=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY;for(;;){O=E*C,_=E*x,$=Math.floor(v/O)*O,F=Math.floor(T/_)*_;const et=Math.ceil(B/O)*O,ye=Math.ceil(P/_)*_;if(K=Math.round((et-$)/C),J=Math.round((ye-F)/x),Math.max(K,J)>125)C*=2,x*=2;else break}const U=C*r.value.zoom,j=x*r.value.zoom,Q=Math.max(1,Math.round(U)),ne=Math.max(1,Math.round(j)),oe=p(Q,ne,o.value);if(!oe)return;oe.setTransform(new DOMMatrix().scale(U/Q,j/ne));const Re=($-v-C/2)*r.value.zoom,ue=(F-T-x/2)*r.value.zoom;b.save(),b.translate(Re,ue),b.fillStyle=oe,b.fillRect(0,0,M+O*r.value.zoom,S+_*r.value.zoom),b.restore()}function y(b){let C=s.value.colWidth,x=s.value.rowHeight;const E=o.value.subdivisionStep,M=l.value.width,S=l.value.height,v=r.value.left,T=r.value.top,B=v+M/r.value.zoom,P=T+S/r.value.zoom;let O=C*E,_=x*E,$=0,F=0,J=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY;for(;;){O=E*C,_=E*x,$=Math.floor(v/O)*O,F=Math.floor(T/_)*_;const et=Math.ceil(B/O)*O,ye=Math.ceil(P/_)*_;if(K=Math.round((et-$)/C),J=Math.round((ye-F)/x),Math.max(K,J)>200)C*=2,x*=2;else break}const U=C*r.value.zoom,j=x*r.value.zoom,Q=Math.max(1,Math.round(U)),ne=Math.max(1,Math.round(j)),oe=m(Q,ne,o.value);if(!oe)return;oe.setTransform(new DOMMatrix().scale(U/Q,j/ne));const Re=($-v)*r.value.zoom,ue=(F-T)*r.value.zoom;b.save(),b.translate(Re,ue),b.fillStyle=oe,b.fillRect(0,0,M+O*r.value.zoom,S+_*r.value.zoom),b.restore()}function k(){const b=d.value;if(!b)return;const C=b.getContext("2d");if(!C)return;const{width:x,height:E}=l.value;x===0||E===0||(b.width=x,b.height=E,C.clearRect(0,0,x,E),C.fillStyle=o.value.color,C.fillRect(0,0,x,E),o.value.kind==="dots"?g(C):o.value.kind==="grid"&&y(C))}return a.watch(()=>[o.value,r.value,s.value,l.value],()=>{k()},{deep:!0}),a.onMounted(()=>{const b=i==null?void 0:i.value;if(b){const C=()=>{l.value={width:b.clientWidth,height:b.clientHeight}};C(),c=new ResizeObserver(C),c.observe(b)}k()}),a.onUnmounted(()=>{c==null||c.disconnect()}),(b,C)=>(a.openBlock(),a.createElementBlock("canvas",{ref_key:"canvasRef",ref:d,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function Ih(n,e){if(e.length===0)return new Set;const t=e[0].tag,o=n.blockDefs[t];if(!o)return new Set;const r=new Set(o.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,l=n.blockDefs[i];if(!l){r.clear();break}const c=new Set(l.components.map(d=>d.name));for(const d of r)c.has(d)||r.delete(d)}return r}const Oh=a.defineComponent({__name:"FloatingMenuBar",setup(n){const e=a.useSlots(),{reset:t}=Dt(),o=a.inject(ua),{selectedIds:r,commonComponents:s}=o,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape","tape"]),l=a.computed(()=>{const d=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&d.push(u)}return d});function c(){t()}return a.onUnmounted(()=>{t()}),(d,u)=>(a.openBlock(),a.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:c},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(l.value,f=>a.renderSlot(d.$slots,`button:${f}`,{key:f,entityIds:a.unref(r)})),128)),a.unref(s).has("color")?a.renderSlot(d.$slots,"button:color",{key:0,entityIds:a.unref(r)},()=>[a.createVNode(Ch,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("shape")?a.renderSlot(d.$slots,"button:shape",{key:1,entityIds:a.unref(r)},()=>[a.createVNode(Eh,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(Sh,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(vh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("penStroke")?a.renderSlot(d.$slots,"button:penStroke",{key:2,entityIds:a.unref(r)},()=>[a.createVNode(xh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("elbowArrow")||a.unref(s).has("arcArrow")?(a.openBlock(),a.createElementBlock(a.Fragment,{key:3},[a.renderSlot(d.$slots,"button:arrowThickness",{entityIds:a.unref(r)},()=>[a.createVNode(wh,{entityIds:a.unref(r)},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadStart",{entityIds:a.unref(r)},()=>[a.createVNode(Hl,{entityIds:a.unref(r),side:"start"},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadEnd",{entityIds:a.unref(r)},()=>[a.createVNode(Hl,{entityIds:a.unref(r),side:"end"},null,8,["entityIds"])])],64)):a.createCommentVNode("",!0),a.unref(s).has("tape")?a.renderSlot(d.$slots,"button:tape",{key:4,entityIds:a.unref(r)},()=>[a.createVNode(Mh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("text")?a.renderSlot(d.$slots,"button:text",{key:5,entityIds:a.unref(r)},()=>[a.createVNode(_C,{entityIds:a.unref(r),showVerticalAlign:a.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])]):a.createCommentVNode("",!0),a.createVNode(Ul)],32))}}),LC={class:"wov-floating-menu-inner"},Rh=a.defineComponent({__name:"FloatingMenu",setup(n){const e=a.inject(ke),t=jf([w.Block,te.Selected]),o=Ie(w.Camera),r=Ie(w.Screen),s=Ie(te.SelectionStateSingleton),i=Mn(),l=a.computed(()=>t.value.map(M=>M.entityId)),c=a.computed(()=>{const M=e==null?void 0:e.getEditor();if(!M||t.value.length===0)return new Set;const S=t.value.map(v=>({tag:v.block.value.tag}));return Ih(M,S)});a.provide(ua,{selectedIds:l,commonComponents:c});const d=[0,0,0,0];function u(...M){let S=1/0,v=1/0,T=-1/0,B=-1/0,P=!1;for(const O of M){if(!O)continue;const _=O.getBoundingClientRect();_.width<=0||(P=!0,S=Math.min(S,_.left),v=Math.min(v,_.top),T=Math.max(T,_.right),B=Math.max(B,_.bottom))}return P?{x:S,y:v,left:S,top:v,right:T,bottom:B,width:T-S,height:B-v,toJSON:()=>({})}:null}const f=a.computed(()=>{if(t.value.length===0)return null;const M=o.value;if(!M)return null;let S=null;for(const v of t.value){const T=v.block.value;ae.Rect.getAabb(T.position,T.size,T.rotateZ,d),ae.Aabb.translate(d,[-M.left,-M.top]),ae.Aabb.scale(d,M.zoom),S===null?S=ae.Aabb.clone(d):ae.Aabb.union(S,d)}return S}),p=a.inject("containerRef"),h=a.computed(()=>{const M=p==null?void 0:p.value;if(!M)return null;o.value,i.updateCounter.value;const S=i.blockElement.value,v=i.textElement.value,T=u(S,v);if(T)return{getBoundingClientRect:()=>T};const B=f.value;if(!B)return null;const P=M.getBoundingClientRect();return{getBoundingClientRect(){return{x:P.left+B[0],y:P.top+B[1],width:B[2]-B[0],height:B[3]-B[1],top:P.top+B[1],left:P.left+B[0],right:P.left+B[2],bottom:P.top+B[3]}}}}),m=a.ref(null),g={name:"clampToViewport",fn({y:M,rects:S}){const B=window.innerHeight-S.floating.height-8;return{y:Math.max(8,Math.min(M,B))}}},{floatingStyles:y}=no(h,m,{placement:"top",middleware:[Zn(12),to({fallbackPlacements:["bottom"]}),eo({padding:8}),g]}),k=a.computed(()=>{const M=f.value,S=r.value;return!M||!S?!0:M[2]<0||M[0]>S.width||M[3]<0||M[1]>S.height}),b=[te.SelectionState.Dragging,te.SelectionState.SelectionBoxDragging],C=a.computed(()=>t.value.length>0&&!k.value&&!b.includes(s.value.state)),x=a.ref(!1);let E;return a.watch(C,M=>{clearTimeout(E),M?E=setTimeout(()=>{x.value=!0},40):x.value=!1},{immediate:!0}),(M,S)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-fade"},{default:a.withCtx(()=>[x.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:m,class:"wov-floating-menu",style:a.normalizeStyle(a.unref(y))},[a.createElementVNode("div",LC,[a.renderSlot(M.$slots,"default",{},()=>[a.createVNode(Oh)])])],4)):a.createCommentVNode("",!0)]),_:3}))}}),VC={key:0,class:"wov-loading-overlay"},$C={class:"wov-loading-spinner"},Ph=a.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(n){const e=a.ref("|"),t=["|","/","-","\\"];let o=null;return a.onMounted(()=>{o=setInterval(()=>{const r=t.indexOf(e.value);e.value=t[(r+1)%t.length]},100)}),a.onUnmounted(()=>{o!==null&&clearInterval(o)}),(r,s)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-loading-fade"},{default:a.withCtx(()=>[n.isLoading?(a.openBlock(),a.createElementBlock("div",VC,[a.createElementVNode("div",$C,a.toDisplayString(e.value),1)])):a.createCommentVNode("",!0)]),_:1}))}}),zC={class:"wov-action-bar"},FC=a.defineComponent({__name:"ActionBar",setup(n){const{getEditor:e}=ce(),t=a.inject(ke),o=a.ref(!1),r=a.ref(!1);if(t){const c=t.registerTickCallback(d=>{const{store:u}=w.getPluginResources(d,Yn);o.value=u.canUndo(),r.value=u.canRedo()});a.onUnmounted(c)}function s(){const c=e();c==null||c.command(w.Undo)}function i(){const c=e();c==null||c.command(w.Redo)}function l(){const c=e();c==null||c.command(te.RemoveSelected)}return(c,d)=>(a.openBlock(),a.createElementBlock("div",zC,[a.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...d[0]||(d[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-undo-icon lucide-undo"},[a.createElementVNode("path",{d:"M3 7v6h6"}),a.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...d[1]||(d[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-redo-icon lucide-redo"},[a.createElementVNode("path",{d:"M21 7v6h-6"}),a.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:l,"aria-label":"Delete"},[...d[2]||(d[2]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-trash-icon lucide-trash"},[a.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),a.createElementVNode("path",{d:"M3 6h18"}),a.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),at=a.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(n){const e=n,t=a.inject(Vs);if(!t)throw new Error("ToolbarButton must be used within a Toolbar component");const o=t,r=a.ref(null),{show:s,hide:i}=Dt(),l=a.computed(()=>o.activeTool.value===e.name);function c(){o.setTool(e.name,e.placementSnapshot,e.cursor)}function d(){o.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){o.onToolPointerUp()}function f(){e.tooltip&&r.value&&s(e.tooltip,r.value)}function p(){i()}return(h,m)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:a.normalizeClass(["wov-toolbar-button",{selected:l.value}]),onClick:c,onPointerdown:d,onPointerup:u,onMouseenter:f,onMouseleave:p},[a.renderSlot(h.$slots,"default")],34))}}),HC='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.35 4.75" width="20" height="20"><defs><style>.cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:.25px;}</style></defs><path class="cls-1" d="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z"/></svg>',UC='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.08 4.75" width="24" height="24"><defs><style>.cls-1{fill:#fff;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:.25px;}.cls-2{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:.51px;}</style></defs><path class="cls-1" d="M.89,2.25v.63M.89,2.25V.75c0-.21.17-.38.38-.38s.38.17.38.38M.89,2.25c0-.21-.17-.37-.38-.37s-.38.17-.38.37v.5c0,1.04.86,1.87,1.91,1.87s1.91-.84,1.91-1.87v-1.25c0-.21-.17-.38-.38-.38s-.38.17.38.38M1.66.75v1.38M1.66.75v-.25c0-.21.17-.38.38-.38s.38.17.38.38v.25M2.42.75v1.38M2.42.75c0-.21.17-.38.38-.38s.38.17.38.38v.75M3.19,1.5v.63"/><line class="cls-2" x1="2.8" y1=".77" x2="2.8" y2="2.03"/><line class="cls-2" x1="2.04" y1=".64" x2="2.04" y2="2.02"/><line class="cls-2" x1="1.27" y1=".84" x2="1.27" y2="2.29"/></svg>',jC='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 8v-2a2 2 0 0 1 2 -2h2" /><path d="M4 16v2a2 2 0 0 0 2 2h2" /><path d="M16 4h2a2 2 0 0 1 2 2v2" /><path d="M16 20h2a2 2 0 0 0 2 -2v-2" /><path d="M9 12l6 0" /><path d="M12 9l0 6" /></svg>',rn={Select:"select",Hand:"hand",Crosshair:"crosshair"},Dh={[rn.Select]:{makeSvg:()=>HC,hotspot:[1,0],rotationOffset:0},[rn.Hand]:{makeSvg:()=>UC,hotspot:[12,12],rotationOffset:0},[rn.Crosshair]:{makeSvg:()=>jC,hotspot:[12,12],rotationOffset:0}},WC={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},_h=a.defineComponent({__name:"SelectTool",setup(n){const{nextEditorTick:e}=ce(),{activeTool:t}=gs();return a.watch(t,(o,r)=>{r==="select"&&e(s=>{te.DeselectAll.spawn(s)})}),(o,r)=>(a.openBlock(),a.createBlock(at,{name:"select",tooltip:"Select",cursor:a.unref(rn).Select},{default:a.withCtx(()=>[(a.openBlock(),a.createElementBlock("svg",WC,[...r[0]||(r[0]=[a.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-width":"0.5",d:"M2.39,2.88C2.38,2.885 2.34,2.9 2.33,2.91C2.32,2.91 2.298,2.939 2.28,2.97L1.51,4.41C1.44,4.54 1.41,4.6 1.37,4.61C1.34,4.62 1.3,4.61 1.27,4.6C1.24,4.58 1.22,4.51 1.18,4.37L0.16,0.41C0.13,0.28 0.11,0.22 0.13,0.18C0.15,0.15 0.17,0.13 0.21,0.12C0.25,0.12 0.31,0.14 0.42,0.2L4.01,2.14C4.14,2.21 4.2,2.24 4.21,2.28C4.22,2.31 4.21,2.35 4.2,2.38C4.18,2.41 4.11,2.43 3.97,2.47L2.39,2.88Z"})],-1)])]))]),_:1},8,["cursor"]))}}),Lh=a.defineComponent({__name:"HandTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"hand",tooltip:"Hand",cursor:a.unref(rn).Hand},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4.47,11.39v3.18M4.47,11.39V3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92M4.47,11.39c0-1.06-.86-1.87-1.92-1.87s-1.92.86-1.92,1.87v2.53c0,5.25,4.35,9.45,9.65,9.45s9.65-4.24,9.65-9.45v-6.32c0-1.06-.86-1.92-1.92-1.92s-1.92.86-1.92,1.92M8.36,3.81v6.97M8.36,3.81v-1.26c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v1.26M12.2,3.81v6.97M12.2,3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v3.79M16.09,7.6v3.18"})],-1)])]),_:1},8,["cursor"]))}}),Vh=a.defineComponent({__name:"StickyNoteTool",setup(n){const e=a.inject(ke),t=a.computed(()=>JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:w.TextAlignment.Center,...e.getDefaults("text")},verticalAlign:{value:w.VerticalAlignment.Center}}));return(o,r)=>(a.openBlock(),a.createBlock(at,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":t.value,"placement-snapshot":t.value},{default:a.withCtx(()=>[...r[0]||(r[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M4 4h12v12H4z"}),a.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),$h=a.defineComponent({__name:"ShapeTool",setup(n){const e=a.inject(ke),t=a.computed(()=>JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:w.StrokeKind.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:w.TextAlignment.Center,...e.getDefaults("text")},verticalAlign:{value:w.VerticalAlignment.Center}}));return(o,r)=>(a.openBlock(),a.createBlock(at,{name:"shape",tooltip:"Shape","drag-out-snapshot":t.value,"placement-snapshot":t.value},{default:a.withCtx(()=>[...r[0]||(r[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),zh=a.defineComponent({__name:"EraserTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"eraser",tooltip:"Eraser"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[a.createElementVNode("path",{d:"M210.5 480L333.5 480L398.8 414.7L225.3 241.2L98.6 367.9L210.6 479.9zM256 544L210.5 544C193.5 544 177.2 537.3 165.2 525.3L49 409C38.1 398.1 32 383.4 32 368C32 352.6 38.1 337.9 49 327L295 81C305.9 70.1 320.6 64 336 64C351.4 64 366.1 70.1 377 81L559 263C569.9 273.9 576 288.6 576 304C576 319.4 569.9 334.1 559 345L424 480L544 480C561.7 480 576 494.3 576 512C576 529.7 561.7 544 544 544L256 544z"})],-1)])]),_:1}))}}),Fh=a.defineComponent({__name:"PenTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"pen",tooltip:"Pen"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M13.586 3.586a2 2 0 1 1 2.828 2.828l-8.793 8.793-3.536.707.707-3.536 8.794-8.792Z","stroke-linecap":"round","stroke-linejoin":"round"}),a.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),Hh=a.defineComponent({__name:"TextTool",setup(n){const e=a.inject(ke),t=a.computed(()=>JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24,...e.getDefaults("text")}})),o=a.computed(()=>JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24,...e.getDefaults("text")}}));return(r,s)=>(a.openBlock(),a.createBlock(at,{name:"text",tooltip:"Text","drag-out-snapshot":o.value,"placement-snapshot":t.value},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-type-icon lucide-type"},[a.createElementVNode("path",{d:"M12 4v16"}),a.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),a.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Uh=a.defineComponent({__name:"ElbowArrowTool",setup(n){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:ee.ArrowHeadKind.None,endArrowHead:ee.ArrowHeadKind.V},connector:{}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),jh=a.defineComponent({__name:"ImageTool",setup(n){const{nextEditorTick:e}=ce(),{show:t,hide:o}=Dt(),{setTool:r}=gs(),{createImageBlock:s}=Uf(),i=a.ref(null),l=a.ref(null);function c(){var p;(p=l.value)==null||p.click()}async function d(p){var x;const h=p.target,m=(x=h.files)==null?void 0:x[0];if(!m)return;if(h.value="",!m.type.startsWith("image/")){console.warn("Selected file is not an image");return}const g=await e(),y=w.Camera.read(g),k=w.Screen.read(g),b=y.left+k.width/y.zoom/2,C=y.top+k.height/y.zoom/2;await s(m,b,C),r("select",void 0,rn.Select)}function u(){i.value&&t("Image",i.value)}function f(){o()}return(p,h)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:c,onMouseenter:u,onMouseleave:f},[h[0]||(h[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),a.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),a.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),a.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",accept:"image/*",style:{display:"none"},onChange:d},null,544)],544))}}),KC={class:"wov-embed-provider-grid"},qC=["onClick"],JC={class:"wov-embed-provider-icon"},GC={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},YC={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},XC={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},QC={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},ZC={key:4,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},ex={key:5,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},tx={key:6,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},nx={key:7,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},ox={class:"wov-embed-provider-label"},rx={class:"wov-embed-panel-header"},sx={class:"wov-embed-url-form"},ix=["placeholder"],lx={key:0,class:"wov-embed-url-error"},Wh=a.defineComponent({__name:"EmbedTool",setup(n){const{nextEditorTick:e}=ce(),{show:t,hide:o}=Dt(),{setTool:r}=gs(),s=a.ref(null),i=a.ref(null),l=a.ref(null),c=a.ref(!1),d=a.ref(null),u=a.ref(""),f=a.ref(""),p=a.inject("containerRef"),{floatingStyles:h}=no(s,i,{placement:"top",middleware:[Zn(16),to(),eo({padding:8})],whileElementsMounted:As}),m=[{value:w.EmbedProvider.Youtube,label:"YouTube",icon:"youtube"},{value:w.EmbedProvider.Spotify,label:"Spotify",icon:"spotify"},{value:w.EmbedProvider.GoogleMaps,label:"Google Maps",icon:"map"},{value:w.EmbedProvider.GoogleCalendar,label:"Google Calendar",icon:"calendar"},{value:w.EmbedProvider.GoogleSlides,label:"Google Slides",icon:"slides"},{value:w.EmbedProvider.Figma,label:"Figma",icon:"figma"},{value:w.EmbedProvider.GithubGist,label:"GitHub Gist",icon:"gist"},{value:w.EmbedProvider.Tldraw,label:"tldraw",icon:"tldraw"}],g=a.computed(()=>{if(!d.value)return"Paste a URL...";switch(d.value){case w.EmbedProvider.Youtube:return"https://www.youtube.com/watch?v=...";case w.EmbedProvider.Spotify:return"https://open.spotify.com/track/...";case w.EmbedProvider.GoogleMaps:return"https://www.google.com/maps/...";case w.EmbedProvider.GoogleCalendar:return"https://calendar.google.com/...";case w.EmbedProvider.GoogleSlides:return"https://docs.google.com/presentation/...";case w.EmbedProvider.Figma:return"https://www.figma.com/...";case w.EmbedProvider.GithubGist:return"https://gist.github.com/...";case w.EmbedProvider.Tldraw:return"https://www.tldraw.com/...";default:return"Paste a URL..."}});function y(){c.value=!c.value,d.value=null,u.value="",f.value=""}function k(v){d.value=v,u.value="",f.value="",a.nextTick(()=>{var T;(T=l.value)==null||T.focus()})}function b(){d.value=null,u.value="",f.value=""}async function C(){const v=u.value.trim();if(!v){f.value="Please enter a URL";return}try{new URL(v)}catch{f.value="Please enter a valid URL";return}const T=d.value??w.detectEmbedProvider(v),B=w.validateEmbedUrl(v,T);if(B){f.value=B;return}const P=w.resolveEmbedUrl(v,T);let O=480,_=320;switch(T){case w.EmbedProvider.Youtube:O=560,_=315;break;case w.EmbedProvider.Spotify:O=352,_=152;break;case w.EmbedProvider.GoogleMaps:O=600,_=450;break;case w.EmbedProvider.GoogleCalendar:O=600,_=500;break;case w.EmbedProvider.GoogleSlides:O=640,_=389;break;case w.EmbedProvider.Figma:O=600,_=400;break;case w.EmbedProvider.GithubGist:O=500,_=300;break;case w.EmbedProvider.Tldraw:O=600,_=400;break}const $=await e(),F=w.Camera.read($),J=w.Screen.read($),K=F.left+J.width/F.zoom/2,U=F.top+J.height/F.zoom/2,j=w.Grid.read($);j.enabled&&(O=Math.max(j.colWidth,Math.round(O/j.colWidth)*j.colWidth),_=Math.max(j.rowHeight,Math.round(_/j.rowHeight)*j.rowHeight));const Q=w.createEntity($);w.addComponent($,Q,w.Block);const ne=w.Block.write($,Q);ne.tag="embed",ne.position[0]=K-O/2,ne.position[1]=U-_/2,ne.size[0]=O,ne.size[1]=_,w.Grid.snapPosition($,ne.position),w.addComponent($,Q,w.Embed);const oe=w.Embed.write($,Q);oe.url=v,oe.embedUrl=P,oe.provider=T,w.addComponent($,Q,Le.Synced,{id:crypto.randomUUID()}),c.value=!1,d.value=null,u.value="",r("select",void 0,rn.Select)}function x(v){v.key==="Enter"?(v.preventDefault(),C()):v.key==="Escape"&&(v.preventDefault(),d.value?b():c.value=!1)}function E(v){const T=v.target;s.value&&!s.value.contains(T)&&i.value&&!i.value.contains(T)&&(c.value=!1)}a.watch(c,v=>{v?document.addEventListener("click",E,!0):document.removeEventListener("click",E,!0)});function M(){s.value&&t("Embed",s.value)}function S(){o()}return(v,T)=>{var B;return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("button",{ref_key:"buttonRef",ref:s,class:a.normalizeClass(["wov-toolbar-button",{"menu-open":c.value}]),onClick:y,onMouseenter:M,onMouseleave:S},[...T[1]||(T[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.createElementVNode("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)])],34),a.unref(p)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(p)},[c.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"wov-embed-panel",style:a.normalizeStyle(a.unref(h))},[d.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createElementVNode("div",rx,[a.createElementVNode("button",{class:"wov-embed-back-button",onClick:b},[...T[11]||(T[11]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("polyline",{points:"15 18 9 12 15 6"})],-1)])]),a.createElementVNode("span",null,a.toDisplayString((B=m.find(P=>P.value===d.value))==null?void 0:B.label),1)]),a.createElementVNode("div",sx,[a.withDirectives(a.createElementVNode("input",{ref_key:"urlInputRef",ref:l,"onUpdate:modelValue":T[0]||(T[0]=P=>u.value=P),type:"text",placeholder:g.value,class:"wov-embed-url-input",onKeydown:x},null,40,ix),[[a.vModelText,u.value]]),f.value?(a.openBlock(),a.createElementBlock("div",lx,a.toDisplayString(f.value),1)):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-embed-submit-button",onClick:C}," Embed ")])],64)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[T[10]||(T[10]=a.createElementVNode("div",{class:"wov-embed-panel-header"},"Add embed",-1)),a.createElementVNode("div",KC,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(m,P=>a.createElementVNode("button",{key:P.value,class:"wov-embed-provider-button",onClick:O=>k(P.value)},[a.createElementVNode("span",JC,[P.icon==="youtube"?(a.openBlock(),a.createElementBlock("svg",GC,[...T[2]||(T[2]=[a.createElementVNode("path",{d:"M2.5 17V7a2 2 0 0 1 2-2h15a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2z"},null,-1),a.createElementVNode("path",{d:"m10 15 5-3-5-3z"},null,-1)])])):P.icon==="spotify"?(a.openBlock(),a.createElementBlock("svg",YC,[...T[3]||(T[3]=[a.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),a.createElementVNode("path",{d:"M8 11.973c2.5-1.473 5.5-.973 7.5.527"},null,-1),a.createElementVNode("path",{d:"M9 15c1.5-1 4-.5 5.5.5"},null,-1),a.createElementVNode("path",{d:"M7 9c3-2 7-1 10 1"},null,-1)])])):P.icon==="map"?(a.openBlock(),a.createElementBlock("svg",XC,[...T[4]||(T[4]=[a.createElementVNode("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"},null,-1),a.createElementVNode("circle",{cx:"12",cy:"9",r:"2.5"},null,-1)])])):P.icon==="calendar"?(a.openBlock(),a.createElementBlock("svg",QC,[...T[5]||(T[5]=[a.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"16",y1:"2",x2:"16",y2:"6"},null,-1),a.createElementVNode("line",{x1:"8",y1:"2",x2:"8",y2:"6"},null,-1),a.createElementVNode("line",{x1:"3",y1:"10",x2:"21",y2:"10"},null,-1)])])):P.icon==="slides"?(a.openBlock(),a.createElementBlock("svg",ZC,[...T[6]||(T[6]=[a.createElementVNode("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"8",y1:"21",x2:"16",y2:"21"},null,-1),a.createElementVNode("line",{x1:"12",y1:"17",x2:"12",y2:"21"},null,-1)])])):P.icon==="figma"?(a.openBlock(),a.createElementBlock("svg",ex,[...T[7]||(T[7]=[a.createElementVNode("path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z"},null,-1),a.createElementVNode("path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z"},null,-1),a.createElementVNode("path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z"},null,-1)])])):P.icon==="gist"?(a.openBlock(),a.createElementBlock("svg",tx,[...T[8]||(T[8]=[a.createElementVNode("polyline",{points:"16 18 22 12 16 6"},null,-1),a.createElementVNode("polyline",{points:"8 6 2 12 8 18"},null,-1)])])):P.icon==="tldraw"?(a.openBlock(),a.createElementBlock("svg",nx,[...T[9]||(T[9]=[a.createElementVNode("path",{fill:"currentColor",d:"M21.474 0H2.526C1.131 0 0 1.18 0 2.637v18.726C0 22.819 1.131 24 2.526 24h18.948C22.869 24 24 22.82 24 21.363V2.637C24 1.181 22.869 0 21.474 0m-11.01 5.388q.595-.607 1.474-.607q.854 0 1.448.607q.595.606.595 1.476c0 .87-.198 1.072-.595 1.476a1.95 1.95 0 0 1-1.448.607q-.879 0-1.474-.607q-.594-.606-.594-1.476c0-.87.198-1.072.594-1.476m3.13 11.49a4.9 4.9 0 0 1-2.018 2.136q-.724.422-1.19-.026q-.438-.422.26-1.002q.387-.29.646-.738q.258-.449.336-.923q.026-.21-.181-.21q-.517-.027-1.06-.581t-.543-1.37q0-.87.594-1.477a2.02 2.02 0 0 1 1.5-.633q.828 0 1.448.633q.62.605.724 1.37q.207 1.424-.517 2.822z"},null,-1)])])):a.createCommentVNode("",!0)]),a.createElementVNode("span",ox,a.toDisplayString(P.label),1)],8,qC)),64))])],64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64)}}}),ax="https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media",Kh=a.defineComponent({__name:"TapeTool",setup(n){const e=JSON.stringify({block:{tag:"tape",size:[200,30]},tape:{thickness:30},asset:{identifier:ax,uploadState:"complete"}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"tape",tooltip:"Tape","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"1",y:"7",width:"18",height:"6",rx:"1",fill:"none",stroke:"currentColor"}),a.createElementVNode("line",{x1:"5",y1:"7",x2:"3",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"9",y1:"7",x2:"7",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"13",y1:"7",x2:"11",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"17",y1:"7",x2:"15",y2:"13",opacity:"0.4"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),cx={class:"wov-toolbar-container"},qh=a.defineComponent({__name:"Toolbar",setup(n){const e=a.useSlots(),{reset:t}=Dt(),{nextEditorTick:o}=ce(),r=a.ref(null),s=a.ref(null),i=Ie(w.Controls),l=a.computed(()=>i.value.leftMouseTool),c=[_h,Lh,Hh,jh,Wh,$h,Uh,Vh,Kh,Fh,zh],d=a.inject("containerRef"),u=a.ref(null),f=a.ref(!1),p=a.ref(null),h=a.ref(null),m=a.ref(1/0),g=a.ref(0),y=a.ref([]),k=a.ref(8),b=a.ref(48),{width:C}=Th(d);function x(){return p.value?Array.from(p.value.children).filter(U=>!U.classList.contains("wov-overflow-button")&&!U.classList.contains("wov-menu-tooltip")):[]}function E(){var ne;const U=x();if(U.length===0)return;g.value=U.length;const j=getComputedStyle(p.value);k.value=parseFloat(j.gap)||8;const Q=((ne=h.value)==null?void 0:ne.offsetWidth)||40;b.value=Q+k.value,y.value=U.map(oe=>oe.offsetWidth)}function M(){if(y.value.length===0)return;const Q=C.value-40-20,ne=k.value,oe=b.value;let Re=0,ue=0;for(let et=0;et<y.value.length;et++){const ye=y.value[et],sn=Re>0?ye+ne:ye,Ct=y.value.length-et-1>0?oe:0;if(Re+sn+Ct<=Q)Re+=sn,ue++;else break}m.value=Math.max(1,ue)}a.watch(C,()=>{y.value.length>0&&M()}),a.onMounted(()=>{a.nextTick(()=>{E(),M()})});const S=a.computed(()=>m.value<g.value);a.watchEffect(()=>{x().forEach((j,Q)=>{j.style.display=Q<m.value?"":"none"})}),a.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((j,Q)=>{j.style.display=Q>=m.value?"":"none"})});const{floatingStyles:v}=no(h,u,{placement:"top",middleware:[Zn(16),to(),eo({padding:8})],whileElementsMounted:As});function T(){f.value=!f.value}function B(){f.value=!1}function P(U){const j=U.target;h.value&&!h.value.contains(j)&&u.value&&!u.value.contains(j)&&B()}a.watch(f,U=>{U?document.addEventListener("click",P,!0):document.removeEventListener("click",P,!0)}),a.watch(S,U=>{U||B()});function O(U,j,Q){s.value=j??null,o(ne=>{const oe=w.Controls.write(ne);oe.leftMouseTool=U,oe.heldSnapshot=j??"",Q&&w.Cursor.setCursor(ne,Q)})}function _(U){o(j=>{const Q=w.Controls.write(j);Q.leftMouseTool="drag-out",Q.heldSnapshot=U})}function $(U,j){r.value=U,s.value=j??null}function F(){r.value=null,s.value=null}function J(){t(),r.value&&s.value&&_(s.value),r.value=null,s.value=null}const K={activeTool:l,heldTool:r,setTool:O,dragOutTool:_,onToolPointerDown:$,onToolPointerUp:F};return a.provide(Vs,K),(U,j)=>(a.openBlock(),a.createElementBlock("div",cx,[a.createVNode(FC),a.createElementVNode("div",{ref_key:"toolsContainerRef",ref:p,class:"wov-toolbar",onMouseleave:J},[a.unref(e).default?a.renderSlot(U.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(Q,ne)=>a.createVNode(a.resolveDynamicComponent(Q),{key:ne})),64)),S.value?(a.openBlock(),a.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:h,class:a.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:T},[...j[0]||(j[0]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[a.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):a.createCommentVNode("",!0),a.createVNode(Ul)],544),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[f.value&&S.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:a.normalizeStyle(a.unref(v))},[a.unref(e).default?a.renderSlot(U.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(Q,ne)=>a.createVNode(a.resolveDynamicComponent(Q),{key:ne})),64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)]))}}),dx=a.defineComponent({__name:"ArcArrowTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),ux={class:"wov-user-presence-avatars"},fx=["src","alt"],hx={class:"wov-user-presence-list"},px=["src","alt"],mx={class:"wov-user-presence-name"},gx=4,Jh=a.defineComponent({__name:"UserPresence",props:{users:{}},setup(n){const e=n,t=a.ref(!1),o=a.ref(null);dC(o,()=>{t.value=!1});function r(l){if(!l)return"?";const c=l.trim().split(/\s+/);return c.length>=2?(c[0][0]+c[1][0]).toUpperCase():l.slice(0,2).toUpperCase()}const s=a.computed(()=>e.users.map(l=>({sessionId:l.sessionId,name:l.name,color:l.color,avatar:l.avatar,initials:r(l.name)}))),i=a.computed(()=>s.value.slice(0,gx));return(l,c)=>n.users.length>1?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"containerRef",ref:o,class:"wov-user-presence"},[a.createElementVNode("button",{class:a.normalizeClass(["wov-user-presence-trigger",{"is-open":t.value}]),onClick:c[0]||(c[0]=d=>t.value=!t.value)},[a.createElementVNode("div",ux,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-avatar",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,fx)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4))),128))])],2),t.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:c[1]||(c[1]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",hx,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-presence-item"},[a.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,px)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4),a.createElementVNode("span",mx,a.toDisplayString(d.name),1)]))),128))])],32)):a.createCommentVNode("",!0)],512)):a.createCommentVNode("",!0)}}),Zl=(n,e)=>e.some(t=>n instanceof t);let Gh,Yh;function yx(){return Gh||(Gh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kx(){return Yh||(Yh=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const ea=new WeakMap,ta=new WeakMap,Ps=new WeakMap;function wx(n){const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("success",s),n.removeEventListener("error",i)},s=()=>{t(On(n.result)),r()},i=()=>{o(n.error),r()};n.addEventListener("success",s),n.addEventListener("error",i)});return Ps.set(e,n),e}function bx(n){if(ea.has(n))return;const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",i),n.removeEventListener("abort",i)},s=()=>{t(),r()},i=()=>{o(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",s),n.addEventListener("error",i),n.addEventListener("abort",i)});ea.set(n,e)}let na={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return ea.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return On(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Xh(n){na=n(na)}function Cx(n){return kx().includes(n)?function(...e){return n.apply(oa(this),e),On(this.request)}:function(...e){return On(n.apply(oa(this),e))}}function xx(n){return typeof n=="function"?Cx(n):(n instanceof IDBTransaction&&bx(n),Zl(n,yx())?new Proxy(n,na):n)}function On(n){if(n instanceof IDBRequest)return wx(n);if(ta.has(n))return ta.get(n);const e=xx(n);return e!==n&&(ta.set(n,e),Ps.set(e,n)),e}const oa=n=>Ps.get(n);function Sx(n,e,{blocked:t,upgrade:o,blocking:r,terminated:s}={}){const i=indexedDB.open(n,e),l=On(i);return o&&i.addEventListener("upgradeneeded",c=>{o(On(i.result),c.oldVersion,c.newVersion,On(i.transaction),c)}),t&&i.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),l.then(c=>{s&&c.addEventListener("close",()=>s()),r&&c.addEventListener("versionchange",d=>r(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const Ex=["get","getKey","getAll","getAllKeys","count"],vx=["put","add","delete","clear"],ra=new Map;function Qh(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(ra.get(e))return ra.get(e);const t=e.replace(/FromIndex$/,""),o=e!==t,r=vx.includes(t);if(!(t in(o?IDBIndex:IDBObjectStore).prototype)||!(r||Ex.includes(t)))return;const s=async function(i,...l){const c=this.transaction(i,r?"readwrite":"readonly");let d=c.store;return o&&(d=d.index(l.shift())),(await Promise.all([d[t](...l),r&&c.done]))[0]};return ra.set(e,s),s}Xh(n=>({...n,get:(e,t,o)=>Qh(e,t)||n.get(e,t,o),has:(e,t)=>!!Qh(e,t)||n.has(e,t)}));const Mx=["continue","continuePrimaryKey","advance"],Zh={},sa=new WeakMap,ep=new WeakMap,Tx={get(n,e){if(!Mx.includes(e))return n[e];let t=Zh[e];return t||(t=Zh[e]=function(...o){sa.set(this,ep.get(this)[e](...o))}),t}};async function*Nx(...n){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...n)),!e)return;e=e;const t=new Proxy(e,Tx);for(ep.set(t,e),Ps.set(t,oa(e));e;)yield t,e=await(sa.get(t)||e.continue()),sa.delete(t)}function tp(n,e){return e===Symbol.asyncIterator&&Zl(n,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Zl(n,[IDBIndex,IDBObjectStore])}Xh(n=>({...n,get(e,t,o){return tp(e,t)?Nx:n.get(e,t,o)},has(e,t){return tp(e,t)||n.has(e,t)}}));async function ia(n,e){const t=await Sx(n,1,{upgrade(o){o.objectStoreNames.contains(e)||o.createObjectStore(e)}});return new Ax(t,e)}var Ax=class{constructor(n,e){this.db=n,this.storeName=e}async get(n){return this.db.get(this.storeName,n)}async put(n,e){await this.db.put(this.storeName,e,n)}async delete(n){await this.db.delete(this.storeName,n)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),t=await e.getAllKeys(),o=await e.getAll(),r=[];for(let s=0;s<t.length;s++)r.push([t[s],o[s]]);return r}async clear(){const n=this.db.transaction(this.storeName,"readwrite");n.objectStore(this.storeName).clear(),await n.done}close(){this.db.close()}},Bx=class{constructor(n){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=n.provider,this.documentId=n.documentId,this.maxRetries=n.provider.maxRetries??3,this.retryDelay=n.provider.retryDelay??5e3}async init(){const n=`wovencanvas-assets-${this.documentId}`,[e,t]=await Promise.all([ia(`${n}-jobs`,"jobs"),ia(`${n}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=t}async upload(n,e,t){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(n,e);const o={identifier:n,metadata:t,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(n,o);const r=URL.createObjectURL(e);return this.blobUrls.set(n,r),new Promise((s,i)=>{this.uploadPromises.set(n,{resolve:s,reject:i}),this.startUpload(n)})}async getDisplayUrl(n){if(!n)return null;const e=this.blobUrls.get(n);if(e)return e;try{return await this.provider.resolveUrl(n)}catch(t){return console.error(`Failed to resolve URL for ${n}:`,t),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const n=await this.jobsStore.getAllEntries();for(const[e]of n){const t=await this.binariesStore.get(e);if(t){const o=URL.createObjectURL(t);this.blobUrls.set(e,o)}this.startUpload(e)}}hasPendingUpload(n){return this.blobUrls.has(n)}isUploading(n){return this.uploading.has(n)}async cancelUpload(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.reject(new Error("Upload cancelled")),this.uploadPromises.delete(n))}close(){var n,e;for(const t of this.blobUrls.values())URL.revokeObjectURL(t);this.blobUrls.clear(),(n=this.jobsStore)==null||n.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(n){if(!this.jobsStore||!this.binariesStore||this.uploading.has(n))return;this.uploading.add(n);const e=await this.jobsStore.get(n),t=await this.binariesStore.get(n);if(!e||!t){this.uploading.delete(n);return}try{await this.provider.upload(t,n,e.metadata),await this.onUploadSuccess(n)}catch(o){await this.onUploadError(n,e,o)}}async onUploadSuccess(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.resolve(),this.uploadPromises.delete(n))}async onUploadError(n,e,t){if(!this.jobsStore)return;const o=t instanceof Error?t.message:"Unknown error";if(console.error(`Upload failed for ${n}:`,o),this.uploading.delete(n),e.retryCount<this.maxRetries){const r={...e,retryCount:e.retryCount+1};await this.jobsStore.put(n,r),setTimeout(()=>{this.startUpload(n)},this.retryDelay*2**e.retryCount)}else{const r=this.uploadPromises.get(n);r&&(r.reject(new Error(o)),this.uploadPromises.delete(n))}}},Ix="wovencanvas-assets",Ox="blobs",Rx=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(n,e,t){return await(await this.getStore()).put(e,{blob:n,metadata:t}),{}}async resolveUrl(n){if(n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/"))return n;const t=await(await this.getStore()).get(n);if(!t)throw new Error(`Asset not found: ${n}`);return URL.createObjectURL(t.blob)}async delete(n){await(await this.getStore()).delete(n)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=ia(Ix,Ox).then(n=>(this.store=n,n))),this.initPromise)}};const Px={class:"wov-selection-box"},Dx=a.defineComponent({__name:"SelectionBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",Px))}}),_x={class:"wov-transform-box"},Lx=a.defineComponent({__name:"TransformBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",_x))}}),Vx={},$x={class:"wov-transform-handle"};function zx(n,e){return a.openBlock(),a.createElementBlock("div",$x)}const Fx=an(Vx,[["render",zx]]),Hx=a.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=me(e.entityId,w.Color),o=me(e.entityId,w.VerticalAlign),r=a.ref(null),s={[w.VerticalAlignment.Top]:"flex-start",[w.VerticalAlignment.Center]:"center",[w.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>{var c;return{backgroundColor:t.value?`rgb(${t.value.red}, ${t.value.green}, ${t.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((c=o.value)==null?void 0:c.value)??w.VerticalAlignment.Top]}}),{handleEditEnd:l}=Pl({blockData:e,containerRef:r,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(c,d)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-sticky-note",style:a.normalizeStyle(i.value)},[a.createVNode(ys,a.mergeProps(e,{"block-element":r.value,onEditEnd:a.unref(l)}),null,16,["block-element","onEditEnd"])],4))}}),Ux=400,jx=10,Wx=w.defineEditorSystem({phase:"capture"},n=>{var u;const e=Fo.read(n);if(!e.snapshot)return;const t=w.Controls.read(n);if(t.leftMouseTool!=="select"||t.heldSnapshot)return;const o=w.getPointerInput(n,[w.PointerButton.Left]);if(o.length===0)return;const r=o.find(f=>f.type==="click"&&!f.obscured);if(!r||r.intersects.length>0)return;const s=performance.now(),i=s-e.lastClickTime,l=r.worldPosition[0]-e.lastClickWorldX,c=r.worldPosition[1]-e.lastClickWorldY,d=Math.sqrt(l*l+c*c);if(i<Ux&&d<jx){let f;try{f=JSON.parse(e.snapshot)}catch{return}if(!((u=f.block)!=null&&u.tag))return;const{editor:p}=w.getResources(n);if(!(f.block.tag in p.blockDefs))return;const h=f.block.tag,m=Ml(n,f,r.worldPosition);w.addComponent(n,m,te.Selected,{}),w.canBlockEdit(n,h)&&w.addComponent(n,m,te.EditAfterPlacing,{});const g=Fo.write(n);g.lastClickTime=0,g.lastClickWorldX=0,g.lastClickWorldY=0}else{const f=Fo.write(n);f.lastClickTime=s,f.lastClickWorldX=r.worldPosition[0],f.lastClickWorldY=r.worldPosition[1]}}),Kx=w.defineEditorSystem({phase:"update"},n=>{const{store:e}=w.getPluginResources(n,Yn);w.on(n,w.Undo,()=>{e.canUndo()&&(te.deselectAll(n),e.undo())}),w.on(n,w.Redo,()=>{e.canRedo()&&(te.deselectAll(n),e.redo())})}),qx=[{name:"Figtree",displayName:"Figtree",url:"https://fonts.googleapis.com/css2?family=Figtree",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/Figtree.png"},{name:"Shantell Sans",displayName:"Shantell Sans",url:"https://fonts.googleapis.com/css2?family=Shantell+Sans",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/ShantellSans.png"},{name:"Courier Prime",displayName:"Courier Prime",url:"https://fonts.googleapis.com/css2?family=Courier+Prime",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/CourierPrime.png"},{name:"EB Garamond",displayName:"EB Garamond",url:"https://fonts.googleapis.com/css2?family=EB+Garamond",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/EBGaramond.png"}];function np(n){return{name:Yn,resources:{store:n.store},singletons:[ms,Fo],systems:[$w,Wx,Kx],setup(e){n.doubleClickSnapshot&&(Fo.write(e).snapshot=n.doubleClickSnapshot)},cursors:Dh,fonts:qx,keybinds:[{command:w.Undo.name,key:w.Key.Z,mod:!0},{command:w.Redo.name,key:w.Key.Y,mod:!0},{command:w.Redo.name,key:w.Key.Z,mod:!0,shift:!0}]}}const Jx=a.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(n){const e=n,{nextEditorTick:t}=ce(),{createImageBlock:o}=Uf(),r=a.ref(!1);let s=0;const i=a.inject("containerRef");function l(b){var C;(C=b.dataTransfer)!=null&&C.types.some(x=>x==="Files"||x==="text/uri-list"||x==="text/html")&&(s++,s===1&&(r.value=!0))}function c(){s--,s===0&&(r.value=!1)}function d(){s=0,r.value=!1}a.onMounted(()=>{const b=i==null?void 0:i.value;b&&(b.addEventListener("dragenter",l),b.addEventListener("dragleave",c),b.addEventListener("drop",d))}),a.onUnmounted(()=>{const b=i==null?void 0:i.value;b&&(b.removeEventListener("dragenter",l),b.removeEventListener("dragleave",c),b.removeEventListener("drop",d))});function u(b){b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="copy")}function f(b){b.preventDefault()}function p(b){b.preventDefault()}async function h(b){if(b.preventDefault(),!b.dataTransfer)return;const C=b.clientX,x=b.clientY,E=Array.from(b.dataTransfer.files).filter(S=>S.type.startsWith("image/"));if(E.length>0){for(const S of E)await y(S,C,x);return}const M=m(b.dataTransfer);M&&await k(M,C,x)}function m(b){const C=b.getData("text/uri-list");if(C){const S=C.split(`
|
|
107
|
-
`).filter(v=>!v.startsWith("#")).find(v=>g(v));if(S)return S}const x=b.getData("text/html");if(x){const M=x.match(/<img[^>]+src=["']([^"']+)["']/i);if(M!=null&&M[1])return M[1]}const E=b.getData("text/plain");return E&&g(E)?E:null}function g(b){try{const x=new URL(b).pathname.toLowerCase();return/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i.test(x)||b.startsWith("data:image/"),!0}catch{return!1}}async function y(b,C,x){const E=await t(),M=w.Camera.read(E),S=w.Screen.read(E),v=M.left+(C-S.left)/M.zoom,T=M.top+(x-S.top)/M.zoom;await o(b,v,T,{maxSize:e.maxSize})}async function k(b,C,x){try{const E=await fetch(b);if(!E.ok){console.warn("Failed to fetch image from URL:",b);return}const M=await E.blob();if(!M.type.startsWith("image/")){console.warn("URL did not return an image:",b);return}const v=new URL(b).pathname.split("/").pop()||"image",T=new File([M],v,{type:M.type});await y(T,C,x)}catch(E){console.warn("Failed to load image from URL:",b,E)}}return(b,C)=>(a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["wov-image-drop-zone",{"wov-drag-over":r.value}]),onDragover:u,onDragenter:f,onDragleave:p,onDrop:h},null,34))}}),Gx=a.defineComponent({__name:"ClipboardHandler",props:{options:{}},setup(n){const e=n,t=a.inject("containerRef",a.ref(null));return Jw(t,e.options),(o,r)=>a.renderSlot(o.$slots,"default")}}),Yx={class:"wov-user-cursors"},Xx={class:"wov-cursor-svg",viewBox:"0 0 4.35 4.75",width:"20",height:"20"},Qx=["fill"],Zx="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z",eS=a.defineComponent({__name:"UserCursors",props:{users:{},currentSessionId:{},camera:{}},setup(n){const e=n,t=a.computed(()=>e.users.filter(o=>o.sessionId!==e.currentSessionId).map(o=>({...o,screenX:(o.position[0]-e.camera.left)*e.camera.zoom,screenY:(o.position[1]-e.camera.top)*e.camera.zoom})));return(o,r)=>(a.openBlock(),a.createElementBlock("div",Yx,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.value,s=>(a.openBlock(),a.createElementBlock("div",{key:s.sessionId,class:"wov-user-cursor",style:a.normalizeStyle({transform:`translate(${s.screenX}px, ${s.screenY}px)`})},[(a.openBlock(),a.createElementBlock("svg",Xx,[a.createElementVNode("path",{fill:s.color,stroke:"#fff","stroke-miterlimit":"10","stroke-width":".25",d:Zx},null,8,Qx)])),a.createElementVNode("span",{class:"wov-cursor-label",style:a.normalizeStyle({backgroundColor:s.color})},a.toDisplayString(s.name),5)],4))),128))]))}}),tS={key:0,class:"wov-offline-indicator"},nS=a.defineComponent({__name:"OfflineIndicator",props:{isOnline:{type:Boolean}},setup(n){return(e,t)=>n.isOnline?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",tS,"Working Offline"))}}),oS={key:0,class:"wov-version-mismatch-overlay"},rS=a.defineComponent({__name:"VersionMismatch",props:{versionMismatch:{type:Boolean}},setup(n){function e(){window.location.reload()}return(t,o)=>n.versionMismatch?(a.openBlock(),a.createElementBlock("div",oS,[a.createElementVNode("div",{class:"wov-version-mismatch-dialog"},[o[0]||(o[0]=a.createElementVNode("p",null,"A new version is available.",-1)),o[1]||(o[1]=a.createElementVNode("p",null,"Please refresh the page to continue.",-1)),a.createElementVNode("button",{onClick:e},"Refresh")])])):a.createCommentVNode("",!0)}}),sS=a.defineComponent({__name:"BackToContentButton",setup(n){const{nextEditorTick:e}=ce(),t=Ie(w.Camera),o=w.defineQuery(d=>d.with(w.Synced,w.Block,w.Aabb)),r=a.ref(0),s=a.inject(ke);if(s){const d=s.registerTickCallback(u=>{o.addedOrRemoved(u).length>0&&(r.value=o.current(u).length)});a.onUnmounted(d)}const i=a.ref(!1);a.watchEffect(()=>{i.value=!t.value.canSeeBlocks&&r.value>0});function l(d,u,f,p,h){const m=u+p,g=f+h;return d[0]<m&&d[2]>u&&d[1]<g&&d[3]>f}function c(){e(d=>{const u=o.current(d);if(u.length===0)return;let f=Number.POSITIVE_INFINITY,p=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const P of u){const O=w.Aabb.read(d,P);f=Math.min(f,O.value[0]),p=Math.min(p,O.value[1]),h=Math.max(h,O.value[2]),m=Math.max(m,O.value[3])}const g=w.Screen.read(d),y=w.Camera.read(d),k=w.getPluginResources(d,_s.CONTROLS_PLUGIN_NAME)??_s.DEFAULT_CONTROLS_OPTIONS;let b=Math.min(g.width/(h-f),g.height/(m-p));b/=1.1,b=Math.min(b,y.zoom),b=Math.max(k.minZoom,Math.min(k.maxZoom,b));const C=(f+h)/2,x=(p+m)/2;let E=C-g.width/b/2,M=x-g.height/b/2;const S=g.width/b,v=g.height/b;let T=!1;for(const P of u){const O=w.Aabb.read(d,P);if(l(O.value,E,M,S,v)){T=!0;break}}if(!T){const P=Math.floor(Math.random()*u.length),O=u[P],_=w.Aabb.read(d,O),$=(_.value[0]+_.value[2])/2,F=(_.value[1]+_.value[3])/2;E=$-S/2,M=F-v/2}const B=w.Camera.write(d);B.left=E,B.top=M,B.zoom=b})}return(d,u)=>i.value?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-back-to-content",onClick:c},[...u[0]||(u[0]=[a.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a.createElementVNode("path",{d:"M10 12L6 8L10 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),a.createTextVNode(" Back to content ",-1)])])):a.createCommentVNode("",!0)}}),iS=["data-entity-id","data-selected","data-held-by-other","data-hovered"],lS=a.defineComponent({__name:"WovenCanvasCore",props:{store:{},editor:{},background:{},assetProvider:{},pluginOptions:{},controls:{},doubleClickSnapshot:{},copyPaste:{},initialState:{}},emits:["ready"],async setup(n,{emit:e}){var ip,lp,ap;let t,o;const r=w.defineQuery(N=>N.tracking(w.Block)),s=w.defineQuery(N=>N.with(w.Block).tracking(w.Connector)),i=w.defineQuery(N=>N.with(w.Block).tracking(te.Selected)),l=w.defineQuery(N=>N.with(w.Block).tracking(w.Held)),c=w.defineQuery(N=>N.with(w.Block).tracking(w.Hovered)),d=w.defineQuery(N=>N.with(w.Block).tracking(w.Edited)),u=w.defineQuery(N=>N.with(w.Block).tracking(w.Opacity)),f=w.defineQuery(N=>N.tracking(w.User)),p=n,h=e,m=a.ref(null),g=a.shallowRef(null),y=w.UserData.parse(((ip=p.editor)==null?void 0:ip.user)??{}),k=new Set,b=new Map,C=a.shallowRef([]),x=new Map,E=new Map,M=new Set,S=new Map,v=a.shallowRef([]),T=a.ref(!0),B=a.ref(!1),P=a.ref(!p.initialState),O=a.shallowRef(w.Camera.default());function _(N,H,A){let G=x.get(N);G||(G=new Map,x.set(N,G));let V=G.get(H);return V||(V=new Set,G.set(H,V)),V.add(A),()=>{V.delete(A),V.size===0&&(G.delete(H),G.size===0&&x.delete(N))}}function $(N,H,A,G=!1){const V=x.get(H);if(!V)return;const L=V.get(A.name);if(!L||L.size===0)return;let Ee=null;G||(Ee=A.snapshot(N,H));for(const ln of L)ln(Ee)}function F(N,H){let A=E.get(N);return A||(A=new Set,E.set(N,A)),A.add(H),()=>{A.delete(H),A.size===0&&E.delete(N)}}function J(N,H){const A=E.get(H.name);if(!A||A.size===0)return;const G=H.snapshot(N);for(const V of A)V(G)}function K(N){return M.add(N),()=>{M.delete(N)}}function U(){return y.sessionId}function j(N){return b.get(N)??null}const Q={hasEntity:N=>k.has(N),getEditor:()=>g.value,getAssetManager:()=>ye,getSessionId:U,getUserBySessionId:j,subscribeComponent:_,subscribeSingleton:F,registerTickCallback:K,defaults:a.reactive({}),setDefaults(N,H){this.defaults[N]={...this.defaults[N],...H}},getDefaults(N){return this.defaults[N]??{}}};a.provide(ke,Q),a.provide("containerRef",m);const ne=Jf();a.provide(fa,ne),Yw(N=>{var H;(H=g.value)==null||H.nextTick(N)});let oe=0,Re=null,ue=null;const et=((ap=(lp=p.store)==null?void 0:lp.persistence)==null?void 0:ap.documentId)??"default";let ye=new Bx({provider:p.assetProvider??new Rx,documentId:et});function sn(N){var G;const H=[],A=p.pluginOptions;return(A==null?void 0:A.controls)!==!1&&H.push(_s.CanvasControlsPlugin((A==null?void 0:A.controls)??{})),(A==null?void 0:A.selection)!==!1&&H.push(te.createSelectionPlugin((A==null?void 0:A.selection)||void 0)),(A==null?void 0:A.eraser)!==!1&&H.push(qo.createEraserPlugin((A==null?void 0:A.eraser)||void 0)),(A==null?void 0:A.pen)!==!1&&H.push(Jo.createPenPlugin()),(A==null?void 0:A.arrows)!==!1&&H.push(ee.createArrowsPlugin((A==null?void 0:A.arrows)||void 0)),(A==null?void 0:A.tapes)!==!1&&H.push(pp.createTapesPlugin()),H.push(np({store:N,doubleClickSnapshot:p.doubleClickSnapshot})),(G=p.editor)!=null&&G.plugins&&H.push(...p.editor.plugins),H}function Ds(){const N=p.store??{},H={history:!0,...N};return N.websocket&&(H.websocket={...N.websocket,onVersionMismatch:A=>{var G,V;B.value=!0,(V=(G=N.websocket)==null?void 0:G.onVersionMismatch)==null||V.call(G,A)},onConnectivityChange:A=>{var G,V;T.value=A,(V=(G=N.websocket)==null?void 0:G.onConnectivityChange)==null||V.call(G,A)}}),H}async function oo(N,H){const A=Ds();N||(delete A.persistence,delete A.websocket),H&&(A.initialState=H),ue=new Le.CanvasStore(A);const G={...p.editor,user:y,plugins:sn(ue),controls:p.controls},V=new w.Editor(N,G);return await V.initialize(),await ue.initialize({components:V.components,singletons:V.singletons}),V}async function Ct(N){N.nextTick(H=>{ue&&ue.sync(H),cS(H),dS(H);for(const A of M)A(H)}),await N.tick()}async function op(){!g.value||!ue||(await Ct(g.value),Re=requestAnimationFrame(op))}if(F(w.Camera.name,N=>{N&&(O.value=N)}),p.initialState&&typeof window>"u"){const N=([t,o]=a.withAsyncContext(()=>oo(null,p.initialState)),t=await t,o(),t);[t,o]=a.withAsyncContext(()=>Ct(N)),await t,o(),[t,o]=a.withAsyncContext(()=>Ct(N)),await t,o(),g.value=N}let rp=null;a.onMounted(async()=>{var A,G,V;if(!m.value)return;rp=()=>{var L;(L=m.value)==null||L.scrollTo(0,0)},m.value.addEventListener("scroll",rp),g.value&&(g.value.dispose(),ue==null||ue.close(),ue=null,oe=0);const N=await oo(m.value,p.initialState);g.value=N,P.value=!1,await(ye==null?void 0:ye.init()),await(ye==null?void 0:ye.resumePendingUploads()),Re=requestAnimationFrame(op);const H=(V=(G=(A=g.value)==null?void 0:A.fonts)==null?void 0:G[0])==null?void 0:V.name;H&&Q.setDefaults("text",{fontFamily:H}),h("ready",g.value,ue)}),a.onUnmounted(()=>{var N;Re!==null&&cancelAnimationFrame(Re),ye==null||ye.close(),ue==null||ue.close(),(N=g.value)==null||N.dispose()});function cS(N){const{events:H,newIndex:A}=N.eventBuffer.readEvents(oe);if(oe=A,H.length===0)return;const{componentsById:G,singletonsById:V}=w.getResources(N);for(const{entityId:L,eventType:Ee,componentId:ln}of H){if(L===w.SINGLETON_ENTITY_ID){if(Ee===w.EventType.CHANGED){const ct=V.get(ln);ct&&J(N,ct)}continue}if(Ee===w.EventType.ADDED)k.add(L);else if(Ee===w.EventType.REMOVED)k.delete(L),x.delete(L);else if(Ee===w.EventType.COMPONENT_ADDED){k.add(L);const ct=G.get(ln);ct&&$(N,L,ct)}else if(Ee===w.EventType.COMPONENT_REMOVED){const ct=G.get(ln);ct&&$(N,L,ct,!0)}else if(Ee===w.EventType.CHANGED){const ct=G.get(ln);ct&&$(N,L,ct)}}}function dS(N){var G;let H=!1;for(const V of r.added(N)){const L=w.Block.snapshot(N,V),Ee=(G=g.value)==null?void 0:G.blockDefs[L.tag],ln=(Ee==null?void 0:Ee.stratum)??"content";S.set(V,a.ref({entityId:V,block:L,stratum:ln,selected:!1,held:null,hovered:!1,edited:!1,opacity:null,connector:null})),H=!0}for(const V of r.removed(N))S.delete(V),H=!0;for(const V of r.changed(N)){const L=S.get(V);if(L){const Ee=w.Block.snapshot(N,V);L.value.block.rank!==Ee.rank&&(H=!0),L.value.block=Ee}}let A=!1;for(const V of f.addedOrChanged(N)){const L=w.User.snapshot(N,V);b.set(L.sessionId,L),A=!0}for(const V of f.removed(N)){const L=w.User.read(N,V);b.delete(L.sessionId),A=!0}A&&(C.value=Array.from(b.values()));for(const V of i.added(N)){const L=S.get(V);L&&!L.value.selected&&(L.value.selected=!0)}for(const V of i.removed(N)){const L=S.get(V);L!=null&&L.value.selected&&(L.value.selected=!1)}for(const V of l.addedOrChanged(N)){const L=S.get(V);L&&(L.value.held=w.Held.snapshot(N,V))}for(const V of l.removed(N)){const L=S.get(V);L&&L.value.held!==null&&(L.value.held=null)}for(const V of c.added(N)){const L=S.get(V);L&&!L.value.hovered&&(L.value.hovered=!0)}for(const V of c.removed(N)){const L=S.get(V);L!=null&&L.value.hovered&&(L.value.hovered=!1)}for(const V of d.added(N)){const L=S.get(V);L&&!L.value.edited&&(L.value.edited=!0)}for(const V of d.removed(N)){const L=S.get(V);L!=null&&L.value.edited&&(L.value.edited=!1)}for(const V of u.addedOrChanged(N)){const L=S.get(V);L&&(L.value.opacity=w.Opacity.snapshot(N,V))}for(const V of u.removed(N)){const L=S.get(V);L&&L.value.opacity!==null&&(L.value.opacity=null)}for(const V of s.addedOrChanged(N)){const L=S.get(V);L&&(L.value.connector=w.Connector.snapshot(N,V))}for(const V of s.removed(N)){const L=S.get(V);L&&L.value.connector!==null&&(L.value.connector=null)}if(H){const V=Array.from(S.values());V.sort((L,Ee)=>L.value.block.rank>Ee.value.block.rank?1:-1),v.value=V}}function uS(N){const H=N.rotateZ!==0,A=N.flip[0],G=N.flip[1];if(!H&&!A&&!G)return;const V=[];return H&&V.push(`rotate(${N.rotateZ}rad)`),A&&V.push("scaleX(-1)"),G&&V.push("scaleY(-1)"),V.join(" ")}function sp(N){const{held:H}=N;if(!H||!H.sessionId||H.sessionId===y.sessionId)return null;const A=j(H.sessionId);return(A==null?void 0:A.color)??null}function fS(N){const{block:H,stratum:A,opacity:G}=N,V=sp(N),L=G!==null?G.value/255:1;return{position:"absolute",left:`${H.position[0]}px`,top:`${H.position[1]}px`,width:`${H.size[0]}px`,height:`${H.size[1]}px`,zIndex:w.STRATUM_ORDER[A]*1e3,transform:uS(H),opacity:L,pointerEvents:"none",userSelect:"none","--wov-held-by-color":V??void 0,transition:L===1?"opacity 0ms 32ms":void 0}}return(N,H)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:m,class:"wov-root",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},[n.background?a.renderSlot(N.$slots,"background",{key:0,background:n.background},()=>[a.createVNode(Bh,{background:n.background},null,8,["background"])]):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"wov-canvas",style:a.normalizeStyle({position:"absolute",transformOrigin:"0 0",transform:`scale(${O.value.zoom}) translate(${-O.value.left}px, ${-O.value.top}px)`,"--wov-zoom":O.value.zoom})},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(v.value,A=>(a.openBlock(),a.createElementBlock("div",{key:A.value.entityId,"data-entity-id":A.value.entityId,style:a.normalizeStyle(fS(A.value)),"data-selected":A.value.selected||void 0,"data-held-by-other":sp(A.value)!==null||void 0,"data-hovered":A.value.hovered||void 0,class:"wov-block"},[a.renderSlot(N.$slots,`block:${A.value.block.tag}`,a.mergeProps({ref_for:!0},A.value),()=>[A.value.block.tag==="selection-box"?(a.openBlock(),a.createBlock(Dx,a.mergeProps({key:0,ref_for:!0},A.value),null,16)):A.value.block.tag==="transform-box"?(a.openBlock(),a.createBlock(Lx,a.mergeProps({key:1,ref_for:!0},A.value),null,16)):A.value.block.tag==="transform-handle"?(a.openBlock(),a.createBlock(Fx,a.mergeProps({key:2,ref_for:!0},A.value),null,16)):A.value.block.tag==="arrow-handle"?(a.openBlock(),a.createBlock(pa,a.mergeProps({key:3,ref_for:!0},A.value),null,16)):A.value.block.tag==="arrow-terminal"?(a.openBlock(),a.createBlock(ma,a.mergeProps({key:4,ref_for:!0},A.value),null,16)):A.value.block.tag==="sticky-note"?(a.openBlock(),a.createBlock(Hx,a.mergeProps({key:5,ref_for:!0},A.value),null,16)):A.value.block.tag==="eraser"?(a.openBlock(),a.createBlock(Ra,a.mergeProps({key:6,ref_for:!0},A.value),null,16)):A.value.block.tag==="pen-stroke"?(a.openBlock(),a.createBlock(Da,a.mergeProps({key:7,ref_for:!0},A.value),null,16)):A.value.block.tag==="arc-arrow"?(a.openBlock(),a.createBlock(ha,a.mergeProps({key:8,ref_for:!0},A.value),null,16)):A.value.block.tag==="elbow-arrow"?(a.openBlock(),a.createBlock(ga,a.mergeProps({key:9,ref_for:!0},A.value),null,16)):A.value.block.tag==="text"?(a.openBlock(),a.createBlock(Xf,a.mergeProps({key:10,ref_for:!0},A.value),null,16)):A.value.block.tag==="image"?(a.openBlock(),a.createBlock(Pa,a.mergeProps({key:11,ref_for:!0},A.value),null,16)):A.value.block.tag==="shape"?(a.openBlock(),a.createBlock(Gf,a.mergeProps({key:12,ref_for:!0},A.value),null,16)):A.value.block.tag==="embed"?(a.openBlock(),a.createBlock(ya,a.mergeProps({key:13,ref_for:!0},A.value),null,16)):A.value.block.tag==="tape"?(a.openBlock(),a.createBlock(Yf,a.mergeProps({key:14,ref_for:!0},A.value),null,16)):a.createCommentVNode("",!0)])],12,iS))),128))],4),g.value?a.renderSlot(N.$slots,"user-cursors",{key:1,users:C.value,currentSessionId:a.unref(y).sessionId,camera:O.value},()=>[a.createVNode(eS,{users:C.value,"current-session-id":a.unref(y).sessionId,camera:O.value},null,8,["users","current-session-id","camera"])]):a.createCommentVNode("",!0),g.value?(a.openBlock(),a.createBlock(Rh,{key:2},{default:a.withCtx(A=>[a.renderSlot(N.$slots,"floating-menu",a.normalizeProps(a.guardReactiveProps(A)))]),_:3})):a.createCommentVNode("",!0),g.value?a.renderSlot(N.$slots,"user-presence",{key:3,users:C.value},()=>[a.createVNode(Jh,{users:C.value},null,8,["users"])]):a.createCommentVNode("",!0),g.value?a.renderSlot(N.$slots,"toolbar",{key:4},()=>[a.createVNode(qh)]):a.createCommentVNode("",!0),g.value?a.renderSlot(N.$slots,"default",{key:5}):a.createCommentVNode("",!0),a.renderSlot(N.$slots,"offline-indicator",{isOnline:T.value},()=>[a.createVNode(nS,{"is-online":T.value},null,8,["is-online"])]),a.renderSlot(N.$slots,"version-mismatch",{versionMismatch:B.value},()=>[a.createVNode(rS,{"version-mismatch":B.value},null,8,["version-mismatch"])]),a.renderSlot(N.$slots,"back-to-content",{},()=>[a.createVNode(sS)]),a.renderSlot(N.$slots,"loading",{isLoading:P.value},()=>[a.createVNode(Ph,{"is-loading":P.value},null,8,["is-loading"])]),g.value?a.renderSlot(N.$slots,"file-drop-zone",{key:6},()=>[a.createVNode(Jx)]):a.createCommentVNode("",!0),g.value?(a.openBlock(),a.createBlock(Gx,{key:7,options:p.copyPaste},null,8,["options"])):a.createCommentVNode("",!0)],512))}}),aS=a.defineComponent({inheritAttrs:!1,__name:"WovenCanvas",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(a.Suspense,null,{default:a.withCtx(()=>[a.createVNode(lS,a.normalizeProps(a.guardReactiveProps(e.$attrs)),a.createSlots({_:2},[a.renderList(e.$slots,(o,r)=>({name:r,fn:a.withCtx(s=>[a.renderSlot(e.$slots,r,a.normalizeProps(a.guardReactiveProps(s??{})))])}))]),1040)]),_:3}))}});Object.defineProperty(R,"CanvasComponentDef",{enumerable:!0,get:()=>Le.CanvasComponentDef}),Object.defineProperty(R,"CanvasSingletonDef",{enumerable:!0,get:()=>Le.CanvasSingletonDef}),Object.defineProperty(R,"CanvasStore",{enumerable:!0,get:()=>Le.CanvasStore}),Object.defineProperty(R,"Synced",{enumerable:!0,get:()=>Le.Synced}),Object.defineProperty(R,"defineCanvasComponent",{enumerable:!0,get:()=>Le.defineCanvasComponent}),Object.defineProperty(R,"defineCanvasSingleton",{enumerable:!0,get:()=>Le.defineCanvasSingleton}),R.ARROW_HEADS=Ls,R.ArcArrow=ha,R.ArcArrowTool=dx,R.ArrowHandle=pa,R.ArrowHead=xt,R.ArrowHeadButton=Hl,R.ArrowTerminal=ma,R.ArrowThicknessButton=wh,R.CURSORS=Dh,R.CanvasBackground=Bh,R.ColorButton=Ch,R.ColorPicker=bh,R.CursorKind=rn,R.EDITING_PLUGIN_NAME=Yn,R.EditableText=ys,R.EditingPlugin=np,R.ElbowArrow=ga,R.ElbowArrowTool=Uh,R.EmbedBlock=ya,R.EmbedTool=Wh,R.Eraser=Ra,R.EraserTool=zh,R.FloatingMenu=Rh,R.FloatingMenuBar=Oh,R.HandTool=Lh,R.IconChevronDown=qe,R.ImageBlock=Pa,R.ImageTool=jh,R.LoadingOverlay=Ph,R.MenuButton=In,R.MenuDropdown=Ke,R.MenuTooltip=Ul,R.PenStroke=Da,R.PenStrokeThicknessButton=xh,R.PenTool=Fh,R.SHAPES=so,R.SelectTool=_h,R.ShapeBlock=Gf,R.ShapeFillColorButton=Sh,R.ShapeKindButton=Eh,R.ShapeStrokeColorButton=vh,R.ShapeTool=$h,R.StickyNoteTool=Vh,R.TapeBlock=Yf,R.TapeImageButton=Mh,R.TapeTool=Kh,R.TextAlignmentButton=jl,R.TextBlock=Xf,R.TextBoldButton=Wl,R.TextColorButton=Ql,R.TextFontFamilyButton=ql,R.TextFontSizeButton=Jl,R.TextItalicButton=Gl,R.TextLinkButton=Xl,R.TextTool=Hh,R.TextUnderlineButton=Yl,R.Toolbar=qh,R.ToolbarButton=at,R.UserPresence=Jh,R.WovenCanvas=aS,R.computeCommonComponents=Ih,R.createTooltipContext=Jf,R.getArrowHead=Rn,R.useComponent=me,R.useComponents=Pt,R.useEditorContext=ce,R.useFonts=Nh,R.useQuery=jf,R.useSingleton=Ie,R.useTextBatchController=qf,R.useTextEditorController=Mn,R.useTextFormatting=rt,R.useTextStretchBehavior=Pl,R.useToolbar=gs,R.useTooltipSingleton=Dt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
|
|
106
|
+
3. "-" cannot repeat`);ue.customSchemes.push([n,e])}function qb(){ue.scanner=$b(ue.customSchemes);for(let n=0;n<ue.tokenQueue.length;n++)ue.tokenQueue[n][1]({scanner:ue.scanner});ue.parser=Hb(ue.scanner.tokens);for(let n=0;n<ue.pluginQueue.length;n++)ue.pluginQueue[n][1]({scanner:ue.scanner,parser:ue.parser});return ue.initialized=!0,ue}function na(n){return ue.initialized||qb(),jb(ue.parser.start,n,yh(ue.scanner.start,n))}na.scan=yh;function Eh(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const o=new ea(t),r=na(n),s=[];for(let i=0;i<r.length;i++){const l=r[i];l.isLink&&(!e||l.t===e)&&o.check(l)&&s.push(l.toFormattedObject(o))}return s}var oa="[\0- -\u2029 ]",Jb=new RegExp(oa),Gb=new RegExp(`${oa}$`),Yb=new RegExp(oa,"g");function Xb(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Qb(n){return new ge({key:new Ee("autolink"),appendTransaction:(e,t,o)=>{const r=e.some(d=>d.docChanged)&&!t.doc.eq(o.doc),s=e.some(d=>d.getMeta("preventAutolink"));if(!r||s)return;const{tr:i}=o,l=Tf(t.doc,[...e]);if(Lf(l).forEach(({newRange:d})=>{const u=aw(o.doc,d,h=>h.isTextblock);let f,p;if(u.length>1)f=u[0],p=o.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const h=o.doc.textBetween(d.from,d.to," "," ");if(!Gb.test(h))return;f=u[0],p=o.doc.textBetween(f.pos,d.to,void 0," ")}if(f&&p){const h=p.split(Jb).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=f.pos+p.lastIndexOf(m);if(!m)return!1;const y=na(m).map(w=>w.toObject(n.defaultProtocol));if(!Xb(y))return!1;y.filter(w=>w.isLink).map(w=>({...w,from:g+w.start+1,to:g+w.end+1})).filter(w=>o.schema.marks.code?!o.doc.rangeHasMark(w.from,w.to,o.schema.marks.code):!0).filter(w=>n.validate(w.value)).filter(w=>n.shouldAutoLink(w.value)).forEach(w=>{Ml(w.from,w.to,o.doc).some(b=>b.mark.type===n.type)||i.addMark(w.from,w.to,n.type.create({href:w.href}))})}}),!!i.steps.length)return i}})}function Zb(n){return new ge({key:new Ee("handleClickLink"),props:{handleClick:(e,t,o)=>{var r,s;if(o.button!==0||!e.editable)return!1;let i=null;if(o.target instanceof HTMLAnchorElement)i=o.target;else{const c=o.target;if(!c)return!1;const d=n.editor.view.dom;i=c.closest("a"),i&&!d.contains(i)&&(i=null)}if(!i)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const c=Df(e.state,n.type.name),d=(r=i.href)!=null?r:c.href,u=(s=i.target)!=null?s:c.target;d&&(window.open(d,u),l=!0)}return l}}})}function eS(n){return new ge({key:new Ee("handlePasteLink"),props:{handlePaste:(e,t,o)=>{const{shouldAutoLink:r}=n,{state:s}=e,{selection:i}=s,{empty:l}=i;if(l)return!1;let c="";o.content.forEach(u=>{c+=u.textContent});const d=Eh(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||r!==void 0&&!r(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function In(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(o=>{const r=typeof o=="string"?o:o.scheme;r&&t.push(r)}),!n||n.replace(Yb,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var tS=oo.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(n=>{if(typeof n=="string"){Ch(n);return}Ch(n.scheme,n.optionalSlashes)})},onDestroy(){Kb()},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:(n,e)=>!!In(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const r=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!In(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!In(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",tn(this.options.HTMLAttributes,n),0]:["a",tn(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,o,r,s;const i=(o=(t=n.attrs)==null?void 0:t.href)!=null?o:"",l=(s=(r=n.attrs)==null?void 0:r.title)!=null?s:"",c=e.renderChildren(n);return l?`[${c}](${i} "${l}")`:`[${c}](${i})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:o=>!!In(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:o=>!!In(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ko({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:o}=this.options,r=Eh(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!In(i,t),protocols:t,defaultProtocol:o}));r.length&&r.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Qb({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:o=>this.options.isAllowedUri(o,{defaultValidate:r=>!!In(r,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Zb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(eS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),vh=tS,nS=de.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Th=nS,oS=20,Mh=(n,e=0)=>{const t=[];return!n.children.length||e>oS||Array.from(n.children).forEach(o=>{o.tagName==="SPAN"?t.push(o):o.children.length&&t.push(...Mh(o,e+1))}),t},rS=n=>{if(!n.children.length)return;const e=Mh(n);e&&e.forEach(t=>{var o,r;const s=t.getAttribute("style"),i=(r=(o=t.parentElement)==null?void 0:o.closest("span"))==null?void 0:r.getAttribute("style");t.setAttribute("style",`${i};${s}`)})},ra=oo.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&rS(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",tn(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,o)=>{if(t.isTextblock)return!0;t.marks.filter(r=>r.type===this.type).some(r=>Object.values(r.attrs).some(s=>!!s))||n.removeMark(o,o+t.nodeSize,this.type)}),!0}}}}),sS=de.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="background-color")return l.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Ah=de.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="color")return l.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),iS=de.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),lS=de.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),aS=de.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});de.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(sS.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push(Ah.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(iS.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(lS.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(aS.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(ra.configure(this.options.textStyle)),n}});var Nh=Ah;function cS(n={}){return new ge({view(e){return new dS(e,n)}})}class dS{constructor(e,t){var o;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(o=t.width)!==null&&o!==void 0?o:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let s=i=>{this[r](i)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}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,o,r=this.editorView.dom,s=r.getBoundingClientRect(),i=s.width/r.offsetWidth,l=s.height/r.offsetHeight;if(t){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=f?m.bottom:m.top;f&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;o={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!o){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*i;o={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.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 d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,h=f.height/c.offsetHeight;d=f.left-c.scrollLeft*p,u=f.top-c.scrollTop*h}this.element.style.left=(o.left-d)/i+"px",this.element.style.top=(o.top-u)/l+"px",this.element.style.width=(o.right-o.left)/i+"px",this.element.style.height=(o.bottom-o.top)/l+"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}),o=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=o&&o.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Md(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ke extends ee{constructor(e){super(e,e)}map(e,t){let o=e.resolve(t.map(this.head));return ke.valid(o)?new ke(o):ee.near(o)}content(){return H.empty}eq(e){return e instanceof ke&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ke(e.resolve(t.pos))}getBookmark(){return new sa(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!uS(e)||!fS(e))return!1;let o=t.type.spec.allowGapCursor;if(o!=null)return o;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,o=!1){e:for(;;){if(!o&&ke.valid(e))return e;let r=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;r+=t;let c=e.doc.resolve(r);if(ke.valid(c))return c}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!G.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),o=!1;continue e}break}s=i,r+=t;let l=e.doc.resolve(r);if(ke.valid(l))return l}return null}}}ke.prototype.visible=!1,ke.findFrom=ke.findGapCursorFrom,ee.jsonID("gapcursor",ke);class sa{constructor(e){this.pos=e}map(e){return new sa(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ke.valid(t)?new ke(t):ee.near(t)}}function Ih(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function uS(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),o=n.node(e);if(t==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||Ih(r.type))return!0;if(r.inlineContent)return!1}}return!0}function fS(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),o=n.node(e);if(t==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||Ih(r.type))return!0;if(r.inlineContent)return!1}}return!0}function hS(){return new ge({props:{decorations:yS,createSelectionBetween(n,e,t){return e.pos==t.pos&&ke.valid(t)?new ke(t):null},handleClick:mS,handleKeyDown:pS,handleDOMEvents:{beforeinput:gS}}})}const pS=mf({ArrowLeft:Ds("horiz",-1),ArrowRight:Ds("horiz",1),ArrowUp:Ds("vert",-1),ArrowDown:Ds("vert",1)});function Ds(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,s){let i=o.selection,l=e>0?i.$to:i.$from,c=i.empty;if(i instanceof Q){if(!s.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=o.doc.resolve(e>0?l.after():l.before())}let d=ke.findGapCursorFrom(l,e,c);return d?(r&&r(o.tr.setSelection(new ke(d))),!0):!1}}function mS(n,e,t){if(!n||!n.editable)return!1;let o=n.state.doc.resolve(e);if(!ke.valid(o))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&G.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ke(o))),!0)}function gS(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ke))return!1;let{$from:t}=n.state.selection,o=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!o)return!1;let r=_.empty;for(let i=o.length-1;i>=0;i--)r=_.from(o[i].createAndFill(null,r));let s=n.state.tr.replace(t.pos,t.pos,new H(r,0,0));return s.setSelection(Q.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function yS(n){if(!(n.selection instanceof ke))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pe.create(n.doc,[Fe.widget(n.selection.head,e,{key:"gapcursor"})])}var Ls=200,Te=function(){};Te.prototype.append=function(e){return e.length?(e=Te.from(e),!this.length&&e||e.length<Ls&&this.leafAppend(e)||this.length<Ls&&e.leafPrepend(this)||this.appendInner(e)):this},Te.prototype.prepend=function(e){return e.length?Te.from(e).append(this):this},Te.prototype.appendInner=function(e){return new kS(this,e)},Te.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Te.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Te.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Te.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},Te.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var r=[];return this.forEach(function(s,i){return r.push(e(s,i))},t,o),r},Te.from=function(e){return e instanceof Te?e:e&&e.length?new Bh(e):Te.empty};var Bh=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,i,l){for(var c=s;c<i;c++)if(r(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,l){for(var c=s-1;c>=i;c--)if(r(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=Ls)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=Ls)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Te);Te.empty=new Bh([]);var kS=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,r,s,i){var l=this.left.length;if(r<l&&this.left.forEachInner(o,r,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(o,Math.max(r-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,r,s,i){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(o,r-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(o,Math.min(r,l),s,i)===!1)return!1},e.prototype.sliceInner=function(o,r){if(o==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(o,r):o>=s?this.right.slice(o-s,r-s):this.left.slice(o,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(o){var r=this.right.leafAppend(o);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(o){var r=this.left.leafPrepend(o);if(r)return new e(r,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Te);const wS=500;class it{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let r,s;t&&(r=this.remapping(o,this.items.length),s=r.maps.length);let i=e.tr,l,c,d=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){r||(r=this.remapping(o,p+1),s=r.maps.length),s--,u.push(f);return}if(r){u.push(new yt(f.map));let h=f.step.map(r.slice(s)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],d.push(new yt(m,void 0,void 0,d.length+u.length))),s--,m&&r.appendMap(m,s)}else i.maybeStep(f.step);if(f.selection)return l=r?f.selection.map(r.slice(s)):f.selection,c=new it(this.items.slice(0,o).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:i,selection:l}}addTransform(e,t,o,r){let s=[],i=this.eventCount,l=this.items,c=!r&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new yt(e.mapping.maps[u],f,t),h;(h=c&&c.merge(p))&&(p=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(p),t&&(i++,t=void 0),r||(c=p)}let d=i-o.depth;return d>SS&&(l=bS(l,d),i-=d),new it(l.append(s),i)}remapping(e,t){let o=new Mo;return this.items.forEach((r,s)=>{let i=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?o.maps.length-r.mirrorOffset:void 0;o.appendMap(r.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new it(this.items.append(e.map(t=>new yt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],r=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},r);let c=t;this.items.forEach(p=>{let h=s.getMirror(--c);if(h==null)return;i=Math.min(i,h);let m=s.maps[h];if(p.step){let g=e.steps[h].invert(e.docs[h]),y=p.selection&&p.selection.map(s.slice(c+1,h));y&&l++,o.push(new yt(m,g,y))}else o.push(new yt(m))},r);let d=[];for(let p=t;p<i;p++)d.push(new yt(s.maps[p]));let u=this.items.slice(0,r).append(d).append(o),f=new it(u,l);return f.emptyItemCount()>wS&&(f=f.compress(this.items.length-o.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,r=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)r.push(i),i.selection&&s++;else if(i.step){let c=i.step.map(t.slice(o)),d=c&&c.getMap();if(o--,d&&t.appendMap(d,o),c){let u=i.selection&&i.selection.map(t.slice(o));u&&s++;let f=new yt(d.invert(),c,u),p,h=r.length-1;(p=r.length&&r[h].merge(f))?r[h]=p:r.push(f)}}else i.map&&o--},this.items.length,0),new it(Te.from(r.reverse()),s)}}it.empty=new it(Te.empty,0);function bS(n,e){let t;return n.forEach((o,r)=>{if(o.selection&&e--==0)return t=r,!1}),n.slice(t)}class yt{constructor(e,t,o,r){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new yt(t.getMap().invert(),t,this.selection)}}}class sn{constructor(e,t,o,r,s){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=r,this.prevComposition=s}}const SS=20;function xS(n,e,t,o){let r=t.getMeta(Bn),s;if(r)return r.historyState;t.getMeta(vS)&&(n=new sn(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Bn))return i.getMeta(Bn).redo?new sn(n.done.addTransform(t,void 0,o,Vs(e)),n.undone,Oh(t.mapping.maps),n.prevTime,n.prevComposition):new sn(n.done,n.undone.addTransform(t,void 0,o,Vs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!CS(t,n.prevRanges)),d=i?ia(n.prevRanges,t.mapping):Oh(t.mapping.maps);return new sn(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,Vs(e)),it.empty,d,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new sn(n.done.rebased(t,s),n.undone.rebased(t,s),ia(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new sn(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ia(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function CS(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,r)=>{for(let s=0;s<e.length;s+=2)o<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function Oh(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,r,s,i)=>e.push(s,i));return e}function ia(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let r=e.map(n[o],1),s=e.map(n[o+1],-1);r<=s&&t.push(r,s)}return t}function ES(n,e,t){let o=Vs(e),r=Bn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,o);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,o),c=new sn(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(Bn,{redo:t,historyState:c})}let la=!1,_h=null;function Vs(n){let e=n.plugins;if(_h!=e){la=!1,_h=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){la=!0;break}}return la}const Bn=new Ee("history"),vS=new Ee("closeHistory");function TS(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ge({key:Bn,state:{init(){return new sn(it.empty,it.empty,null,0,-1)},apply(e,t,o){return xS(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,r=o=="historyUndo"?Ph:o=="historyRedo"?Dh:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Rh(n,e){return(t,o)=>{let r=Bn.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(o){let s=ES(r,t,n);s&&o(e?s.scrollIntoView():s)}return!0}}const Ph=Rh(!1,!0),Dh=Rh(!0,!0);de.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const o=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(o)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new ge({key:new Ee("characterCount"),appendTransaction:(e,t,o)=>{if(n)return;const r=this.options.limit;if(r==null||r===0){n=!0;return}const s=this.storage.characters({node:o.doc});if(s>r){const i=s-r,l=0,c=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const d=o.tr.deleteRange(l,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const o=this.options.limit;if(!e.docChanged||o===0||o===null||o===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=o||r>o&&s>o&&s<=r)return!0;if(r>o&&s>o&&s>r||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-o,d=l-c,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>o)}})]}}),de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[cS(this.options)]}}),de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ge({key:new Ee("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:o}=this.editor,{anchor:r}=e,s=[];if(!t||!o)return pe.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(c.isText)return;if(!(r>=d&&r<=d+c.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((c,d)=>{if(c.isText||!(r>=d&&r<=d+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Fe.node(d,d+c.nodeSize,{class:this.options.className}))}),pe.create(n,s)}}})]}}),de.create({name:"gapCursor",addProseMirrorPlugins(){return[hS()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ce(q(n,"allowGapCursor",t)))!=null?e:null}}});var Lh="placeholder";function MS(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Lh,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${MS(this.options.dataAttribute)}`:`data-${Lh}`;return[new ge({key:new Ee("placeholder"),props:{decorations:({doc:e,selection:t})=>{const o=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!o)return null;const i=this.editor.isEmpty;return e.descendants((l,c)=>{const d=r>=c&&r<=c+l.nodeSize,u=!l.isLeaf&&Xr(l);if((d||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=Fe.node(c,c+l.nodeSize,{class:f.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:d}):this.options.placeholder});s.push(p)}return this.options.includeChildren}),pe.create(e,s)}}})]}}),de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new ge({key:new Ee("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||ww(t.selection)||n.view.dragging?null:pe.create(t.doc,[Fe.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Vh({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new Ee(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",o=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(t).includes(r.name));return[new ge({key:e,appendTransaction:(r,s,i)=>{const{doc:l,tr:c,schema:d}=i,u=e.getState(i),f=l.content.size,p=d.nodes[t];if(u)return c.insert(f,p.create())},state:{init:(r,s)=>{const i=s.tr.doc.lastChild;return!Vh({node:i,types:o})},apply:(r,s)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return s;const i=r.doc.lastChild;return!Vh({node:i,types:o})}}})]}});var AS=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Ph(n,e),redo:()=>({state:n,dispatch:e})=>Dh(n,e)}},addProseMirrorPlugins(){return[TS(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()}}});const so="editing",aa=50,$s=1e3;function ca(n){var e;if(!n)return null;try{const t=JSON.parse(n);return(e=t.block)!=null&&e.tag?t:(console.warn("Block snapshot missing required tag:",t),null)}catch{return console.warn("Invalid block snapshot JSON:",n),null}}function or(n,e,t){const o=k.getBlockDef(n,e.block.tag);if(!o)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const r=e.block.size??[100,100],s=[t[0]-r[0]/2,t[1]-r[1]/2];k.Grid.snapPosition(n,s);const[i,l]=s,c=e.block.rank??k.RankBounds.genNext(n),d=k.createEntity(n);"synced"in e||k.addComponent(n,d,k.Synced,{id:crypto.randomUUID()});const u=Object.assign({},e.block,{position:[i,l],size:r,rank:c});k.addComponent(n,d,k.Block,u);for(const f of o.components)if(!(f.name in e))k.addComponent(n,d,f);else{const p=e[f.name];k.addComponent(n,d,f,p)}return d}function NS(n){return n.trimEnd().split(/\r?\n/).map(e=>`<p>${e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")||""}</p>`).join("")}function $h(n){if(n.startsWith("#"))return n.toUpperCase();const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const t=parseInt(e[1],10).toString(16).padStart(2,"0"),o=parseInt(e[2],10).toString(16).padStart(2,"0"),r=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${t}${o}${r}`.toUpperCase()}return n}function rr(n){const e=Math.round(n.red),t=Math.round(n.green),o=Math.round(n.blue),r=Math.round(n.alpha);return r<255?"#"+[e,t,o,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,t,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function da(n){n=n.replace(/^#/,"");let e,t,o,r=255;if(n.length===6)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16);else if(n.length===8)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);else return null;return{red:e,green:t,blue:o,alpha:r}}function zh(n){const e=da(n);if(!e)return{h:0,s:100,v:100,a:255};const t=e.red/255,o=e.green/255,r=e.blue/255,s=Math.max(t,o,r),i=Math.min(t,o,r),l=s-i;let c=0;const d=s===0?0:l/s*100,u=s*100;if(l!==0)switch(s){case t:c=((o-r)/l+(o<r?6:0))*60;break;case o:c=((r-t)/l+2)*60;break;case r:c=((t-o)/l+4)*60;break}return{h:c,s:d,v:u,a:e.alpha}}function Fh(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const p=h=>Math.round(h*255).toString(16).padStart(2,"0");return`#${p(r)}${p(s)}${p(i)}`}function Hh(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const p=m=>Math.round(m*255).toString(16).padStart(2,"0"),h=Math.round(n.a).toString(16).padStart(2,"0");return n.a<255?`#${p(r)}${p(s)}${p(i)}${h}`:`#${p(r)}${p(s)}${p(i)}`}const Oe=a.shallowRef(null),ua=a.shallowRef(null),fa=a.shallowRef(null),kt=a.ref(0);function On(){const n={hasEditor:a.computed(()=>Oe.value!==null),isBold:a.computed(()=>{var s;return kt.value,((s=Oe.value)==null?void 0:s.isActive("bold"))??!1}),isItalic:a.computed(()=>{var s;return kt.value,((s=Oe.value)==null?void 0:s.isActive("italic"))??!1}),isUnderline:a.computed(()=>{var s;return kt.value,((s=Oe.value)==null?void 0:s.isActive("underline"))??!1}),alignment:a.computed(()=>{kt.value;const s=Oe.value;return s?s.isActive({textAlign:"center"})?"center":s.isActive({textAlign:"right"})?"right":s.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:a.computed(()=>{kt.value;const s=Oe.value;if(!s)return null;const l=s.getAttributes("textStyle").color??null;return l?$h(l):null}),linkHref:a.computed(()=>{kt.value;const s=Oe.value;return s?s.getAttributes("link").href??null:null})},e={toggleBold(){const s=Oe.value;if(!s)return;const{from:i,to:l}=s.state.selection,c=i===l;let d=s.chain().focus();c&&(d=d.selectAll()),d=d.toggleBold(),c&&(d=d.setTextSelection(l)),d.run()},toggleItalic(){const s=Oe.value;if(!s)return;const{from:i,to:l}=s.state.selection,c=i===l;let d=s.chain().focus();c&&(d=d.selectAll()),d=d.toggleItalic(),c&&(d=d.setTextSelection(l)),d.run()},toggleUnderline(){const s=Oe.value;if(!s)return;const{from:i,to:l}=s.state.selection,c=i===l;let d=s.chain().focus();c&&(d=d.selectAll()),d=d.toggleUnderline(),c&&(d=d.setTextSelection(l)),d.run()},setAlignment(s){const i=Oe.value;i&&i.chain().selectAll().setTextAlign(s).run()},setColor(s){const i=Oe.value;if(!i)return;const{from:l,to:c}=i.state.selection;l===c?i.chain().focus().selectAll().setColor(s).setTextSelection(c).run():i.chain().focus().setColor(s).run()},setLink(s){const i=Oe.value;if(!i)return;const{from:l,to:c}=i.state.selection;l===c?i.chain().focus().selectAll().setLink({href:s}).setTextSelection(c).run():i.chain().focus().setLink({href:s}).run()},removeLink(){const s=Oe.value;if(!s)return;const{from:i,to:l}=s.state.selection;i===l?s.chain().focus().selectAll().unsetLink().setTextSelection(l).run():s.chain().focus().unsetLink().run()}};function t(s,i,l){Oe.value=s,fa.value=i,ua.value=l,s.on("selectionUpdate",()=>{kt.value++}),s.on("transaction",()=>{kt.value++})}function o(){Oe.value=null,fa.value=null,ua.value=null}function r(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{kt.value++})})}return{editor:Oe,blockElement:ua,textElement:fa,state:n,commands:e,updateCounter:kt,register:t,unregister:o,repositionMenu:r}}const jh=1,Wh="Synced",Uh="application/x-woven-canvas",Kh=k.defineQuery(n=>n.with(k.Block,k.Selected));function IS(n){let e=[...Kh.current(n)];if(e.length===0)return null;const t=new Set(e);for(const f of e)for(const p of k.getDescendants(n,f))t.add(p);e=[...t];const{componentsById:o}=k.getResources(n),r=new Map([...o].filter(([,f])=>f.sync==="document")),s=k.Synced._getComponentId(n),i=new Set;for(const f of e)k.hasComponent(n,f,k.Synced)&&i.add(k.Synced.read(n,f).id);const l=new Set(e),c=[],d=ae.Aabb.zero();let u=!1;for(const f of e){const p={};k.hasComponent(n,f,k.Synced)&&(p[Wh]=k.Synced.snapshot(n,f));for(const h of n.entityBuffer.getComponentIds(f)){if(h===s)continue;const m=r.get(h);if(m){const g=m.snapshot(n,f),y=OS(n,m.schema,g);if(m.name==="block"&&y.parentId!=null){const w=k.Block.read(n,f).parentId;if(w!==null&&!l.has(w)){const b=k.Block.getWorldPosition(n,f);y.position=[b[0],b[1]],y.parentId=null}}p[m.name]=y}}if(c.push(p),k.hasComponent(n,f,k.Aabb)){const{value:h}=k.Aabb.read(n,f);u?ae.Aabb.union(d,h):(ae.Aabb.copy(d,h),u=!0)}}return{version:jh,center:ae.Aabb.center(d),entities:c}}function BS(n,e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||t.version!==jh||!Array.isArray(t.entities)||t.entities.length===0)return null;const{componentsByName:o}=k.getResources(n),r=k.Synced._getComponentId(n),s=[];for(const i of t.entities){const l=new Map;for(const[c,d]of Object.entries(i)){if(c===Wh){l.set(r,d);continue}const u=o.get(c);u&&u.sync==="document"&&l.set(u._getComponentId(n),d)}s.push(l)}return{entities:s,center:t.center}}function OS(n,e,t){var r;const o={...t};for(const[s,i]of Object.entries(e))if(((r=i==null?void 0:i.def)==null?void 0:r.type)==="ref"){const l=t[s];o[s]=l!=null&&k.hasComponent(n,l,k.Synced)?k.Synced.read(n,l).id:null}return o}function _S(n){var t;const e=[];for(const[o,r]of Object.entries(n))((t=r==null?void 0:r.def)==null?void 0:t.type)==="ref"&&e.push(o);return e}function RS(n,e,t,o,r){var i;const s=t.write(n,e);for(const[l,c]of Object.entries(t.schema))if(((i=c==null?void 0:c.def)==null?void 0:i.type)==="ref"){const d=o[l];d!=null&&(s[l]=r.get(d)??null)}}function qh(n,e,t,o){if(e.length===0)return;const{componentsById:r}=k.getResources(n),s=new Map([...r].filter(([,h])=>h.sync==="document")),i=k.Synced._getComponentId(n),l=k.Block._getComponentId(n);let c;if(o)c=ae.Vec2.clone(o),ae.Vec2.sub(c,t);else{const h=k.Camera.getWorldCenter(n);c=ae.Vec2.clone(h),ae.Vec2.sub(c,t),k.Grid.snapPosition(n,c)}const d=[...e].sort((h,m)=>{var w,b;const g=((w=h.get(l))==null?void 0:w.rank)??"",y=((b=m.get(l))==null?void 0:b.rank)??"";return g<y?-1:g>y?1:0});k.deselectAll(n);const u=new Map,f=[];for(const h of d){const m=k.createEntity(n),g=h.get(i);g!=null&&g.id&&u.set(g.id,m),k.addComponent(n,m,k.Synced,{id:crypto.randomUUID()});for(const[y,w]of h){if(y===i)continue;const b=s.get(y);if(!b)continue;const x={...w};if(y===l){if(!(w.parentId!=null)){const C=ae.Vec2.clone(x.position);ae.Vec2.add(C,c),x.position=C}x.rank=k.RankBounds.genNext(n)}const S=_S(b.schema);if(S.length>0){for(const E of S)delete x[E];f.push({entityId:m,componentDef:b,componentData:w})}k.addComponent(n,m,b,x)}k.selectBlock(n,m)}for(const{entityId:h,componentDef:m,componentData:g}of f)RS(n,h,m,g,u);const p=[];for(const h of d){const m=h.get(i);if(!(m!=null&&m.id))continue;const g=u.get(m.id);if(!g||!k.hasComponent(n,g,k.Block)||k.Block.read(n,g).parentId!==null)continue;const w=k.Block.getCenter(n,g),b=k.findFrameAtPoint(n,w,g);b!==null&&p.push({entityId:g,frameId:b})}p.length>0&&k.AssignFrameChildren.spawn(n,{assignments:p})}function PS(n,e,t,o){const r=k.Text.default(),s=document.createElement("div");if(s.style.position="absolute",s.style.visibility="hidden",s.style.fontFamily=r.fontFamily,s.style.fontSize=`${r.fontSizePx}px`,s.style.lineHeight=`${r.lineHeight}`,s.style.letterSpacing=`${r.letterSpacingEm}em`,s.style.width="fit-content",s.style.wordBreak="break-word",s.style.minWidth="2px",e){const c=o/t,d=Math.min($s,c/2);s.style.maxWidth=`${d}px`,s.style.whiteSpace="pre-wrap"}else s.style.whiteSpace="pre";s.classList.add("wov-editable-text"),s.innerHTML=n,document.body.appendChild(s);const i=s.offsetWidth,l=s.offsetHeight;return document.body.removeChild(s),{width:i,height:l}}function DS(n,e={}){const t=e.enabled??!0,o=e.canPasteTextAsBlock??!0;if(!t)return;const{getEditor:r,nextEditorTick:s}=fe(),i=a.inject(Se),l=On();let c=null;a.watch(()=>l.editor.value,h=>{if(!h||!c)return;const{plainText:m,html:g}=c;c=null;const y=new DataTransfer;y.setData("text/plain",m),g&&y.setData("text/html",g);const w=new ClipboardEvent("paste",{clipboardData:y,bubbles:!0,cancelable:!0});h.view.dom.dispatchEvent(w),s(b=>{k.DeselectAll.spawn(b)})});function d(h){if(l.editor.value||!h.clipboardData)return!1;const m=r();if(!m)return!1;const g=m._getContext(),y=IS(g);return y?(h.clipboardData.setData(Uh,JSON.stringify(y)),h.clipboardData.setData("text/plain",`${y.entities.length} block${y.entities.length===1?"":"s"}`),h.preventDefault(),!0):!1}function u(h){d(h)}function f(h){d(h)&&s(m=>{for(const g of Kh.current(m))k.isAlive(m,g)&&k.cascadeDelete(m,g)})}async function p(h){var B,P,V,F;if(l.editor.value)return;const m=document.activeElement;if(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement||m!=null&&m.isContentEditable)return;const g=((B=h.clipboardData)==null?void 0:B.getData(Uh))??"",y=((P=h.clipboardData)==null?void 0:P.getData("text/html"))??"",w=((V=h.clipboardData)==null?void 0:V.getData("text/plain"))??"";if(g){h.preventDefault();const z=await s(),J=BS(z,g);if(J){const j=k.Mouse.read(z);if(j.position[0]!==0||j.position[1]!==0){const W=k.Camera.read(z),X=[W.left+j.position[0]/W.zoom,W.top+j.position[1]/W.zoom];qh(z,J.entities,J.center,X)}else qh(z,J.entities,J.center)}return}if(!o||!w.trim())return;const b=await s();c={plainText:w,html:y};const x=k.Mouse.read(b),S=k.Camera.read(b),E=[S.left+x.position[0]/S.zoom,S.top+x.position[1]/S.zoom],M=NS(w),C=w.length>aa,T=((F=n.value)==null?void 0:F.clientWidth)??$s,v=PS(M,C,S.zoom,T),I=or(b,{block:{tag:"text",size:[v.width,v.height]},text:{constrainWidth:C,fontSizePx:24,...i.getDefaults("text")}},E);k.canBlockEdit(b,"text")&&k.addComponent(b,I,k.EditAfterPlacing,{}),k.SelectBlock.spawn(b,{entityId:I,deselectOthers:!0})}a.onMounted(()=>{const h=n.value;h&&(h.addEventListener("paste",p),h.addEventListener("copy",u),h.addEventListener("cut",f))}),a.onUnmounted(()=>{const h=n.value;h&&(h.removeEventListener("paste",p),h.removeEventListener("copy",u),h.removeEventListener("cut",f))})}function Vt(n,e){const t=a.inject(Se);if(!t)throw new Error("useComponents must be used within a WovenCanvas component");const o=a.shallowRef(new Map),r=new Map;function s(l){if(r.has(l))return;const c=t.getEditor();if(c){const u=c._getContext();if(k.hasComponent(u,l,e)){const f=new Map(o.value);f.set(l,e.snapshot(u,l)),o.value=f}else{const f=new Map(o.value);f.set(l,null),o.value=f}}const d=t.subscribeComponent(l,e.name,u=>{const f=new Map(o.value);f.set(l,u),o.value=f});r.set(l,d)}function i(l){const c=r.get(l);if(c){c(),r.delete(l);const d=new Map(o.value);d.delete(l),o.value=d}}return a.watch(()=>a.toValue(n),(l,c)=>{const d=new Set(l),u=new Set(c??[]);for(const f of u)d.has(f)||i(f);for(const f of d)u.has(f)||s(f)},{immediate:!0}),a.onUnmounted(()=>{for(const l of r.values())l();r.clear()}),o}function Jh(){const n=a.inject(Se);if(!n)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=fe();function t(s){return new Promise((i,l)=>{const c=new window.Image;c.onload=()=>{i({width:c.naturalWidth,height:c.naturalHeight}),URL.revokeObjectURL(c.src)},c.onerror=()=>{l(new Error("Failed to load image")),URL.revokeObjectURL(c.src)},c.src=URL.createObjectURL(s)})}async function o(s,i,l,c={}){const{maxSize:d=400}=c,u=await t(s),f=await e(),p=Math.min(1,d/Math.max(u.width,u.height));let h=Math.round(u.width*p),m=Math.round(u.height*p);const g=k.Grid.read(f);g.enabled&&(h=Math.max(g.colWidth,Math.round(h/g.colWidth)*g.colWidth),m=Math.max(g.rowHeight,Math.round(m/g.rowHeight)*g.rowHeight));const y=k.createEntity(f);k.addComponent(f,y,k.Block);const w=k.Block.write(f,y);w.tag="image",w.position[0]=i-h/2,w.position[1]=l-m/2,w.size[0]=h,w.size[1]=m,k.Grid.snapPosition(f,w.position);const b=crypto.randomUUID();k.addComponent(f,y,k.Asset);const x=k.Asset.write(f,y);x.identifier=b,x.uploadState=k.UploadState.Pending,k.addComponent(f,y,k.Image);const S=k.Image.write(f,y);return S.width=u.width,S.height=u.height,S.alt=s.name,k.addComponent(f,y,Ve.Synced,{id:crypto.randomUUID()}),(n==null?void 0:n.getAssetManager())&&r(y,b,s),y}function r(s,i,l){const c=n==null?void 0:n.getAssetManager();c&&c.upload(i,l,{filename:l.name,mimeType:l.type}).catch(d=>{console.error("Asset upload failed:",d)})}return{getImageDimensions:t,createImageBlock:o}}const LS=k.defineQuery(n=>n.with(k.Block,k.Edited,k.Text));function VS(n){const e=typeof window<"u"?window.visualViewport:null;if(!e)return;const t=On();let o=null,r=!1;const s=40,i=.2;function l(){return e?window.innerHeight-e.height>window.innerHeight*i:!1}function c(){if(e){if(!l()){if(o&&r){const d=o;o=null,r=!1,n(u=>{const f=k.Camera.write(u);f.left=d.left,f.top=d.top}),t.repositionMenu()}return}n(d=>{const f=LS.current(d)[Symbol.iterator]().next().value;if(!f)return;const p=k.Block.read(d,f),h=k.Camera.read(d);if(!p||!h)return;const m=h.zoom,g=(p.position[1]-h.top)*m,y=(p.position[1]+p.size[1]-h.top)*m,w=e.height,b=e.offsetTop,x=b,S=b+w;if(y+s<=S&&g>=x)return;o||(o={left:h.left,top:h.top});const E=p.position[1]+p.size[1]/2,M=b+w/2,C=E-M/m,T=k.Camera.write(d);T.top=C,r=!0,t.repositionMenu()})}}e.addEventListener("resize",c),a.onUnmounted(()=>{if(e.removeEventListener("resize",c),o&&r){const d=o;o=null,r=!1,n(u=>{const f=k.Camera.write(u);f.left=d.left,f.top=d.top})}})}function Gh(n){const e=a.inject(Se);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const t=a.shallowRef([]),o=k.defineQuery(f=>f.with(...n)),r=new Map;let s=!1;function i(f){const p=e.getEditor();if(!p)return{refs:{},unsubscribes:[]};const h=p._getContext(),m={},g=[];for(const y of n){const w=a.shallowRef(y.snapshot(h,f));m[y.name]=w;const b=e.subscribeComponent(f,y.name,x=>{w.value=x});g.push(b)}return{refs:m,unsubscribes:g}}function l(f){const p=r.get(f);if(p){for(const h of p.unsubscribes)h();r.delete(f)}}function c(){const f=[];for(const[p,h]of r)f.push({entityId:p,...h.refs});return f}function d(f){if(!s){const g=o.current(f);for(const y of g)r.set(y,i(y));t.value=c(),s=!0;return}const p=o.added(f),h=o.removed(f);let m=!1;for(const g of h)l(g),m=!0;for(const g of p)r.has(g)||(r.set(g,i(g)),m=!0);m&&(t.value=c())}const u=e.registerTickCallback(d);return a.onUnmounted(()=>{u();for(const f of r.keys())l(f)}),t}function _e(n){const e=a.inject(Se);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const t=a.shallowRef(n.default()),o=e.getEditor();if(o){const i=o._getContext();t.value=n.snapshot(i)}const r=e.subscribeSingleton(n.name,i=>{t.value=i??{}});let s=null;return o||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const l=i._getContext();t.value=n.snapshot(l),s==null||s(),s=null}})),a.onUnmounted(()=>{r(),s==null||s()}),t}function ha(n,e,t){if(!n.closest(".wov-block")){const h=n.getBoundingClientRect();return{width:h.width,height:h.height,left:0,top:0}}const r=n.getBoundingClientRect(),s=t.value.left,i=t.value.top,l=new DOMPoint(r.left+r.width/2-s,r.top+r.height/2-i),c=e.value.zoom,d=new DOMMatrix;d.translateSelf(-e.value.left*c,-e.value.top*c),d.scaleSelf(c,c),d.invertSelf();const u=d.transformPoint(l),f=n.offsetWidth,p=n.offsetHeight;return{width:f,height:p,left:u.x-f/2,top:u.y-p/2}}const Re=[th,oh,rh,ra,Nh,ih,lh,ah,vh.configure({openOnClick:!1}),Th.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function $S(n){return n.type==="text"&&typeof n.text=="string"}function wt(n,e){if($S(n)){e(n);return}if(n.content)for(const t of n.content)wt(t,e)}function pa(n,e){if(n.type==="paragraph"){e(n);return}if(n.content)for(const t of n.content)pa(t,e)}function zS(n,e){var t;return((t=n.marks)==null?void 0:t.some(o=>o.type===e))??!1}function FS(n){var o,r;const e=(o=n.marks)==null?void 0:o.find(s=>s.type==="textStyle"),t=((r=e==null?void 0:e.attrs)==null?void 0:r.color)??null;return t?$h(t):null}function HS(n,e){if(!n.trim())return!1;const t=st(n,Re);let o=!1,r=!0,s=0;return wt(t,i=>{s++,zS(i,e)?o=!0:r=!1}),s===0?!1:r?!0:o?null:!1}function jS(n){if(!n.trim())return"left";const e=st(n,Re);let t="left";return pa(e,o=>{var s;const r=(s=o.attrs)==null?void 0:s.textAlign;r&&(t=r)}),t}function WS(n){if(!n.trim())return null;const e=st(n,Re);let t=null;return wt(e,o=>{t===null&&(t=FS(o))}),t}function ma(n,e){if(!n.trim())return n;const t=st(n,Re);return wt(t,o=>{const r=o.marks??[];r.findIndex(i=>i.type===e)===-1&&(o.marks=[...r,{type:e}])}),no(t,Re)}function ga(n,e){if(!n.trim())return n;const t=st(n,Re);return wt(t,o=>{const r=o.marks??[];o.marks=r.filter(s=>s.type!==e)}),no(t,Re)}function US(n,e){if(!n.trim())return n;const t=st(n,Re);return pa(t,o=>{o.attrs={...o.attrs,textAlign:e}}),no(t,Re)}function KS(n,e){if(!n.trim())return n;const t=st(n,Re);return wt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="textStyle");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,color:e}},o.marks=r):o.marks=[...r,{type:"textStyle",attrs:{color:e}}]}),no(t,Re)}function qS(n){if(!n.trim())return null;const e=st(n,Re);let t=null;return wt(e,o=>{var r,s;if(t===null){const i=(r=o.marks)==null?void 0:r.find(l=>l.type==="link");(s=i==null?void 0:i.attrs)!=null&&s.href&&(t=i.attrs.href)}}),t}function JS(n,e){if(!n.trim())return n;const t=st(n,Re);return wt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="link");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,href:e}},o.marks=r):o.marks=[...r,{type:"link",attrs:{href:e,target:"_blank",rel:"noopener noreferrer"}}]}),no(t,Re)}function GS(n){if(!n.trim())return n;const e=st(n,Re);return wt(e,t=>{const o=t.marks??[];t.marks=o.filter(r=>r.type!=="link")}),no(e,Re)}function Yh(n){const e=document.querySelector(`[data-entity-id="${n}"]`);if(!e)return null;const t=e.firstElementChild;return t||e.querySelector(".wov-editable-text")}function Xh(n,e,t,o){var c;const r=n.cloneNode(!0);r.style.position="absolute",r.style.visibility="hidden",r.style.pointerEvents="none",r.style.top="0",r.style.left="0";const s=r.classList.contains("wov-editable-text")?r:r.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${o.fontSizePx}px`,s.style.fontFamily=o.fontFamily,s.style.lineHeight=String(o.lineHeight),s.style.letterSpacing=`${o.letterSpacingEm}em`);const i=r.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=o.content:s?s.innerHTML=o.content:r.innerHTML=o.content,(c=n.parentElement)==null||c.appendChild(r);const l=ha(r,e,t);return r.remove(),l}function Qh(n){const{nextEditorTick:e}=fe(),t=a.inject(Se),o=Vt(n,k.Text),r=_e(k.Camera),s=_e(k.Screen),i=On(),l={hasTextEntities:a.computed(()=>{for(const h of o.value.values())if(h)return!0;return!1}),hasTextContent:a.computed(()=>{for(const h of o.value.values()){if(!h)continue;const m=h.content?st(h.content,Re):null;if(m){let g=!1;if(wt(m,y=>{var w;(w=y.text)!=null&&w.trim()&&(g=!0)}),g)return!0}}return!1}),isBold:a.computed(()=>c("bold")),isItalic:a.computed(()=>c("italic")),isUnderline:a.computed(()=>c("underline")),alignment:a.computed(()=>{let h=null;for(const m of o.value.values()){if(!m)continue;const g=jS(m.content);if(h===null)h=g;else if(h!==g)return null}return h??"left"}),color:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values()){if(!g)continue;const y=WS(g.content);if(!m)h=y,m=!0;else if(h!==y)return null}return h}),fontSize:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values())if(g){if(!m)h=g.fontSizePx,m=!0;else if(h!==g.fontSizePx)return null}return h}),fontFamily:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values())if(g){if(!m)h=g.fontFamily,m=!0;else if(h!==g.fontFamily)return null}return h}),linkHref:a.computed(()=>{let h=null,m=!1;for(const g of o.value.values()){if(!g)continue;const y=qS(g.content);if(!m)h=y,m=!0;else if(h!==y)return null}return h})};function c(h){let m=null,g=!1;for(const y of o.value.values()){if(!y)continue;const w=HS(y.content,h);if(!g)m=w,g=!0;else if(m!==w)return null}return m}const d={toggleBold(){f(h=>l.isBold.value?ga(h,"bold"):ma(h,"bold"))},toggleItalic(){f(h=>l.isItalic.value?ga(h,"italic"):ma(h,"italic"))},toggleUnderline(){f(h=>l.isUnderline.value?ga(h,"underline"):ma(h,"underline"))},setAlignment(h){p(m=>US(m,h))},setColor(h){p(m=>KS(m,h))},setFontSize(h){u(m=>({...m,fontSizePx:h}),m=>{m.fontSizePx=h})},setFontFamily(h){t.setDefaults("text",{fontFamily:h}),u(m=>({...m,fontFamily:h}),m=>{m.fontFamily=h})},setTextStyle(h){const m={};h.fontFamily!==void 0&&(m.fontFamily=h.fontFamily),h.fontSizePx!==void 0&&(m.fontSizePx=h.fontSizePx),h.lineHeight!==void 0&&(m.lineHeight=h.lineHeight),h.letterSpacingEm!==void 0&&(m.letterSpacingEm=h.letterSpacingEm),Object.keys(m).length>0&&t.setDefaults("text",m),u(g=>({...g,fontFamily:h.fontFamily??g.fontFamily,fontSizePx:h.fontSizePx??g.fontSizePx,lineHeight:h.lineHeight??g.lineHeight,letterSpacingEm:h.letterSpacingEm??g.letterSpacingEm}),g=>{h.fontFamily!==void 0&&(g.fontFamily=h.fontFamily),h.fontSizePx!==void 0&&(g.fontSizePx=h.fontSizePx),h.lineHeight!==void 0&&(g.lineHeight=h.lineHeight),h.letterSpacingEm!==void 0&&(g.letterSpacingEm=h.letterSpacingEm)})},setLink(h){p(m=>JS(m,h))},removeLink(){p(h=>GS(h))}};function u(h,m){const g=a.toValue(n),y=[];for(const w of g){const b=o.value.get(w);if(!b)continue;const x=Yh(w);if(x){const S=Xh(x,r,s,h(b));y.push({entityId:w,...S})}}e(w=>{for(const b of g)m(k.Text.write(w,b));for(const{entityId:b,width:x,height:S,left:E,top:M}of y){const C=k.Block.write(w,b);C.size=[x,S],C.position=[E,M]}a.nextTick(()=>{var b;i.updateCounter.value++,(b=i.editor.value)==null||b.commands.focus()})})}function f(h){const m=a.toValue(n),g=[];for(const y of m){const w=o.value.get(y);if(!w)continue;const b=h(w.content),x=Yh(y);if(x){const S=Xh(x,r,s,{...w,content:b});g.push({entityId:y,content:b,...S})}else g.push({entityId:y,content:b,width:0,height:0,left:0,top:0})}e(y=>{for(const{entityId:w,content:b,width:x,height:S,left:E,top:M}of g){const C=k.Text.write(y,w);if(C.content=b,x>0&&S>0){const T=k.Block.write(y,w);T.size=[x,S],T.position=[E,M]}}})}function p(h){const m=a.toValue(n);e(g=>{for(const y of m){const w=k.Text.write(g,y);w.content=h(w.content)}})}return{state:l,commands:d}}function lt(n){const e=On(),t=Qh(n),o=e.state.hasEditor;return{state:a.reactive({hasTextToFormat:a.computed(()=>o.value||t.state.hasTextEntities.value),hasEditor:o,hasTextContent:a.computed(()=>t.state.hasTextContent.value),showTextMenuButtons:a.computed(()=>o.value||t.state.hasTextContent.value),isBold:a.computed(()=>o.value?e.state.isBold.value:t.state.isBold.value===!0),isItalic:a.computed(()=>o.value?e.state.isItalic.value:t.state.isItalic.value===!0),isUnderline:a.computed(()=>o.value?e.state.isUnderline.value:t.state.isUnderline.value===!0),alignment:a.computed(()=>o.value?e.state.alignment.value:t.state.alignment.value??"left"),color:a.computed(()=>o.value?e.state.color.value:t.state.color.value),fontSize:a.computed(()=>t.state.fontSize.value),fontFamily:a.computed(()=>t.state.fontFamily.value),linkHref:a.computed(()=>o.value?e.state.linkHref.value:t.state.linkHref.value)}),commands:{toggleBold(){o.value?e.commands.toggleBold():t.commands.toggleBold()},toggleItalic(){o.value?e.commands.toggleItalic():t.commands.toggleItalic()},toggleUnderline(){o.value?e.commands.toggleUnderline():t.commands.toggleUnderline()},setAlignment(i){o.value?e.commands.setAlignment(i):t.commands.setAlignment(i)},setColor(i){o.value?e.commands.setColor(i):t.commands.setColor(i)},setFontSize(i){t.commands.setFontSize(i)},setFontFamily(i){t.commands.setFontFamily(i)},setTextStyle(i){t.commands.setTextStyle(i)},setLink(i){o.value?e.commands.setLink(i):t.commands.setLink(i)},removeLink(){o.value?e.commands.removeLink():t.commands.removeLink()}}}}function ya(n){const e=_e(k.Camera),t=_e(k.Screen),o=_e(k.TransformBoxStateSingleton),r=_e(k.SelectionStateSingleton),{nextEditorTick:s}=fe();let i=!1,l=null;function c(u,f){const{entityId:p}=a.toValue(n.blockData),h=a.toValue(n.minWidth)??0,m=a.toValue(n.minHeight)??0,g=Math.max(f.width,h),y=Math.max(f.height,m),w=k.Block.read(u,p),b=Math.abs(w.size[0]-g)>.5,x=Math.abs(w.size[1]-y)>.5;if(!b&&!x)return;const S=k.Block.write(u,p);S.size=[g,y],k.Block.setWorldPosition(u,p,[f.left,f.top]),o.value.transformBoxId!==null&&k.UpdateTransformBox.spawn(u,{transformBoxId:o.value.transformBoxId})}a.watch(()=>r.value,()=>{s(u=>{const f=YS(u);if(i&&!f){const p=n.containerRef.value;if(!p)return;l=ha(p,e,t),c(u,l),l=null}i=f})},{flush:"sync"});function d(u){const{content:f,...p}=u;s(h=>{const{entityId:m}=a.toValue(n.blockData);if(k.Text.read(h,m).content!==f){const y=k.Text.write(h,m);y.content=f}c(h,p)})}return{handleEditEnd:d}}function YS(n){const e=k.SelectionStateSingleton.read(n);return e.state===k.SelectionState.Dragging&&e.draggedEntity!==null&&k.hasComponent(n,e.draggedEntity,k.TransformHandle)&&k.TransformHandle.read(n,e.draggedEntity).kind===k.TransformHandleKind.Stretch}function zs(){const n=a.inject(Si);if(!n)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:n.activeTool,heldTool:n.heldTool,setTool:n.setTool,dragOutTool:n.dragOutTool,onToolPointerDown:n.onToolPointerDown,onToolPointerUp:n.onToolPointerUp,isActive:e=>a.computed(()=>n.activeTool.value===e)}}const XS=500,QS=1500,Fs=a.ref(null),sr=a.ref(!1),io=a.ref(!1);let ir=null,lr=null,ar=null;function ka(){ir&&(clearTimeout(ir),ir=null),lr&&(clearTimeout(lr),lr=null)}function wa(){ar&&(ar.disconnect(),ar=null)}function ZS(n){wa(),!(typeof MutationObserver>"u"||typeof document>"u")&&(ar=new MutationObserver(()=>{n.isConnected||Zh()}),ar.observe(document.body,{childList:!0,subtree:!0}))}function e2(n,e){ka(),Fs.value={text:n,anchor:e},ZS(e),io.value?sr.value=!0:ir=setTimeout(()=>{sr.value=!0,io.value=!0,ir=null},XS)}function t2(){ka(),wa(),sr.value=!1,Fs.value=null,io.value&&(lr=setTimeout(()=>{io.value=!1,lr=null},QS))}function Zh(){ka(),wa(),sr.value=!1,Fs.value=null,io.value=!1}const n2={activeTooltip:a.readonly(Fs),isVisible:a.readonly(sr),isWarmedUp:a.readonly(io),show:e2,hide:t2,reset:Zh},Hs=a.ref([]);function $t(){return n2}const o2={key:1},r2=["innerHTML"],js=a.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(n,{expose:e,emit:t}){var T;const o=n,r=t,s=me(o.entityId,k.Text),i=_e(k.Camera),l=_e(k.Screen),c=On(),{nextEditorTick:d,getEditor:u}=fe(),f=_e(k.Mouse),p=a.ref(null);e({editableTextRef:p});const h=a.ref(((T=s.value)==null?void 0:T.content)??""),m=a.shallowRef(null);async function g(){var J,j;p.value&&(p.value.style.opacity="0");const v=await d(),I=k.Block.read(v,o.entityId),B=(((J=l.value)==null?void 0:J.width)??$s)/(((j=i.value)==null?void 0:j.zoom)??1),P=Math.min($s,B/2),V=Math.max(I.size[0],P),F=k.Block.write(v,o.entityId);F.size=[V,I.size[1]];const z=k.Text.write(v,o.entityId);z.constrainWidth=!0,k.ResetKeyboard.spawn(v),requestAnimationFrame(()=>{p.value&&(p.value.style.opacity=""),requestAnimationFrame(()=>{c.updateCounter.value++})})}function y(v,I){var z,J,j;const B=s.value;if(!B)return!1;const P=((z=I.clipboardData)==null?void 0:z.getData("text/html"))??"",V=((J=I.clipboardData)==null?void 0:J.getData("text/plain"))??"";if(!/<[^>]+data-pm-slice=/.test(P)){I.preventDefault();const K=V.trimEnd().split(/\r?\n/).map(W=>({type:"paragraph",content:W?[{type:"text",text:W}]:[]}));return(j=m.value)==null||j.commands.insertContent(K),!B.constrainWidth&&V.length>aa&&g(),!0}return!B.constrainWidth&&V.length>aa&&g(),!1}function w(){var I,B,P;const v=((I=u())==null?void 0:I.readonly)===!0;return new pb({extensions:[th,oh,rh,ra,Nh,ih,lh,ah,vh.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),Th.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((B=s.value)==null?void 0:B.defaultAlignment)??"left"}),AS],content:((P=s.value)==null?void 0:P.content)??"",editable:!v,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:y}})}a.watch(()=>o.edited,async v=>{if(v&&p.value){if(m.value=w(),await b(m.value),!o.blockElement)return;c.register(m.value,p.value,o.blockElement)}else m.value&&(c.unregister(),x(m.value),m.value.destroy(),m.value=null)},{immediate:!0});async function b(v){var V;const I=(V=f.value)==null?void 0:V.position,B=l.value;await a.nextTick(),await new Promise(F=>requestAnimationFrame(F));const P=p.value;if(I&&B&&P){const F=I[0]+B.left,z=I[1]+B.top,J=v.view.posAtCoords({left:F,top:z});if(J){v.chain().focus().setTextSelection(J.pos).run();return}}v.commands.focus("start")}function x(v){let I=v.getHTML();const P=I.replace(/<[^>]*>/g,"").trim().length>0;P||(I=""),h.value=I,d(V=>{var K,W;const F=k.getBlockDef(V,o.block.tag);if(!P&&((K=F.editOptions)!=null&&K.removeWhenTextEmpty)){k.removeEntity(V,o.entityId);return}const z=(W=p.value)==null?void 0:W.closest(".wov-block"),J=(z==null?void 0:z.firstElementChild)??p.value;if(!J){console.warn("EditableText: no element to measure");return}const j=ha(J,i,l);r("editEnd",{content:I,...j})})}a.watch(()=>{var v;return(v=s.value)==null?void 0:v.content},v=>{v!==void 0&&(m.value?m.value.getHTML()!==v&&m.value.commands.setContent(v,{emitUpdate:!1}):h.value=v)});const S=a.computed(()=>{const v=s.value;if(!v)return{};const[I,B]=o.block.flip,P=I?-1:1,V=B?-1:1,F=I||B;return{fontFamily:v.fontFamily,fontSize:`${v.fontSizePx}px`,lineHeight:v.lineHeight,letterSpacing:`${v.letterSpacingEm}em`,width:v.constrainWidth?"100%":"fit-content",whiteSpace:v.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:o.edited?"auto":"none",userSelect:o.edited?"auto":"none",transform:F?`scale(${P}, ${V})`:void 0}});function E(v){v.key==="Control"||v.key==="Meta"||v.stopPropagation()}function M(v){o.edited&&v.stopPropagation()}function C(v){if(o.edited)return;const I=v.target.closest("a");if(!I)return;const B=I.getAttribute("href");B&&(v.preventDefault(),v.stopPropagation(),window.open(B,"_blank","noopener,noreferrer"))}return a.onUnmounted(()=>{m.value&&(c.unregister(),m.value.destroy(),m.value=null)}),(v,I)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"editableTextRef",ref:p,class:"wov-editable-text",style:a.normalizeStyle(S.value),onKeydown:E,onPointerdown:M,onPointermove:M,onPointerup:M,onClick:C},[m.value?(a.openBlock(),a.createBlock(a.unref(mb),{key:0,editor:m.value},null,8,["editor"])):(a.openBlock(),a.createElementBlock("div",o2,[a.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:h.value},null,8,r2)]))],36))}}),s2={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},i2=["d","fill","stroke","stroke-width","stroke-dasharray"],ep=a.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=me(e.entityId,k.Shape),o=me(e.entityId,k.VerticalAlign),r=a.ref(null),s={[k.VerticalAlignment.Top]:"flex-start",[k.VerticalAlignment.Center]:"center",[k.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>t.value?`rgba(${t.value.fillRed}, ${t.value.fillGreen}, ${t.value.fillBlue}, ${(t.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),l=a.computed(()=>t.value?t.value.strokeKind===k.StrokeKind.None?"none":`rgba(${t.value.strokeRed}, ${t.value.strokeGreen}, ${t.value.strokeBlue}, ${t.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),c=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeWidth)??2}),d=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeKind)??k.StrokeKind.Solid}),u=a.computed(()=>{var g;return xo[((g=t.value)==null?void 0:g.kind)??"rectangle"]??xo.rectangle}),f=a.computed(()=>{const g=c.value;switch(d.value){case k.StrokeKind.Dashed:return`${g*3} ${g*3}`;case k.StrokeKind.None:return"";default:return""}}),p=a.computed(()=>{var g;return{overflow:e.edited?"visible":"hidden",alignItems:s[((g=o.value)==null?void 0:g.value)??k.VerticalAlignment.Top]}}),{nextEditorTick:h}=fe();function m(g){h(y=>{if(k.Text.read(y,e.entityId).content===g.content)return;const b=k.Text.write(y,e.entityId);b.content=g.content})}return(g,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-shape-block"},[(a.openBlock(),a.createElementBlock("svg",s2,[a.createElementVNode("path",{d:u.value,fill:i.value,stroke:l.value,"stroke-width":c.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,i2)])),a.createElementVNode("div",{class:"wov-shape-content",style:a.normalizeStyle(p.value)},[a.createVNode(js,a.mergeProps(e,{"block-element":r.value,onEditEnd:m}),null,16,["block-element"])],4)],512))}}),l2={class:"wov-tape-block"},a2={key:0,class:"wov-tape-placeholder"},tp=a.defineComponent({__name:"TapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},async setup(n){let e,t;const o=n,r=a.inject(Se);if(!r)throw new Error("TapeBlock must be used within a WovenCanvas component");const s=r,i=me(o.entityId,k.Asset),l=s.getAssetManager(),c=i.value;let d=null;l&&(c!=null&&c.identifier)&&(d=([e,t]=a.withAsyncContext(()=>l.getDisplayUrl(c.identifier)),e=await e,t(),e));const u=a.ref(d),f=a.ref(!d),p=a.ref(!1);let h=!0;a.onUnmounted(()=>{h=!1});async function m(){const g=s.getAssetManager();if(!g)return;const y=i.value;if(!y||!y.identifier){f.value=!1;return}try{f.value=!0,p.value=!1;const w=await g.getDisplayUrl(y.identifier);if(!h)return;w?(u.value=w,f.value=!1):y.uploadState===k.UploadState.Failed&&(p.value=!0,f.value=!1)}catch(w){if(!h)return;console.error("Failed to get tape display URL:",w),p.value=!0,f.value=!1}}return a.watch(()=>i.value,()=>{m()},{immediate:!0}),a.onMounted(()=>{m()}),(g,y)=>(a.openBlock(),a.createElementBlock("div",l2,[f.value&&!u.value?(a.openBlock(),a.createElementBlock("div",a2)):u.value?(a.openBlock(),a.createElementBlock("div",{key:1,class:"wov-tape-image",style:a.normalizeStyle({backgroundImage:`url(${u.value})`})},null,4)):a.createCommentVNode("",!0)]))}}),c2=["data-text-empty"],np=a.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=me(e.entityId,k.Text),r=a.computed(()=>{var d;return(((d=o.value)==null?void 0:d.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),s=a.computed(()=>{var l;return((l=o.value)==null?void 0:l.constrainWidth)??!1}),{handleEditEnd:i}=ya({blockData:e,containerRef:t});return(l,c)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-text-block","data-text-empty":r.value||void 0,style:a.normalizeStyle({width:s.value?"100%":"fit-content"})},[a.createVNode(js,a.mergeProps(e,{"block-element":t.value,onEditEnd:a.unref(i)}),null,16,["block-element","onEditEnd"])],12,c2))}}),Ws=Math.min,_n=Math.max,Us=Math.round,Ks=Math.floor,bt=n=>({x:n,y:n}),d2={left:"right",right:"left",bottom:"top",top:"bottom"},u2={start:"end",end:"start"};function op(n,e,t){return _n(n,Ws(e,t))}function qs(n,e){return typeof n=="function"?n(e):n}function Rn(n){return n.split("-")[0]}function Js(n){return n.split("-")[1]}function rp(n){return n==="x"?"y":"x"}function sp(n){return n==="y"?"height":"width"}const f2=new Set(["top","bottom"]);function ln(n){return f2.has(Rn(n))?"y":"x"}function ip(n){return rp(ln(n))}function h2(n,e,t){t===void 0&&(t=!1);const o=Js(n),r=ip(n),s=sp(r);let i=r==="x"?o===(t?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=Gs(i)),[i,Gs(i)]}function p2(n){const e=Gs(n);return[ba(n),e,ba(e)]}function ba(n){return n.replace(/start|end/g,e=>u2[e])}const lp=["left","right"],ap=["right","left"],m2=["top","bottom"],g2=["bottom","top"];function y2(n,e,t){switch(n){case"top":case"bottom":return t?e?ap:lp:e?lp:ap;case"left":case"right":return e?m2:g2;default:return[]}}function k2(n,e,t,o){const r=Js(n);let s=y2(Rn(n),t==="start",o);return r&&(s=s.map(i=>i+"-"+r),e&&(s=s.concat(s.map(ba)))),s}function Gs(n){return n.replace(/left|right|bottom|top/g,e=>d2[e])}function w2(n){return{top:0,right:0,bottom:0,left:0,...n}}function b2(n){return typeof n!="number"?w2(n):{top:n,right:n,bottom:n,left:n}}function Ys(n){const{x:e,y:t,width:o,height:r}=n;return{width:o,height:r,top:t,left:e,right:e+o,bottom:t+r,x:e,y:t}}function cp(n,e,t){let{reference:o,floating:r}=n;const s=ln(e),i=ip(e),l=sp(i),c=Rn(e),d=s==="y",u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,p=o[l]/2-r[l]/2;let h;switch(c){case"top":h={x:u,y:o.y-r.height};break;case"bottom":h={x:u,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:f};break;case"left":h={x:o.x-r.width,y:f};break;default:h={x:o.x,y:o.y}}switch(Js(e)){case"start":h[i]-=p*(t&&d?-1:1);break;case"end":h[i]+=p*(t&&d?-1:1);break}return h}async function S2(n,e){var t;e===void 0&&(e={});const{x:o,y:r,platform:s,rects:i,elements:l,strategy:c}=n,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=qs(e,n),m=b2(h),y=l[p?f==="floating"?"reference":"floating":f],w=Ys(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(y)))==null||t?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),b=f==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),S=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Ys(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:x,strategy:c}):b);return{top:(w.top-E.top+m.top)/S.y,bottom:(E.bottom-w.bottom+m.bottom)/S.y,left:(w.left-E.left+m.left)/S.x,right:(E.right-w.right+m.right)/S.x}}const x2=async(n,e,t)=>{const{placement:o="bottom",strategy:r="absolute",middleware:s=[],platform:i}=t,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let d=await i.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:f}=cp(d,o,c),p=o,h={},m=0;for(let y=0;y<l.length;y++){var g;const{name:w,fn:b}=l[y],{x,y:S,data:E,reset:M}=await b({x:u,y:f,initialPlacement:o,placement:p,strategy:r,middlewareData:h,rects:d,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:S2},elements:{reference:n,floating:e}});u=x??u,f=S??f,h={...h,[w]:{...h[w],...E}},M&&m<=50&&(m++,typeof M=="object"&&(M.placement&&(p=M.placement),M.rects&&(d=M.rects===!0?await i.getElementRects({reference:n,floating:e,strategy:r}):M.rects),{x:u,y:f}=cp(d,p,c)),y=-1)}return{x:u,y:f,placement:p,strategy:r,middlewareData:h}},C2=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,o;const{placement:r,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=qs(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const w=Rn(r),b=ln(l),x=Rn(l)===l,S=await(c.isRTL==null?void 0:c.isRTL(d.floating)),E=p||(x||!g?[Gs(l)]:p2(l)),M=m!=="none";!p&&M&&E.push(...k2(l,g,m,S));const C=[l,...E],T=await c.detectOverflow(e,y),v=[];let I=((o=s.flip)==null?void 0:o.overflows)||[];if(u&&v.push(T[w]),f){const F=h2(r,i,S);v.push(T[F[0]],T[F[1]])}if(I=[...I,{placement:r,overflows:v}],!v.every(F=>F<=0)){var B,P;const F=(((B=s.flip)==null?void 0:B.index)||0)+1,z=C[F];if(z&&(!(f==="alignment"?b!==ln(z):!1)||I.every(K=>ln(K.placement)===b?K.overflows[0]>0:!0)))return{data:{index:F,overflows:I},reset:{placement:z}};let J=(P=I.filter(j=>j.overflows[0]<=0).sort((j,K)=>j.overflows[1]-K.overflows[1])[0])==null?void 0:P.placement;if(!J)switch(h){case"bestFit":{var V;const j=(V=I.filter(K=>{if(M){const W=ln(K.placement);return W===b||W==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(W=>W>0).reduce((W,X)=>W+X,0)]).sort((K,W)=>K[1]-W[1])[0])==null?void 0:V[0];j&&(J=j);break}case"initialPlacement":J=l;break}if(r!==J)return{reset:{placement:J}}}return{}}}},E2=new Set(["left","top"]);async function v2(n,e){const{placement:t,platform:o,elements:r}=n,s=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Rn(t),l=Js(t),c=ln(t)==="y",d=E2.has(i)?-1:1,u=s&&c?-1:1,f=qs(e,n);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof m=="number"&&(h=l==="end"?m*-1:m),c?{x:h*u,y:p*d}:{x:p*d,y:h*u}}const T2=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,o;const{x:r,y:s,placement:i,middlewareData:l}=e,c=await v2(e,n);return i===((t=l.offset)==null?void 0:t.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:i}}}}},M2=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:o,placement:r,platform:s}=e,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:w=>{let{x:b,y:x}=w;return{x:b,y:x}}},...d}=qs(n,e),u={x:t,y:o},f=await s.detectOverflow(e,d),p=ln(Rn(r)),h=rp(p);let m=u[h],g=u[p];if(i){const w=h==="y"?"top":"left",b=h==="y"?"bottom":"right",x=m+f[w],S=m-f[b];m=op(x,m,S)}if(l){const w=p==="y"?"top":"left",b=p==="y"?"bottom":"right",x=g+f[w],S=g-f[b];g=op(x,g,S)}const y=c.fn({...e,[h]:m,[p]:g});return{...y,data:{x:y.x-t,y:y.y-o,enabled:{[h]:i,[p]:l}}}}}};function Xs(){return typeof window<"u"}function Pn(n){return Sa(n)?(n.nodeName||"").toLowerCase():"#document"}function qe(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function St(n){var e;return(e=(Sa(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Sa(n){return Xs()?n instanceof Node||n instanceof qe(n).Node:!1}function at(n){return Xs()?n instanceof Element||n instanceof qe(n).Element:!1}function xt(n){return Xs()?n instanceof HTMLElement||n instanceof qe(n).HTMLElement:!1}function dp(n){return!Xs()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof qe(n).ShadowRoot}const A2=new Set(["inline","contents"]);function cr(n){const{overflow:e,overflowX:t,overflowY:o,display:r}=ct(n);return/auto|scroll|overlay|hidden|clip/.test(e+o+t)&&!A2.has(r)}const N2=new Set(["table","td","th"]);function I2(n){return N2.has(Pn(n))}const B2=[":popover-open",":modal"];function Qs(n){return B2.some(e=>{try{return n.matches(e)}catch{return!1}})}const O2=["transform","translate","scale","rotate","perspective"],_2=["transform","translate","scale","rotate","perspective","filter"],R2=["paint","layout","strict","content"];function xa(n){const e=Ca(),t=at(n)?ct(n):n;return O2.some(o=>t[o]?t[o]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||_2.some(o=>(t.willChange||"").includes(o))||R2.some(o=>(t.contain||"").includes(o))}function P2(n){let e=an(n);for(;xt(e)&&!lo(e);){if(xa(e))return e;if(Qs(e))return null;e=an(e)}return null}function Ca(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const D2=new Set(["html","body","#document"]);function lo(n){return D2.has(Pn(n))}function ct(n){return qe(n).getComputedStyle(n)}function Zs(n){return at(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function an(n){if(Pn(n)==="html")return n;const e=n.assignedSlot||n.parentNode||dp(n)&&n.host||St(n);return dp(e)?e.host:e}function up(n){const e=an(n);return lo(e)?n.ownerDocument?n.ownerDocument.body:n.body:xt(e)&&cr(e)?e:up(e)}function dr(n,e,t){var o;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=up(n),s=r===((o=n.ownerDocument)==null?void 0:o.body),i=qe(r);if(s){const l=Ea(i);return e.concat(i,i.visualViewport||[],cr(r)?r:[],l&&t?dr(l):[])}return e.concat(r,dr(r,[],t))}function Ea(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function fp(n){const e=ct(n);let t=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=xt(n),s=r?n.offsetWidth:t,i=r?n.offsetHeight:o,l=Us(t)!==s||Us(o)!==i;return l&&(t=s,o=i),{width:t,height:o,$:l}}function va(n){return at(n)?n:n.contextElement}function ao(n){const e=va(n);if(!xt(e))return bt(1);const t=e.getBoundingClientRect(),{width:o,height:r,$:s}=fp(e);let i=(s?Us(t.width):t.width)/o,l=(s?Us(t.height):t.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const L2=bt(0);function hp(n){const e=qe(n);return!Ca()||!e.visualViewport?L2:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function V2(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==qe(n)?!1:e}function Dn(n,e,t,o){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=va(n);let i=bt(1);e&&(o?at(o)&&(i=ao(o)):i=ao(n));const l=V2(s,t,o)?hp(s):bt(0);let c=(r.left+l.x)/i.x,d=(r.top+l.y)/i.y,u=r.width/i.x,f=r.height/i.y;if(s){const p=qe(s),h=o&&at(o)?qe(o):o;let m=p,g=Ea(m);for(;g&&o&&h!==m;){const y=ao(g),w=g.getBoundingClientRect(),b=ct(g),x=w.left+(g.clientLeft+parseFloat(b.paddingLeft))*y.x,S=w.top+(g.clientTop+parseFloat(b.paddingTop))*y.y;c*=y.x,d*=y.y,u*=y.x,f*=y.y,c+=x,d+=S,m=qe(g),g=Ea(m)}}return Ys({width:u,height:f,x:c,y:d})}function ei(n,e){const t=Zs(n).scrollLeft;return e?e.left+t:Dn(St(n)).left+t}function pp(n,e){const t=n.getBoundingClientRect(),o=t.left+e.scrollLeft-ei(n,t),r=t.top+e.scrollTop;return{x:o,y:r}}function $2(n){let{elements:e,rect:t,offsetParent:o,strategy:r}=n;const s=r==="fixed",i=St(o),l=e?Qs(e.floating):!1;if(o===i||l&&s)return t;let c={scrollLeft:0,scrollTop:0},d=bt(1);const u=bt(0),f=xt(o);if((f||!f&&!s)&&((Pn(o)!=="body"||cr(i))&&(c=Zs(o)),xt(o))){const h=Dn(o);d=ao(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const p=i&&!f&&!s?pp(i,c):bt(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-c.scrollLeft*d.x+u.x+p.x,y:t.y*d.y-c.scrollTop*d.y+u.y+p.y}}function z2(n){return Array.from(n.getClientRects())}function F2(n){const e=St(n),t=Zs(n),o=n.ownerDocument.body,r=_n(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=_n(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let i=-t.scrollLeft+ei(n);const l=-t.scrollTop;return ct(o).direction==="rtl"&&(i+=_n(e.clientWidth,o.clientWidth)-r),{width:r,height:s,x:i,y:l}}const mp=25;function H2(n,e){const t=qe(n),o=St(n),r=t.visualViewport;let s=o.clientWidth,i=o.clientHeight,l=0,c=0;if(r){s=r.width,i=r.height;const u=Ca();(!u||u&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}const d=ei(o);if(d<=0){const u=o.ownerDocument,f=u.body,p=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(o.clientWidth-f.clientWidth-h);m<=mp&&(s-=m)}else d<=mp&&(s+=d);return{width:s,height:i,x:l,y:c}}const j2=new Set(["absolute","fixed"]);function W2(n,e){const t=Dn(n,!0,e==="fixed"),o=t.top+n.clientTop,r=t.left+n.clientLeft,s=xt(n)?ao(n):bt(1),i=n.clientWidth*s.x,l=n.clientHeight*s.y,c=r*s.x,d=o*s.y;return{width:i,height:l,x:c,y:d}}function gp(n,e,t){let o;if(e==="viewport")o=H2(n,t);else if(e==="document")o=F2(St(n));else if(at(e))o=W2(e,t);else{const r=hp(n);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Ys(o)}function yp(n,e){const t=an(n);return t===e||!at(t)||lo(t)?!1:ct(t).position==="fixed"||yp(t,e)}function U2(n,e){const t=e.get(n);if(t)return t;let o=dr(n,[],!1).filter(l=>at(l)&&Pn(l)!=="body"),r=null;const s=ct(n).position==="fixed";let i=s?an(n):n;for(;at(i)&&!lo(i);){const l=ct(i),c=xa(i);!c&&l.position==="fixed"&&(r=null),(s?!c&&!r:!c&&l.position==="static"&&!!r&&j2.has(r.position)||cr(i)&&!c&&yp(n,i))?o=o.filter(u=>u!==i):r=l,i=an(i)}return e.set(n,o),o}function K2(n){let{element:e,boundary:t,rootBoundary:o,strategy:r}=n;const i=[...t==="clippingAncestors"?Qs(e)?[]:U2(e,this._c):[].concat(t),o],l=i[0],c=i.reduce((d,u)=>{const f=gp(e,u,r);return d.top=_n(f.top,d.top),d.right=Ws(f.right,d.right),d.bottom=Ws(f.bottom,d.bottom),d.left=_n(f.left,d.left),d},gp(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function q2(n){const{width:e,height:t}=fp(n);return{width:e,height:t}}function J2(n,e,t){const o=xt(e),r=St(e),s=t==="fixed",i=Dn(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=bt(0);function d(){c.x=ei(r)}if(o||!o&&!s)if((Pn(e)!=="body"||cr(r))&&(l=Zs(e)),o){const h=Dn(e,!0,s,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop}else r&&d();s&&!o&&r&&d();const u=r&&!o&&!s?pp(r,l):bt(0),f=i.left+l.scrollLeft-c.x-u.x,p=i.top+l.scrollTop-c.y-u.y;return{x:f,y:p,width:i.width,height:i.height}}function Ta(n){return ct(n).position==="static"}function kp(n,e){if(!xt(n)||ct(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return St(n)===t&&(t=t.ownerDocument.body),t}function wp(n,e){const t=qe(n);if(Qs(n))return t;if(!xt(n)){let r=an(n);for(;r&&!lo(r);){if(at(r)&&!Ta(r))return r;r=an(r)}return t}let o=kp(n,e);for(;o&&I2(o)&&Ta(o);)o=kp(o,e);return o&&lo(o)&&Ta(o)&&!xa(o)?t:o||P2(n)||t}const G2=async function(n){const e=this.getOffsetParent||wp,t=this.getDimensions,o=await t(n.floating);return{reference:J2(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Y2(n){return ct(n).direction==="rtl"}const X2={convertOffsetParentRelativeRectToViewportRelativeRect:$2,getDocumentElement:St,getClippingRect:K2,getOffsetParent:wp,getElementRects:G2,getClientRects:z2,getDimensions:q2,getScale:ao,isElement:at,isRTL:Y2};function bp(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function Q2(n,e){let t=null,o;const r=St(n);function s(){var l;clearTimeout(o),(l=t)==null||l.disconnect(),t=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=n.getBoundingClientRect(),{left:u,top:f,width:p,height:h}=d;if(l||e(),!p||!h)return;const m=Ks(f),g=Ks(r.clientWidth-(u+p)),y=Ks(r.clientHeight-(f+h)),w=Ks(u),x={rootMargin:-m+"px "+-g+"px "+-y+"px "+-w+"px",threshold:_n(0,Ws(1,c))||1};let S=!0;function E(M){const C=M[0].intersectionRatio;if(C!==c){if(!S)return i();C?i(!1,C):o=setTimeout(()=>{i(!1,1e-7)},1e3)}C===1&&!bp(d,n.getBoundingClientRect())&&i(),S=!1}try{t=new IntersectionObserver(E,{...x,root:r.ownerDocument})}catch{t=new IntersectionObserver(E,x)}t.observe(n)}return i(!0),s}function ti(n,e,t,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,d=va(n),u=r||s?[...d?dr(d):[],...dr(e)]:[];u.forEach(w=>{r&&w.addEventListener("scroll",t,{passive:!0}),s&&w.addEventListener("resize",t)});const f=d&&l?Q2(d,t):null;let p=-1,h=null;i&&(h=new ResizeObserver(w=>{let[b]=w;b&&b.target===d&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),t()}),d&&!c&&h.observe(d),h.observe(e));let m,g=c?Dn(n):null;c&&y();function y(){const w=Dn(n);g&&!bp(g,w)&&t(),g=w,m=requestAnimationFrame(y)}return t(),()=>{var w;u.forEach(b=>{r&&b.removeEventListener("scroll",t),s&&b.removeEventListener("resize",t)}),f==null||f(),(w=h)==null||w.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const co=T2,uo=M2,fo=C2,Z2=(n,e,t)=>{const o=new Map,r={platform:X2,...t},s={...r.platform,_c:o};return x2(n,e,{...r,platform:s})};function ex(n){return n!=null&&typeof n=="object"&&"$el"in n}function Sp(n){if(ex(n)){const e=n.$el;return Sa(e)&&Pn(e)==="#comment"?null:e}return n}function ur(n){return typeof n=="function"?n():a.unref(n)}function xp(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Cp(n,e){const t=xp(n);return Math.round(e*t)/t}function ho(n,e,t){t===void 0&&(t={});const o=t.whileElementsMounted,r=a.computed(()=>{var C;return(C=ur(t.open))!=null?C:!0}),s=a.computed(()=>ur(t.middleware)),i=a.computed(()=>{var C;return(C=ur(t.placement))!=null?C:"bottom"}),l=a.computed(()=>{var C;return(C=ur(t.strategy))!=null?C:"absolute"}),c=a.computed(()=>{var C;return(C=ur(t.transform))!=null?C:!0}),d=a.computed(()=>Sp(n.value)),u=a.computed(()=>Sp(e.value)),f=a.ref(0),p=a.ref(0),h=a.ref(l.value),m=a.ref(i.value),g=a.shallowRef({}),y=a.ref(!1),w=a.computed(()=>{const C={position:h.value,left:"0",top:"0"};if(!u.value)return C;const T=Cp(u.value,f.value),v=Cp(u.value,p.value);return c.value?{...C,transform:"translate("+T+"px, "+v+"px)",...xp(u.value)>=1.5&&{willChange:"transform"}}:{position:h.value,left:T+"px",top:v+"px"}});let b;function x(){if(d.value==null||u.value==null)return;const C=r.value;Z2(d.value,u.value,{middleware:s.value,placement:i.value,strategy:l.value}).then(T=>{f.value=T.x,p.value=T.y,h.value=T.strategy,m.value=T.placement,g.value=T.middlewareData,y.value=C!==!1})}function S(){typeof b=="function"&&(b(),b=void 0)}function E(){if(S(),o===void 0){x();return}if(d.value!=null&&u.value!=null){b=o(d.value,u.value,x);return}}function M(){r.value||(y.value=!1)}return a.watch([s,i,l,r],x,{flush:"sync"}),a.watch([d,u],E,{flush:"sync"}),a.watch(r,M,{flush:"sync"}),a.getCurrentScope()&&a.onScopeDispose(S),{x:a.shallowReadonly(f),y:a.shallowReadonly(p),strategy:a.shallowReadonly(h),placement:a.shallowReadonly(m),middlewareData:a.shallowReadonly(g),isPositioned:a.shallowReadonly(y),floatingStyles:w,update:x}}const tx=["menu-open"],Je=a.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(n,{emit:e}){const t=n,o=e,r=a.inject("containerRef"),s=a.inject(gc,null),i=a.inject(yc,0),l=Math.random().toString(36).slice(2);a.provide(yc,i+1);const{show:c,hide:d}=$t(),u=a.ref(!1);s&&a.watch(()=>s.value.get(i),x=>{x!==void 0&&x!==l&&u.value&&(u.value=!1)});const f=a.ref(null),p=a.ref(null),{floatingStyles:h}=ho(f,p,{placement:t.placement,middleware:[co(t.offsetPx),fo(),uo({padding:8})],whileElementsMounted:ti});function m(){t.disabled||(u.value=!u.value)}function g(){u.value=!1}function y(x){var T,v,I;const S=x.target,E=(T=f.value)==null?void 0:T.contains(S),M=(v=p.value)==null?void 0:v.contains(S),C=(I=S.closest)==null?void 0:I.call(S,".wov-menu-dropdown");!E&&!M&&!C&&g()}function w(){t.title&&f.value&&!u.value&&c(t.title,f.value)}function b(){d()}return a.watch(u,x=>{x?(d(),document.addEventListener("click",y,!0),s&&(s.value.set(i,l),s.value=new Map(s.value)),o("open")):(document.removeEventListener("click",y,!0),(s==null?void 0:s.value.get(i))===l&&(s.value.delete(i),s.value=new Map(s.value)),o("close"))}),a.onUnmounted(()=>{document.removeEventListener("click",y,!0)}),(x,S)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:a.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:S[0]||(S[0]=a.withModifiers(()=>{},["prevent"])),onClick:m,onMouseenter:w,onMouseleave:b},[a.renderSlot(x.$slots,"button",{isOpen:u.value})],42,tx),a.unref(r)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(r)},[u.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"wov-menu-dropdown",style:a.normalizeStyle(a.unref(h))},[a.renderSlot(x.$slots,"dropdown",{close:g})],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),nx={},ox={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function rx(n,e){return a.openBlock(),a.createElementBlock("svg",ox,[...e[0]||(e[0]=[a.createElementVNode("path",{d:"M233.4 278.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 210.7 86.6 41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"},null,-1)])])}const Ge=pn(nx,[["render",rx]]),sx={class:"wov-menu-button"},ix=["innerHTML"],lx=["onClick"],ax=["innerHTML"],Ma=a.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),o=a.shallowRef(null),r=a.computed(()=>{const l=o.value??(e.side==="start"?te.ArrowHeadKind.None:te.ArrowHeadKind.V);return Hn(l)});t(l=>{let c=null;for(const d of e.entityIds){if(k.hasComponent(l,d,te.ElbowArrow)){const u=te.ElbowArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?te.ArrowHeadKind.None:te.ArrowHeadKind.V;return}}if(k.hasComponent(l,d,te.ArcArrow)){const u=te.ArcArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?te.ArrowHeadKind.None:te.ArrowHeadKind.V;return}}}o.value=c});function s(l){o.value=l,t(c=>{for(const d of e.entityIds){if(k.hasComponent(c,d,te.ElbowArrow)){const u=te.ElbowArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}if(k.hasComponent(c,d,te.ArcArrow)){const u=te.ArcArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}}})}function i(l){if(!l)return"";const c=e.side==="start";return`<line x1="${c?8:4}" y1="12" x2="${c?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${c?4:20}, 12) scale(${c?"-0.8, 0.8":"0.8"})`}">${l.svg}</g>`}return(l,c)=>(a.openBlock(),a.createBlock(Je,{title:n.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:a.withCtx(()=>[a.createElementVNode("div",sx,[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(r.value)},null,8,ix)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(a.unref(bi),d=>(a.openBlock(),a.createElementBlock("button",{key:d.kind,class:a.normalizeClass(["wov-menu-option",{"is-active":o.value===d.kind}]),onClick:u=>s(d.kind)},[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(d)},null,8,ax))],10,lx))),128))]),_:1},8,["title"]))}}),cx={class:"wov-menu-button"},dx=["onClick"],Ep=a.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],t=n,{nextEditorTick:o}=fe(),r=a.shallowRef(null);o(i=>{let l=null;for(const c of t.entityIds){if(k.hasComponent(i,c,te.ElbowArrow)){const d=te.ElbowArrow.read(i,c);if(l===null)l=d.thickness;else if(d.thickness!==l){r.value=null;return}}if(k.hasComponent(i,c,te.ArcArrow)){const d=te.ArcArrow.getThickness(i,c);if(l===null)l=d;else if(d!==l){r.value=null;return}}}r.value=l});function s(i){r.value=i,o(l=>{for(const c of t.entityIds){if(k.hasComponent(l,c,te.ElbowArrow)){const d=te.ElbowArrow.write(l,c);d.thickness=i}k.hasComponent(l,c,te.ArcArrow)&&te.ArcArrow.setThickness(l,c,i)}})}return(i,l)=>(a.openBlock(),a.createBlock(Je,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",cx,[l[0]||(l[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,c=>a.createElementVNode("button",{key:c.value,class:a.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":r.value===c.value}]),onClick:d=>s(c.value)},a.toDisplayString(c.label),11,dx)),64))]),_:1}))}}),ux=["value"],fx=a.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(t.modelValue??"");a.watch(()=>t.modelValue,u=>{u&&u!==r.value&&(r.value=u)});function s(u){const f=u.startsWith("#")?u:`#${u}`;return/^#[0-9A-Fa-f]{6}$/.test(f)}function i(u){return(u.startsWith("#")?u:`#${u}`).toLowerCase()}function l(u){let p=u.target.value;if((p.length===6||p.length===7)&&s(p)){const h=i(p);r.value=h,o("update:modelValue",h)}}function c(u){const p=u.target.value;if(p&&s(p)){const h=i(p);r.value=h,o("update:modelValue",h)}else t.modelValue&&(r.value=t.modelValue)}function d(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,p=f.value;if(p&&s(p)){const h=i(p);r.value=h,o("update:modelValue",h),setTimeout(()=>f.select())}}}return(u,f)=>(a.openBlock(),a.createElementBlock("input",{id:"wov-color-input",class:"wov-color-input",type:"text",size:"1","aria-label":"Hex color value",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",value:r.value,onInput:l,onChange:c,onKeydown:d},null,40,ux))}}),hx={class:"wov-color-picker"},px={class:"wov-color-picker-area"},mx={class:"wov-color-picker-selector-gradient"},gx="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",vp=a.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),s=a.ref(null),i=a.ref(null),l=a.ref({x:100,y:0}),c=a.ref(0),d=a.ref(0),u=a.ref(!1),f=a.computed(()=>{var M,C;return u.value||((M=r.value)==null?void 0:M.isDragging)||((C=s.value)==null?void 0:C.isDragging)}),p=a.computed(()=>({h:c.value/100*360,s:l.value.x,v:100-l.value.y,a:(100-d.value)/100*255})),h=a.computed(()=>Fh({h:p.value.h,s:100,v:100})),m=a.computed(()=>Fh({h:p.value.h,s:p.value.s,v:p.value.v})),g=a.computed(()=>t.withOpacity?Hh(p.value):m.value),y=a.computed(()=>`linear-gradient(to top, transparent 0%, ${m.value} 100%)`);function w(M){if(M){const C=zh(M);l.value={x:C.s,y:100-C.v},c.value=C.h/360*100,d.value=100-C.a/255*100}}function b(M){w(M),o("update:modelValue",t.withOpacity?Hh(zh(M)):M)}w(t.modelValue),a.watch(()=>t.modelValue,M=>{f.value||w(M)}),a.watch([l,c,d],()=>{f.value&&o("update:modelValue",g.value)});function x(M){u.value=!0,S(M),window.addEventListener("pointermove",S),window.addEventListener("pointerup",E)}function S(M){if(!i.value)return;const C=i.value.getBoundingClientRect(),T=Math.max(0,Math.min(100,(M.clientX-C.left)/C.width*100)),v=Math.max(0,Math.min(100,(M.clientY-C.top)/C.height*100));l.value={x:T,y:v}}function E(){u.value=!1,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",E)}return(M,C)=>{const T=a.resolveComponent("ColorSlider");return a.openBlock(),a.createElementBlock("div",hx,[a.createVNode(fx,{modelValue:g.value,"onUpdate:modelValue":b},null,8,["modelValue"]),a.createElementVNode("div",px,[a.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:a.normalizeStyle({backgroundColor:h.value}),onPointerdown:a.withModifiers(x,["prevent"])},[a.createElementVNode("div",mx,[a.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:a.normalizeStyle({left:`${l.value.x}%`,top:`${l.value.y}%`,backgroundColor:m.value})},null,4)])],36),a.createVNode(T,{ref_key:"hueSliderRef",ref:r,modelValue:c.value,"onUpdate:modelValue":C[0]||(C[0]=v=>c.value=v),thumbColor:h.value,background:gx},null,8,["modelValue","thumbColor"]),n.withOpacity?(a.openBlock(),a.createBlock(T,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:d.value,"onUpdate:modelValue":C[1]||(C[1]=v=>d.value=v),thumbColor:m.value,background:y.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):a.createCommentVNode("",!0)])])}}}),yx={class:"wov-color-bubbles-container"},kx={key:1,class:"wov-color-bubbles"},wx=["onClick"],ni=a.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(n,{emit:e}){const t=n,o=e,r=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=a.computed(()=>{const m=t.palette??r,g=t.withPicker,y=m.length%2===1;return g&&!y||!g&&y?m.slice(0,-1):m}),i=a.ref(!1),l=a.ref(t.currentColor??"#ff0000");function c(m,g){const y=w=>{const b=w.replace(/^#/,"").toLowerCase();return b.length===6?`${b}ff`:b};return y(m)===y(g)}function d(m){return t.hideHighlight||!t.currentColor?!1:c(t.currentColor,m)}function u(){return t.hideHighlight||!t.currentColor?!1:!s.value.some(m=>c(t.currentColor,m))}function f(m){const g=da(m);g&&o("change",g)}function p(){!i.value&&t.currentColor&&(l.value=t.currentColor),i.value=!i.value,o("picker-open",i.value)}function h(m){l.value=m;const g=da(m);g&&o("change",g)}return(m,g)=>(a.openBlock(),a.createElementBlock("div",yx,[i.value?(a.openBlock(),a.createBlock(vp,{key:0,modelValue:l.value,"onUpdate:modelValue":[g[0]||(g[0]=y=>l.value=y),h],withOpacity:n.withOpacity},null,8,["modelValue","withOpacity"])):(a.openBlock(),a.createElementBlock("div",kx,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,y=>(a.openBlock(),a.createElementBlock("div",{key:y,class:a.normalizeClass(["wov-color-bubble",{selected:d(y)}]),style:a.normalizeStyle({backgroundColor:y}),onMousedown:g[1]||(g[1]=a.withModifiers(()=>{},["prevent"])),onClick:w=>f(y)},null,46,wx))),128)),n.withPicker?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:g[2]||(g[2]=a.withModifiers(()=>{},["prevent"])),onClick:p},null,34)):a.createCommentVNode("",!0)]))]))}}),bx={class:"wov-color-button"},Tp=a.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),o=Vt(()=>e.entityIds,k.Color),r=a.computed(()=>{const d=new Set;for(const u of o.value.values())if(u){const f=rr(u);d.add(f)}return Array.from(d)}),s=a.computed(()=>r.value.length>1),i=a.computed(()=>r.value[0]??null),l=a.computed(()=>{if(r.value.length===0)return{backgroundColor:"#000"};if(r.value.length>=2){const d=r.value[0],u=r.value[1];return{background:`linear-gradient(45deg, ${d} 0%, ${d} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:r.value[0]}});function c(d){const u=rr(d);t(f=>{for(const p of e.entityIds)k.Color.fromHex(f,p,u)})}return(d,u)=>(a.openBlock(),a.createBlock(Je,{title:"Color"},{button:a.withCtx(()=>[a.createElementVNode("div",bx,[a.createElementVNode("div",{class:"wov-color-swatch",style:a.normalizeStyle(l.value)},null,4),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(ni,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:c},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Ln=a.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),{show:s,hide:i}=$t();function l(u){o("click",u)}function c(){t.title&&r.value&&s(t.title,r.value)}function d(){i()}return(u,f)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:"wov-menu-button",onClick:l,onMouseenter:c,onMouseleave:d},[a.renderSlot(u.$slots,"default")],544))}}),Mp=a.defineComponent({__name:"MenuTooltip",setup(n){const{activeTooltip:e,isVisible:t}=$t(),o=a.ref(null),r=a.computed(()=>{var d;return((d=e.value)==null?void 0:d.anchor)??null}),{floatingStyles:s}=ho(r,o,{placement:"top",middleware:[co(8),fo({fallbackPlacements:["bottom"]}),uo({padding:8})]}),i=Symbol("menu-tooltip"),l=a.computed(()=>Hs.value[0]===i);a.onMounted(()=>{Hs.value.push(i)}),a.onUnmounted(()=>{Hs.value=Hs.value.filter(d=>d!==i)});const c=a.computed(()=>{var d;return l.value&&t.value&&((d=e.value)==null?void 0:d.text)});return(d,u)=>(a.openBlock(),a.createBlock(a.Teleport,{to:"body"},[a.createVNode(a.Transition,{name:"wov-tooltip-fade"},{default:a.withCtx(()=>{var f;return[c.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:o,class:"wov-menu-tooltip",style:a.normalizeStyle(a.unref(s))},a.toDisplayString((f=a.unref(e))==null?void 0:f.text),5)):a.createCommentVNode("",!0)]}),_:1})]))}}),Sx={class:"wov-menu-button"},xx=["onClick"],Ap=a.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],t=n,{nextEditorTick:o}=fe(),r=Vt(()=>t.entityIds,wr.PenStroke),s=a.computed(()=>{let l=null;for(const c of r.value.values())if(c){if(l===null)l=c.thickness;else if(c.thickness!==l)return null}return l});function i(l){o(c=>{for(const d of t.entityIds){const u=wr.PenStroke.write(c,d);u.thickness=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Je,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",Sx,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("button",{key:d.value,class:a.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===d.value}]),onClick:u=>i(d.value)},a.toDisplayString(d.label),11,xx)),64))]),_:1}))}}),Cx={class:"wov-fill-color-button"},Ex={class:"wov-fill-dropdown"},vx={key:0,class:"wov-fill-mode-section"},Tx=["title","onClick"],Mx={viewBox:"0 0 24 24",fill:"none"},Ax=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],Np=a.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),o=Vt(()=>e.entityIds,k.Shape),r=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=a.computed(()=>{const h=o.value.values().next().value,m=(h==null?void 0:h.fillAlpha)??255;return m===0?"none":m<200?"faded":"solid"}),i=a.computed(()=>{const h=new Set;for(const m of o.value.values())if(m){const g=m.fillAlpha??255;g===0?h.add("none"):g<200?h.add("faded"):h.add("solid")}return h.size>1});function l(h){t(m=>{for(const g of e.entityIds){const y=k.Shape.write(m,g);y.fillAlpha=h}})}const c=a.computed(()=>{const h=new Set;for(const m of o.value.values())if(m){const g=rr({red:m.fillRed,green:m.fillGreen,blue:m.fillBlue,alpha:m.fillAlpha??255});h.add(g)}return Array.from(h)}),d=a.computed(()=>c.value.length>1),u=a.computed(()=>c.value[0]??"#4a90d9");function f(h){t(m=>{for(const g of e.entityIds){const y=k.Shape.write(m,g);y.fillRed=h.red,y.fillGreen=h.green,y.fillBlue=h.blue,y.fillAlpha=h.alpha}})}const p=a.ref(!1);return(h,m)=>(a.openBlock(),a.createBlock(Je,{title:"Fill Color"},{button:a.withCtx(()=>[a.createElementVNode("div",Cx,[m[1]||(m[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M5.879,2.625L14.121,2.625C15.906,2.625 17.375,4.094 17.375,5.879L17.375,14.121C17.375,15.906 15.906,17.375 14.121,17.375L5.88,17.375C4.095,17.375 2.626,15.906 2.626,14.121L2.626,5.88C2.626,4.095 4.095,2.626 5.88,2.626L5.879,2.625Z","stroke-width":"1.25"}),a.createElementVNode("path",{d:"M2.779,14.655L14.543,2.871M10.238,17.308L17.318,10.229M2.876,9.577L9.853,2.6M5.397,17.239L17.16,5.476","stroke-width":"1.25"})],-1)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",Ex,[p.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",vx,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,g=>a.createElementVNode("button",{key:g.mode,class:a.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&g.mode===s.value}]),title:g.label,onClick:y=>l(g.alpha)},[(a.openBlock(),a.createElementBlock("svg",Mx,[a.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:g.mode==="none"?"none":"currentColor","fill-opacity":g.mode==="faded"?.4:1,stroke:g.mode==="none"?"currentColor":"none","stroke-width":g.mode==="none"?1.5:0,"stroke-dasharray":g.mode==="none"?"3 3":""},null,8,Ax)])),a.createElementVNode("span",null,a.toDisplayString(g.label),1)],10,Tx)),64))])),a.createVNode(ni,{currentColor:u.value,hideHighlight:d.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:m[0]||(m[0]=g=>p.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),Nx={class:"wov-shape-kind-button"},Ix={class:"wov-shape-kind-dropdown"},Bx=["onClick"],Ox={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},_x=["d"],Ip=a.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),o=Vt(()=>e.entityIds,k.Shape),r=a.computed(()=>{const c=o.value.values().next().value;return(c==null?void 0:c.kind)??"rectangle"}),s=a.computed(()=>{const c=new Set;for(const d of o.value.values())d&&c.add(d.kind);return c.size>1}),i=a.computed(()=>Object.keys(xo).map(c=>({kind:c,label:c.charAt(0).toUpperCase()+c.slice(1)})));function l(c){t(d=>{for(const u of e.entityIds){const f=k.Shape.write(d,u);f.kind=c}})}return(c,d)=>(a.openBlock(),a.createBlock(Je,{title:"Shape Type"},{button:a.withCtx(()=>[a.createElementVNode("div",Nx,[d[0]||(d[0]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),a.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",Ix,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,u=>(a.openBlock(),a.createElementBlock("button",{key:u.kind,class:a.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===r.value}]),onClick:f=>l(u.kind)},[(a.openBlock(),a.createElementBlock("svg",Ox,[a.createElementVNode("path",{d:a.unref(xo)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,_x)])),a.createElementVNode("span",null,a.toDisplayString(u.label),1)],10,Bx))),128))])]),_:1}))}}),Rx={class:"wov-stroke-style-section"},Px=["title","onClick"],Dx={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},Lx=["stroke-dasharray","stroke-opacity"],Vx=a.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(n,{emit:e}){const t=e,o=[{kind:k.StrokeKind.Solid,label:"Solid"},{kind:k.StrokeKind.Dashed,label:"Dashed"},{kind:k.StrokeKind.None,label:"None"}];function r(i){switch(i){case k.StrokeKind.Dashed:return"6 6";case k.StrokeKind.None:return"";default:return""}}function s(i){t("change",i)}return(i,l)=>(a.openBlock(),a.createElementBlock("div",Rx,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(o,c=>a.createElementVNode("button",{key:c.kind,class:a.normalizeClass(["wov-stroke-style-option",{"is-active":!n.hasMultipleStyles&&c.kind===n.currentStyle}]),title:c.label,onClick:d=>s(c.kind)},[(a.openBlock(),a.createElementBlock("svg",Dx,[a.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":r(c.kind),"stroke-opacity":c.kind===a.unref(k.StrokeKind).None?.3:1},null,8,Lx)])),a.createElementVNode("span",null,a.toDisplayString(c.label),1)],10,Px)),64))]))}}),$x={class:"wov-stroke-color-button"},zx={class:"wov-stroke-dropdown"},Fx={key:1,class:"wov-stroke-divider"},Bp=a.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),o=Vt(()=>e.entityIds,k.Shape),r=a.ref(!1),s=a.computed(()=>{const p=new Set;for(const h of o.value.values())if(h){const m=rr({red:h.strokeRed,green:h.strokeGreen,blue:h.strokeBlue,alpha:255});p.add(m)}return Array.from(p)}),i=a.computed(()=>s.value.length>1),l=a.computed(()=>s.value[0]??"#000000"),c=a.computed(()=>{const p=o.value.values().next().value;return(p==null?void 0:p.strokeKind)??k.StrokeKind.Solid}),d=a.computed(()=>{const p=new Set;for(const h of o.value.values())h&&p.add(h.strokeKind);return p.size>1});function u(p){t(h=>{for(const m of e.entityIds){const g=k.Shape.write(h,m);g.strokeRed=p.red,g.strokeGreen=p.green,g.strokeBlue=p.blue}})}function f(p){t(h=>{for(const m of e.entityIds){const g=k.Shape.write(h,m);g.strokeKind=p}})}return(p,h)=>(a.openBlock(),a.createBlock(Je,{title:"Stroke Color"},{button:a.withCtx(()=>[a.createElementVNode("div",$x,[h[1]||(h[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43","stroke-width":"1.25"})],-1)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",zx,[r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createBlock(Vx,{key:0,currentStyle:c.value,hasMultipleStyles:d.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",Fx)),a.createVNode(ni,{currentColor:l.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:h[0]||(h[0]=m=>r.value=m)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),Hx={class:"wov-tape-image-button"},jx={class:"wov-tape-image-bubbles"},Wx=["onClick"],Op=a.defineComponent({__name:"TapeImageButton",props:{entityIds:{}},setup(n){const e=[{name:"Masking Tape",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media"},{name:"Transparent",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F522899b7-0ae9-4303-bdca-71105d835210.png?generation=1715183195130528&alt=media"},{name:"Arabic",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F3658d208-67e9-48a4-865b-44842187b523.png?generation=1715183192038109&alt=media"},{name:"Balloons",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7d836c56-ae9a-44e6-a624-e6a49286dcde.png?generation=1715183193267076&alt=media"},{name:"Flowers",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2Fc1a1b89a-543f-4817-8afa-76544e94d776.png?generation=1715183194007112&alt=media"}],t=n,{nextEditorTick:o}=fe(),r=Vt(()=>t.entityIds,k.Asset),s=a.computed(()=>{for(const l of r.value.values())if(l!=null&&l.identifier)return l.identifier;return null});function i(l){o(c=>{for(const d of t.entityIds){const u=k.Asset.write(c,d);u.identifier=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Je,{title:"Tape Style"},{button:a.withCtx(()=>[a.createElementVNode("div",Hx,[a.createElementVNode("div",{class:"wov-tape-image-swatch",style:a.normalizeStyle(s.value?{backgroundImage:`url(${s.value})`}:{})},null,4),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",jx,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("div",{key:d.url,class:a.normalizeClass(["wov-tape-image-bubble",{selected:s.value===d.url}]),style:a.normalizeStyle({backgroundImage:`url(${d.url})`}),onMousedown:c[0]||(c[0]=a.withModifiers(()=>{},["prevent"])),onClick:u=>i(d.url)},null,46,Wx)),64))])]),_:1}))}}),Ux={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},Kx={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},qx={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},Jx={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},Aa=a.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds),r=[k.TextAlignment.Left,k.TextAlignment.Center,k.TextAlignment.Right,k.TextAlignment.Justify];function s(){const i=r.indexOf(t.alignment),l=r[(i+1)%r.length];o.setAlignment(l)}return(i,l)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ln,{key:0,title:"Text Align",onClick:s},{default:a.withCtx(()=>[a.unref(t).alignment===a.unref(k.TextAlignment).Left?(a.openBlock(),a.createElementBlock("svg",Ux,[...l[0]||(l[0]=[a.createElementVNode("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):a.unref(t).alignment===a.unref(k.TextAlignment).Center?(a.openBlock(),a.createElementBlock("svg",Kx,[...l[1]||(l[1]=[a.createElementVNode("path",{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},null,-1)])])):a.unref(t).alignment===a.unref(k.TextAlignment).Right?(a.openBlock(),a.createElementBlock("svg",qx,[...l[2]||(l[2]=[a.createElementVNode("path",{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",Jx,[...l[3]||(l[3]=[a.createElementVNode("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),Na=a.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ln,{key:0,title:"Bold",class:a.normalizeClass({"wov-active":a.unref(t).isBold}),onClick:a.unref(o).toggleBold},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}});function Gx(n,e){return a.getCurrentScope()?(a.onScopeDispose(n,e),!0):!1}const Yx=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Xx=Object.prototype.toString,Qx=n=>Xx.call(n)==="[object Object]",oi=()=>{};function ri(n){return Array.isArray(n)?n:[n]}function Zx(n){return a.getCurrentInstance()}function eC(n,e=!0,t){Zx()?a.onMounted(n,t):e?n():a.nextTick(n)}function tC(n,e,t){return a.watch(n,e,{...t,immediate:!0})}const si=Yx?window:void 0;function dt(n){var e;const t=a.toValue(n);return(e=t==null?void 0:t.$el)!==null&&e!==void 0?e:t}function Ia(...n){const e=(o,r,s,i)=>(o.addEventListener(r,s,i),()=>o.removeEventListener(r,s,i)),t=a.computed(()=>{const o=ri(a.toValue(n[0])).filter(r=>r!=null);return o.every(r=>typeof r!="string")?o:void 0});return tC(()=>{var o,r;return[(o=(r=t.value)===null||r===void 0?void 0:r.map(s=>dt(s)))!==null&&o!==void 0?o:[si].filter(s=>s!=null),ri(a.toValue(t.value?n[1]:n[0])),ri(a.unref(t.value?n[2]:n[1])),a.toValue(t.value?n[3]:n[2])]},([o,r,s,i],l,c)=>{if(!(o!=null&&o.length)||!(r!=null&&r.length)||!(s!=null&&s.length))return;const d=Qx(i)?{...i}:i,u=o.flatMap(f=>r.flatMap(p=>s.map(h=>e(f,p,h,d))));c(()=>{u.forEach(f=>f())})},{flush:"post"})}function nC(n,e,t={}){const{window:o=si,ignore:r=[],capture:s=!0,detectIframe:i=!1,controls:l=!1}=t;if(!o)return l?{stop:oi,cancel:oi,trigger:oi}:oi;let c=!0;const d=y=>a.toValue(r).some(w=>{if(typeof w=="string")return Array.from(o.document.querySelectorAll(w)).some(b=>b===y.target||y.composedPath().includes(b));{const b=dt(w);return b&&(y.target===b||y.composedPath().includes(b))}});function u(y){const w=a.toValue(y);return w&&w.$.subTree.shapeFlag===16}function f(y,w){const b=a.toValue(y),x=b.$.subTree&&b.$.subTree.children;return x==null||!Array.isArray(x)?!1:x.some(S=>S.el===w.target||w.composedPath().includes(S.el))}const p=y=>{const w=dt(n);if(y.target!=null&&!(!(w instanceof Element)&&u(n)&&f(n,y))&&!(!w||w===y.target||y.composedPath().includes(w))){if("detail"in y&&y.detail===0&&(c=!d(y)),!c){c=!0;return}e(y)}};let h=!1;const m=[Ia(o,"click",y=>{h||(h=!0,setTimeout(()=>{h=!1},0),p(y))},{passive:!0,capture:s}),Ia(o,"pointerdown",y=>{const w=dt(n);c=!d(y)&&!!(w&&!y.composedPath().includes(w))},{passive:!0}),i&&Ia(o,"blur",y=>{setTimeout(()=>{var w;const b=dt(n);((w=o.document.activeElement)===null||w===void 0?void 0:w.tagName)==="IFRAME"&&!(b!=null&&b.contains(o.document.activeElement))&&e(y)},0)},{passive:!0})].filter(Boolean),g=()=>m.forEach(y=>y());return l?{stop:g,cancel:()=>{c=!1},trigger:y=>{c=!0,p(y),c=!1}}:g}function oC(){const n=a.shallowRef(!1),e=a.getCurrentInstance();return e&&a.onMounted(()=>{n.value=!0},e),n}function rC(n){const e=oC();return a.computed(()=>(e.value,!!n()))}function sC(n,e,t={}){const{window:o=si,...r}=t;let s;const i=rC(()=>o&&"ResizeObserver"in o),l=()=>{s&&(s.disconnect(),s=void 0)},c=a.watch(a.computed(()=>{const u=a.toValue(n);return Array.isArray(u)?u.map(f=>dt(f)):[dt(u)]}),u=>{if(l(),i.value&&o){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,r)}},{immediate:!0,flush:"post"}),d=()=>{l(),c()};return Gx(d),{isSupported:i,stop:d}}function _p(n,e={width:0,height:0},t={}){const{window:o=si,box:r="content-box"}=t,s=a.computed(()=>{var f;return(f=dt(n))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=a.shallowRef(e.width),l=a.shallowRef(e.height),{stop:c}=sC(n,([f])=>{const p=r==="border-box"?f.borderBoxSize:r==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(o&&s.value){const h=dt(n);if(h){const m=h.getBoundingClientRect();i.value=m.width,l.value=m.height}}else if(p){const h=ri(p);i.value=h.reduce((m,{inlineSize:g})=>m+g,0),l.value=h.reduce((m,{blockSize:g})=>m+g,0)}else i.value=f.contentRect.width,l.value=f.contentRect.height},t);eC(()=>{const f=dt(n);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,l.value="offsetHeight"in f?f.offsetHeight:e.height)});const d=a.watch(()=>dt(n),f=>{i.value=f?e.width:0,l.value=f?e.height:0});function u(){c(),d()}return{width:i,height:l,stop:u}}function Rp(){const n=a.inject(Se);if(!n)throw new Error("useFonts must be used within a WovenCanvas component");return a.computed(()=>{const e=n.getEditor();return e?e.fonts.filter(t=>t.selectable):[]})}const iC={class:"wov-font-family-button"},lC={class:"wov-font-family-label"},aC={class:"wov-font-list"},cC=["onClick"],dC=["src","alt"],Ba=a.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds),r=Rp(),s=a.computed(()=>r.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=a.computed(()=>t.fontFamily),l=a.computed(()=>{const u=i.value;if(u===null)return"Mixed";const f=s.value.find(p=>p.name===u);return(f==null?void 0:f.displayName)??u});function c(u){o.setFontFamily(u)}function d(u){u.stopPropagation()}return(u,f)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Je,{key:0,title:"Font Family"},{button:a.withCtx(()=>[a.createElementVNode("div",iC,[a.createElementVNode("span",lC,a.toDisplayString(l.value),1),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-family-menu",onWheel:d,onClick:f[0]||(f[0]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",aC,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,p=>(a.openBlock(),a.createElementBlock("div",{key:p.name,class:a.normalizeClass(["wov-font-item",{active:i.value===p.name}]),onClick:h=>c(p.name)},[p.previewImage?(a.openBlock(),a.createElementBlock("img",{key:0,class:"wov-font-preview",src:p.previewImage,alt:p.name},null,8,dC)):(a.openBlock(),a.createElementBlock("span",{key:1,class:"wov-font-name",style:a.normalizeStyle({fontFamily:p.name})},a.toDisplayString(p.displayName),5))],10,cC))),128))])],32)]),_:1})):a.createCommentVNode("",!0)}}),uC={class:"wov-font-size-button"},fC={class:"wov-font-size-label"},hC=["onClick"],pC={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},mC={class:"wov-input-container"},gC=["value"],Oa=a.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds),r=[{label:"Small",value:16,displayValue:10},{label:"Medium",value:24,displayValue:12},{label:"Large",value:40,displayValue:16},{label:"Huge",value:96,displayValue:20}],s=a.computed(()=>t.fontSize),i=a.computed(()=>{const p=s.value;if(p===null)return"Mixed";const h=r.find(m=>m.value===p);return h?h.label:`${+p.toFixed(1)} px`}),l=a.computed(()=>{const p=s.value;return p===null?"":String(+p.toFixed(1))});function c(p){o.setFontSize(p)}function d(p){const h=p.target,m=Number.parseFloat(h.value);!Number.isNaN(m)&&m>0&&c(m)}function u(p){p.key==="Enter"&&p.target.blur()}function f(p){p.stopPropagation()}return(p,h)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Je,{key:0,title:"Font Size"},{button:a.withCtx(()=>[a.createElementVNode("div",uC,[a.createElementVNode("span",fC,a.toDisplayString(i.value),1),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:h[0]||(h[0]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,m=>a.createElementVNode("div",{key:m.value,class:a.normalizeClass(["wov-font-size-option",{active:s.value===m.value}]),onClick:g=>c(m.value)},[s.value===m.value?(a.openBlock(),a.createElementBlock("svg",pC,[...h[1]||(h[1]=[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},null,-1)])])):a.createCommentVNode("",!0),a.createElementVNode("span",{class:"wov-option-label",style:a.normalizeStyle({fontSize:`${m.displayValue}px`})},a.toDisplayString(m.label),5)],10,hC)),64)),h[3]||(h[3]=a.createElementVNode("div",{class:"wov-separator"},null,-1)),a.createElementVNode("div",mC,[a.createElementVNode("input",{class:"wov-custom-input",value:l.value,onInput:d,onKeydown:u,placeholder:"Custom size"},null,40,gC),h[2]||(h[2]=a.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):a.createCommentVNode("",!0)}}),_a=a.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ln,{key:0,title:"Italic",class:a.normalizeClass({"wov-active":a.unref(t).isItalic}),onClick:a.unref(o).toggleItalic},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),Ra=a.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ln,{key:0,title:"Underline",class:a.normalizeClass({"wov-active":a.unref(t).isUnderline}),onClick:a.unref(o).toggleUnderline},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),yC={class:"wov-link-input-container"},kC=["onKeydown"],Pa=a.defineComponent({__name:"TextLinkButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds),r=a.ref(!1),s=a.ref(""),i=a.ref(null),l=a.ref(null),c=a.ref(null),d=a.inject("containerRef"),{floatingStyles:u}=ho(l,c,{placement:"top",middleware:[co(8),fo(),uo({padding:8})],whileElementsMounted:ti});function f(){s.value=t.linkHref??"",r.value=!0,a.nextTick(()=>{var g,y;(g=i.value)==null||g.focus(),(y=i.value)==null||y.select()})}function p(){const g=s.value.trim();g?o.setLink(g):o.removeLink(),r.value=!1}function h(){o.removeLink(),s.value="",r.value=!1}function m(g){var w,b;const y=g.target;!((w=l.value)!=null&&w.contains(y))&&!((b=c.value)!=null&&b.contains(y))&&(r.value=!1)}return a.watch(r,g=>{g?document.addEventListener("click",m,!0):document.removeEventListener("click",m,!0)}),(g,y)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:l},[a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ln,{key:0,title:"Link",class:a.normalizeClass({"wov-active":a.unref(t).linkHref!==null}),onClick:f},{default:a.withCtx(()=>[...y[3]||(y[3]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 7-34.4-7.4-44.6s-34.4-7-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372.1 74 321.1 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.8l-1.1 1.6c-10.3 14.4-7 34.4 7.4 44.6s34.4 7 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})],-1)])]),_:1},8,["class"])):a.createCommentVNode("",!0)],512),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[r.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:c,class:"wov-link-input-dropdown",style:a.normalizeStyle(a.unref(u)),onKeydown:y[2]||(y[2]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",yC,[a.withDirectives(a.createElementVNode("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":y[0]||(y[0]=w=>s.value=w),class:"wov-link-input",placeholder:"Paste or type URL",onKeydown:[a.withKeys(a.withModifiers(p,["prevent"]),["enter"]),y[1]||(y[1]=a.withKeys(a.withModifiers(w=>r.value=!1,["prevent"]),["esc"]))]},null,40,kC),[[a.vModelText,s.value]]),s.value||a.unref(t).linkHref?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-link-action-button",title:"Remove link",onClick:h},[...y[4]||(y[4]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 12.5 32.8 0 45.3s32.8 12.5 45.3 0L237.3 256 342.6 150.6z"})],-1)])])):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-link-action-button",title:"Apply link",onClick:p},[...y[5]||(y[5]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})],-1)])])])],36)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),wC={class:"wov-text-color-button"},bC={class:"wov-text-icon-container"},Da=a.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=lt(()=>e.entityIds),r=a.computed(()=>t.color??"#000000"),s=a.computed(()=>({backgroundColor:r.value}));function i(l){o.setColor(rr(l))}return(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Je,{key:0,title:"Text Color"},{button:a.withCtx(()=>[a.createElementVNode("div",wC,[a.createElementVNode("div",bC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createElementVNode("div",{class:"wov-color-underline",style:a.normalizeStyle(s.value)},null,4)]),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(ni,{currentColor:r.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):a.createCommentVNode("",!0)}}),SC={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-start-icon lucide-align-vertical-justify-start"},xC={key:1,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-center-icon lucide-align-vertical-justify-center"},CC={key:2,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-end-icon lucide-align-vertical-justify-end"},Pp=a.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),{state:o}=lt(()=>e.entityIds),r=[k.VerticalAlignment.Top,k.VerticalAlignment.Center,k.VerticalAlignment.Bottom],s=Vt(()=>e.entityIds,k.VerticalAlign),i=a.computed(()=>{let c=null;for(const d of s.value.values()){const u=(d==null?void 0:d.value)??k.VerticalAlignment.Top;if(c===null)c=u;else if(c!==u)return null}return c});function l(){const c=i.value??k.VerticalAlignment.Top,d=r.indexOf(c),u=r[(d+1)%r.length];t(f=>{for(const p of e.entityIds){const h=k.VerticalAlign.write(f,p);h.value=u}})}return(c,d)=>a.unref(o).showTextMenuButtons?(a.openBlock(),a.createBlock(Ln,{key:0,title:"Vertical Align",onClick:l},{default:a.withCtx(()=>[i.value===a.unref(k.VerticalAlignment).Top||i.value===null?(a.openBlock(),a.createElementBlock("svg",SC,[...d[0]||(d[0]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===a.unref(k.VerticalAlignment).Center?(a.openBlock(),a.createElementBlock("svg",xC,[...d[1]||(d[1]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",CC,[...d[2]||(d[2]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),EC={class:"wov-text-group-button"},vC={class:"wov-text-group-dropdown"},TC={class:"wov-text-group-row wov-text-group-row-full"},MC={class:"wov-text-group-row"},AC=a.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(n){const e=n,{state:t}=lt(()=>e.entityIds),o=a.inject("containerRef"),{width:r}=_p(o),s=a.computed(()=>r.value>0&&r.value<600),i=a.ref(new Map);return a.provide(gc,i),(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[s.value?(a.openBlock(),a.createBlock(Je,{key:0,title:"Text Formatting",placement:"top"},{button:a.withCtx(()=>[a.createElementVNode("div",EC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createVNode(Ge,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",vC,[a.createElementVNode("div",TC,[a.createVNode(Ba,{entityIds:n.entityIds},null,8,["entityIds"]),c[1]||(c[1]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(Oa,{entityIds:n.entityIds},null,8,["entityIds"])]),a.createElementVNode("div",MC,[a.createVNode(Na,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(_a,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Ra,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Pa,{entityIds:n.entityIds},null,8,["entityIds"]),c[2]||(c[2]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(Da,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Aa,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Pp,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)])])]),_:1})):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createVNode(Ba,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Oa,{entityIds:n.entityIds},null,8,["entityIds"]),c[3]||(c[3]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Na,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(_a,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Ra,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Pa,{entityIds:n.entityIds},null,8,["entityIds"]),c[4]||(c[4]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Da,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Aa,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Pp,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)],64))],64)):a.createCommentVNode("",!0)}}),Dp=a.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(n){const e=n,t={kind:"none",color:"#f4f4f4",strokeColor:"#a1a1a1",subdivisionStep:5},o=a.computed(()=>({...t,...e.background})),r=_e(k.Camera),s=_e(k.Grid),i=a.inject("containerRef"),l=a.ref({width:0,height:0});let c=null;const d=a.ref(null);let u=null;typeof document<"u"&&(u=document.createElement("canvas"));function f(b,x,S,E){const M=E/2;b.beginPath(),b.arc(x,S,M,0,Math.PI*2),b.fill()}function p(b,x,S){if(!u)return null;const E=S.dotSize??2,M=b*S.subdivisionStep,C=x*S.subdivisionStep;if(M<=0||C<=0)return null;u.width=M,u.height=C;const T=u.getContext("2d");if(!T)return null;if(T.clearRect(0,0,M,C),T.fillStyle=S.strokeColor,S.subdivisionStep===1)f(T,M/2,C/2,E);else for(let v=0;v<S.subdivisionStep;v++)for(let I=0;I<S.subdivisionStep;I++){const B=(v+.5)*(M/S.subdivisionStep),P=(I+.5)*(C/S.subdivisionStep),F=v===0&&I===0?2*E:E;f(T,B,P,F)}return T.createPattern(u,"repeat")}function h(b,x,S,E,M,C){b.lineWidth=C,b.beginPath(),b.moveTo(x,S),b.lineTo(E,M),b.stroke()}function m(b,x,S){if(!u)return null;const E=S.gridSize??1,M=b*S.subdivisionStep,C=x*S.subdivisionStep;if(M<=0||C<=0)return null;u.width=M,u.height=C;const T=u.getContext("2d");if(!T)return null;if(T.clearRect(0,0,M,C),T.strokeStyle=S.strokeColor,S.subdivisionStep===1)h(T,0,0,M,0,E),h(T,0,0,0,C,E);else{const v=M/S.subdivisionStep,I=C/S.subdivisionStep;for(let B=0;B<=S.subdivisionStep;B++){const P=B*v,V=B%S.subdivisionStep===0;h(T,P,0,P,C,V?2*E:E)}for(let B=0;B<=S.subdivisionStep;B++){const P=B*I,V=B%S.subdivisionStep===0;h(T,0,P,M,P,V?2*E:E)}}return T.createPattern(u,"repeat")}function g(b){let x=s.value.colWidth,S=s.value.rowHeight;const E=o.value.subdivisionStep,M=l.value.width,C=l.value.height,T=r.value.left,v=r.value.top,I=T+M/r.value.zoom,B=v+C/r.value.zoom;let P=x*E,V=S*E,F=0,z=0,J=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY;for(;;){P=E*x,V=E*S,F=Math.floor(T/P)*P,z=Math.floor(v/V)*V;const ot=Math.ceil(I/P)*P,he=Math.ceil(B/V)*V;if(j=Math.round((ot-F)/x),J=Math.round((he-z)/S),Math.max(j,J)>125)x*=2,S*=2;else break}const K=x*r.value.zoom,W=S*r.value.zoom,X=Math.max(1,Math.round(K)),re=Math.max(1,Math.round(W)),ie=p(X,re,o.value);if(!ie)return;ie.setTransform(new DOMMatrix().scale(K/X,W/re));const be=(F-T-x/2)*r.value.zoom,se=(z-v-S/2)*r.value.zoom;b.save(),b.translate(be,se),b.fillStyle=ie,b.fillRect(0,0,M+P*r.value.zoom,C+V*r.value.zoom),b.restore()}function y(b){let x=s.value.colWidth,S=s.value.rowHeight;const E=o.value.subdivisionStep,M=l.value.width,C=l.value.height,T=r.value.left,v=r.value.top,I=T+M/r.value.zoom,B=v+C/r.value.zoom;let P=x*E,V=S*E,F=0,z=0,J=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY;for(;;){P=E*x,V=E*S,F=Math.floor(T/P)*P,z=Math.floor(v/V)*V;const ot=Math.ceil(I/P)*P,he=Math.ceil(B/V)*V;if(j=Math.round((ot-F)/x),J=Math.round((he-z)/S),Math.max(j,J)>200)x*=2,S*=2;else break}const K=x*r.value.zoom,W=S*r.value.zoom,X=Math.max(1,Math.round(K)),re=Math.max(1,Math.round(W)),ie=m(X,re,o.value);if(!ie)return;ie.setTransform(new DOMMatrix().scale(K/X,W/re));const be=(F-T)*r.value.zoom,se=(z-v)*r.value.zoom;b.save(),b.translate(be,se),b.fillStyle=ie,b.fillRect(0,0,M+P*r.value.zoom,C+V*r.value.zoom),b.restore()}function w(){const b=d.value;if(!b)return;const x=b.getContext("2d");if(!x)return;const{width:S,height:E}=l.value;S===0||E===0||(b.width=S,b.height=E,x.clearRect(0,0,S,E),x.fillStyle=o.value.color,x.fillRect(0,0,S,E),o.value.kind==="dots"?g(x):o.value.kind==="grid"&&y(x))}return a.watch(()=>[o.value,r.value,s.value,l.value],()=>{w()},{deep:!0}),a.onMounted(()=>{const b=i==null?void 0:i.value;if(b){const x=()=>{l.value={width:b.clientWidth,height:b.clientHeight}};x(),c=new ResizeObserver(x),c.observe(b)}w()}),a.onUnmounted(()=>{c==null||c.disconnect()}),(b,x)=>(a.openBlock(),a.createElementBlock("canvas",{ref_key:"canvasRef",ref:d,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}}),Lp=a.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(n){const e=n,{nextEditorTick:t,getEditor:o}=fe(),{createImageBlock:r}=Jh(),s=a.ref(!1);let i=0;function l(){var S;return((S=o())==null?void 0:S.readonly)===!0}const c=a.inject("containerRef");function d(S){var E;l()||(E=S.dataTransfer)!=null&&E.types.some(M=>M==="Files"||M==="text/uri-list"||M==="text/html")&&(i++,i===1&&(s.value=!0))}function u(){i--,i===0&&(s.value=!1)}function f(){i=0,s.value=!1}a.onMounted(()=>{const S=c==null?void 0:c.value;S&&(S.addEventListener("dragenter",d),S.addEventListener("dragleave",u),S.addEventListener("drop",f))}),a.onUnmounted(()=>{const S=c==null?void 0:c.value;S&&(S.removeEventListener("dragenter",d),S.removeEventListener("dragleave",u),S.removeEventListener("drop",f))});function p(S){S.preventDefault(),S.dataTransfer&&(S.dataTransfer.dropEffect="copy")}function h(S){S.preventDefault()}function m(S){S.preventDefault()}async function g(S){if(S.preventDefault(),l()||!S.dataTransfer)return;const E=S.clientX,M=S.clientY,C=Array.from(S.dataTransfer.files).filter(v=>v.type.startsWith("image/"));if(C.length>0){for(const v of C)await b(v,E,M);return}const T=y(S.dataTransfer);T&&await x(T,E,M)}function y(S){const E=S.getData("text/uri-list");if(E){const v=E.split(`
|
|
107
|
+
`).filter(I=>!I.startsWith("#")).find(I=>w(I));if(v)return v}const M=S.getData("text/html");if(M){const T=M.match(/<img[^>]+src=["']([^"']+)["']/i);if(T!=null&&T[1])return T[1]}const C=S.getData("text/plain");return C&&w(C)?C:null}function w(S){try{const M=new URL(S).pathname.toLowerCase();return/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i.test(M)||S.startsWith("data:image/"),!0}catch{return!1}}async function b(S,E,M){const C=await t(),T=k.Camera.read(C),v=k.Screen.read(C),I=T.left+(E-v.left)/T.zoom,B=T.top+(M-v.top)/T.zoom;await r(S,I,B,{maxSize:e.maxSize})}async function x(S,E,M){try{const C=await fetch(S);if(!C.ok){console.warn("Failed to fetch image from URL:",S);return}const T=await C.blob();if(!T.type.startsWith("image/")){console.warn("URL did not return an image:",S);return}const I=new URL(S).pathname.split("/").pop()||"image",B=new File([T],I,{type:T.type});await b(B,E,M)}catch(C){console.warn("Failed to load image from URL:",S,C)}}return(S,E)=>(a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["wov-image-drop-zone",{"wov-drag-over":s.value}]),onDragover:p,onDragenter:h,onDragleave:m,onDrop:g},null,34))}});function Vp(n,e){if(e.length===0)return new Set;const t=e[0].tag,o=n.blockDefs[t];if(!o)return new Set;const r=new Set(o.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,l=n.blockDefs[i];if(!l){r.clear();break}const c=new Set(l.components.map(d=>d.name));for(const d of r)c.has(d)||r.delete(d)}return r}const $p=a.defineComponent({__name:"FloatingMenuBar",setup(n){const e=a.useSlots(),{reset:t}=$t(),o=a.inject(kc),{selectedIds:r,commonComponents:s}=o,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape","tape"]),l=a.computed(()=>{const d=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&d.push(u)}return d});function c(){t()}return a.onUnmounted(()=>{t()}),(d,u)=>(a.openBlock(),a.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:c},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(l.value,f=>a.renderSlot(d.$slots,`button:${f}`,{key:f,entityIds:a.unref(r)})),128)),a.unref(s).has("color")?a.renderSlot(d.$slots,"button:color",{key:0,entityIds:a.unref(r)},()=>[a.createVNode(Tp,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("shape")?a.renderSlot(d.$slots,"button:shape",{key:1,entityIds:a.unref(r)},()=>[a.createVNode(Ip,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(Np,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(Bp,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("penStroke")?a.renderSlot(d.$slots,"button:penStroke",{key:2,entityIds:a.unref(r)},()=>[a.createVNode(Ap,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("elbowArrow")||a.unref(s).has("arcArrow")?(a.openBlock(),a.createElementBlock(a.Fragment,{key:3},[a.renderSlot(d.$slots,"button:arrowThickness",{entityIds:a.unref(r)},()=>[a.createVNode(Ep,{entityIds:a.unref(r)},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadStart",{entityIds:a.unref(r)},()=>[a.createVNode(Ma,{entityIds:a.unref(r),side:"start"},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadEnd",{entityIds:a.unref(r)},()=>[a.createVNode(Ma,{entityIds:a.unref(r),side:"end"},null,8,["entityIds"])])],64)):a.createCommentVNode("",!0),a.unref(s).has("tape")?a.renderSlot(d.$slots,"button:tape",{key:4,entityIds:a.unref(r)},()=>[a.createVNode(Op,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("text")?a.renderSlot(d.$slots,"button:text",{key:5,entityIds:a.unref(r)},()=>[a.createVNode(AC,{entityIds:a.unref(r),showVerticalAlign:a.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])]):a.createCommentVNode("",!0)],32))}}),NC={class:"wov-floating-menu-inner"},zp=a.defineComponent({__name:"FloatingMenu",setup(n){const e=a.inject(Se),t=Gh([k.Block,k.Selected]),o=_e(k.Camera),r=_e(k.Screen),s=_e(k.SelectionStateSingleton),i=On(),l=a.computed(()=>t.value.map(M=>M.entityId)),c=a.computed(()=>{const M=e==null?void 0:e.getEditor();if(!M||t.value.length===0)return new Set;const C=t.value.map(T=>({tag:T.block.value.tag}));return Vp(M,C)});a.provide(kc,{selectedIds:l,commonComponents:c});const d=[0,0,0,0];function u(...M){let C=1/0,T=1/0,v=-1/0,I=-1/0,B=!1;for(const P of M){if(!P)continue;const V=P.getBoundingClientRect();V.width<=0||(B=!0,C=Math.min(C,V.left),T=Math.min(T,V.top),v=Math.max(v,V.right),I=Math.max(I,V.bottom))}return B?{x:C,y:T,left:C,top:T,right:v,bottom:I,width:v-C,height:I-T,toJSON:()=>({})}:null}const f=a.computed(()=>{if(t.value.length===0)return null;const M=o.value;if(!M)return null;let C=null;const T=e==null?void 0:e.getEditor(),v=T==null?void 0:T._getContext();for(const I of t.value){const B=I.block.value,P=v?k.Block.getWorldPosition(v,I.entityId):B.position;ae.Rect.getAabb(P,B.size,B.rotateZ,d),ae.Aabb.translate(d,[-M.left,-M.top]),ae.Aabb.scale(d,M.zoom),C===null?C=ae.Aabb.clone(d):ae.Aabb.union(C,d)}return C}),p=a.inject("containerRef"),h=a.computed(()=>{const M=p==null?void 0:p.value;if(!M)return null;o.value,i.updateCounter.value;const C=i.blockElement.value,T=i.textElement.value,v=u(C,T);if(v)return{getBoundingClientRect:()=>v};const I=f.value;if(!I)return null;const B=M.getBoundingClientRect();return{getBoundingClientRect(){return{x:B.left+I[0],y:B.top+I[1],width:I[2]-I[0],height:I[3]-I[1],top:B.top+I[1],left:B.left+I[0],right:B.left+I[2],bottom:B.top+I[3]}}}}),m=a.ref(null),g={name:"clampToViewport",fn({y:M,rects:C}){const I=window.innerHeight-C.floating.height-8;return{y:Math.max(8,Math.min(M,I))}}},{floatingStyles:y}=ho(h,m,{placement:"top",middleware:[co(12),fo({fallbackPlacements:["bottom"]}),uo({padding:8}),g]}),w=a.computed(()=>{const M=f.value,C=r.value;return!M||!C?!0:M[2]<0||M[0]>C.width||M[3]<0||M[1]>C.height}),b=[k.SelectionState.Dragging,k.SelectionState.SelectionBoxDragging],x=a.computed(()=>t.value.length>0&&!w.value&&!b.includes(s.value.state)),S=a.ref(!1);let E;return a.watch(x,M=>{clearTimeout(E),M?E=setTimeout(()=>{S.value=!0},40):S.value=!1},{immediate:!0}),(M,C)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-fade"},{default:a.withCtx(()=>[S.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:m,class:"wov-floating-menu",style:a.normalizeStyle(a.unref(y))},[a.createElementVNode("div",NC,[a.renderSlot(M.$slots,"default",{},()=>[a.createVNode($p)])])],4)):a.createCommentVNode("",!0)]),_:3}))}}),IC={key:0,class:"wov-loading-overlay"},BC={class:"wov-loading-spinner"},Fp=a.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(n){const e=a.ref("|"),t=["|","/","-","\\"];let o=null;return a.onMounted(()=>{o=setInterval(()=>{const r=t.indexOf(e.value);e.value=t[(r+1)%t.length]},100)}),a.onUnmounted(()=>{o!==null&&clearInterval(o)}),(r,s)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-loading-fade"},{default:a.withCtx(()=>[n.isLoading?(a.openBlock(),a.createElementBlock("div",IC,[a.createElementVNode("div",BC,a.toDisplayString(e.value),1)])):a.createCommentVNode("",!0)]),_:1}))}}),OC={class:"wov-action-bar"},_C=a.defineComponent({__name:"ActionBar",setup(n){const{getEditor:e}=fe(),t=a.inject(Se),o=a.ref(!1),r=a.ref(!1);if(t){const c=t.registerTickCallback(d=>{const{store:u}=k.getPluginResources(d,so);o.value=u.canUndo(),r.value=u.canRedo()});a.onUnmounted(c)}function s(){const c=e();c==null||c.command(k.Undo)}function i(){const c=e();c==null||c.command(k.Redo)}function l(){const c=e();c==null||c.command(k.RemoveSelected)}return(c,d)=>(a.openBlock(),a.createElementBlock("div",OC,[a.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...d[0]||(d[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-undo-icon lucide-undo"},[a.createElementVNode("path",{d:"M3 7v6h6"}),a.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...d[1]||(d[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-redo-icon lucide-redo"},[a.createElementVNode("path",{d:"M21 7v6h-6"}),a.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:l,"aria-label":"Delete"},[...d[2]||(d[2]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-trash-icon lucide-trash"},[a.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),a.createElementVNode("path",{d:"M3 6h18"}),a.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),nt=a.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},drawSnapshot:{},cursor:{default:"crosshair"}},setup(n){const e=n,t=a.inject(Si);if(!t)throw new Error("ToolbarButton must be used within a Toolbar component");const o=t,r=a.ref(null),{show:s,hide:i}=$t(),l=a.computed(()=>o.activeTool.value===e.name);function c(){o.setTool(e.name,{snapshot:e.placementSnapshot,drawSnapshot:e.drawSnapshot,cursor:e.cursor})}function d(){o.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){o.onToolPointerUp()}function f(){e.tooltip&&r.value&&s(e.tooltip,r.value)}function p(){i()}return(h,m)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:a.normalizeClass(["wov-toolbar-button",{selected:l.value}]),onClick:c,onPointerdown:d,onPointerup:u,onMouseenter:f,onMouseleave:p},[a.renderSlot(h.$slots,"default")],34))}}),RC='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.35 4.75" width="20" height="20"><defs><style>.cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:.25px;}</style></defs><path class="cls-1" d="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z"/></svg>',PC='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.08 4.75" width="24" height="24"><defs><style>.cls-1{fill:#fff;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:.25px;}.cls-2{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:.51px;}</style></defs><path class="cls-1" d="M.89,2.25v.63M.89,2.25V.75c0-.21.17-.38.38-.38s.38.17.38.38M.89,2.25c0-.21-.17-.37-.38-.37s-.38.17-.38.37v.5c0,1.04.86,1.87,1.91,1.87s1.91-.84,1.91-1.87v-1.25c0-.21-.17-.38-.38-.38s-.38.17.38.38M1.66.75v1.38M1.66.75v-.25c0-.21.17-.38.38-.38s.38.17.38.38v.25M2.42.75v1.38M2.42.75c0-.21.17-.38.38-.38s.38.17.38.38v.75M3.19,1.5v.63"/><line class="cls-2" x1="2.8" y1=".77" x2="2.8" y2="2.03"/><line class="cls-2" x1="2.04" y1=".64" x2="2.04" y2="2.02"/><line class="cls-2" x1="1.27" y1=".84" x2="1.27" y2="2.29"/></svg>',DC='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 8v-2a2 2 0 0 1 2 -2h2" /><path d="M4 16v2a2 2 0 0 0 2 2h2" /><path d="M16 4h2a2 2 0 0 1 2 2v2" /><path d="M16 20h2a2 2 0 0 0 2 -2v-2" /><path d="M9 12l6 0" /><path d="M12 9l0 6" /></svg>',cn={Select:"select",Hand:"hand",Crosshair:"crosshair"},Hp={[cn.Select]:{makeSvg:()=>RC,hotspot:[1,0],rotationOffset:0},[cn.Hand]:{makeSvg:()=>PC,hotspot:[12,12],rotationOffset:0},[cn.Crosshair]:{makeSvg:()=>DC,hotspot:[12,12],rotationOffset:0}},LC={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},jp=a.defineComponent({__name:"SelectTool",setup(n){const{nextEditorTick:e}=fe(),{activeTool:t}=zs();return a.watch(t,(o,r)=>{r==="select"&&e(s=>{k.DeselectAll.spawn(s)})}),(o,r)=>(a.openBlock(),a.createBlock(nt,{name:"select",tooltip:"Select",cursor:a.unref(cn).Select},{default:a.withCtx(()=>[(a.openBlock(),a.createElementBlock("svg",LC,[...r[0]||(r[0]=[a.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-width":"0.5",d:"M2.39,2.88C2.38,2.885 2.34,2.9 2.33,2.91C2.32,2.91 2.298,2.939 2.28,2.97L1.51,4.41C1.44,4.54 1.41,4.6 1.37,4.61C1.34,4.62 1.3,4.61 1.27,4.6C1.24,4.58 1.22,4.51 1.18,4.37L0.16,0.41C0.13,0.28 0.11,0.22 0.13,0.18C0.15,0.15 0.17,0.13 0.21,0.12C0.25,0.12 0.31,0.14 0.42,0.2L4.01,2.14C4.14,2.21 4.2,2.24 4.21,2.28C4.22,2.31 4.21,2.35 4.2,2.38C4.18,2.41 4.11,2.43 3.97,2.47L2.39,2.88Z"})],-1)])]))]),_:1},8,["cursor"]))}}),Wp=a.defineComponent({__name:"HandTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(nt,{name:"hand",tooltip:"Hand",cursor:a.unref(cn).Hand},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4.47,11.39v3.18M4.47,11.39V3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92M4.47,11.39c0-1.06-.86-1.87-1.92-1.87s-1.92.86-1.92,1.87v2.53c0,5.25,4.35,9.45,9.65,9.45s9.65-4.24,9.65-9.45v-6.32c0-1.06-.86-1.92-1.92-1.92s-1.92.86-1.92,1.92M8.36,3.81v6.97M8.36,3.81v-1.26c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v1.26M12.2,3.81v6.97M12.2,3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v3.79M16.09,7.6v3.18"})],-1)])]),_:1},8,["cursor"]))}}),Up=a.defineComponent({__name:"StickyNoteTool",setup(n){const e=a.inject(Se),t=a.computed(()=>JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:k.TextAlignment.Center,...e.getDefaults("text")},verticalAlign:{value:k.VerticalAlignment.Center}}));return(o,r)=>(a.openBlock(),a.createBlock(nt,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":t.value,"placement-snapshot":t.value},{default:a.withCtx(()=>[...r[0]||(r[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M4 4h12v12H4z"}),a.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Kp=a.defineComponent({__name:"ShapeTool",setup(n){const e=a.inject(Se),t=a.computed(()=>JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:k.StrokeKind.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:k.TextAlignment.Center,...e.getDefaults("text")},verticalAlign:{value:k.VerticalAlignment.Center}}));return(o,r)=>(a.openBlock(),a.createBlock(nt,{name:"shape",tooltip:"Shape","drag-out-snapshot":t.value,"draw-snapshot":t.value},{default:a.withCtx(()=>[...r[0]||(r[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","draw-snapshot"]))}}),qp=a.defineComponent({__name:"EraserTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(nt,{name:"eraser",tooltip:"Eraser"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[a.createElementVNode("path",{d:"M210.5 480L333.5 480L398.8 414.7L225.3 241.2L98.6 367.9L210.6 479.9zM256 544L210.5 544C193.5 544 177.2 537.3 165.2 525.3L49 409C38.1 398.1 32 383.4 32 368C32 352.6 38.1 337.9 49 327L295 81C305.9 70.1 320.6 64 336 64C351.4 64 366.1 70.1 377 81L559 263C569.9 273.9 576 288.6 576 304C576 319.4 569.9 334.1 559 345L424 480L544 480C561.7 480 576 494.3 576 512C576 529.7 561.7 544 544 544L256 544z"})],-1)])]),_:1}))}}),Jp=a.defineComponent({__name:"PenTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(nt,{name:"pen",tooltip:"Pen"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M13.586 3.586a2 2 0 1 1 2.828 2.828l-8.793 8.793-3.536.707.707-3.536 8.794-8.792Z","stroke-linecap":"round","stroke-linejoin":"round"}),a.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),Gp=a.defineComponent({__name:"TextTool",setup(n){const e=a.inject(Se),t=a.computed(()=>JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24,...e.getDefaults("text")}})),o=a.computed(()=>JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24,...e.getDefaults("text")}}));return(r,s)=>(a.openBlock(),a.createBlock(nt,{name:"text",tooltip:"Text","drag-out-snapshot":o.value,"placement-snapshot":t.value},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-type-icon lucide-type"},[a.createElementVNode("path",{d:"M12 4v16"}),a.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),a.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Yp=a.defineComponent({__name:"ElbowArrowTool",setup(n){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:te.ArrowHeadKind.None,endArrowHead:te.ArrowHeadKind.V},connector:{}});return(t,o)=>(a.openBlock(),a.createBlock(nt,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),Xp=a.defineComponent({__name:"ImageTool",setup(n){const{nextEditorTick:e}=fe(),{show:t,hide:o}=$t(),{setTool:r}=zs(),{createImageBlock:s}=Jh(),i=a.ref(null),l=a.ref(null);function c(){var p;(p=l.value)==null||p.click()}async function d(p){var S;const h=p.target,m=(S=h.files)==null?void 0:S[0];if(!m)return;if(h.value="",!m.type.startsWith("image/")){console.warn("Selected file is not an image");return}const g=await e(),y=k.Camera.read(g),w=k.Screen.read(g),b=y.left+w.width/y.zoom/2,x=y.top+w.height/y.zoom/2;await s(m,b,x),r("select",{cursor:cn.Select})}function u(){i.value&&t("Image",i.value)}function f(){o()}return(p,h)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:c,onMouseenter:u,onMouseleave:f},[h[0]||(h[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),a.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),a.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),a.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",accept:"image/*",style:{display:"none"},onChange:d},null,544)],544))}}),VC={class:"wov-embed-provider-grid"},$C=["onClick"],zC={class:"wov-embed-provider-icon"},FC={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},HC={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},jC={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},WC={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},UC={key:4,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},KC={key:5,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},qC={key:6,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},JC={key:7,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},GC={class:"wov-embed-provider-label"},YC={class:"wov-embed-panel-header"},XC={class:"wov-embed-url-form"},QC=["placeholder"],ZC={key:0,class:"wov-embed-url-error"},Qp=a.defineComponent({__name:"EmbedTool",setup(n){const{nextEditorTick:e}=fe(),{show:t,hide:o}=$t(),{setTool:r}=zs(),s=a.ref(null),i=a.ref(null),l=a.ref(null),c=a.ref(!1),d=a.ref(null),u=a.ref(""),f=a.ref(""),p=a.inject("containerRef"),{floatingStyles:h}=ho(s,i,{placement:"top",middleware:[co(16),fo(),uo({padding:8})],whileElementsMounted:ti}),m=[{value:k.EmbedProvider.Youtube,label:"YouTube",icon:"youtube"},{value:k.EmbedProvider.Spotify,label:"Spotify",icon:"spotify"},{value:k.EmbedProvider.GoogleMaps,label:"Google Maps",icon:"map"},{value:k.EmbedProvider.GoogleCalendar,label:"Google Calendar",icon:"calendar"},{value:k.EmbedProvider.GoogleSlides,label:"Google Slides",icon:"slides"},{value:k.EmbedProvider.Figma,label:"Figma",icon:"figma"},{value:k.EmbedProvider.GithubGist,label:"GitHub Gist",icon:"gist"},{value:k.EmbedProvider.Tldraw,label:"tldraw",icon:"tldraw"}],g=a.computed(()=>{if(!d.value)return"Paste a URL...";switch(d.value){case k.EmbedProvider.Youtube:return"https://www.youtube.com/watch?v=...";case k.EmbedProvider.Spotify:return"https://open.spotify.com/track/...";case k.EmbedProvider.GoogleMaps:return"https://www.google.com/maps/...";case k.EmbedProvider.GoogleCalendar:return"https://calendar.google.com/...";case k.EmbedProvider.GoogleSlides:return"https://docs.google.com/presentation/...";case k.EmbedProvider.Figma:return"https://www.figma.com/...";case k.EmbedProvider.GithubGist:return"https://gist.github.com/...";case k.EmbedProvider.Tldraw:return"https://www.tldraw.com/...";default:return"Paste a URL..."}});function y(){c.value=!c.value,d.value=null,u.value="",f.value=""}function w(T){d.value=T,u.value="",f.value="",a.nextTick(()=>{var v;(v=l.value)==null||v.focus()})}function b(){d.value=null,u.value="",f.value=""}async function x(){const T=u.value.trim();if(!T){f.value="Please enter a URL";return}try{new URL(T)}catch{f.value="Please enter a valid URL";return}const v=d.value??k.detectEmbedProvider(T),I=k.validateEmbedUrl(T,v);if(I){f.value=I;return}const B=k.resolveEmbedUrl(T,v);let P=480,V=320;switch(v){case k.EmbedProvider.Youtube:P=560,V=315;break;case k.EmbedProvider.Spotify:P=352,V=152;break;case k.EmbedProvider.GoogleMaps:P=600,V=450;break;case k.EmbedProvider.GoogleCalendar:P=600,V=500;break;case k.EmbedProvider.GoogleSlides:P=640,V=389;break;case k.EmbedProvider.Figma:P=600,V=400;break;case k.EmbedProvider.GithubGist:P=500,V=300;break;case k.EmbedProvider.Tldraw:P=600,V=400;break}const F=await e(),z=k.Camera.read(F),J=k.Screen.read(F),j=z.left+J.width/z.zoom/2,K=z.top+J.height/z.zoom/2,W=k.Grid.read(F);W.enabled&&(P=Math.max(W.colWidth,Math.round(P/W.colWidth)*W.colWidth),V=Math.max(W.rowHeight,Math.round(V/W.rowHeight)*W.rowHeight));const X=k.createEntity(F);k.addComponent(F,X,k.Block);const re=k.Block.write(F,X);re.tag="embed",re.position[0]=j-P/2,re.position[1]=K-V/2,re.size[0]=P,re.size[1]=V,k.Grid.snapPosition(F,re.position),k.addComponent(F,X,k.Embed);const ie=k.Embed.write(F,X);ie.url=T,ie.embedUrl=B,ie.provider=v,k.addComponent(F,X,Ve.Synced,{id:crypto.randomUUID()}),c.value=!1,d.value=null,u.value="",r("select",{cursor:cn.Select})}function S(T){T.key==="Enter"?(T.preventDefault(),x()):T.key==="Escape"&&(T.preventDefault(),d.value?b():c.value=!1)}function E(T){const v=T.target;s.value&&!s.value.contains(v)&&i.value&&!i.value.contains(v)&&(c.value=!1)}a.watch(c,T=>{T?document.addEventListener("click",E,!0):document.removeEventListener("click",E,!0)});function M(){s.value&&t("Embed",s.value)}function C(){o()}return(T,v)=>{var I;return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("button",{ref_key:"buttonRef",ref:s,class:a.normalizeClass(["wov-toolbar-button",{"menu-open":c.value}]),onClick:y,onMouseenter:M,onMouseleave:C},[...v[1]||(v[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.createElementVNode("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)])],34),a.unref(p)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(p)},[c.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"wov-embed-panel",style:a.normalizeStyle(a.unref(h))},[d.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createElementVNode("div",YC,[a.createElementVNode("button",{class:"wov-embed-back-button",onClick:b},[...v[11]||(v[11]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("polyline",{points:"15 18 9 12 15 6"})],-1)])]),a.createElementVNode("span",null,a.toDisplayString((I=m.find(B=>B.value===d.value))==null?void 0:I.label),1)]),a.createElementVNode("div",XC,[a.withDirectives(a.createElementVNode("input",{ref_key:"urlInputRef",ref:l,"onUpdate:modelValue":v[0]||(v[0]=B=>u.value=B),type:"text",placeholder:g.value,class:"wov-embed-url-input",onKeydown:S},null,40,QC),[[a.vModelText,u.value]]),f.value?(a.openBlock(),a.createElementBlock("div",ZC,a.toDisplayString(f.value),1)):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-embed-submit-button",onClick:x}," Embed ")])],64)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[v[10]||(v[10]=a.createElementVNode("div",{class:"wov-embed-panel-header"},"Add embed",-1)),a.createElementVNode("div",VC,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(m,B=>a.createElementVNode("button",{key:B.value,class:"wov-embed-provider-button",onClick:P=>w(B.value)},[a.createElementVNode("span",zC,[B.icon==="youtube"?(a.openBlock(),a.createElementBlock("svg",FC,[...v[2]||(v[2]=[a.createElementVNode("path",{d:"M2.5 17V7a2 2 0 0 1 2-2h15a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2z"},null,-1),a.createElementVNode("path",{d:"m10 15 5-3-5-3z"},null,-1)])])):B.icon==="spotify"?(a.openBlock(),a.createElementBlock("svg",HC,[...v[3]||(v[3]=[a.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),a.createElementVNode("path",{d:"M8 11.973c2.5-1.473 5.5-.973 7.5.527"},null,-1),a.createElementVNode("path",{d:"M9 15c1.5-1 4-.5 5.5.5"},null,-1),a.createElementVNode("path",{d:"M7 9c3-2 7-1 10 1"},null,-1)])])):B.icon==="map"?(a.openBlock(),a.createElementBlock("svg",jC,[...v[4]||(v[4]=[a.createElementVNode("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"},null,-1),a.createElementVNode("circle",{cx:"12",cy:"9",r:"2.5"},null,-1)])])):B.icon==="calendar"?(a.openBlock(),a.createElementBlock("svg",WC,[...v[5]||(v[5]=[a.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"16",y1:"2",x2:"16",y2:"6"},null,-1),a.createElementVNode("line",{x1:"8",y1:"2",x2:"8",y2:"6"},null,-1),a.createElementVNode("line",{x1:"3",y1:"10",x2:"21",y2:"10"},null,-1)])])):B.icon==="slides"?(a.openBlock(),a.createElementBlock("svg",UC,[...v[6]||(v[6]=[a.createElementVNode("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"8",y1:"21",x2:"16",y2:"21"},null,-1),a.createElementVNode("line",{x1:"12",y1:"17",x2:"12",y2:"21"},null,-1)])])):B.icon==="figma"?(a.openBlock(),a.createElementBlock("svg",KC,[...v[7]||(v[7]=[a.createElementVNode("path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z"},null,-1),a.createElementVNode("path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z"},null,-1),a.createElementVNode("path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z"},null,-1)])])):B.icon==="gist"?(a.openBlock(),a.createElementBlock("svg",qC,[...v[8]||(v[8]=[a.createElementVNode("polyline",{points:"16 18 22 12 16 6"},null,-1),a.createElementVNode("polyline",{points:"8 6 2 12 8 18"},null,-1)])])):B.icon==="tldraw"?(a.openBlock(),a.createElementBlock("svg",JC,[...v[9]||(v[9]=[a.createElementVNode("path",{fill:"currentColor",d:"M21.474 0H2.526C1.131 0 0 1.18 0 2.637v18.726C0 22.819 1.131 24 2.526 24h18.948C22.869 24 24 22.82 24 21.363V2.637C24 1.181 22.869 0 21.474 0m-11.01 5.388q.595-.607 1.474-.607q.854 0 1.448.607q.595.606.595 1.476c0 .87-.198 1.072-.595 1.476a1.95 1.95 0 0 1-1.448.607q-.879 0-1.474-.607q-.594-.606-.594-1.476c0-.87.198-1.072.594-1.476m3.13 11.49a4.9 4.9 0 0 1-2.018 2.136q-.724.422-1.19-.026q-.438-.422.26-1.002q.387-.29.646-.738q.258-.449.336-.923q.026-.21-.181-.21q-.517-.027-1.06-.581t-.543-1.37q0-.87.594-1.477a2.02 2.02 0 0 1 1.5-.633q.828 0 1.448.633q.62.605.724 1.37q.207 1.424-.517 2.822z"},null,-1)])])):a.createCommentVNode("",!0)]),a.createElementVNode("span",GC,a.toDisplayString(B.label),1)],8,$C)),64))])],64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64)}}}),eE="https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media",Zp=a.defineComponent({__name:"TapeTool",setup(n){const e=JSON.stringify({block:{tag:"tape",size:[200,30]},tape:{thickness:30},asset:{identifier:eE,uploadState:"complete"}});return(t,o)=>(a.openBlock(),a.createBlock(nt,{name:"tape",tooltip:"Tape","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"1",y:"7",width:"18",height:"6",rx:"1",fill:"none",stroke:"currentColor"}),a.createElementVNode("line",{x1:"5",y1:"7",x2:"3",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"9",y1:"7",x2:"7",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"13",y1:"7",x2:"11",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"17",y1:"7",x2:"15",y2:"13",opacity:"0.4"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),tE=a.defineComponent({__name:"FrameTool",setup(n){const e=a.computed(()=>JSON.stringify({block:{tag:"frame",size:[400,300]},frame:{label:"Frame"}}));return(t,o)=>(a.openBlock(),a.createBlock(nt,{name:"frame",tooltip:"Frame","drag-out-snapshot":e.value,"draw-snapshot":e.value},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),a.createElementVNode("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),a.createElementVNode("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),a.createElementVNode("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})],-1)])]),_:1},8,["drag-out-snapshot","draw-snapshot"]))}}),nE={class:"wov-toolbar-container"},em=a.defineComponent({__name:"Toolbar",setup(n){const e=a.useSlots(),{reset:t}=$t(),{nextEditorTick:o}=fe(),r=a.ref(null),s=a.ref(null),i=_e(k.Controls),l=a.computed(()=>i.value.activeToolName),c=[jp,Wp,Gp,Xp,Qp,Kp,tE,Yp,Up,Zp,Jp,qp],d=a.inject("containerRef"),u=a.ref(null),f=a.ref(!1),p=a.ref(null),h=a.ref(null),m=a.ref(1/0),g=a.ref(0),y=a.ref([]),w=a.ref(8),b=a.ref(48),{width:x}=_p(d);function S(){return p.value?Array.from(p.value.children).filter(K=>!K.classList.contains("wov-overflow-button")&&!K.classList.contains("wov-menu-tooltip")):[]}function E(){var re;const K=S();if(K.length===0)return;g.value=K.length;const W=getComputedStyle(p.value);w.value=parseFloat(W.gap)||8;const X=((re=h.value)==null?void 0:re.offsetWidth)||40;b.value=X+w.value,y.value=K.map(ie=>ie.offsetWidth)}function M(){if(y.value.length===0)return;const X=x.value-40-20,re=w.value,ie=b.value;let be=0,se=0;for(let ot=0;ot<y.value.length;ot++){const he=y.value[ot],hn=be>0?he+re:he,Et=y.value.length-ot-1>0?ie:0;if(be+hn+Et<=X)be+=hn,se++;else break}m.value=Math.max(1,se)}a.watch(x,()=>{y.value.length>0&&M()}),a.onMounted(()=>{a.nextTick(()=>{E(),M()})});const C=a.computed(()=>m.value<g.value);a.watchEffect(()=>{S().forEach((W,X)=>{W.style.display=X<m.value?"":"none"})}),a.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((W,X)=>{W.style.display=X>=m.value?"":"none"})});const{floatingStyles:T}=ho(h,u,{placement:"top",middleware:[co(16),fo(),uo({padding:8})],whileElementsMounted:ti});function v(){f.value=!f.value}function I(){f.value=!1}function B(K){const W=K.target;h.value&&!h.value.contains(W)&&u.value&&!u.value.contains(W)&&I()}a.watch(f,K=>{K?document.addEventListener("click",B,!0):document.removeEventListener("click",B,!0)}),a.watch(C,K=>{K||I()});function P(K,W){const{snapshot:X,drawSnapshot:re,cursor:ie}=W??{};s.value=X??re??null,o(be=>{const se=k.Controls.write(be);se.activeToolName=K,re?(se.leftMouseTool="draw",se.heldSnapshot=re):(se.leftMouseTool=K,se.heldSnapshot=X??""),ie&&k.Cursor.setCursor(be,ie)})}function V(K){o(W=>{const X=k.Controls.write(W);X.leftMouseTool="drag-out",X.heldSnapshot=K})}function F(K,W){r.value=K,s.value=W??null}function z(){r.value=null,s.value=null}function J(){t(),r.value&&s.value&&V(s.value),r.value=null,s.value=null}const j={activeTool:l,heldTool:r,setTool:P,dragOutTool:V,onToolPointerDown:F,onToolPointerUp:z};return a.provide(Si,j),(K,W)=>(a.openBlock(),a.createElementBlock("div",nE,[a.createVNode(_C),a.createElementVNode("div",{ref_key:"toolsContainerRef",ref:p,class:"wov-toolbar",onMouseleave:J},[a.unref(e).default?a.renderSlot(K.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(X,re)=>a.createVNode(a.resolveDynamicComponent(X),{key:re})),64)),C.value?(a.openBlock(),a.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:h,class:a.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:v},[...W[0]||(W[0]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[a.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):a.createCommentVNode("",!0)],544),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[f.value&&C.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:a.normalizeStyle(a.unref(T))},[a.unref(e).default?a.renderSlot(K.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(X,re)=>a.createVNode(a.resolveDynamicComponent(X),{key:re})),64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)]))}}),oE=a.defineComponent({__name:"ArcArrowTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(nt,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),rE={class:"wov-user-presence-avatars"},sE=["src","alt"],iE={class:"wov-user-presence-list"},lE=["src","alt"],aE={class:"wov-user-presence-name"},cE=4,tm=a.defineComponent({__name:"UserPresence",props:{users:{}},setup(n){const e=n,t=a.ref(!1),o=a.ref(null);nC(o,()=>{t.value=!1});function r(l){if(!l)return"?";const c=l.trim().split(/\s+/);return c.length>=2?(c[0][0]+c[1][0]).toUpperCase():l.slice(0,2).toUpperCase()}const s=a.computed(()=>e.users.map(l=>({sessionId:l.sessionId,name:l.name,color:l.color,avatar:l.avatar,initials:r(l.name)}))),i=a.computed(()=>s.value.slice(0,cE));return(l,c)=>n.users.length>1?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"containerRef",ref:o,class:"wov-user-presence"},[a.createElementVNode("button",{class:a.normalizeClass(["wov-user-presence-trigger",{"is-open":t.value}]),onClick:c[0]||(c[0]=d=>t.value=!t.value)},[a.createElementVNode("div",rE,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-avatar",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,sE)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4))),128))])],2),t.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:c[1]||(c[1]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",iE,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-presence-item"},[a.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,lE)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4),a.createElementVNode("span",aE,a.toDisplayString(d.name),1)]))),128))])],32)):a.createCommentVNode("",!0)],512)):a.createCommentVNode("",!0)}}),La=(n,e)=>e.some(t=>n instanceof t);let nm,om;function dE(){return nm||(nm=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function uE(){return om||(om=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Va=new WeakMap,$a=new WeakMap,ii=new WeakMap;function fE(n){const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("success",s),n.removeEventListener("error",i)},s=()=>{t(Vn(n.result)),r()},i=()=>{o(n.error),r()};n.addEventListener("success",s),n.addEventListener("error",i)});return ii.set(e,n),e}function hE(n){if(Va.has(n))return;const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",i),n.removeEventListener("abort",i)},s=()=>{t(),r()},i=()=>{o(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",s),n.addEventListener("error",i),n.addEventListener("abort",i)});Va.set(n,e)}let za={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Va.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Vn(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function rm(n){za=n(za)}function pE(n){return uE().includes(n)?function(...e){return n.apply(Fa(this),e),Vn(this.request)}:function(...e){return Vn(n.apply(Fa(this),e))}}function mE(n){return typeof n=="function"?pE(n):(n instanceof IDBTransaction&&hE(n),La(n,dE())?new Proxy(n,za):n)}function Vn(n){if(n instanceof IDBRequest)return fE(n);if($a.has(n))return $a.get(n);const e=mE(n);return e!==n&&($a.set(n,e),ii.set(e,n)),e}const Fa=n=>ii.get(n);function gE(n,e,{blocked:t,upgrade:o,blocking:r,terminated:s}={}){const i=indexedDB.open(n,e),l=Vn(i);return o&&i.addEventListener("upgradeneeded",c=>{o(Vn(i.result),c.oldVersion,c.newVersion,Vn(i.transaction),c)}),t&&i.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),l.then(c=>{s&&c.addEventListener("close",()=>s()),r&&c.addEventListener("versionchange",d=>r(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const yE=["get","getKey","getAll","getAllKeys","count"],kE=["put","add","delete","clear"],Ha=new Map;function sm(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Ha.get(e))return Ha.get(e);const t=e.replace(/FromIndex$/,""),o=e!==t,r=kE.includes(t);if(!(t in(o?IDBIndex:IDBObjectStore).prototype)||!(r||yE.includes(t)))return;const s=async function(i,...l){const c=this.transaction(i,r?"readwrite":"readonly");let d=c.store;return o&&(d=d.index(l.shift())),(await Promise.all([d[t](...l),r&&c.done]))[0]};return Ha.set(e,s),s}rm(n=>({...n,get:(e,t,o)=>sm(e,t)||n.get(e,t,o),has:(e,t)=>!!sm(e,t)||n.has(e,t)}));const wE=["continue","continuePrimaryKey","advance"],im={},ja=new WeakMap,lm=new WeakMap,bE={get(n,e){if(!wE.includes(e))return n[e];let t=im[e];return t||(t=im[e]=function(...o){ja.set(this,lm.get(this)[e](...o))}),t}};async function*SE(...n){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...n)),!e)return;e=e;const t=new Proxy(e,bE);for(lm.set(t,e),ii.set(t,Fa(e));e;)yield t,e=await(ja.get(t)||e.continue()),ja.delete(t)}function am(n,e){return e===Symbol.asyncIterator&&La(n,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&La(n,[IDBIndex,IDBObjectStore])}rm(n=>({...n,get(e,t,o){return am(e,t)?SE:n.get(e,t,o)},has(e,t){return am(e,t)||n.has(e,t)}}));async function Wa(n,e){const t=await gE(n,1,{upgrade(o){o.objectStoreNames.contains(e)||o.createObjectStore(e)}});return new xE(t,e)}var xE=class{constructor(n,e){this.db=n,this.storeName=e}async get(n){return this.db.get(this.storeName,n)}async put(n,e){await this.db.put(this.storeName,e,n)}async delete(n){await this.db.delete(this.storeName,n)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),t=await e.getAllKeys(),o=await e.getAll(),r=[];for(let s=0;s<t.length;s++)r.push([t[s],o[s]]);return r}async clear(){const n=this.db.transaction(this.storeName,"readwrite");n.objectStore(this.storeName).clear(),await n.done}close(){this.db.close()}},CE=class{constructor(n){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.startListeners=new Set,this.completeListeners=new Set,this.errorListeners=new Set,this.provider=n.provider,this.documentId=n.documentId,this.maxRetries=n.provider.maxRetries??3,this.retryDelay=n.provider.retryDelay??5e3}onUploadStart(n){return this.startListeners.add(n),()=>{this.startListeners.delete(n)}}onUploadComplete(n){return this.completeListeners.add(n),()=>{this.completeListeners.delete(n)}}onUploadError(n){return this.errorListeners.add(n),()=>{this.errorListeners.delete(n)}}async init(){const n=`wovencanvas-assets-${this.documentId}`,[e,t]=await Promise.all([Wa(`${n}-jobs`,"jobs"),Wa(`${n}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=t}async upload(n,e,t){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const o=URL.createObjectURL(e);this.blobUrls.set(n,o),await this.binariesStore.put(n,e);const r={identifier:n,metadata:t,createdAt:Date.now(),retryCount:0};return await this.jobsStore.put(n,r),new Promise((s,i)=>{this.uploadPromises.set(n,{resolve:s,reject:i}),this.startUpload(n)})}async getDisplayUrl(n){if(!n)return null;const e=this.blobUrls.get(n);if(e)return e;try{return await this.provider.resolveUrl(n)}catch(t){return console.error(`Failed to resolve URL for ${n}:`,t),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const n=await this.jobsStore.getAllEntries();for(const[e]of n){const t=await this.binariesStore.get(e);if(t){const o=URL.createObjectURL(t);this.blobUrls.set(e,o)}this.startUpload(e)}}hasPendingUpload(n){return this.blobUrls.has(n)}isUploading(n){return this.uploading.has(n)}async cancelUpload(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.reject(new Error("Upload cancelled")),this.uploadPromises.delete(n))}close(){var n,e;for(const t of this.blobUrls.values())URL.revokeObjectURL(t);this.blobUrls.clear(),(n=this.jobsStore)==null||n.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(n){if(!this.jobsStore||!this.binariesStore||this.uploading.has(n))return;this.uploading.add(n);const e=await this.jobsStore.get(n),t=await this.binariesStore.get(n);if(!e||!t){this.uploading.delete(n);return}for(const o of this.startListeners)o(n);try{await this.provider.upload(t,n,e.metadata),await this.handleUploadSuccess(n)}catch(o){await this.handleUploadError(n,e,o)}}async handleUploadSuccess(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);for(const o of this.completeListeners)o(n);const t=this.uploadPromises.get(n);t&&(t.resolve(),this.uploadPromises.delete(n))}async handleUploadError(n,e,t){if(!this.jobsStore)return;const o=t instanceof Error?t.message:"Unknown error";if(console.error(`Upload failed for ${n}:`,o),this.uploading.delete(n),e.retryCount<this.maxRetries){const r={...e,retryCount:e.retryCount+1};await this.jobsStore.put(n,r),setTimeout(()=>{this.startUpload(n)},this.retryDelay*2**e.retryCount)}else{const r=t instanceof Error?t:new Error(o);for(const i of this.errorListeners)i(n,r);const s=this.uploadPromises.get(n);s&&(s.reject(r),this.uploadPromises.delete(n))}}},EE="wovencanvas-assets",vE="blobs",TE=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(n,e,t){return await(await this.getStore()).put(e,{blob:n,metadata:t}),{}}async resolveUrl(n){if(n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/"))return n;const t=await(await this.getStore()).get(n);if(!t)throw new Error(`Asset not found: ${n}`);return URL.createObjectURL(t.blob)}async delete(n){await(await this.getStore()).delete(n)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=Wa(EE,vE).then(n=>(this.store=n,n))),this.initPromise)}};const ME={class:"wov-selection-box"},AE=a.defineComponent({__name:"SelectionBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",ME))}}),NE={class:"wov-transform-box"},IE=a.defineComponent({__name:"TransformBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",NE))}}),BE={},OE={class:"wov-transform-handle"};function _E(n,e){return a.openBlock(),a.createElementBlock("div",OE)}const RE=pn(BE,[["render",_E]]),PE=a.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=me(e.entityId,k.Color),o=me(e.entityId,k.VerticalAlign),r=a.ref(null),s={[k.VerticalAlignment.Top]:"flex-start",[k.VerticalAlignment.Center]:"center",[k.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>{var c;return{backgroundColor:t.value?`rgb(${t.value.red}, ${t.value.green}, ${t.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((c=o.value)==null?void 0:c.value)??k.VerticalAlignment.Top]}}),{handleEditEnd:l}=ya({blockData:e,containerRef:r,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(c,d)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-sticky-note",style:a.normalizeStyle(i.value)},[a.createVNode(js,a.mergeProps(e,{"block-element":r.value,onEditEnd:a.unref(l)}),null,16,["block-element","onEditEnd"])],4))}}),DE=a.defineComponent({__name:"FrameBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,{nextEditorTick:t}=fe(),o=me(e.entityId,k.Frame),r=me(e.entityId,k.FrameDropTarget),s=a.computed(()=>r.value!==null),i=a.computed(()=>{var f;return((f=o.value)==null?void 0:f.label)??"Frame"}),l=a.computed(()=>{const[f,p]=e.block.flip;if(!(!f&&!p))return{transform:`scale(${f?-1:1}, ${p?-1:1})`}}),c=a.ref(null);function d(){var p,h;const f=((h=(p=c.value)==null?void 0:p.textContent)==null?void 0:h.trim())||"Frame";f!==i.value&&t(m=>{const g=k.Frame.write(m,e.entityId);g.label=f})}function u(f){var p;(f.key==="Enter"||f.key==="Escape")&&(f.preventDefault(),(p=c.value)==null||p.blur()),f.stopPropagation()}return(f,p)=>(a.openBlock(),a.createElementBlock("div",{class:"wov-frame-block",style:a.normalizeStyle(l.value)},[a.createElementVNode("div",{class:a.normalizeClass(["wov-frame-border",{"wov-frame-border--hovered":e.hovered,"wov-frame-border--selected":e.selected,"wov-frame-border--drop-target":s.value}])},null,2),a.createElementVNode("div",{ref_key:"labelRef",ref:c,class:"wov-frame-label",contenteditable:"true",onBlur:d,onKeydown:u},a.toDisplayString(i.value),545)],4))}}),li=Ve.defineCanvasSingleton({name:"blockPlacementState"},{editedCheckpoint:k.field.string().default("").max(36)}),LE=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),fr=Ve.defineCanvasSingleton({name:"doubleClickState"},{snapshot:k.field.string().max(1024).default(LE),lastClickTime:k.field.float64().default(0),lastClickWorldX:k.field.float64().default(0),lastClickWorldY:k.field.float64().default(0)}),ut={Idle:"idle",Pointing:"pointing",Drawing:"drawing"},cm=k.defineEditorState("placementDrawState",{state:k.field.string().max(16).default(ut.Idle),activeEntity:k.field.ref(),pointingStartWorld:k.field.tuple(k.field.float64(),2).default([0,0])}),dm=k.defineQuery(n=>n.with(k.Edited));function um(n,e,t,o,r){const s=or(n,e,t),i=k.findFrameAtPoint(n,t,s);if(i!==null){const p=k.Block.getWorldPosition(n,s),h=k.Block.write(n,s);h.parentId=i,k.Block.setWorldPosition(n,s,p)}const{sessionId:l}=k.getResources(n);k.addComponent(n,s,k.Held,{sessionId:l});const c=k.Block.getWorldPosition(n,s);if(k.canBlockEdit(n,e.block.tag)&&(k.addComponent(n,s,k.EditAfterPlacing,{}),r==="placement")){const{store:p}=k.getPluginResources(n,so),h=p.createCheckpoint();if(h){const m=li.write(n);m.editedCheckpoint=h}}const d=k.SelectionStateSingleton.write(n);d.state=r==="dragOut"?k.SelectionState.Dragging:k.SelectionState.Pointing,d.dragStart=t,d.draggedEntity=s,d.draggedEntityStart=c,d.pointingStartClient=o,d.pointingStartWorld=t,d.isCloning=!1;const u=k.Controls.write(n);u.leftMouseTool="select",u.activeToolName="select",u.heldSnapshot="";const f=k.Cursor.write(n);f.cursorKind="select",f.rotation=0}function VE(n){const e=li.read(n);if(e.editedCheckpoint){const t=e.editedCheckpoint;li.write(n).editedCheckpoint="";const{store:o}=k.getPluginResources(n,so);o.onSettled(()=>o.squashToCheckpoint(t),{frames:5})}}const $E=k.defineEditorSystem({phase:"capture"},n=>{if(k.isReadonly(n))return;dm.removed(n).length>0&&dm.current(n).length===0&&VE(n);const e=k.Controls.read(n);if(!e.heldSnapshot||e.leftMouseTool==="draw")return;const t=k.getPointerInput(n,[k.PointerButton.Left]);if(t.length===0)return;const o=ca(e.heldSnapshot);if(!o)return;if(e.leftMouseTool==="drag-out"){const s=t.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;um(n,o,s.worldPosition,s.screenPosition,"dragOut")}else{const s=t.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;um(n,o,s.worldPosition,s.screenPosition,"placement")}}),zE=400,FE=10,HE=k.defineEditorSystem({phase:"capture"},n=>{var f,p;if(k.isReadonly(n))return;const e=fr.read(n);if(!e.snapshot)return;const t=k.Controls.read(n);if(t.leftMouseTool!=="select"||t.heldSnapshot)return;const o=k.getPointerInput(n,[k.PointerButton.Left]);if(o.length===0)return;const r=o.find(h=>h.type==="click"&&!h.obscured);if(!r||r.intersects.some(h=>!k.hasComponent(n,h,k.Frame)))return;const i=performance.now(),l=i-e.lastClickTime,c=r.worldPosition[0]-e.lastClickWorldX,d=r.worldPosition[1]-e.lastClickWorldY,u=Math.sqrt(c*c+d*d);if(l<zE&&u<FE){let h;try{h=JSON.parse(e.snapshot)}catch{return}if(!((f=h.block)!=null&&f.tag))return;const{editor:m}=k.getResources(n);if(!(h.block.tag in m.blockDefs))return;const g=or(n,h,r.worldPosition),y=k.findFrameAtPoint(n,r.worldPosition,g);if(y!==null){const b=k.Block.getWorldPosition(n,g),x=k.Block.write(n,g);x.parentId=y,k.Block.setWorldPosition(n,g,b)}if(k.hasComponent(n,g,k.Text)&&!k.Text.read(n,g).fontFamily){const x=(p=m.fonts[0])==null?void 0:p.name;x&&(k.Text.write(n,g).fontFamily=x)}k.addComponent(n,g,k.Selected,{}),k.canBlockEdit(n,h.block.tag)&&k.addComponent(n,g,k.EditAfterPlacing,{});const w=fr.write(n);w.lastClickTime=0,w.lastClickWorldX=0,w.lastClickWorldY=0}else{const h=fr.write(n);h.lastClickTime=i,h.lastClickWorldX=r.worldPosition[0],h.lastClickWorldY=r.worldPosition[1]}});function jE(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function WE(){const n=jE();if(n.__xstate__)return n.__xstate__}const UE=n=>{if(typeof window>"u")return;const e=WE();e&&e.register(n)};class fm{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){const t={value:e,next:null};if(this._current){this._last.next=t,this._last=t;return}this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){const e=this._current;this._process(e.value),this._current=e.next}this._last=null}}const hm=".",KE="",pm="",qE="#",JE="*",mm="xstate.init",GE="xstate.error",Ua="xstate.stop";function YE(n,e){return{type:`xstate.after.${n}.${e}`}}function Ka(n,e){return{type:`xstate.done.state.${n}`,output:e}}function XE(n,e){return{type:`xstate.done.actor.${n}`,output:e,actorId:n}}function gm(n,e){return{type:`xstate.error.actor.${n}`,error:e,actorId:n}}function ym(n){return{type:mm,input:n}}function Ct(n){setTimeout(()=>{throw n})}const QE=typeof Symbol=="function"&&Symbol.observable||"@@observable";function km(n,e){const t=wm(n),o=wm(e);return typeof o=="string"?typeof t=="string"?o===t:!1:typeof t=="string"?t in o:Object.keys(t).every(r=>r in o?km(t[r],o[r]):!1)}function qa(n){if(xm(n))return n;const e=[];let t="";for(let o=0;o<n.length;o++){switch(n.charCodeAt(o)){case 92:t+=n[o+1],o++;continue;case 46:e.push(t),t="";continue}t+=n[o]}return e.push(t),e}function wm(n){if(_v(n))return n.value;if(typeof n!="string")return n;const e=qa(n);return ZE(e)}function ZE(n){if(n.length===1)return n[0];const e={};let t=e;for(let o=0;o<n.length-1;o++)if(o===n.length-2)t[n[o]]=n[o+1];else{const r=t;t={},r[n[o]]=t}return e}function bm(n,e){const t={},o=Object.keys(n);for(let r=0;r<o.length;r++){const s=o[r];t[s]=e(n[s],s,n,r)}return t}function Sm(n){return xm(n)?n:[n]}function dn(n){return n===void 0?[]:Sm(n)}function Ja(n,e,t,o){return typeof n=="function"?n({context:e,event:t,self:o}):n}function xm(n){return Array.isArray(n)}function ev(n){return n.type.startsWith("xstate.error.actor")}function po(n){return Sm(n).map(e=>typeof e>"u"||typeof e=="string"?{target:e}:e)}function Cm(n){if(!(n===void 0||n===KE))return dn(n)}function Ga(n,e,t){var s,i,l;const o=typeof n=="object",r=o?n:void 0;return{next:(s=o?n.next:n)==null?void 0:s.bind(r),error:(i=o?n.error:e)==null?void 0:i.bind(r),complete:(l=o?n.complete:t)==null?void 0:l.bind(r)}}function Em(n,e){return`${e}.${n}`}function Ya(n,e){const t=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!t)return n.implementations.actors[e];const[,o,r]=t,i=n.getStateNodeById(r).config.invoke;return(Array.isArray(i)?i[o]:i).src}function tv(n,e){if(e===n||e===JE)return!0;if(!e.endsWith(".*"))return!1;const t=e.split("."),o=n.split(".");for(let r=0;r<t.length;r++){const s=t[r],i=o[r];if(s==="*")return r===t.length-1;if(s!==i)return!1}return!0}function vm(n,e){return`${n.sessionId}.${e}`}let nv=0;function ov(n,e){const t=new Map,o=new Map,r=new WeakMap,s=new Set,i={},{clock:l,logger:c}=e,d={schedule:(p,h,m,g,y=Math.random().toString(36).slice(2))=>{const w={source:p,target:h,event:m,delay:g,id:y,startedAt:Date.now()},b=vm(p,y);f._snapshot._scheduledEvents[b]=w;const x=l.setTimeout(()=>{delete i[b],delete f._snapshot._scheduledEvents[b],f._relay(p,h,m)},g);i[b]=x},cancel:(p,h)=>{const m=vm(p,h),g=i[m];delete i[m],delete f._snapshot._scheduledEvents[m],g!==void 0&&l.clearTimeout(g)},cancelAll:p=>{for(const h in f._snapshot._scheduledEvents){const m=f._snapshot._scheduledEvents[h];m.source===p&&d.cancel(p,m.id)}}},u=p=>{if(!s.size)return;const h={...p,rootId:n.sessionId};s.forEach(m=>{var g;return(g=m.next)==null?void 0:g.call(m,h)})},f={_snapshot:{_scheduledEvents:((e==null?void 0:e.snapshot)&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${nv++}`,_register:(p,h)=>(t.set(p,h),p),_unregister:p=>{t.delete(p.sessionId);const h=r.get(p);h!==void 0&&(o.delete(h),r.delete(p))},get:p=>o.get(p),getAll:()=>Object.fromEntries(o.entries()),_set:(p,h)=>{const m=o.get(p);if(m&&m!==h)throw new Error(`Actor with system ID '${p}' already exists.`);o.set(p,h),r.set(h,p)},inspect:p=>{const h=Ga(p);return s.add(h),{unsubscribe(){s.delete(h)}}},_sendInspectionEvent:u,_relay:(p,h,m)=>{f._sendInspectionEvent({type:"@xstate.event",sourceRef:p,actorRef:h,event:m}),h._send(m)},scheduler:d,getSnapshot:()=>({_scheduledEvents:{...f._snapshot._scheduledEvents}}),start:()=>{const p=f._snapshot._scheduledEvents;f._snapshot._scheduledEvents={};for(const h in p){const{source:m,target:g,event:y,delay:w,id:b}=p[h];d.schedule(m,g,y,w,b)}},_clock:l,_logger:c};return f}let Xa=!1;const Qa=1;let We=function(n){return n[n.NotStarted=0]="NotStarted",n[n.Running=1]="Running",n[n.Stopped=2]="Stopped",n}({});const rv={clock:{setTimeout:(n,e)=>setTimeout(n,e),clearTimeout:n=>clearTimeout(n)},logger:console.log.bind(console),devTools:!1};class sv{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new fm(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=We.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const o={...rv,...t},{clock:r,logger:s,parent:i,syncSnapshot:l,id:c,systemId:d,inspect:u}=o;this.system=i?i.system:ov(this,{clock:r,logger:s}),u&&!i&&this.system.inspect(Ga(u)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=(t==null?void 0:t.logger)??this.system._logger,this.clock=(t==null?void 0:t.clock)??this.system._clock,this._parent=i,this._syncSnapshot=l,this.options=o,this.src=o.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:f=>{this._deferred.push(f)},system:this.system,stopChild:f=>{if(f._parent!==this)throw new Error(`Cannot stop child actor ${f.id} of ${this.id} because it is not a child`);f._stop()},emit:f=>{const p=this.eventListeners.get(f.type),h=this.eventListeners.get("*");if(!p&&!h)return;const m=[...p?p.values():[],...h?h.values():[]];for(const g of m)try{g(f)}catch(y){Ct(y)}},actionExecutor:f=>{const p=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:f.type,params:f.params}}),!f.exec)return;const h=Xa;try{Xa=!0,f.exec(f.info,f.params)}finally{Xa=h}};this._processingStatus===We.Running?p():this._deferred.push(p)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),d&&(this.systemId=d,this.system._set(d,this)),this._initState((t==null?void 0:t.snapshot)??(t==null?void 0:t.state)),d&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(e){var t;try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,(t=this.options)==null?void 0:t.input)}catch(o){this._snapshot={status:"error",output:void 0,error:o}}}update(e,t){var r,s;this._snapshot=e;let o;for(;o=this._deferred.shift();)try{o()}catch(i){this._deferred.length=0,this._snapshot={...e,status:"error",error:i}}switch(this._snapshot.status){case"active":for(const i of this.observers)try{(r=i.next)==null||r.call(i,e)}catch(l){Ct(l)}break;case"done":for(const i of this.observers)try{(s=i.next)==null||s.call(i,e)}catch(l){Ct(l)}this._stopProcedure(),this._complete(),this._doneEvent=XE(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:t,snapshot:e})}subscribe(e,t,o){var s;const r=Ga(e,t,o);if(this._processingStatus!==We.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{(s=r.complete)==null||s.call(r)}catch(i){Ct(i)}break;case"error":{const i=this._snapshot.error;if(!r.error)Ct(i);else try{r.error(i)}catch(l){Ct(l)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let o=this.eventListeners.get(e);o||(o=new Set,this.eventListeners.set(e,o));const r=t.bind(void 0);return o.add(r),{unsubscribe:()=>{o.delete(r)}}}start(){if(this._processingStatus===We.Running)return this;this._syncSnapshot&&this.subscribe({next:o=>{o.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:o})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=We.Running;const e=ym(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case"done":return this.update(this._snapshot,e),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(o){return this._snapshot={...this._snapshot,status:"error",error:o},this._error(o),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,o;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(r){o={err:r}}if(o){const{err:r}=o;this._snapshot={...this._snapshot,status:"error",error:r},this._error(r);return}this.update(t,e),e.type===Ua&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===We.Stopped?this:(this.mailbox.clear(),this._processingStatus===We.NotStarted?(this._processingStatus=We.Stopped,this):(this.mailbox.enqueue({type:Ua}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var e;for(const t of this.observers)try{(e=t.complete)==null||e.call(t)}catch(o){Ct(o)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||Ct(e),this.eventListeners.clear();return}let t=!1;for(const o of this.observers){const r=o.error;t||(t=!r);try{r==null||r(e)}catch(s){Ct(s)}}this.observers.clear(),this.eventListeners.clear(),t&&Ct(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,gm(this.id,e))}_stopProcedure(){return this._processingStatus!==We.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new fm(this._process.bind(this)),this._processingStatus=We.Stopped,this.system._unregister(this),this)}_send(e){this._processingStatus!==We.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){const{devTools:e}=this.options;e&&(typeof e=="function"?e:UE)(this)}toJSON(){return{xstate$$type:Qa,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[QE](){return this}getSnapshot(){return this._snapshot}}function ai(n,...[e]){return new sv(n,e)}function iv(n,e,t,o,{sendId:r}){const s=typeof r=="function"?r(t,o):r;return[e,{sendId:s},void 0]}function lv(n,e){n.defer(()=>{n.system.scheduler.cancel(n.self,e.sendId)})}function Za(n){function e(t,o){}return e.type="xstate.cancel",e.sendId=n,e.resolve=iv,e.execute=lv,e}function av(n,e,t,o,{id:r,systemId:s,src:i,input:l,syncSnapshot:c}){const d=typeof i=="string"?Ya(e.machine,i):i,u=typeof r=="function"?r(t):r;let f,p;return d&&(p=typeof l=="function"?l({context:e.context,event:t.event,self:n.self}):l,f=ai(d,{id:u,src:i,parent:n.self,syncSnapshot:c,systemId:s,input:p})),[zn(e,{children:{...e.children,[u]:f}}),{id:r,systemId:s,actorRef:f,src:i,input:p},void 0]}function cv(n,{actorRef:e}){e&&n.defer(()=>{e._processingStatus!==We.Stopped&&e.start()})}function ec(...[n,{id:e,systemId:t,input:o,syncSnapshot:r=!1}={}]){function s(i,l){}return s.type="xstate.spawnChild",s.id=e,s.systemId=t,s.src=n,s.input=o,s.syncSnapshot=r,s.resolve=av,s.execute=cv,s}function dv(n,e,t,o,{actorRef:r}){const s=typeof r=="function"?r(t,o):r,i=typeof s=="string"?e.children[s]:s;let l=e.children;return i&&(l={...l},delete l[i.id]),[zn(e,{children:l}),i,void 0]}function Tm(n,e){const t=e.getSnapshot();if(t&&"children"in t)for(const o of Object.values(t.children))Tm(n,o);n.system._unregister(e)}function uv(n,e){if(e){if(Tm(n,e),e._processingStatus!==We.Running){n.stopChild(e);return}n.defer(()=>{n.stopChild(e)})}}function ci(n){function e(t,o){}return e.type="xstate.stopChild",e.actorRef=n,e.resolve=dv,e.execute=uv,e}function di(n,e,t,o){const{machine:r}=o,s=typeof n=="function",i=s?n:r.implementations.guards[typeof n=="string"?n:n.type];if(!s&&!i)throw new Error(`Guard '${typeof n=="string"?n:n.type}' is not implemented.'.`);if(typeof i!="function")return di(i,e,t,o);const l={context:e,event:t},c=s||typeof n=="string"?void 0:"params"in n?typeof n.params=="function"?n.params({context:e,event:t}):n.params:void 0;return"check"in i?i.check(o,l,i):i(l,c)}function tc(n){return n.type==="atomic"||n.type==="final"}function mo(n){return Object.values(n.states).filter(e=>e.type!=="history")}function hr(n,e){const t=[];if(e===n)return t;let o=n.parent;for(;o&&o!==e;)t.push(o),o=o.parent;return t}function ui(n){const e=new Set(n),t=Am(e);for(const o of e)if(o.type==="compound"&&(!t.get(o)||!t.get(o).length))Bm(o).forEach(r=>e.add(r));else if(o.type==="parallel"){for(const r of mo(o))if(r.type!=="history"&&!e.has(r)){const s=Bm(r);for(const i of s)e.add(i)}}for(const o of e){let r=o.parent;for(;r;)e.add(r),r=r.parent}return e}function Mm(n,e){const t=e.get(n);if(!t)return{};if(n.type==="compound"){const r=t[0];if(r){if(tc(r))return r.key}else return{}}const o={};for(const r of t)o[r.key]=Mm(r,e);return o}function Am(n){const e=new Map;for(const t of n)e.has(t)||e.set(t,[]),t.parent&&(e.has(t.parent)||e.set(t.parent,[]),e.get(t.parent).push(t));return e}function Nm(n,e){const t=ui(e);return Mm(n,Am(t))}function nc(n,e){return e.type==="compound"?mo(e).some(t=>t.type==="final"&&n.has(t)):e.type==="parallel"?mo(e).every(t=>nc(n,t)):e.type==="final"}const fi=n=>n[0]===qE;function fv(n,e){return n.transitions.get(e)||[...n.transitions.keys()].filter(o=>tv(e,o)).sort((o,r)=>r.length-o.length).flatMap(o=>n.transitions.get(o))}function hv(n){const e=n.config.after;if(!e)return[];const t=r=>{const s=YE(r,n.id),i=s.type;return n.entry.push(cc(s,{id:i,delay:r})),n.exit.push(Za(i)),i};return Object.keys(e).flatMap(r=>{const s=e[r],i=typeof s=="string"?{target:s}:s,l=Number.isNaN(+r)?r:+r,c=t(l);return dn(i).map(d=>({...d,event:c,delay:l}))}).map(r=>{const{delay:s}=r;return{...un(n,r.event,r),delay:s}})}function un(n,e,t){const o=Cm(t.target),r=t.reenter??!1,s=yv(n,o),i={...t,actions:dn(t.actions),guard:t.guard,target:s,source:n,reenter:r,eventType:e,toJSON:()=>({...i,source:`#${n.id}`,target:s?s.map(l=>`#${l.id}`):void 0})};return i}function pv(n){const e=new Map;if(n.config.on)for(const t of Object.keys(n.config.on)){if(t===pm)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const o=n.config.on[t];e.set(t,po(o).map(r=>un(n,t,r)))}if(n.config.onDone){const t=`xstate.done.state.${n.id}`;e.set(t,po(n.config.onDone).map(o=>un(n,t,o)))}for(const t of n.invoke){if(t.onDone){const o=`xstate.done.actor.${t.id}`;e.set(o,po(t.onDone).map(r=>un(n,o,r)))}if(t.onError){const o=`xstate.error.actor.${t.id}`;e.set(o,po(t.onError).map(r=>un(n,o,r)))}if(t.onSnapshot){const o=`xstate.snapshot.${t.id}`;e.set(o,po(t.onSnapshot).map(r=>un(n,o,r)))}}for(const t of n.after){let o=e.get(t.eventType);o||(o=[],e.set(t.eventType,o)),o.push(t)}return e}function mv(n){const e=[],t=o=>{Object.values(o).forEach(r=>{if(r.config.route&&r.config.id){const s=r.config.id,i=r.config.route.guard,l=(d,u)=>d.event.to!==`#${s}`?!1:i&&typeof i=="function"?i(d,u):!0,c={...r.config.route,guard:l,target:`#${s}`};e.push(un(n,"xstate.route",c))}r.states&&t(r.states)})};t(n.states),e.length>0&&n.transitions.set("xstate.route",e)}function gv(n,e){const t=typeof e=="string"?n.states[e]:e?n.states[e.target]:void 0;if(!t&&e)throw new Error(`Initial state node "${e}" not found on parent state node #${n.id}`);const o={source:n,actions:!e||typeof e=="string"?[]:dn(e.actions),eventType:null,reenter:!1,target:t?[t]:[],toJSON:()=>({...o,source:`#${n.id}`,target:t?[`#${t.id}`]:[]})};return o}function yv(n,e){if(e!==void 0)return e.map(t=>{if(typeof t!="string")return t;if(fi(t))return n.machine.getStateNodeById(t);const o=t[0]===hm;if(o&&!n.parent)return hi(n,t.slice(1));const r=o?n.key+t:t;if(n.parent)try{return hi(n.parent,r)}catch(s){throw new Error(`Invalid transition definition for state node '${n.id}':
|
|
108
|
+
${s.message}`)}else throw new Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function Im(n){const e=Cm(n.config.target);return e?{target:e.map(t=>typeof t=="string"?hi(n.parent,t):t)}:n.parent.initial}function $n(n){return n.type==="history"}function Bm(n){const e=Om(n);for(const t of e)for(const o of hr(t,n))e.add(o);return e}function Om(n){const e=new Set;function t(o){if(!e.has(o)){if(e.add(o),o.type==="compound")t(o.initial.target[0]);else if(o.type==="parallel")for(const r of mo(o))t(r)}}return t(n),e}function go(n,e){if(fi(e))return n.machine.getStateNodeById(e);if(!n.states)throw new Error(`Unable to retrieve child state '${e}' from '${n.id}'; no child states exist.`);const t=n.states[e];if(!t)throw new Error(`Child state '${e}' does not exist on '${n.id}'`);return t}function hi(n,e){if(typeof e=="string"&&fi(e))try{return n.machine.getStateNodeById(e)}catch{}const t=qa(e).slice();let o=n;for(;t.length;){const r=t.shift();if(!r.length)break;o=go(o,r)}return o}function pi(n,e){if(typeof e=="string"){const r=n.states[e];if(!r)throw new Error(`State '${e}' does not exist on '${n.id}'`);return[n,r]}const t=Object.keys(e),o=t.map(r=>go(n,r)).filter(Boolean);return[n.machine.root,n].concat(o,t.reduce((r,s)=>{const i=go(n,s);if(!i)return r;const l=pi(i,e[s]);return r.concat(l)},[]))}function kv(n,e,t,o){const s=go(n,e).next(t,o);return!s||!s.length?n.next(t,o):s}function wv(n,e,t,o){const r=Object.keys(e),s=go(n,r[0]),i=oc(s,e[r[0]],t,o);return!i||!i.length?n.next(t,o):i}function bv(n,e,t,o){const r=[];for(const s of Object.keys(e)){const i=e[s];if(!i)continue;const l=go(n,s),c=oc(l,i,t,o);c&&r.push(...c)}return r.length?r:n.next(t,o)}function oc(n,e,t,o){return typeof e=="string"?kv(n,e,t,o):Object.keys(e).length===1?wv(n,e,t,o):bv(n,e,t,o)}function Sv(n){return Object.keys(n.states).map(e=>n.states[e]).filter(e=>e.type==="history")}function fn(n,e){let t=n;for(;t.parent&&t.parent!==e;)t=t.parent;return t.parent===e}function xv(n,e){const t=new Set(n),o=new Set(e);for(const r of t)if(o.has(r))return!0;for(const r of o)if(t.has(r))return!0;return!1}function _m(n,e,t){const o=new Set;for(const r of n){let s=!1;const i=new Set;for(const l of o)if(xv(sc([r],e,t),sc([l],e,t)))if(fn(r.source,l.source))i.add(l);else{s=!0;break}if(!s){for(const l of i)o.delete(l);o.add(r)}}return Array.from(o)}function Cv(n){const[e,...t]=n;for(const o of hr(e,void 0))if(t.every(r=>fn(r,o)))return o}function rc(n,e){if(!n.target)return[];const t=new Set;for(const o of n.target)if($n(o))if(e[o.id])for(const r of e[o.id])t.add(r);else for(const r of rc(Im(o),e))t.add(r);else t.add(o);return[...t]}function Rm(n,e){const t=rc(n,e);if(!t)return;if(!n.reenter&&t.every(r=>r===n.source||fn(r,n.source)))return n.source;const o=Cv(t.concat(n.source));if(o)return o;if(!n.reenter)return n.source.machine.root}function sc(n,e,t){var r;const o=new Set;for(const s of n)if((r=s.target)!=null&&r.length){const i=Rm(s,t);s.reenter&&s.source===i&&o.add(i);for(const l of e)fn(l,i)&&o.add(l)}return[...o]}function Ev(n,e){if(n.length!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;return!0}function vv(n,e,t,o,r){return ic([{target:[...Om(n)],source:n,reenter:!0,actions:[],eventType:null,toJSON:null}],e,t,o,!0,r)}function ic(n,e,t,o,r,s){const i=[];if(!n.length)return[e,i];const l=t.actionExecutor;t.actionExecutor=c=>{i.push(c),l(c)};try{const c=new Set(e._nodes);let d=e.historyValue;const u=_m(n,c,d);let f=e;r||([f,d]=Nv(f,o,t,u,c,d,s,t.actionExecutor)),f=ko(f,o,t,u.flatMap(h=>h.actions),s,void 0),f=Mv(f,o,t,u,c,s,d,r);const p=[...c];f.status==="done"&&(f=ko(f,o,t,p.sort((h,m)=>m.order-h.order).flatMap(h=>h.exit),s,void 0));try{return d===e.historyValue&&Ev(e._nodes,c)?[f,i]:[zn(f,{_nodes:p,historyValue:d}),i]}catch(h){throw h}}finally{t.actionExecutor=l}}function Tv(n,e,t,o,r){if(o.output===void 0)return;const s=Ka(r.id,r.output!==void 0&&r.parent?Ja(r.output,n.context,e,t.self):void 0);return Ja(o.output,n.context,s,t.self)}function Mv(n,e,t,o,r,s,i,l){let c=n;const d=new Set,u=new Set;Av(o,i,u,d),l&&u.add(n.machine.root);const f=new Set;for(const p of[...d].sort((h,m)=>h.order-m.order)){r.add(p);const h=[];h.push(...p.entry);for(const m of p.invoke)h.push(ec(m.src,{...m,syncSnapshot:!!m.onSnapshot}));if(u.has(p)){const m=p.initial.actions;h.push(...m)}if(c=ko(c,e,t,h,s,p.invoke.map(m=>m.id)),p.type==="final"){const m=p.parent;let g=(m==null?void 0:m.type)==="parallel"?m:m==null?void 0:m.parent,y=g||p;for((m==null?void 0:m.type)==="compound"&&s.push(Ka(m.id,p.output!==void 0?Ja(p.output,c.context,e,t.self):void 0));(g==null?void 0:g.type)==="parallel"&&!f.has(g)&&nc(r,g);)f.add(g),s.push(Ka(g.id)),y=g,g=g.parent;if(g)continue;c=zn(c,{status:"done",output:Tv(c,e,t,c.machine.root,y)})}}return c}function Av(n,e,t,o){for(const r of n){const s=Rm(r,e);for(const l of r.target||[])!$n(l)&&(r.source!==l||r.source!==s||r.reenter)&&(o.add(l),t.add(l)),yo(l,e,t,o);const i=rc(r,e);for(const l of i){const c=hr(l,s);(s==null?void 0:s.type)==="parallel"&&c.push(s),Pm(o,e,t,c,!r.source.parent&&r.reenter?void 0:s)}}}function yo(n,e,t,o){var r;if($n(n))if(e[n.id]){const s=e[n.id];for(const i of s)o.add(i),yo(i,e,t,o);for(const i of s)lc(i,n.parent,o,e,t)}else{const s=Im(n);for(const i of s.target)o.add(i),s===((r=n.parent)==null?void 0:r.initial)&&t.add(n.parent),yo(i,e,t,o);for(const i of s.target)lc(i,n.parent,o,e,t)}else if(n.type==="compound"){const[s]=n.initial.target;$n(s)||(o.add(s),t.add(s)),yo(s,e,t,o),lc(s,n,o,e,t)}else if(n.type==="parallel")for(const s of mo(n).filter(i=>!$n(i)))[...o].some(i=>fn(i,s))||($n(s)||(o.add(s),t.add(s)),yo(s,e,t,o))}function Pm(n,e,t,o,r){for(const s of o)if((!r||fn(s,r))&&n.add(s),s.type==="parallel")for(const i of mo(s).filter(l=>!$n(l)))[...n].some(l=>fn(l,i))||(n.add(i),yo(i,e,t,n))}function lc(n,e,t,o,r){Pm(t,o,r,hr(n,e))}function Nv(n,e,t,o,r,s,i,l){let c=n;const d=sc(o,r,s);d.sort((f,p)=>p.order-f.order);let u;for(const f of d)for(const p of Sv(f)){let h;p.history==="deep"?h=m=>tc(m)&&fn(m,f):h=m=>m.parent===f,u??(u={...s}),u[p.id]=Array.from(r).filter(h)}for(const f of d)c=ko(c,e,t,[...f.exit,...f.invoke.map(p=>ci(p.id))],i,void 0),r.delete(f);return[c,u||s]}function Iv(n,e){return n.implementations.actions[e]}function Dm(n,e,t,o,r,s){const{machine:i}=n;let l=n;for(const c of o){const d=typeof c=="function",u=d?c:Iv(i,typeof c=="string"?c:c.type),f={context:l.context,event:e,self:t.self,system:t.system},p=d||typeof c=="string"?void 0:"params"in c?typeof c.params=="function"?c.params({context:l.context,event:e}):c.params:void 0;if(!u||!("resolve"in u)){t.actionExecutor({type:typeof c=="string"?c:typeof c=="object"?c.type:c.name||"(anonymous)",info:f,params:p,exec:u});continue}const h=u,[m,g,y]=h.resolve(t,l,f,p,u,r);l=m,"retryResolve"in h&&(s==null||s.push([h,g])),"execute"in h&&t.actionExecutor({type:h.type,info:f,params:g,exec:h.execute.bind(null,t,g)}),y&&(l=Dm(l,e,t,y,r,s))}return l}function ko(n,e,t,o,r,s){const i=s?[]:void 0,l=Dm(n,e,t,o,{internalQueue:r,deferredActorIds:s},i);return i==null||i.forEach(([c,d])=>{c.retryResolve(t,l,d)}),l}function ac(n,e,t,o){let r=n;const s=[];function i(d,u,f){t.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:t.self,event:u,snapshot:d[0],_transitions:f}),s.push(d)}if(e.type===Ua)return r=zn(Lm(r,e,t),{status:"stopped"}),i([r,[]],e,[]),{snapshot:r,microsteps:s};let l=e;if(l.type!==mm){const d=l,u=ev(d),f=Vm(d,r);if(u&&!f.length)return r=zn(n,{status:"error",error:d.error}),i([r,[]],d,[]),{snapshot:r,microsteps:s};const p=ic(f,n,t,l,!1,o);r=p[0],i(p,d,f)}let c=!0;for(;r.status==="active";){let d=c?Bv(r,l):[];const u=d.length?r:void 0;if(!d.length){if(!o.length)break;l=o.shift(),d=Vm(l,r)}const f=ic(d,r,t,l,!1,o);r=f[0],c=r!==u,i(f,l,d)}return r.status!=="active"&&Lm(r,l,t),{snapshot:r,microsteps:s}}function Lm(n,e,t){return ko(n,e,t,Object.values(n.children).map(o=>ci(o)),[],void 0)}function Vm(n,e){return e.machine.getTransitionData(e,n)}function Bv(n,e){const t=new Set,o=n._nodes.filter(tc);for(const r of o)e:for(const s of[r].concat(hr(r,void 0)))if(s.always){for(const i of s.always)if(i.guard===void 0||di(i.guard,n.context,e,n)){t.add(i);break e}}return _m(Array.from(t),new Set(n._nodes),n.historyValue)}function Ov(n,e){const t=ui(pi(n,e));return Nm(n,[...t])}function _v(n){return!!n&&typeof n=="object"&&"machine"in n&&"value"in n}const Rv=function(e){return km(e,this.value)},Pv=function(e){return this.tags.has(e)},Dv=function(e){const t=this.machine.getTransitionData(this,e);return!!(t!=null&&t.length)&&t.some(o=>o.target!==void 0||o.actions.length)},Lv=function(){const{_nodes:e,tags:t,machine:o,getMeta:r,toJSON:s,can:i,hasTag:l,matches:c,...d}=this;return{...d,tags:Array.from(t)}},Vv=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function mi(n,e){return{status:n.status,output:n.output,error:n.error,machine:e,context:n.context,_nodes:n._nodes,value:Nm(e.root,n._nodes),tags:new Set(n._nodes.flatMap(t=>t.tags)),children:n.children,historyValue:n.historyValue||{},matches:Rv,hasTag:Pv,can:Dv,getMeta:Vv,toJSON:Lv}}function zn(n,e={}){return mi({...n,...e},n.machine)}function $v(n){if(typeof n!="object"||n===null)return{};const e={};for(const t in n){const o=n[t];Array.isArray(o)&&(e[t]=o.map(r=>({id:r.id})))}return e}function zv(n,e){const{_nodes:t,tags:o,machine:r,children:s,context:i,can:l,hasTag:c,matches:d,getMeta:u,toJSON:f,...p}=n,h={};for(const g in s){const y=s[g];h[g]={snapshot:y.getPersistedSnapshot(e),src:y.src,systemId:y.systemId,syncSnapshot:y._syncSnapshot}}return{...p,context:$m(i),children:h,historyValue:$v(p.historyValue)}}function $m(n){let e;for(const t in n){const o=n[t];if(o&&typeof o=="object")if("sessionId"in o&&"send"in o&&"ref"in o)e??(e=Array.isArray(n)?n.slice():{...n}),e[t]={xstate$$type:Qa,id:o.id};else{const r=$m(o);r!==o&&(e??(e=Array.isArray(n)?n.slice():{...n}),e[t]=r)}}return e??n}function Fv(n,e,t,o,{event:r,id:s,delay:i},{internalQueue:l}){const c=e.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const d=typeof r=="function"?r(t,o):r;let u;if(typeof i=="string"){const f=c&&c[i];u=typeof f=="function"?f(t,o):f}else u=typeof i=="function"?i(t,o):i;return typeof u!="number"&&l.push(d),[e,{event:d,id:s,delay:u},void 0]}function Hv(n,e){const{event:t,delay:o,id:r}=e;if(typeof o=="number"){n.defer(()=>{const s=n.self;n.system.scheduler.schedule(s,s,t,o,r)});return}}function cc(n,e){function t(o,r){}return t.type="xstate.raise",t.event=n,t.id=e==null?void 0:e.id,t.delay=e==null?void 0:e.delay,t.resolve=Fv,t.execute=Hv,t}function jv(n,{machine:e,context:t},o,r){const s=(i,l)=>{if(typeof i=="string"){const c=Ya(e,i);if(!c)throw new Error(`Actor logic '${i}' not implemented in machine '${e.id}'`);const d=ai(c,{id:l==null?void 0:l.id,parent:n.self,syncSnapshot:l==null?void 0:l.syncSnapshot,input:typeof(l==null?void 0:l.input)=="function"?l.input({context:t,event:o,self:n.self}):l==null?void 0:l.input,src:i,systemId:l==null?void 0:l.systemId});return r[d.id]=d,d}else return ai(i,{id:l==null?void 0:l.id,parent:n.self,syncSnapshot:l==null?void 0:l.syncSnapshot,input:l==null?void 0:l.input,src:i,systemId:l==null?void 0:l.systemId})};return(i,l)=>{const c=s(i,l);return r[c.id]=c,n.defer(()=>{c._processingStatus!==We.Stopped&&c.start()}),c}}function Wv(n,e,t,o,{assignment:r}){if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const s={},i={context:e.context,event:t.event,spawn:jv(n,e,t.event,s),self:n.self,system:n.system};let l={};if(typeof r=="function")l=r(i,o);else for(const d of Object.keys(r)){const u=r[d];l[d]=typeof u=="function"?u(i,o):u}const c=Object.assign({},e.context,l);return[zn(e,{context:c,children:Object.keys(s).length?{...e.children,...s}:e.children}),void 0,void 0]}function Fn(n){function e(t,o){}return e.type="xstate.assign",e.assignment=n,e.resolve=Wv,e}const zm=new WeakMap;function wo(n,e,t){let o=zm.get(n);return o?e in o||(o[e]=t()):(o={[e]:t()},zm.set(n,o)),o[e]}const Uv={},pr=n=>typeof n=="string"?{type:n}:typeof n=="function"?"resolve"in n?{type:n.type}:{type:n.name}:n;class gi{constructor(e,t){if(this.config=e,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=t._parent,this.key=t._key,this.machine=t._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(hm),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?bm(this.config.states,(o,r)=>new gi(o,{_parent:this,_key:r,_machine:this.machine})):Uv,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=dn(this.config.entry).slice(),this.exit=dn(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=dn(e.tags).slice()}_initialize(){this.transitions=pv(this),this.config.always&&(this.always=po(this.config.always).map(e=>un(this,pm,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(pr),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(pr),eventType:null})}:void 0,history:this.history,states:bm(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(pr)})),entry:this.entry.map(pr),exit:this.exit.map(pr),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return wo(this,"invoke",()=>dn(this.config.invoke).map((e,t)=>{const{src:o,systemId:r}=e,s=e.id??Em(this.id,t),i=typeof o=="string"?o:`xstate.invoke.${Em(this.id,t)}`;return{...e,src:i,id:s,systemId:r,toJSON(){const{onDone:l,onError:c,...d}=e;return{...d,type:"xstate.invoke",src:i,id:s}}}}))}get on(){return wo(this,"on",()=>[...this.transitions].flatMap(([t,o])=>o.map(r=>[t,r])).reduce((t,[o,r])=>(t[o]=t[o]||[],t[o].push(r),t),{}))}get after(){return wo(this,"delayedTransitions",()=>hv(this))}get initial(){return wo(this,"initial",()=>gv(this,this.config.initial))}next(e,t){const o=t.type,r=[];let s;const i=wo(this,`candidates-${o}`,()=>fv(this,o));for(const l of i){const{guard:c}=l,d=e.context;let u=!1;try{u=!c||di(c,d,t,e)}catch(f){const p=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${p?`'${p}' `:""}in transition for event '${o}' in state node '${this.id}':
|
|
109
|
+
${f.message}`)}if(u){r.push(...l.actions),s=l;break}}return s?[s]:void 0}get events(){return wo(this,"events",()=>{const{states:e}=this,t=new Set(this.ownEvents);if(e)for(const o of Object.keys(e)){const r=e[o];if(r.states)for(const s of r.events)t.add(`${s}`)}return Array.from(t)})}get ownEvents(){const e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(o=>this.transitions.get(o).some(r=>!(!r.target&&!r.actions.length&&!r.reenter))));return Array.from(t)}}const Kv="#";class dc{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||"(machine)",this.implementations={actors:(t==null?void 0:t.actors)??{},actions:(t==null?void 0:t.actions)??{},delays:(t==null?void 0:t.delays)??{},guards:(t==null?void 0:t.guards)??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new gi(e,{_key:this.id,_machine:this}),this.root._initialize(),mv(this.root),this.states=this.root.states,this.events=this.root.events}provide(e){const{actions:t,guards:o,actors:r,delays:s}=this.implementations;return new dc(this.config,{actions:{...t,...e.actions},guards:{...o,...e.guards},actors:{...r,...e.actors},delays:{...s,...e.delays}})}resolveState(e){const t=Ov(this.root,e.value),o=ui(pi(this.root,t));return mi({_nodes:[...o],context:e.context||{},children:{},status:nc(o,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,o){return ac(e,t,o,[]).snapshot}microstep(e,t,o){return ac(e,t,o,[]).microsteps.map(([r])=>r)}getTransitionData(e,t){return oc(this.root,e.value,e,t)||[]}_getPreInitialState(e,t,o){const{context:r}=this.config,s=mi({context:typeof r!="function"&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return typeof r=="function"?ko(s,t,e,[Fn(({spawn:l,event:c,self:d})=>r({spawn:l,input:c.input,self:d}))],o,void 0):s}getInitialSnapshot(e,t){const o=ym(t),r=[],s=this._getPreInitialState(e,o,r),[i]=vv(this.root,s,e,o,r),{snapshot:l}=ac(i,o,e,r);return l}start(e){Object.values(e.children).forEach(t=>{t.getSnapshot().status==="active"&&t.start()})}getStateNodeById(e){const t=qa(e),o=t.slice(1),r=fi(t[0])?t[0].slice(Kv.length):t[0],s=this.idMap.get(r);if(!s)throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return hi(s,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return zv(e,t)}restoreSnapshot(e,t){const o={},r=e.children;Object.keys(r).forEach(f=>{const p=r[f],h=p.snapshot,m=p.src,g=typeof m=="string"?Ya(this,m):m;if(!g)return;const y=ai(g,{id:f,parent:t.self,syncSnapshot:p.syncSnapshot,snapshot:h,src:m,systemId:p.systemId});o[f]=y});function s(f,p){if(p instanceof gi)return p;try{return f.machine.getStateNodeById(p.id)}catch{}}function i(f,p){if(!p||typeof p!="object")return{};const h={};for(const m in p){const g=p[m];for(const y of g){const w=s(f,y);w&&(h[m]??(h[m]=[]),h[m].push(w))}}return h}const l=i(this.root,e.historyValue),c=mi({...e,children:o,_nodes:Array.from(ui(pi(this.root,e.value))),historyValue:l},this),d=new Set;function u(f,p){if(!d.has(f)){d.add(f);for(const h in f){const m=f[h];if(m&&typeof m=="object"){if("xstate$$type"in m&&m.xstate$$type===Qa){f[h]=p[m.id];continue}u(m,p)}}}}return u(c.context,o),c}}function qv(n,e,t,o,{event:r}){const s=typeof r=="function"?r(t,o):r;return[e,{event:s},void 0]}function Jv(n,{event:e}){n.defer(()=>n.emit(e))}function Fm(n){function e(t,o){}return e.type="xstate.emit",e.event=n,e.resolve=qv,e.execute=Jv,e}let uc=function(n){return n.Parent="#_parent",n.Internal="#_internal",n}({});function Gv(n,e,t,o,{to:r,event:s,id:i,delay:l},c){var m;const d=e.machine.implementations.delays;if(typeof s=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${s}" }) instead`);const u=typeof s=="function"?s(t,o):s;let f;if(typeof l=="string"){const g=d&&d[l];f=typeof g=="function"?g(t,o):g}else f=typeof l=="function"?l(t,o):l;const p=typeof r=="function"?r(t,o):r;let h;if(typeof p=="string"){if(p===uc.Parent?h=n.self._parent:p===uc.Internal?h=n.self:p.startsWith("#_")?h=e.children[p.slice(2)]:h=(m=c.deferredActorIds)!=null&&m.includes(p)?p:e.children[p],!h)throw new Error(`Unable to send event to actor '${p}' from machine '${e.machine.id}'.`)}else h=p||n.self;return[e,{to:h,targetId:typeof p=="string"?p:void 0,event:u,id:i,delay:f},void 0]}function Yv(n,e,t){typeof t.to=="string"&&(t.to=e.children[t.to])}function Xv(n,e){n.defer(()=>{const{to:t,event:o,delay:r,id:s}=e;if(typeof r=="number"){n.system.scheduler.schedule(n.self,t,o,r,s);return}n.system._relay(n.self,t,o.type===GE?gm(n.self.id,o.data):o)})}function fc(n,e,t){function o(r,s){}return o.type="xstate.sendTo",o.to=n,o.event=e,o.id=t==null?void 0:t.id,o.delay=t==null?void 0:t.delay,o.resolve=Gv,o.retryResolve=Yv,o.execute=Xv,o}function Qv(n,e){return fc(uc.Parent,n,e)}function Zv(n,e,t,o,{collect:r}){const s=[],i=function(c){s.push(c)};return i.assign=(...l)=>{s.push(Fn(...l))},i.cancel=(...l)=>{s.push(Za(...l))},i.raise=(...l)=>{s.push(cc(...l))},i.sendTo=(...l)=>{s.push(fc(...l))},i.sendParent=(...l)=>{s.push(Qv(...l))},i.spawnChild=(...l)=>{s.push(ec(...l))},i.stopChild=(...l)=>{s.push(ci(...l))},i.emit=(...l)=>{s.push(Fm(...l))},r({context:t.context,event:t.event,enqueue:i,check:l=>di(l,e.context,t.event,e),self:n.self,system:n.system},o),[e,void 0,s]}function eT(n){function e(t,o){}return e.type="xstate.enqueueActions",e.collect=n,e.resolve=Zv,e}function tT(n,e,t,o,{value:r,label:s}){return[e,{value:typeof r=="function"?r(t,o):r,label:s},void 0]}function nT({logger:n},{value:e,label:t}){t?n(t,e):n(e)}function oT(n=({context:t,event:o})=>({context:t,event:o}),e){function t(o,r){}return t.type="xstate.log",t.value=n,t.label=e,t.resolve=tT,t.execute=nT,t}function rT(n,e){return new dc(n,e)}function Hm({schemas:n,actors:e,actions:t,guards:o,delays:r}){return{assign:Fn,sendTo:fc,raise:cc,log:oT,cancel:Za,stopChild:ci,enqueueActions:eT,emit:Fm,spawnChild:ec,createStateConfig:s=>s,createAction:s=>s,createMachine:s=>rT({...s,schemas:n},{actors:e,actions:t,guards:o,delays:r}),extend:s=>Hm({schemas:n,actors:e,actions:{...t,...s.actions},guards:{...o,...s.guards},delays:{...r,...s.delays}})}}const sT=4,jm=1,Wm="draw";function Um(n,e,t){const o=k.findFrameAtPoint(n,t,e);if(o!==null){const r=k.Block.getWorldPosition(n,e),s=k.Block.write(n,e);s.parentId=o,k.Block.setWorldPosition(n,e,r)}}const iT=Hm({guards:{isThresholdReached:({context:n,event:e})=>ae.Vec2.distance(n.pointingStartWorld,e.worldPosition)*e.cameraZoom>=sT},actions:{setPointingStart:Fn({pointingStartWorld:({event:n})=>[n.worldPosition[0],n.worldPosition[1]]}),resetContext:Fn({pointingStartWorld:()=>[0,0],activeEntity:()=>null}),addEntity:Fn({activeEntity:({context:n,event:e})=>{const t=ca(k.Controls.read(e.ctx).heldSnapshot);if(!t)return null;const o={...t,block:{...t.block,size:[1,1]}},r=or(e.ctx,o,n.pointingStartWorld);return Um(e.ctx,r,n.pointingStartWorld),r}}),drawEntity:({context:n,event:e})=>{if(!n.activeEntity)return;const t=[n.pointingStartWorld[0],n.pointingStartWorld[1]],o=[e.worldPosition[0],e.worldPosition[1]];k.Grid.snapPosition(e.ctx,t),k.Grid.snapPosition(e.ctx,o);const r=Math.min(t[0],o[0]),s=Math.min(t[1],o[1]),i=Math.max(Math.abs(o[0]-t[0]),1),l=Math.max(Math.abs(o[1]-t[1]),1),c=k.Block.write(e.ctx,n.activeEntity);c.size=[i,l],k.Block.setWorldPosition(e.ctx,n.activeEntity,[r,s])},completeEntity:({context:n,event:e})=>{if(!n.activeEntity)return;const t=k.Block.read(e.ctx,n.activeEntity);if(t.size[0]<jm||t.size[1]<jm){k.removeEntity(e.ctx,n.activeEntity);return}k.selectBlock(e.ctx,n.activeEntity)},removeEntity:Fn({activeEntity:({context:n,event:e})=>(n.activeEntity&&k.removeEntity(e.ctx,n.activeEntity),null)}),placeEntity:({context:n,event:e})=>{const t=ca(k.Controls.read(e.ctx).heldSnapshot);if(!t)return;const o=or(e.ctx,t,n.pointingStartWorld);Um(e.ctx,o,n.pointingStartWorld),k.selectBlock(e.ctx,o)},exitToSelect:({event:n})=>{const e=k.Controls.write(n.ctx);e.leftMouseTool="select",e.activeToolName="select",e.heldSnapshot="";const t=k.Cursor.write(n.ctx);t.cursorKind="select"},deselectAll:({event:n})=>{k.DeselectAll.spawn(n.ctx)}}}).createMachine({id:"drawPlacement",initial:ut.Idle,context:{activeEntity:null,pointingStartWorld:[0,0]},states:{[ut.Idle]:{entry:"resetContext",on:{pointerDown:{actions:"deselectAll",target:ut.Pointing}}},[ut.Pointing]:{entry:"setPointingStart",on:{pointerMove:{guard:"isThresholdReached",target:ut.Drawing},pointerUp:{actions:["placeEntity","exitToSelect"],target:ut.Idle},cancel:{target:ut.Idle}}},[ut.Drawing]:{entry:"addEntity",on:{pointerMove:{actions:"drawEntity"},pointerUp:{actions:["completeEntity","exitToSelect"],target:ut.Idle},cancel:{actions:"removeEntity",target:ut.Idle}}}}}),lT=k.defineEditorSystem({phase:"capture",priority:100},n=>{if(k.isReadonly(n))return;const e=k.Controls.read(n);if(e.leftMouseTool!==Wm||!e.heldSnapshot)return;const t=k.Controls.getButtons(n,Wm);if(t.length===0)return;const o=k.getPointerInput(n,t);o.length!==0&&cm.run(n,iT,o)}),aT=k.defineEditorSystem({phase:"update"},n=>{if(k.isReadonly(n))return;const{store:e}=k.getPluginResources(n,so);k.on(n,k.Undo,()=>{e.canUndo()&&(k.deselectAll(n),e.undo())}),k.on(n,k.Redo,()=>{e.canRedo()&&(k.deselectAll(n),e.redo())})}),cT=[{name:"Figtree",displayName:"Figtree",url:"https://fonts.googleapis.com/css2?family=Figtree",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/Figtree.png"},{name:"Shantell Sans",displayName:"Shantell Sans",url:"https://fonts.googleapis.com/css2?family=Shantell+Sans",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/ShantellSans.png"},{name:"Courier Prime",displayName:"Courier Prime",url:"https://fonts.googleapis.com/css2?family=Courier+Prime",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/CourierPrime.png"},{name:"EB Garamond",displayName:"EB Garamond",url:"https://fonts.googleapis.com/css2?family=EB+Garamond",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/EBGaramond.png"}];function Km(n){return{name:so,resources:{store:n.store},singletons:[li,fr,cm],systems:[$E,lT,HE,aT],setup(e){n.doubleClickSnapshot&&(fr.write(e).snapshot=n.doubleClickSnapshot)},cursors:Hp,fonts:cT,keybinds:[{command:k.Undo.name,key:k.Key.Z,mod:!0},{command:k.Redo.name,key:k.Key.Y,mod:!0},{command:k.Redo.name,key:k.Key.Z,mod:!0,shift:!0}]}}const dT=a.defineComponent({__name:"ClipboardHandler",props:{options:{}},setup(n){const e=n,t=a.inject("containerRef",a.ref(null));return DS(t,e.options),(o,r)=>a.renderSlot(o.$slots,"default")}}),uT={class:"wov-user-cursors"},fT={class:"wov-cursor-svg",viewBox:"0 0 4.35 4.75",width:"20",height:"20"},hT=["fill"],pT="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z",mT=a.defineComponent({__name:"UserCursors",props:{users:{},currentSessionId:{},camera:{}},setup(n){const e=n,t=a.computed(()=>e.users.filter(o=>o.sessionId!==e.currentSessionId).map(o=>({...o,screenX:(o.position[0]-e.camera.left)*e.camera.zoom,screenY:(o.position[1]-e.camera.top)*e.camera.zoom})));return(o,r)=>(a.openBlock(),a.createElementBlock("div",uT,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.value,s=>(a.openBlock(),a.createElementBlock("div",{key:s.sessionId,class:"wov-user-cursor",style:a.normalizeStyle({transform:`translate(${s.screenX}px, ${s.screenY}px)`})},[(a.openBlock(),a.createElementBlock("svg",fT,[a.createElementVNode("path",{fill:s.color,stroke:"#fff","stroke-miterlimit":"10","stroke-width":".25",d:pT},null,8,hT)])),a.createElementVNode("span",{class:"wov-cursor-label",style:a.normalizeStyle({backgroundColor:s.color})},a.toDisplayString(s.name),5)],4))),128))]))}}),gT={key:0,class:"wov-offline-indicator"},yT=a.defineComponent({__name:"OfflineIndicator",props:{isOnline:{type:Boolean}},setup(n){return(e,t)=>n.isOnline?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",gT,"Working Offline"))}}),kT={key:0,class:"wov-version-mismatch-overlay"},wT=a.defineComponent({__name:"VersionMismatch",props:{versionMismatch:{type:Boolean}},setup(n){function e(){window.location.reload()}return(t,o)=>n.versionMismatch?(a.openBlock(),a.createElementBlock("div",kT,[a.createElementVNode("div",{class:"wov-version-mismatch-dialog"},[o[0]||(o[0]=a.createElementVNode("p",null,"A new version is available.",-1)),o[1]||(o[1]=a.createElementVNode("p",null,"Please refresh the page to continue.",-1)),a.createElementVNode("button",{onClick:e},"Refresh")])])):a.createCommentVNode("",!0)}}),bT=a.defineComponent({__name:"BackToContentButton",setup(n){const{nextEditorTick:e}=fe(),t=_e(k.Camera),o=k.defineQuery(d=>d.with(k.Synced,k.Block,k.Aabb)),r=a.ref(0),s=a.inject(Se);if(s){const d=s.registerTickCallback(u=>{o.addedOrRemoved(u).length>0&&(r.value=o.current(u).length)});a.onUnmounted(d)}const i=a.ref(!1);a.watchEffect(()=>{i.value=!t.value.canSeeBlocks&&r.value>0});function l(d,u,f,p,h){const m=u+p,g=f+h;return d[0]<m&&d[2]>u&&d[1]<g&&d[3]>f}function c(){e(d=>{const u=o.current(d);if(u.length===0)return;let f=Number.POSITIVE_INFINITY,p=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const B of u){const P=k.Aabb.read(d,B);f=Math.min(f,P.value[0]),p=Math.min(p,P.value[1]),h=Math.max(h,P.value[2]),m=Math.max(m,P.value[3])}const g=k.Screen.read(d),y=k.Camera.read(d),w=k.getPluginResources(d,wi.CONTROLS_PLUGIN_NAME)??wi.DEFAULT_CONTROLS_OPTIONS;let b=Math.min(g.width/(h-f),g.height/(m-p));b/=1.1,b=Math.min(b,y.zoom),b=Math.max(w.minZoom,Math.min(w.maxZoom,b));const x=(f+h)/2,S=(p+m)/2;let E=x-g.width/b/2,M=S-g.height/b/2;const C=g.width/b,T=g.height/b;let v=!1;for(const B of u){const P=k.Aabb.read(d,B);if(l(P.value,E,M,C,T)){v=!0;break}}if(!v){const B=Math.floor(Math.random()*u.length),P=u[B],V=k.Aabb.read(d,P),F=(V.value[0]+V.value[2])/2,z=(V.value[1]+V.value[3])/2;E=F-C/2,M=z-T/2}const I=k.Camera.write(d);I.left=E,I.top=M,I.zoom=b})}return(d,u)=>i.value?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-back-to-content",onClick:c},[...u[0]||(u[0]=[a.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a.createElementVNode("path",{d:"M10 12L6 8L10 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),a.createTextVNode(" Back to content ",-1)])])):a.createCommentVNode("",!0)}}),ST=["data-entity-id","data-selected","data-held-by-other","data-hovered"],xT=a.defineComponent({__name:"WovenCanvasCore",props:{store:{},editor:{},background:{},assetProvider:{},pluginOptions:{},controls:{},doubleClickSnapshot:{},copyPaste:{},initialState:{}},emits:["ready"],async setup(n,{emit:e}){var Ym,Xm,Qm;let t,o;const r=k.defineQuery(A=>A.tracking(k.Block)),s=k.defineQuery(A=>A.with(k.Asset)),i=k.defineQuery(A=>A.with(k.Block).tracking(k.Connector)),l=k.defineQuery(A=>A.with(k.Block).tracking(k.Selected)),c=k.defineQuery(A=>A.with(k.Block).tracking(k.Held)),d=k.defineQuery(A=>A.with(k.Block).tracking(k.Hovered)),u=k.defineQuery(A=>A.with(k.Block).tracking(k.Edited)),f=k.defineQuery(A=>A.with(k.Block).tracking(k.Opacity)),p=k.defineQuery(A=>A.tracking(k.User)),h=n,m=e,g=a.ref(null),y=a.shallowRef(null),w=k.UserData.parse(((Ym=h.editor)==null?void 0:Ym.user)??{}),b=new Set,x=new Map,S=a.shallowRef([]),E=new Map,M=new Map,C=new Set,T=new Map,v=a.shallowRef([]),I=a.ref(!0),B=a.ref(!1),P=a.ref(!h.initialState),V=a.shallowRef(k.Camera.default());function F(A,$,N){let U=E.get(A);U||(U=new Map,E.set(A,U));let L=U.get($);return L||(L=new Set,U.set($,L)),L.add(N),()=>{L.delete(N),L.size===0&&(U.delete($),U.size===0&&E.delete(A))}}function z(A,$,N,U=!1){const L=E.get($);if(!L)return;const O=L.get(N.name);if(!O||O.size===0)return;let Y=null;U||(Y=N.snapshot(A,$));for(const ne of O)ne(Y)}function J(A,$){let N=M.get(A);return N||(N=new Set,M.set(A,N)),N.add($),()=>{N.delete($),N.size===0&&M.delete(A)}}function j(A,$){const N=M.get($.name);if(!N||N.size===0)return;const U=$.snapshot(A);for(const L of N)L(U)}function K(A){return C.add(A),()=>{C.delete(A)}}function W(){return w.sessionId}function X(A){return x.get(A)??null}const re={hasEntity:A=>b.has(A),getEditor:()=>y.value,getAssetManager:()=>he,getSessionId:W,getUserBySessionId:X,subscribeComponent:F,subscribeSingleton:J,registerTickCallback:K,defaults:a.reactive({}),setDefaults(A,$){this.defaults[A]={...this.defaults[A],...$}},getDefaults(A){return this.defaults[A]??{}}};a.provide(Se,re),a.provide("containerRef",g),VS(A=>{var $;($=y.value)==null||$.nextTick(A)});let ie=0,be=null,se=null;const ot=((Qm=(Xm=h.store)==null?void 0:Xm.persistence)==null?void 0:Qm.documentId)??"default";let he=new CE({provider:h.assetProvider??new TE,documentId:ot});function hn(A){var U;const $=[],N=h.pluginOptions;return(N==null?void 0:N.controls)!==!1&&$.push(wi.CanvasControlsPlugin((N==null?void 0:N.controls)??{})),(N==null?void 0:N.eraser)!==!1&&$.push(kr.createEraserPlugin((N==null?void 0:N.eraser)||void 0)),(N==null?void 0:N.pen)!==!1&&$.push(wr.createPenPlugin()),(N==null?void 0:N.arrows)!==!1&&$.push(te.createArrowsPlugin((N==null?void 0:N.arrows)||void 0)),(N==null?void 0:N.tapes)!==!1&&$.push(ag.createTapesPlugin()),$.push(Km({store:A,doubleClickSnapshot:h.doubleClickSnapshot})),(U=h.editor)!=null&&U.plugins&&$.push(...h.editor.plugins),$}function yi(){const A=h.store??{},$={history:!0,...A};return A.websocket&&($.websocket={...A.websocket,onVersionMismatch:N=>{var U,L;B.value=!0,(L=(U=A.websocket)==null?void 0:U.onVersionMismatch)==null||L.call(U,N)},onConnectivityChange:N=>{var U,L;I.value=N,(L=(U=A.websocket)==null?void 0:U.onConnectivityChange)==null||L.call(U,N)}}),$}async function bo(A,$){const N=yi();A||(delete N.persistence,delete N.websocket),$&&(N.initialState=$),se=new Ve.CanvasStore(N);const U={...h.editor,user:w,plugins:hn(se),controls:h.controls},L=new k.Editor(A,U);return await L.initialize(),await se.initialize({components:L.components,singletons:L.singletons}),L}async function Et(A){A.nextTick($=>{se&&se.sync($),ET($),vT($);for(const N of C)N($)}),await A.tick()}async function qm(){!y.value||!se||(await Et(y.value),be=requestAnimationFrame(qm))}if(J(k.Camera.name,A=>{A&&(V.value=A)}),h.initialState&&typeof window>"u"){const A=([t,o]=a.withAsyncContext(()=>bo(null,h.initialState)),t=await t,o(),t);[t,o]=a.withAsyncContext(()=>Et(A)),await t,o(),[t,o]=a.withAsyncContext(()=>Et(A)),await t,o(),y.value=A}let Jm=null;a.onMounted(async()=>{var N,U,L;if(!g.value)return;Jm=()=>{var O;(O=g.value)==null||O.scrollTo(0,0)},g.value.addEventListener("scroll",Jm),y.value&&(y.value.dispose(),se==null||se.close(),se=null,ie=0);const A=await bo(g.value,h.initialState);if(y.value=A,P.value=!1,await(he==null?void 0:he.init()),he){const O=(Y,ne)=>{A.nextTick(oe=>{for(const vt of s.current(oe))if(k.Asset.read(oe,vt).identifier===Y){k.Asset.patch(oe,vt,{uploadState:ne});return}})};he.onUploadStart(Y=>O(Y,k.UploadState.Uploading)),he.onUploadComplete(Y=>O(Y,k.UploadState.Complete)),he.onUploadError(Y=>O(Y,k.UploadState.Failed))}await(he==null?void 0:he.resumePendingUploads()),be=requestAnimationFrame(qm);const $=(L=(U=(N=y.value)==null?void 0:N.fonts)==null?void 0:U[0])==null?void 0:L.name;$&&re.setDefaults("text",{fontFamily:$}),m("ready",y.value,se)}),a.onUnmounted(()=>{var A;be!==null&&cancelAnimationFrame(be),he==null||he.close(),se==null||se.close(),(A=y.value)==null||A.dispose()});function ET(A){const{events:$,newIndex:N}=A.eventBuffer.readEvents(ie);if(ie=N,$.length===0)return;const{componentsById:U,singletonsById:L}=k.getResources(A);for(const{entityId:O,eventType:Y,componentId:ne}of $){if(O===k.SINGLETON_ENTITY_ID){if(Y===k.EventType.CHANGED){const oe=L.get(ne);oe&&j(A,oe)}continue}if(Y===k.EventType.ADDED)b.add(O);else if(Y===k.EventType.REMOVED)b.delete(O),E.delete(O);else if(Y===k.EventType.COMPONENT_ADDED){b.add(O);const oe=U.get(ne);oe&&z(A,O,oe)}else if(Y===k.EventType.COMPONENT_REMOVED){const oe=U.get(ne);oe&&z(A,O,oe,!0)}else if(Y===k.EventType.CHANGED){const oe=U.get(ne);oe&&z(A,O,oe)}}}function vT(A){var U;let $=!1;for(const L of r.added(A)){const O=k.Block.snapshot(A,L),Y=(U=y.value)==null?void 0:U.blockDefs[O.tag],ne=(Y==null?void 0:Y.stratum)??"content";T.set(L,a.ref({entityId:L,block:O,stratum:ne,selected:!1,held:null,hovered:!1,edited:!1,opacity:null,connector:null})),$=!0}for(const L of r.removed(A))T.delete(L),$=!0;for(const L of r.changed(A)){const O=T.get(L);if(O){const Y=k.Block.snapshot(A,L);(O.value.block.rank!==Y.rank||O.value.block.parentId!==Y.parentId)&&($=!0),O.value.block=Y}}let N=!1;for(const L of p.addedOrChanged(A)){const O=k.User.snapshot(A,L);x.set(O.sessionId,O),N=!0}for(const L of p.removed(A)){const O=k.User.read(A,L);x.delete(O.sessionId),N=!0}N&&(S.value=Array.from(x.values()));for(const L of l.added(A)){const O=T.get(L);O&&!O.value.selected&&(O.value.selected=!0)}for(const L of l.removed(A)){const O=T.get(L);O!=null&&O.value.selected&&(O.value.selected=!1)}for(const L of c.addedOrChanged(A)){const O=T.get(L);O&&(O.value.held=k.Held.snapshot(A,L))}for(const L of c.removed(A)){const O=T.get(L);O&&O.value.held!==null&&(O.value.held=null)}for(const L of d.added(A)){const O=T.get(L);O&&!O.value.hovered&&(O.value.hovered=!0)}for(const L of d.removed(A)){const O=T.get(L);O!=null&&O.value.hovered&&(O.value.hovered=!1)}for(const L of u.added(A)){const O=T.get(L);O&&!O.value.edited&&(O.value.edited=!0)}for(const L of u.removed(A)){const O=T.get(L);O!=null&&O.value.edited&&(O.value.edited=!1)}for(const L of f.addedOrChanged(A)){const O=T.get(L);O&&(O.value.opacity=k.Opacity.snapshot(A,L))}for(const L of f.removed(A)){const O=T.get(L);O&&O.value.opacity!==null&&(O.value.opacity=null)}for(const L of i.addedOrChanged(A)){const O=T.get(L);O&&(O.value.connector=k.Connector.snapshot(A,L))}for(const L of i.removed(A)){const O=T.get(L);O&&O.value.connector!==null&&(O.value.connector=null)}if($){const L=Array.from(T.values()),O=Y=>{const ne=T.get(Y);if(!ne)return null;const oe=ne.value;return{rank:oe.block.rank,stratum:oe.stratum,parentId:oe.block.parentId}};L.sort((Y,ne)=>{const oe={rank:Y.value.block.rank,stratum:Y.value.stratum,parentId:Y.value.block.parentId},vt={rank:ne.value.block.rank,stratum:ne.value.stratum,parentId:ne.value.block.parentId};return k.compareBlockOrder(O,oe,vt)}),v.value=L}}function TT(A){const $=A.rotateZ!==0,N=A.flip[0],U=A.flip[1];if(!$&&!N&&!U)return;const L=[];return $&&L.push(`rotate(${A.rotateZ}rad)`),N&&L.push("scaleX(-1)"),U&&L.push("scaleY(-1)"),L.join(" ")}function Gm(A){const{held:$}=A;if(!$||!$.sessionId||$.sessionId===w.sessionId)return null;const N=X($.sessionId);return(N==null?void 0:N.color)??null}function ki(A,$,N,U){const L=A-U[0],O=$-U[1];if(N.rotateZ===0)return[L,O];const Y=N.size[0]/2,ne=N.size[1]/2,oe=L-Y,vt=O-ne,mr=Math.cos(-N.rotateZ),gr=Math.sin(-N.rotateZ);return[oe*mr-vt*gr+Y,oe*gr+vt*mr+ne]}function hc(A){let $=A.block.position[0],N=A.block.position[1],U=A.block.parentId;const L=new Set;for(;U!==null&&!L.has(U);){L.add(U);const O=T.get(U);if(!O)break;$+=O.value.block.position[0],N+=O.value.block.position[1],U=O.value.block.parentId}return[$,N]}function MT(A){var N,U;const $=(N=y.value)==null?void 0:N.blockDefs[A];return((U=$==null?void 0:$.components)==null?void 0:U.some(L=>L===k.Frame))??!1}function AT(A){let $=-1/0,N=-1/0,U=1/0,L=1/0,O=A.block.parentId;for(;O!==null;){const Y=T.get(O);if(!Y)break;if(MT(Y.value.block.tag)){const ne=Y.value.block,oe=hc(Y.value);$=Math.max($,oe[0]),N=Math.max(N,oe[1]),U=Math.min(U,oe[0]+ne.size[0]),L=Math.min(L,oe[1]+ne.size[1])}O=Y.value.block.parentId}return $===-1/0?null:[$,N,U,L]}function NT(A){const $=AT(A);if(!$)return;const[N,U,L,O]=$,Y=A.block,ne=hc(A);if(Y.rotateZ===0){const Zm=U-ne[1],eg=N-ne[0],tg=ne[1]+Y.size[1]-O,ng=ne[0]+Y.size[0]-L;return Zm<=0&&eg<=0&&tg<=0&&ng<=0?void 0:`inset(${Zm}px ${ng}px ${tg}px ${eg}px)`}const oe=ki(N,U,Y,ne),vt=ki(L,U,Y,ne),mr=ki(L,O,Y,ne),gr=ki(N,O,Y,ne);return`polygon(${oe[0]}px ${oe[1]}px, ${vt[0]}px ${vt[1]}px, ${mr[0]}px ${mr[1]}px, ${gr[0]}px ${gr[1]}px)`}function IT(A){const{block:$,stratum:N,opacity:U}=A,L=Gm(A),O=U!==null?U.value/255:1,Y=NT(A),ne=hc(A);return{position:"absolute",left:`${ne[0]}px`,top:`${ne[1]}px`,width:`${$.size[0]}px`,height:`${$.size[1]}px`,zIndex:k.STRATUM_ORDER[N]*1e3,transform:TT($),opacity:O,pointerEvents:"none",userSelect:"none","--wov-held-by-color":L??void 0,transition:O===1?"opacity 0ms 32ms":void 0,clipPath:Y}}return(A,$)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:g,class:"wov-root",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},[n.background?a.renderSlot(A.$slots,"background",{key:0,background:n.background},()=>[a.createVNode(Dp,{background:n.background},null,8,["background"])]):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"wov-canvas",style:a.normalizeStyle({position:"absolute",transformOrigin:"0 0",transform:`scale(${V.value.zoom}) translate(${-V.value.left}px, ${-V.value.top}px)`,"--wov-zoom":V.value.zoom})},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(v.value,N=>(a.openBlock(),a.createElementBlock("div",{key:N.value.entityId,"data-entity-id":N.value.entityId,style:a.normalizeStyle(IT(N.value)),"data-selected":N.value.selected||void 0,"data-held-by-other":Gm(N.value)!==null||void 0,"data-hovered":N.value.hovered||void 0,class:"wov-block"},[a.renderSlot(A.$slots,`block:${N.value.block.tag}`,a.mergeProps({ref_for:!0},N.value),()=>[N.value.block.tag==="selection-box"?(a.openBlock(),a.createBlock(AE,a.mergeProps({key:0,ref_for:!0},N.value),null,16)):N.value.block.tag==="transform-box"?(a.openBlock(),a.createBlock(IE,a.mergeProps({key:1,ref_for:!0},N.value),null,16)):N.value.block.tag==="transform-handle"?(a.openBlock(),a.createBlock(RE,a.mergeProps({key:2,ref_for:!0},N.value),null,16)):N.value.block.tag==="arrow-handle"?(a.openBlock(),a.createBlock(bc,a.mergeProps({key:3,ref_for:!0},N.value),null,16)):N.value.block.tag==="arrow-terminal"?(a.openBlock(),a.createBlock(Sc,a.mergeProps({key:4,ref_for:!0},N.value),null,16)):N.value.block.tag==="sticky-note"?(a.openBlock(),a.createBlock(PE,a.mergeProps({key:5,ref_for:!0},N.value),null,16)):N.value.block.tag==="eraser"?(a.openBlock(),a.createBlock($c,a.mergeProps({key:6,ref_for:!0},N.value),null,16)):N.value.block.tag==="pen-stroke"?(a.openBlock(),a.createBlock(Fc,a.mergeProps({key:7,ref_for:!0},N.value),null,16)):N.value.block.tag==="arc-arrow"?(a.openBlock(),a.createBlock(wc,a.mergeProps({key:8,ref_for:!0},N.value),null,16)):N.value.block.tag==="elbow-arrow"?(a.openBlock(),a.createBlock(xc,a.mergeProps({key:9,ref_for:!0},N.value),null,16)):N.value.block.tag==="text"?(a.openBlock(),a.createBlock(np,a.mergeProps({key:10,ref_for:!0},N.value),null,16)):N.value.block.tag==="image"?(a.openBlock(),a.createBlock(zc,a.mergeProps({key:11,ref_for:!0},N.value),null,16)):N.value.block.tag==="shape"?(a.openBlock(),a.createBlock(ep,a.mergeProps({key:12,ref_for:!0},N.value),null,16)):N.value.block.tag==="embed"?(a.openBlock(),a.createBlock(Cc,a.mergeProps({key:13,ref_for:!0},N.value),null,16)):N.value.block.tag==="tape"?(a.openBlock(),a.createBlock(tp,a.mergeProps({key:14,ref_for:!0},N.value),null,16)):N.value.block.tag==="frame"?(a.openBlock(),a.createBlock(DE,a.mergeProps({key:15,ref_for:!0},N.value),null,16)):a.createCommentVNode("",!0)])],12,ST))),128))],4),y.value?a.renderSlot(A.$slots,"user-cursors",{key:1,users:S.value,currentSessionId:a.unref(w).sessionId,camera:V.value},()=>[a.createVNode(mT,{users:S.value,"current-session-id":a.unref(w).sessionId,camera:V.value},null,8,["users","current-session-id","camera"])]):a.createCommentVNode("",!0),y.value?(a.openBlock(),a.createBlock(zp,{key:2},{default:a.withCtx(N=>[a.renderSlot(A.$slots,"floating-menu",a.normalizeProps(a.guardReactiveProps(N)))]),_:3})):a.createCommentVNode("",!0),y.value?a.renderSlot(A.$slots,"user-presence",{key:3,users:S.value},()=>[a.createVNode(tm,{users:S.value},null,8,["users"])]):a.createCommentVNode("",!0),y.value?a.renderSlot(A.$slots,"toolbar",{key:4},()=>[a.createVNode(em)]):a.createCommentVNode("",!0),y.value?a.renderSlot(A.$slots,"default",{key:5}):a.createCommentVNode("",!0),a.renderSlot(A.$slots,"offline-indicator",{isOnline:I.value},()=>[a.createVNode(yT,{"is-online":I.value},null,8,["is-online"])]),a.renderSlot(A.$slots,"version-mismatch",{versionMismatch:B.value},()=>[a.createVNode(wT,{"version-mismatch":B.value},null,8,["version-mismatch"])]),a.renderSlot(A.$slots,"back-to-content",{},()=>[a.createVNode(bT)]),a.renderSlot(A.$slots,"loading",{isLoading:P.value},()=>[a.createVNode(Fp,{"is-loading":P.value},null,8,["is-loading"])]),y.value?a.renderSlot(A.$slots,"file-drop-zone",{key:6},()=>[a.createVNode(Lp)]):a.createCommentVNode("",!0),y.value?(a.openBlock(),a.createBlock(dT,{key:7,options:h.copyPaste},null,8,["options"])):a.createCommentVNode("",!0),a.createVNode(Mp)],512))}}),CT=a.defineComponent({inheritAttrs:!1,__name:"WovenCanvas",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(a.Suspense,null,{default:a.withCtx(()=>[a.createVNode(xT,a.normalizeProps(a.guardReactiveProps(e.$attrs)),a.createSlots({_:2},[a.renderList(e.$slots,(o,r)=>({name:r,fn:a.withCtx(s=>[a.renderSlot(e.$slots,r,a.normalizeProps(a.guardReactiveProps(s??{})))])}))]),1040)]),_:3}))}});Object.defineProperty(R,"CanvasComponentDef",{enumerable:!0,get:()=>Ve.CanvasComponentDef}),Object.defineProperty(R,"CanvasSingletonDef",{enumerable:!0,get:()=>Ve.CanvasSingletonDef}),Object.defineProperty(R,"CanvasStore",{enumerable:!0,get:()=>Ve.CanvasStore}),Object.defineProperty(R,"Synced",{enumerable:!0,get:()=>Ve.Synced}),Object.defineProperty(R,"defineCanvasComponent",{enumerable:!0,get:()=>Ve.defineCanvasComponent}),Object.defineProperty(R,"defineCanvasSingleton",{enumerable:!0,get:()=>Ve.defineCanvasSingleton}),R.ARROW_HEADS=bi,R.ArcArrow=wc,R.ArcArrowTool=oE,R.ArrowHandle=bc,R.ArrowHead=Tt,R.ArrowHeadButton=Ma,R.ArrowTerminal=Sc,R.ArrowThicknessButton=Ep,R.CURSORS=Hp,R.CanvasBackground=Dp,R.ColorButton=Tp,R.ColorPicker=vp,R.CursorKind=cn,R.EDITING_PLUGIN_NAME=so,R.EditableText=js,R.EditingPlugin=Km,R.ElbowArrow=xc,R.ElbowArrowTool=Yp,R.EmbedBlock=Cc,R.EmbedTool=Qp,R.Eraser=$c,R.EraserTool=qp,R.FileDropZone=Lp,R.FloatingMenu=zp,R.FloatingMenuBar=$p,R.HandTool=Wp,R.IconChevronDown=Ge,R.ImageBlock=zc,R.ImageTool=Xp,R.LoadingOverlay=Fp,R.MenuButton=Ln,R.MenuDropdown=Je,R.MenuTooltip=Mp,R.PenStroke=Fc,R.PenStrokeThicknessButton=Ap,R.PenTool=Jp,R.SHAPES=xo,R.SelectTool=jp,R.ShapeBlock=ep,R.ShapeFillColorButton=Np,R.ShapeKindButton=Ip,R.ShapeStrokeColorButton=Bp,R.ShapeTool=Kp,R.StickyNoteTool=Up,R.TapeBlock=tp,R.TapeImageButton=Op,R.TapeTool=Zp,R.TextAlignmentButton=Aa,R.TextBlock=np,R.TextBoldButton=Na,R.TextColorButton=Da,R.TextFontFamilyButton=Ba,R.TextFontSizeButton=Oa,R.TextItalicButton=_a,R.TextLinkButton=Pa,R.TextTool=Gp,R.TextUnderlineButton=Ra,R.Toolbar=em,R.ToolbarButton=nt,R.UserPresence=tm,R.WOVEN_CANVAS_KEY=Se,R.WovenCanvas=CT,R.computeCommonComponents=Vp,R.getArrowHead=Hn,R.useComponent=me,R.useComponents=Vt,R.useEditorContext=fe,R.useFonts=Rp,R.useQuery=Gh,R.useSingleton=_e,R.useTextBatchController=Qh,R.useTextEditorController=On,R.useTextFormatting=lt,R.useTextStretchBehavior=ya,R.useToolbar=zs,R.useTooltipSingleton=$t,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
|