@woven-canvas/vue 0.1.14 → 0.1.15
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/README.md +1 -1
- package/build/components/CanvasBackground.vue.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/build/index.umd.cjs +1 -1
- package/package.json +9 -12
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasBackground.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasBackground.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CanvasBackground.vue.d.ts","sourceRoot":"","sources":["../../src/components/CanvasBackground.vue"],"names":[],"mappings":"AAoXA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,UAAU,KAAK;IACb,UAAU,EAAE,iBAAiB,CAAC;CAC/B;;AAmYD,wBAMG"}
|
package/build/index.js
CHANGED
|
@@ -30446,6 +30446,7 @@ const LD = { class: "wov-font-family-button" }, FD = { class: "wov-font-family-l
|
|
|
30446
30446
|
function u(g, v, y) {
|
|
30447
30447
|
if (!l) return null;
|
|
30448
30448
|
const w = y.dotSize ?? 2, k = g * y.subdivisionStep, b = v * y.subdivisionStep;
|
|
30449
|
+
if (k <= 0 || b <= 0) return null;
|
|
30449
30450
|
l.width = k, l.height = b;
|
|
30450
30451
|
const x = l.getContext("2d");
|
|
30451
30452
|
if (!x) return null;
|
|
@@ -30465,6 +30466,7 @@ const LD = { class: "wov-font-family-button" }, FD = { class: "wov-font-family-l
|
|
|
30465
30466
|
function f(g, v, y) {
|
|
30466
30467
|
if (!l) return null;
|
|
30467
30468
|
const w = y.gridSize ?? 1, k = g * y.subdivisionStep, b = v * y.subdivisionStep;
|
|
30469
|
+
if (k <= 0 || b <= 0) return null;
|
|
30468
30470
|
l.width = k, l.height = b;
|
|
30469
30471
|
const x = l.getContext("2d");
|
|
30470
30472
|
if (!x) return null;
|
package/build/index.umd.cjs
CHANGED
|
@@ -167,5 +167,5 @@ ${k}
|
|
|
167
167
|
`);l.push(f)}}),l.join(`
|
|
168
168
|
`)}function BN(t,e,n={}){const{state:r}=e,{doc:o,tr:s}=r,i=t;o.descendants((a,l)=>{const c=s.mapping.map(l),u=s.mapping.map(l)+a.nodeSize;let f=null;if(a.marks.forEach(m=>{if(m!==i)return!1;f=m}),!f)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,m)}}),s.docChanged&&e.view.dispatch(s)}var wd=class qk extends gd{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new qk(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function ma(t){return new hN({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const s=ke(t.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),f=n.from+l.indexOf(a),p=f+a.length;if(Vy(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(k=>k===t.type&&k!==g.mark.type)).filter(g=>g.to>f).length)return null;p<n.to&&i.delete(p,n.to),f>n.from&&i.delete(n.from+u,f),c=n.from+u+a.length,i.addMark(n.from+u,c,t.type.create(s||{})),i.removeStoredMark(t.type)}}})}function n0(t){return d.customRef((e,n)=>({get(){return e(),t},set(r){t=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})}}))}var ON=class extends SN{constructor(t={}){return super(t),this.contentComponent=null,this.appContext=null,this.reactiveState=n0(this.view.state),this.reactiveExtensionStorage=n0(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),d.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(t,e){const n=super.registerPlugin(t,e);return this.reactiveState&&(this.reactiveState.value=n),n}unregisterPlugin(t){const e=super.unregisterPlugin(t);return this.reactiveState&&e&&(this.reactiveState.value=e),e}},IN=d.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(t){const e=d.ref(),n=d.getCurrentInstance();return d.watchEffect(()=>{const r=t.editor;r&&r.options.element&&e.value&&d.nextTick(()=>{var o;if(!e.value||!((o=r.view.dom)!=null&&o.parentNode))return;const s=d.unref(e.value);e.value.append(...r.view.dom.parentNode.childNodes),r.contentComponent=n.ctx._,n&&(r.appContext={...n.appContext,provides:n.provides}),r.setOptions({element:s}),r.createNodeViews()})}),d.onBeforeUnmount(()=>{const r=t.editor;r&&(r.contentComponent=null,r.appContext=null)}),{rootEl:e}},render(){return d.h("div",{ref:t=>{this.rootEl=t}})}});d.defineComponent({name:"NodeViewContent",props:{as:{type:String,default:"div"}},render(){return d.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}}),d.defineComponent({name:"NodeViewWrapper",props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var t,e;return d.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(t=this.$slots).default)==null?void 0:e.call(t))}}),d.defineComponent({name:"MarkViewContent",props:{as:{type:String,default:"span"}},render(){return d.h(this.as,{style:{whiteSpace:"inherit"},"data-mark-view-content":""})}});var PN=wd.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
169
169
|
|
|
170
|
-
`):""}),r0=PN,o0=" ",RN=" ",DN=wd.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",vo(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===o0||r[0].text===RN)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?o0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),s0=DN,zN=wd.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),i0=zN,a0=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},$N=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VN=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,LN=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,FN=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jN=As.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return a0("strong",{...vo(this.options.HTMLAttributes,t),children:a0("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[pa({find:$N,type:this.type}),pa({find:LN,type:this.type})]},addPasteRules(){return[ma({find:VN,type:this.type}),ma({find:FN,type:this.type})]}}),l0=jN,HN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,WN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ZN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,UN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,KN=As.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",vo(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[pa({find:HN,type:this.type}),pa({find:ZN,type:this.type})]},addPasteRules(){return[ma({find:WN,type:this.type}),ma({find:UN,type:this.type})]}}),c0=KN,JN=As.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",vo(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const s=o[2].trim();return{type:"underline",raw:o[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),d0=JN,qN=be.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:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!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")}}}),u0=qN,GN=20,f0=(t,e=0)=>{const n=[];return!t.children.length||e>GN||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...f0(r,e+1))}),n},YN=t=>{if(!t.children.length)return;const e=f0(t);e&&e.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},vd=As.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&YN(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",vo(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),XN=be.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="background-color")return a.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),h0=be.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="color")return a.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),QN=be.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),eB=be.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),tB=be.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});be.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(XN.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(h0.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(QN.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(eB.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(tB.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(vd.configure(this.options.textStyle)),t}});var p0=h0;function nB(t={}){return new Oe({view(e){return new rB(e,t)}})}class rB{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let g=m.getBoundingClientRect(),y=f?g.bottom:g.top;f&&p&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*a;r={left:g.left,right:g.right,top:y-k,bottom:y+k}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*i;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),p=f.width/l.offsetWidth,m=f.height/l.offsetHeight;c=f.left-l.scrollLeft*p,u=f.top-l.scrollTop*m}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!s){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Om(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}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 xe extends ie{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return xe.valid(r)?new xe(r):ie.near(r)}content(){return L.empty}eq(e){return e instanceof xe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new xe(e.resolve(n.pos))}getBookmark(){return new bd(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!oB(e)||!sB(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&xe.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(n>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=n;let l=e.doc.resolve(o);if(xe.valid(l))return l}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!G.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*n),r=!1;continue e}break}s=i,o+=n;let a=e.doc.resolve(o);if(xe.valid(a))return a}return null}}}xe.prototype.visible=!1,xe.findFrom=xe.findGapCursorFrom,ie.jsonID("gapcursor",xe);class bd{constructor(e){this.pos=e}map(e){return new bd(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return xe.valid(n)?new xe(n):ie.near(n)}}function m0(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function oB(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||m0(o.type))return!0;if(o.inlineContent)return!1}}return!0}function sB(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||m0(o.type))return!0;if(o.inlineContent)return!1}}return!0}function iB(){return new Oe({props:{decorations:dB,createSelectionBetween(t,e,n){return e.pos==n.pos&&xe.valid(n)?new xe(n):null},handleClick:lB,handleKeyDown:aB,handleDOMEvents:{beforeinput:cB}}})}const aB=wy({ArrowLeft:ga("horiz",-1),ArrowRight:ga("horiz",1),ArrowUp:ga("vert",-1),ArrowDown:ga("vert",1)});function ga(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof re){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=xe.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new xe(c))),!0):!1}}function lB(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!xe.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&G.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new xe(r))),!0)}function cB(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof xe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=B.empty;for(let i=r.length-1;i>=0;i--)o=B.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new L(o,0,0));return s.setSelection(re.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function dB(t){if(!(t.selection instanceof xe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ce.create(t.doc,[nt.widget(t.selection.head,e,{key:"gapcursor"})])}var ya=200,$e=function(){};$e.prototype.append=function(e){return e.length?(e=$e.from(e),!this.length&&e||e.length<ya&&this.leafAppend(e)||this.length<ya&&e.leafPrepend(this)||this.appendInner(e)):this},$e.prototype.prepend=function(e){return e.length?$e.from(e).append(this):this},$e.prototype.appendInner=function(e){return new uB(this,e)},$e.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?$e.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},$e.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},$e.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)},$e.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},n,r),o},$e.from=function(e){return e instanceof $e?e:e&&e.length?new g0(e):$e.empty};var g0=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,a){for(var l=s;l<i;l++)if(o(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,a){for(var l=s-1;l>=i;l--)if(o(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=ya)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=ya)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}($e);$e.empty=new g0([]);var uB=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(s,a),i)===!1||s>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,s)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(s,a)-a,i+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(o,a),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}($e);const fB=500;class Ot{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;n&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){o||(o=this.remapping(r,p+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Jt(f.map));let m=f.step.map(o.slice(s)),g;m&&i.maybeStep(m).doc&&(g=i.mapping.maps[i.mapping.maps.length-1],c.push(new Jt(g,void 0,void 0,c.length+u.length))),s--,g&&o.appendMap(g,s)}else i.maybeStep(f.step);if(f.selection)return a=o?f.selection.map(o.slice(s)):f.selection,l=new Ot(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,n,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new Jt(e.mapping.maps[u],f,n),m;(m=l&&l.merge(p))&&(p=m,u?s.pop():a=a.slice(0,a.length-1)),s.push(p),n&&(i++,n=void 0),o||(l=p)}let c=i-r.depth;return c>pB&&(a=hB(a,c),i-=c),new Ot(a.append(s),i)}remapping(e,n){let r=new ds;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ot(this.items.append(e.map(n=>new Jt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},o);let l=n;this.items.forEach(p=>{let m=s.getMirror(--l);if(m==null)return;i=Math.min(i,m);let g=s.maps[m];if(p.step){let y=e.steps[m].invert(e.docs[m]),k=p.selection&&p.selection.map(s.slice(l+1,m));k&&a++,r.push(new Jt(g,y,k))}else r.push(new Jt(g))},o);let c=[];for(let p=n;p<i;p++)c.push(new Jt(s.maps[p]));let u=this.items.slice(0,o).append(c).append(r),f=new Ot(u,a);return f.emptyItemCount()>fB&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&s++;let f=new Jt(c.invert(),l,u),p,m=o.length-1;(p=o.length&&o[m].merge(f))?o[m]=p:o.push(f)}}else i.map&&r--},this.items.length,0),new Ot($e.from(o.reverse()),s)}}Ot.empty=new Ot($e.empty,0);function hB(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}class Jt{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Jt(n.getMap().invert(),n,this.selection)}}}class Hn{constructor(e,n,r,o,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const pB=20;function mB(t,e,n,r){let o=n.getMeta(Tr),s;if(o)return o.historyState;n.getMeta(kB)&&(t=new Hn(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Tr))return i.getMeta(Tr).redo?new Hn(t.done.addTransform(n,void 0,r,ka(e)),t.undone,y0(n.mapping.maps),t.prevTime,t.prevComposition):new Hn(t.done,t.undone.addTransform(n,void 0,r,ka(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!gB(n,t.prevRanges)),c=i?Sd(t.prevRanges,n.mapping):y0(n.mapping.maps);return new Hn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,ka(e)),Ot.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Hn(t.done.rebased(n,s),t.undone.rebased(n,s),Sd(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Hn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Sd(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function gB(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(n=!0)}),n}function y0(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,s,i)=>e.push(s,i));return e}function Sd(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),s=e.map(t[r+1],-1);o<=s&&n.push(o,s)}return n}function yB(t,e,n){let r=ka(e),o=Tr.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Hn(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(Tr,{redo:n,historyState:l})}let Cd=!1,k0=null;function ka(t){let e=t.plugins;if(k0!=e){Cd=!1,k0=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Cd=!0;break}}return Cd}const Tr=new Qe("history"),kB=new Qe("closeHistory");function wB(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Oe({key:Tr,state:{init(){return new Hn(Ot.empty,Ot.empty,null,0,-1)},apply(e,n,r){return mB(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?v0:r=="historyRedo"?b0:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function w0(t,e){return(n,r)=>{let o=Tr.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=yB(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const v0=w0(!1,!0),b0=w0(!0,!0);be.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Oe({key:new Qe("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),be.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[nB(this.options)]}}),be.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Oe({key:new Qe("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return Ce.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(nt.node(c,c+l.nodeSize,{class:this.options.className}))}),Ce.create(t,s)}}})]}}),be.create({name:"gapCursor",addProseMirrorPlugins(){return[iB()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ke(U(t,"allowGapCursor",n)))!=null?e:null}}});var S0="placeholder";function vB(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}be.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:S0,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${vB(this.options.dataAttribute)}`:`data-${S0}`;return[new Oe({key:new Qe("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,s=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((a,l)=>{const c=o>=l&&o<=l+a.nodeSize,u=!a.isLeaf&&ca(a);if((c||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=nt.node(l,l+a.nodeSize,{class:f.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(p)}return this.options.includeChildren}),Ce.create(e,s)}}})]}}),be.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Oe({key:new Qe("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||zA(n.selection)||t.view.dragging?null:Ce.create(n.doc,[nt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function C0({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}be.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Qe(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new Oe({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,u=e.getState(i),f=a.content.size,p=c.nodes[n];if(u)return l.insert(f,p.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!C0({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!C0({node:i,types:r})}}})]}});var bB=be.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>v0(t,e),redo:()=>({state:t,dispatch:e})=>b0(t,e)}},addProseMirrorPlugins(){return[wB(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()}}});function Wn(t,e){const n=d.inject(pt);if(!n)throw new Error("useComponents must be used within a WovenCanvas component");const r=d.shallowRef(new Map),o=new Map;function s(a){if(o.has(a))return;const l=n.getEditor();if(l){const u=l._getContext();if(h.hasComponent(u,a,e)){const f=new Map(r.value);f.set(a,e.snapshot(u,a)),r.value=f}else{const f=new Map(r.value);f.set(a,null),r.value=f}}const c=n.subscribeComponent(a,e.name,u=>{const f=new Map(r.value);f.set(a,u),r.value=f});o.set(a,c)}function i(a){const l=o.get(a);if(l){l(),o.delete(a);const c=new Map(r.value);c.delete(a),r.value=c}}return d.watch(()=>d.toValue(t),(a,l)=>{const c=new Set(a),u=new Set(l??[]);for(const f of u)c.has(f)||i(f);for(const f of c)u.has(f)||s(f)},{immediate:!0}),d.onUnmounted(()=>{for(const a of o.values())a();o.clear()}),r}function x0(){const t=d.inject(pt);if(!t)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=Ee();function n(s){return new Promise((i,a)=>{const l=new window.Image;l.onload=()=>{i({width:l.naturalWidth,height:l.naturalHeight}),URL.revokeObjectURL(l.src)},l.onerror=()=>{a(new Error("Failed to load image")),URL.revokeObjectURL(l.src)},l.src=URL.createObjectURL(s)})}async function r(s,i,a,l={}){const{maxSize:c=400}=l,u=await n(s),f=await e(),p=Math.min(1,c/Math.max(u.width,u.height));let m=Math.round(u.width*p),g=Math.round(u.height*p);const y=h.Grid.read(f);y.enabled&&(m=Math.max(y.colWidth,Math.round(m/y.colWidth)*y.colWidth),g=Math.max(y.rowHeight,Math.round(g/y.rowHeight)*y.rowHeight));const k=h.createEntity(f);h.addComponent(f,k,h.Block);const w=h.Block.write(f,k);w.tag="image",w.position[0]=i-m/2,w.position[1]=a-g/2,w.size[0]=m,w.size[1]=g,h.Grid.snapPosition(f,w.position);const v=crypto.randomUUID();h.addComponent(f,k,h.Asset);const b=h.Asset.write(f,k);b.identifier=v,b.uploadState=h.UploadState.Pending,h.addComponent(f,k,h.Image);const S=h.Image.write(f,k);return S.width=u.width,S.height=u.height,S.alt=s.name,h.addComponent(f,k,at.Synced,{id:crypto.randomUUID()}),(t==null?void 0:t.getAssetManager())&&o(k,v,s),k}async function o(s,i,a){const l=t==null?void 0:t.getAssetManager();if(l)try{await l.upload(i,a,{filename:a.name,mimeType:a.type});const c=await e(),u=h.Asset.write(c,s);u.uploadState=h.UploadState.Complete}catch{const c=await e(),u=h.Asset.write(c,s);u.uploadState=h.UploadState.Failed}}return{getImageDimensions:n,createImageBlock:r}}function _0(t){const e=d.inject(pt);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const n=d.shallowRef([]),r=h.defineQuery(f=>f.with(...t)),o=new Map;let s=!1;function i(f){const p=e.getEditor();if(!p)return{refs:{},unsubscribes:[]};const m=p._getContext(),g={},y=[];for(const k of t){const w=d.shallowRef(k.snapshot(m,f));g[k.name]=w;const v=e.subscribeComponent(f,k.name,b=>{w.value=b});y.push(v)}return{refs:g,unsubscribes:y}}function a(f){const p=o.get(f);if(p){for(const m of p.unsubscribes)m();o.delete(f)}}function l(){const f=[];for(const[p,m]of o)f.push({entityId:p,...m.refs});return f}function c(f){if(!s){const y=r.current(f);for(const k of y)o.set(k,i(k));n.value=l(),s=!0;return}const p=r.added(f),m=r.removed(f);let g=!1;for(const y of m)a(y),g=!0;for(const y of p)o.has(y)||(o.set(y,i(y)),g=!0);g&&(n.value=l())}const u=e.registerTickCallback(c);return d.onUnmounted(()=>{u();for(const f of o.keys())a(f)}),n}function Ze(t){const e=d.inject(pt);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const n=d.shallowRef(t.default()),r=e.getEditor();if(r){const i=r._getContext();n.value=t.snapshot(i)}const o=e.subscribeSingleton(t.name,i=>{n.value=i??{}});let s=null;return r||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const a=i._getContext();n.value=t.snapshot(a),s==null||s(),s=null}})),d.onUnmounted(()=>{o(),s==null||s()}),n}function xd(t,e,n){if(!t.closest(".wov-block")){const m=t.getBoundingClientRect();return{width:m.width,height:m.height,left:0,top:0}}const o=t.getBoundingClientRect(),s=n.value.left,i=n.value.top,a=new DOMPoint(o.left+o.width/2-s,o.top+o.height/2-i),l=e.value.zoom,c=new DOMMatrix;c.translateSelf(-e.value.left*l,-e.value.top*l),c.scaleSelf(l,l),c.invertSelf();const u=c.transformPoint(a),f=t.offsetWidth,p=t.offsetHeight;return{width:f,height:p,left:u.x-f/2,top:u.y-p/2}}function E0(t){if(t.startsWith("#"))return t.toUpperCase();const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const n=parseInt(e[1],10).toString(16).padStart(2,"0"),r=parseInt(e[2],10).toString(16).padStart(2,"0"),o=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`.toUpperCase()}return t}function Ns(t){const e=Math.round(t.red),n=Math.round(t.green),r=Math.round(t.blue),o=Math.round(t.alpha);return o<255?"#"+[e,n,r,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,n,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function _d(t){t=t.replace(/^#/,"");let e,n,r,o=255;if(t.length===6)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);else if(t.length===8)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16),o=parseInt(t.slice(6,8),16);else return null;return{red:e,green:n,blue:r,alpha:o}}function T0(t){const e=_d(t);if(!e)return{h:0,s:100,v:100,a:255};const n=e.red/255,r=e.green/255,o=e.blue/255,s=Math.max(n,r,o),i=Math.min(n,r,o),a=s-i;let l=0;const c=s===0?0:a/s*100,u=s*100;if(a!==0)switch(s){case n:l=((r-o)/a+(r<o?6:0))*60;break;case r:l=((o-n)/a+2)*60;break;case o:l=((n-r)/a+4)*60;break}return{h:l,s:c,v:u,a:e.alpha}}function M0(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const p=m=>Math.round(m*255).toString(16).padStart(2,"0");return`#${p(o)}${p(s)}${p(i)}`}function A0(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const p=g=>Math.round(g*255).toString(16).padStart(2,"0"),m=Math.round(t.a).toString(16).padStart(2,"0");return t.a<255?`#${p(o)}${p(s)}${p(i)}${m}`:`#${p(o)}${p(s)}${p(i)}`}const st=d.shallowRef(null),Ed=d.shallowRef(null),Td=d.shallowRef(null),Zn=d.ref(0);function Bs(){const t={hasEditor:d.computed(()=>st.value!==null),isBold:d.computed(()=>{var o;return Zn.value,((o=st.value)==null?void 0:o.isActive("bold"))??!1}),isItalic:d.computed(()=>{var o;return Zn.value,((o=st.value)==null?void 0:o.isActive("italic"))??!1}),isUnderline:d.computed(()=>{var o;return Zn.value,((o=st.value)==null?void 0:o.isActive("underline"))??!1}),alignment:d.computed(()=>{Zn.value;const o=st.value;return o?o.isActive({textAlign:"center"})?"center":o.isActive({textAlign:"right"})?"right":o.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:d.computed(()=>{Zn.value;const o=st.value;if(!o)return null;const i=o.getAttributes("textStyle").color??null;return i?E0(i):null})},e={toggleBold(){const o=st.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleBold(),a&&(l=l.setTextSelection(i)),l.run()},toggleItalic(){const o=st.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleItalic(),a&&(l=l.setTextSelection(i)),l.run()},toggleUnderline(){const o=st.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleUnderline(),a&&(l=l.setTextSelection(i)),l.run()},setAlignment(o){const s=st.value;s&&s.chain().selectAll().setTextAlign(o).run()},setColor(o){const s=st.value;if(!s)return;const{from:i,to:a}=s.state.selection;i===a?s.chain().focus().selectAll().setColor(o).setTextSelection(a).run():s.chain().focus().setColor(o).run()}};function n(o,s,i){st.value=o,Td.value=s,Ed.value=i,o.on("selectionUpdate",()=>{Zn.value++}),o.on("transaction",()=>{Zn.value++})}function r(){st.value=null,Td.value=null,Ed.value=null}return{editor:st,blockElement:Ed,textElement:Td,state:t,commands:e,updateCounter:Zn,register:n,unregister:r}}const vt=[r0,s0,i0,vd,p0,l0,c0,d0,u0.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function SB(t){return t.type==="text"&&typeof t.text=="string"}function Mr(t,e){if(SB(t)){e(t);return}if(t.content)for(const n of t.content)Mr(n,e)}function Md(t,e){if(t.type==="paragraph"){e(t);return}if(t.content)for(const n of t.content)Md(n,e)}function CB(t,e){var n;return((n=t.marks)==null?void 0:n.some(r=>r.type===e))??!1}function xB(t){var r,o;const e=(r=t.marks)==null?void 0:r.find(s=>s.type==="textStyle"),n=((o=e==null?void 0:e.attrs)==null?void 0:o.color)??null;return n?E0(n):null}function _B(t,e){if(!t.trim())return!1;const n=jn(t,vt);let r=!1,o=!0,s=0;return Mr(n,i=>{s++,CB(i,e)?r=!0:o=!1}),s===0?!1:o?!0:r?null:!1}function EB(t){if(!t.trim())return"left";const e=jn(t,vt);let n="left";return Md(e,r=>{var s;const o=(s=r.attrs)==null?void 0:s.textAlign;o&&(n=o)}),n}function TB(t){if(!t.trim())return null;const e=jn(t,vt);let n=null;return Mr(e,r=>{n===null&&(n=xB(r))}),n}function Ad(t,e){if(!t.trim())return t;const n=jn(t,vt);return Mr(n,r=>{const o=r.marks??[];o.findIndex(i=>i.type===e)===-1&&(r.marks=[...o,{type:e}])}),aa(n,vt)}function Nd(t,e){if(!t.trim())return t;const n=jn(t,vt);return Mr(n,r=>{const o=r.marks??[];r.marks=o.filter(s=>s.type!==e)}),aa(n,vt)}function MB(t,e){if(!t.trim())return t;const n=jn(t,vt);return Md(n,r=>{r.attrs={...r.attrs,textAlign:e}}),aa(n,vt)}function AB(t,e){if(!t.trim())return t;const n=jn(t,vt);return Mr(n,r=>{const o=r.marks??[],s=o.findIndex(i=>i.type==="textStyle");s!==-1?(o[s]={...o[s],attrs:{...o[s].attrs,color:e}},r.marks=o):r.marks=[...o,{type:"textStyle",attrs:{color:e}}]}),aa(n,vt)}function N0(t){const e=document.querySelector(`[data-entity-id="${t}"]`);if(!e)return null;const n=e.firstElementChild;return n||e.querySelector(".wov-editable-text")}function B0(t,e,n,r){var l;const o=t.cloneNode(!0);o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none",o.style.top="0",o.style.left="0";const s=o.classList.contains("wov-editable-text")?o:o.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${r.fontSizePx}px`,s.style.fontFamily=r.fontFamily);const i=o.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=r.content:s?s.innerHTML=r.content:o.innerHTML=r.content,(l=t.parentElement)==null||l.appendChild(o);const a=xd(o,e,n);return o.remove(),a}function O0(t){const{nextEditorTick:e}=Ee(),n=Wn(t,h.Text),r=Ze(h.Camera),o=Ze(h.Screen),s=Bs(),i={hasTextEntities:d.computed(()=>{for(const p of n.value.values())if(p)return!0;return!1}),hasTextContent:d.computed(()=>{for(const p of n.value.values()){if(!p)continue;const m=p.content?jn(p.content,vt):null;if(m){let g=!1;if(Mr(m,y=>{var k;(k=y.text)!=null&&k.trim()&&(g=!0)}),g)return!0}}return!1}),isBold:d.computed(()=>a("bold")),isItalic:d.computed(()=>a("italic")),isUnderline:d.computed(()=>a("underline")),alignment:d.computed(()=>{let p=null;for(const m of n.value.values()){if(!m)continue;const g=EB(m.content);if(p===null)p=g;else if(p!==g)return null}return p??"left"}),color:d.computed(()=>{let p=null,m=!1;for(const g of n.value.values()){if(!g)continue;const y=TB(g.content);if(!m)p=y,m=!0;else if(p!==y)return null}return p}),fontSize:d.computed(()=>{let p=null,m=!1;for(const g of n.value.values())if(g){if(!m)p=g.fontSizePx,m=!0;else if(p!==g.fontSizePx)return null}return p}),fontFamily:d.computed(()=>{let p=null,m=!1;for(const g of n.value.values())if(g){if(!m)p=g.fontFamily,m=!0;else if(p!==g.fontFamily)return null}return p})};function a(p){let m=null,g=!1;for(const y of n.value.values()){if(!y)continue;const k=_B(y.content,p);if(!g)m=k,g=!0;else if(m!==k)return null}return m}const l={toggleBold(){u(p=>i.isBold.value?Nd(p,"bold"):Ad(p,"bold"))},toggleItalic(){u(p=>i.isItalic.value?Nd(p,"italic"):Ad(p,"italic"))},toggleUnderline(){u(p=>i.isUnderline.value?Nd(p,"underline"):Ad(p,"underline"))},setAlignment(p){f(m=>MB(m,p))},setColor(p){f(m=>AB(m,p))},setFontSize(p){c(m=>({...m,fontSizePx:p}),m=>{m.fontSizePx=p})},setFontFamily(p){c(m=>({...m,fontFamily:p}),m=>{m.fontFamily=p})}};function c(p,m){const g=d.toValue(t),y=[];for(const k of g){const w=n.value.get(k);if(!w)continue;const v=N0(k);if(v){const b=B0(v,r,o,p(w));y.push({entityId:k,...b})}}e(k=>{for(const w of g)m(h.Text.write(k,w));for(const{entityId:w,width:v,height:b,left:S,top:C}of y){const _=h.Block.write(k,w);_.size=[v,b],_.position=[S,C]}d.nextTick(()=>{s.updateCounter.value++})})}function u(p){const m=d.toValue(t),g=[];for(const y of m){const k=n.value.get(y);if(!k)continue;const w=p(k.content),v=N0(y);if(v){const b=B0(v,r,o,{...k,content:w});g.push({entityId:y,content:w,...b})}else g.push({entityId:y,content:w,width:0,height:0,left:0,top:0})}e(y=>{for(const{entityId:k,content:w,width:v,height:b,left:S,top:C}of g){const _=h.Text.write(y,k);if(_.content=w,v>0&&b>0){const x=h.Block.write(y,k);x.size=[v,b],x.position=[S,C]}}})}function f(p){const m=d.toValue(t);e(g=>{for(const y of m){const k=h.Text.write(g,y);k.content=p(k.content)}})}return{state:i,commands:l}}function qt(t){const e=Bs(),n=O0(t),r=e.state.hasEditor;return{state:d.reactive({hasTextToFormat:d.computed(()=>r.value||n.state.hasTextEntities.value),hasEditor:r,hasTextContent:d.computed(()=>n.state.hasTextContent.value),showTextMenuButtons:d.computed(()=>r.value||n.state.hasTextContent.value),isBold:d.computed(()=>r.value?e.state.isBold.value:n.state.isBold.value===!0),isItalic:d.computed(()=>r.value?e.state.isItalic.value:n.state.isItalic.value===!0),isUnderline:d.computed(()=>r.value?e.state.isUnderline.value:n.state.isUnderline.value===!0),alignment:d.computed(()=>r.value?e.state.alignment.value:n.state.alignment.value??"left"),color:d.computed(()=>r.value?e.state.color.value:n.state.color.value),fontSize:d.computed(()=>n.state.fontSize.value),fontFamily:d.computed(()=>n.state.fontFamily.value)}),commands:{toggleBold(){r.value?e.commands.toggleBold():n.commands.toggleBold()},toggleItalic(){r.value?e.commands.toggleItalic():n.commands.toggleItalic()},toggleUnderline(){r.value?e.commands.toggleUnderline():n.commands.toggleUnderline()},setAlignment(i){r.value?e.commands.setAlignment(i):n.commands.setAlignment(i)},setColor(i){r.value?e.commands.setColor(i):n.commands.setColor(i)},setFontSize(i){n.commands.setFontSize(i)},setFontFamily(i){n.commands.setFontFamily(i)}}}}function Bd(t){const e=Ze(h.Camera),n=Ze(h.Screen),r=Ze(xl),o=Ze(Tt),{nextEditorTick:s}=Ee();let i=!1,a=null;function l(u,f){const{entityId:p}=d.toValue(t.blockData),m=d.toValue(t.minWidth)??0,g=d.toValue(t.minHeight)??0,y=Math.max(f.width,m),k=Math.max(f.height,g),w=h.Block.read(u,p),v=Math.abs(w.size[0]-y)>.5,b=Math.abs(w.size[1]-k)>.5;if(!v&&!b)return;const S=h.Block.write(u,p);S.size=[y,k],S.position=[f.left,f.top],r.value.transformBoxId!==null&&vl.spawn(u,{transformBoxId:r.value.transformBoxId})}d.watch(()=>o.value,()=>{s(u=>{const f=NB(u);if(i&&!f){const p=t.containerRef.value;if(!p)return;a=xd(p,e,n),l(u,a),a=null}i=f})},{flush:"sync"});function c(u){const{content:f,...p}=u;s(m=>{const{entityId:g}=d.toValue(t.blockData);if(h.Text.read(m,g).content!==f){const k=h.Text.write(m,g);k.content=f}l(m,p)})}return{handleEditEnd:c}}function NB(t){const e=Tt.read(t);return e.state===de.Dragging&&e.draggedEntity!==null&&h.hasComponent(t,e.draggedEntity,ve)&&ve.read(t,e.draggedEntity).kind===Et.Stretch}function Od(){const t=d.inject(Ul);if(!t)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:t.activeTool,heldTool:t.heldTool,setTool:t.setTool,dragOutTool:t.dragOutTool,onToolPointerDown:t.onToolPointerDown,onToolPointerUp:t.onToolPointerUp,isActive:e=>d.computed(()=>t.activeTool.value===e)}}const BB=500,OB=1500;function I0(){const t=d.ref(null),e=d.ref(!1),n=d.ref(!1);let r=null,o=null;function s(){r&&(clearTimeout(r),r=null),o&&(clearTimeout(o),o=null)}function i(c,u){s(),t.value={text:c,anchor:u},n.value?e.value=!0:r=setTimeout(()=>{e.value=!0,n.value=!0,r=null},BB)}function a(){s(),e.value=!1,t.value=null,n.value&&(o=setTimeout(()=>{n.value=!1,o=null},OB))}function l(){s(),e.value=!1,t.value=null,n.value=!1}return{activeTooltip:d.readonly(t),isVisible:d.readonly(e),isWarmedUp:d.readonly(n),show:i,hide:a,reset:l}}function Un(){const t=d.inject(yh);if(!t)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return t}const IB={key:1},PB=["innerHTML"],RB=50,DB=300,wa=d.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(t,{expose:e,emit:n}){var C;const r=t,o=n,s=Pe(r.entityId,h.Text),i=Ze(h.Camera),a=Ze(h.Screen),l=Bs(),{nextEditorTick:c}=Ee(),u=Ze(h.Mouse),f=d.ref(null);e({editableTextRef:f});const p=d.ref(((C=s.value)==null?void 0:C.content)??""),m=d.shallowRef(null);function g(_,x){var I;const T=s.value;return!T||T.constrainWidth||(((I=x.clipboardData)==null?void 0:I.getData("text/plain"))??"").length>RB&&c(V=>{const K=h.Text.write(V,r.entityId);K.constrainWidth=!0;const M=h.Block.read(V,r.entityId),$=Math.max(M.size[0],DB),Z=h.Block.write(V,r.entityId);Z.size=[$,M.size[1]],h.ResetKeyboard.spawn(V),Xr.spawn(V)}),!1}function y(){var _,x;return new ON({extensions:[r0,s0,i0,vd,p0,l0,c0,d0,u0.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((_=s.value)==null?void 0:_.defaultAlignment)??"left"}),bB],content:((x=s.value)==null?void 0:x.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:g}})}d.watch(()=>r.edited,async _=>{if(_&&f.value){if(m.value=y(),await k(m.value),!r.blockElement)return;l.register(m.value,f.value,r.blockElement)}else m.value&&(l.unregister(),w(m.value),m.value.destroy(),m.value=null)},{immediate:!0});async function k(_){var I;const x=(I=u.value)==null?void 0:I.position,T=a.value;await d.nextTick(),await new Promise(V=>requestAnimationFrame(V));const N=f.value;if(x&&T&&N){const V=x[0]+T.left,K=x[1]+T.top,M=_.view.posAtCoords({left:V,top:K});if(M){_.chain().focus().setTextSelection(M.pos).run();return}}_.commands.focus("start")}function w(_){let x=_.getHTML();const N=x.replace(/<[^>]*>/g,"").trim().length>0;N||(x=""),p.value=x,c(I=>{var Z,ae;const V=h.getBlockDef(I,r.block.tag);if(!N&&((Z=V.editOptions)!=null&&Z.removeWhenTextEmpty)){h.removeEntity(I,r.entityId);return}const K=(ae=f.value)==null?void 0:ae.closest(".wov-block"),M=(K==null?void 0:K.firstElementChild)??f.value;if(!M){console.warn("EditableText: no element to measure");return}const $=xd(M,i,a);o("editEnd",{content:x,...$})})}d.watch(()=>{var _;return(_=s.value)==null?void 0:_.content},_=>{_!==void 0&&(m.value?m.value.getHTML()!==_&&m.value.commands.setContent(_,{emitUpdate:!1}):p.value=_)});const v=d.computed(()=>{const _=s.value;if(!_)return{};const[x,T]=r.block.flip,N=x?-1:1,I=T?-1:1,V=x||T;return{fontFamily:_.fontFamily,fontSize:`${_.fontSizePx}px`,lineHeight:_.lineHeight,letterSpacing:`${_.letterSpacingEm}em`,width:_.constrainWidth?"100%":"fit-content",whiteSpace:_.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:r.edited?"auto":"none",userSelect:r.edited?"auto":"none",transform:V?`scale(${N}, ${I})`:void 0}});function b(_){_.key==="Control"||_.key==="Meta"||_.stopPropagation()}function S(_){r.edited&&_.stopPropagation()}return d.onUnmounted(()=>{m.value&&(l.unregister(),m.value.destroy(),m.value=null)}),(_,x)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:d.normalizeStyle(v.value),onKeydown:b,onPointerdown:S,onPointermove:S,onPointerup:S},[m.value?(d.openBlock(),d.createBlock(d.unref(IN),{key:0,editor:m.value},null,8,["editor"])):(d.openBlock(),d.createElementBlock("div",IB,[d.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:p.value},null,8,PB)]))],36))}}),zB={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},$B=["d","fill","stroke","stroke-width","stroke-dasharray"],P0=d.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Pe(e.entityId,h.Shape),r=Pe(e.entityId,h.VerticalAlign),o=d.ref(null),s={[h.VerticalAlignment.Top]:"flex-start",[h.VerticalAlignment.Center]:"center",[h.VerticalAlignment.Bottom]:"flex-end"},i=d.computed(()=>n.value?`rgba(${n.value.fillRed}, ${n.value.fillGreen}, ${n.value.fillBlue}, ${(n.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),a=d.computed(()=>n.value?n.value.strokeKind===h.StrokeKind.None?"none":`rgba(${n.value.strokeRed}, ${n.value.strokeGreen}, ${n.value.strokeBlue}, ${n.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),l=d.computed(()=>{var y;return((y=n.value)==null?void 0:y.strokeWidth)??2}),c=d.computed(()=>{var y;return((y=n.value)==null?void 0:y.strokeKind)??h.StrokeKind.Solid}),u=d.computed(()=>{var y;return ss[((y=n.value)==null?void 0:y.kind)??"rectangle"]??ss.rectangle}),f=d.computed(()=>{const y=l.value;switch(c.value){case h.StrokeKind.Dashed:return`${y*3} ${y*3}`;case h.StrokeKind.None:return"";case h.StrokeKind.Solid:default:return""}}),p=d.computed(()=>{var y;return{overflow:e.edited?"visible":"hidden",alignItems:s[((y=r.value)==null?void 0:y.value)??h.VerticalAlignment.Top]}}),{nextEditorTick:m}=Ee();function g(y){m(k=>{if(h.Text.read(k,e.entityId).content===y.content)return;const v=h.Text.write(k,e.entityId);v.content=y.content})}return(y,k)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-shape-block"},[(d.openBlock(),d.createElementBlock("svg",zB,[d.createElementVNode("path",{d:u.value,fill:i.value,stroke:a.value,"stroke-width":l.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,$B)])),d.createElementVNode("div",{class:"wov-shape-content",style:d.normalizeStyle(p.value)},[d.createVNode(wa,d.mergeProps(e,{"block-element":o.value,onEditEnd:g}),null,16,["block-element"])],4)],512))}}),VB=["data-text-empty"],R0=d.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=d.ref(null),r=Pe(e.entityId,h.Text),o=d.computed(()=>{var c;return(((c=r.value)==null?void 0:c.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),s=d.computed(()=>{var a;return((a=r.value)==null?void 0:a.constrainWidth)??!1}),{handleEditEnd:i}=Bd({blockData:e,containerRef:n});return(a,l)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:n,class:"wov-text-block","data-text-empty":o.value||void 0,style:d.normalizeStyle({width:s.value?"100%":"fit-content"})},[d.createVNode(wa,d.mergeProps(e,{"block-element":n.value,onEditEnd:d.unref(i)}),null,16,["block-element","onEditEnd"])],12,VB))}}),va=Math.min,Ar=Math.max,ba=Math.round,Sa=Math.floor,Gt=t=>({x:t,y:t}),LB={left:"right",right:"left",bottom:"top",top:"bottom"},FB={start:"end",end:"start"};function D0(t,e,n){return Ar(t,va(e,n))}function Ca(t,e){return typeof t=="function"?t(e):t}function Nr(t){return t.split("-")[0]}function xa(t){return t.split("-")[1]}function z0(t){return t==="x"?"y":"x"}function $0(t){return t==="y"?"height":"width"}const jB=new Set(["top","bottom"]);function Kn(t){return jB.has(Nr(t))?"y":"x"}function V0(t){return z0(Kn(t))}function HB(t,e,n){n===void 0&&(n=!1);const r=xa(t),o=V0(t),s=$0(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=_a(i)),[i,_a(i)]}function WB(t){const e=_a(t);return[Id(t),e,Id(e)]}function Id(t){return t.replace(/start|end/g,e=>FB[e])}const L0=["left","right"],F0=["right","left"],ZB=["top","bottom"],UB=["bottom","top"];function KB(t,e,n){switch(t){case"top":case"bottom":return n?e?F0:L0:e?L0:F0;case"left":case"right":return e?ZB:UB;default:return[]}}function JB(t,e,n,r){const o=xa(t);let s=KB(Nr(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(Id)))),s}function _a(t){return t.replace(/left|right|bottom|top/g,e=>LB[e])}function qB(t){return{top:0,right:0,bottom:0,left:0,...t}}function GB(t){return typeof t!="number"?qB(t):{top:t,right:t,bottom:t,left:t}}function Ea(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function j0(t,e,n){let{reference:r,floating:o}=t;const s=Kn(e),i=V0(e),a=$0(i),l=Nr(e),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(l){case"top":m={x:u,y:r.y-o.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(xa(e)){case"start":m[i]-=p*(n&&c?-1:1);break;case"end":m[i]+=p*(n&&c?-1:1);break}return m}async function YB(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=Ca(e,t),g=GB(m),k=a[p?f==="floating"?"reference":"floating":f],w=Ea(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},C=Ea(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(w.top-C.top+g.top)/S.y,bottom:(C.bottom-w.bottom+g.bottom)/S.y,left:(w.left-C.left+g.left)/S.x,right:(C.right-w.right+g.right)/S.x}}const XB=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:f}=j0(c,r,l),p=r,m={},g=0;for(let k=0;k<a.length;k++){var y;const{name:w,fn:v}=a[k],{x:b,y:S,data:C,reset:_}=await v({x:u,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:c,platform:{...i,detectOverflow:(y=i.detectOverflow)!=null?y:YB},elements:{reference:t,floating:e}});u=b??u,f=S??f,m={...m,[w]:{...m[w],...C}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(c=_.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):_.rects),{x:u,y:f}=j0(c,p,l)),k=-1)}return{x:u,y:f,placement:p,strategy:o,middlewareData:m}},QB=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...k}=Ca(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=Nr(o),v=Kn(a),b=Nr(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=p||(b||!y?[_a(a)]:WB(a)),_=g!=="none";!p&&_&&C.push(...JB(a,y,g,S));const x=[a,...C],T=await l.detectOverflow(e,k),N=[];let I=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&N.push(T[w]),f){const $=HB(o,i,S);N.push(T[$[0]],T[$[1]])}if(I=[...I,{placement:o,overflows:N}],!N.every($=>$<=0)){var V,K;const $=(((V=s.flip)==null?void 0:V.index)||0)+1,Z=x[$];if(Z&&(!(f==="alignment"?v!==Kn(Z):!1)||I.every(j=>Kn(j.placement)===v?j.overflows[0]>0:!0)))return{data:{index:$,overflows:I},reset:{placement:Z}};let ae=(K=I.filter(X=>X.overflows[0]<=0).sort((X,j)=>X.overflows[1]-j.overflows[1])[0])==null?void 0:K.placement;if(!ae)switch(m){case"bestFit":{var M;const X=(M=I.filter(j=>{if(_){const q=Kn(j.placement);return q===v||q==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(q=>q>0).reduce((q,te)=>q+te,0)]).sort((j,q)=>j[1]-q[1])[0])==null?void 0:M[0];X&&(ae=X);break}case"initialPlacement":ae=a;break}if(o!==ae)return{reset:{placement:ae}}}return{}}}},eO=new Set(["left","top"]);async function tO(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Nr(n),a=xa(n),l=Kn(n)==="y",c=eO.has(i)?-1:1,u=s&&l?-1:1,f=Ca(e,t);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),l?{x:m*u,y:p*c}:{x:p*c,y:m*u}}const nO=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await tO(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},rO=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:v,y:b}=w;return{x:v,y:b}}},...c}=Ca(t,e),u={x:n,y:r},f=await s.detectOverflow(e,c),p=Kn(Nr(o)),m=z0(p);let g=u[m],y=u[p];if(i){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",b=g+f[w],S=g-f[v];g=D0(b,g,S)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",b=y+f[w],S=y-f[v];y=D0(b,y,S)}const k=l.fn({...e,[m]:g,[p]:y});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[m]:i,[p]:a}}}}}};function Ta(){return typeof window<"u"}function Br(t){return Pd(t)?(t.nodeName||"").toLowerCase():"#document"}function ut(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Yt(t){var e;return(e=(Pd(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Pd(t){return Ta()?t instanceof Node||t instanceof ut(t).Node:!1}function It(t){return Ta()?t instanceof Element||t instanceof ut(t).Element:!1}function Xt(t){return Ta()?t instanceof HTMLElement||t instanceof ut(t).HTMLElement:!1}function H0(t){return!Ta()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ut(t).ShadowRoot}const oO=new Set(["inline","contents"]);function Os(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=Pt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!oO.has(o)}const sO=new Set(["table","td","th"]);function iO(t){return sO.has(Br(t))}const aO=[":popover-open",":modal"];function Ma(t){return aO.some(e=>{try{return t.matches(e)}catch{return!1}})}const lO=["transform","translate","scale","rotate","perspective"],cO=["transform","translate","scale","rotate","perspective","filter"],dO=["paint","layout","strict","content"];function Rd(t){const e=Dd(),n=It(t)?Pt(t):t;return lO.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||cO.some(r=>(n.willChange||"").includes(r))||dO.some(r=>(n.contain||"").includes(r))}function uO(t){let e=Jn(t);for(;Xt(e)&&!bo(e);){if(Rd(e))return e;if(Ma(e))return null;e=Jn(e)}return null}function Dd(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fO=new Set(["html","body","#document"]);function bo(t){return fO.has(Br(t))}function Pt(t){return ut(t).getComputedStyle(t)}function Aa(t){return It(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Jn(t){if(Br(t)==="html")return t;const e=t.assignedSlot||t.parentNode||H0(t)&&t.host||Yt(t);return H0(e)?e.host:e}function W0(t){const e=Jn(t);return bo(e)?t.ownerDocument?t.ownerDocument.body:t.body:Xt(e)&&Os(e)?e:W0(e)}function Is(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=W0(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=ut(o);if(s){const a=zd(i);return e.concat(i,i.visualViewport||[],Os(o)?o:[],a&&n?Is(a):[])}return e.concat(o,Is(o,[],n))}function zd(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Z0(t){const e=Pt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Xt(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=ba(n)!==s||ba(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function $d(t){return It(t)?t:t.contextElement}function So(t){const e=$d(t);if(!Xt(e))return Gt(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=Z0(e);let i=(s?ba(n.width):n.width)/r,a=(s?ba(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const hO=Gt(0);function U0(t){const e=ut(t);return!Dd()||!e.visualViewport?hO:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function pO(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ut(t)?!1:e}function Or(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=$d(t);let i=Gt(1);e&&(r?It(r)&&(i=So(r)):i=So(t));const a=pO(s,n,r)?U0(s):Gt(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const p=ut(s),m=r&&It(r)?ut(r):r;let g=p,y=zd(g);for(;y&&r&&m!==g;){const k=So(y),w=y.getBoundingClientRect(),v=Pt(y),b=w.left+(y.clientLeft+parseFloat(v.paddingLeft))*k.x,S=w.top+(y.clientTop+parseFloat(v.paddingTop))*k.y;l*=k.x,c*=k.y,u*=k.x,f*=k.y,l+=b,c+=S,g=ut(y),y=zd(g)}}return Ea({width:u,height:f,x:l,y:c})}function Na(t,e){const n=Aa(t).scrollLeft;return e?e.left+n:Or(Yt(t)).left+n}function K0(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Na(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function mO(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=Yt(r),a=e?Ma(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Gt(1);const u=Gt(0),f=Xt(r);if((f||!f&&!s)&&((Br(r)!=="body"||Os(i))&&(l=Aa(r)),Xt(r))){const m=Or(r);c=So(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const p=i&&!f&&!s?K0(i,l):Gt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+p.x,y:n.y*c.y-l.scrollTop*c.y+u.y+p.y}}function gO(t){return Array.from(t.getClientRects())}function yO(t){const e=Yt(t),n=Aa(t),r=t.ownerDocument.body,o=Ar(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Ar(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Na(t);const a=-n.scrollTop;return Pt(r).direction==="rtl"&&(i+=Ar(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const J0=25;function kO(t,e){const n=ut(t),r=Yt(t),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Dd();(!u||u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Na(r);if(c<=0){const u=r.ownerDocument,f=u.body,p=getComputedStyle(f),m=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-m);g<=J0&&(s-=g)}else c<=J0&&(s+=c);return{width:s,height:i,x:a,y:l}}const wO=new Set(["absolute","fixed"]);function vO(t,e){const n=Or(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Xt(t)?So(t):Gt(1),i=t.clientWidth*s.x,a=t.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function q0(t,e,n){let r;if(e==="viewport")r=kO(t,n);else if(e==="document")r=yO(Yt(t));else if(It(e))r=vO(e,n);else{const o=U0(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Ea(r)}function G0(t,e){const n=Jn(t);return n===e||!It(n)||bo(n)?!1:Pt(n).position==="fixed"||G0(n,e)}function bO(t,e){const n=e.get(t);if(n)return n;let r=Is(t,[],!1).filter(a=>It(a)&&Br(a)!=="body"),o=null;const s=Pt(t).position==="fixed";let i=s?Jn(t):t;for(;It(i)&&!bo(i);){const a=Pt(i),l=Rd(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&wO.has(o.position)||Os(i)&&!l&&G0(t,i))?r=r.filter(u=>u!==i):o=a,i=Jn(i)}return e.set(t,r),r}function SO(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?Ma(e)?[]:bO(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=q0(e,u,o);return c.top=Ar(f.top,c.top),c.right=va(f.right,c.right),c.bottom=va(f.bottom,c.bottom),c.left=Ar(f.left,c.left),c},q0(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function CO(t){const{width:e,height:n}=Z0(t);return{width:e,height:n}}function xO(t,e,n){const r=Xt(e),o=Yt(e),s=n==="fixed",i=Or(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Gt(0);function c(){l.x=Na(o)}if(r||!r&&!s)if((Br(e)!=="body"||Os(o))&&(a=Aa(e)),r){const m=Or(e,!0,s,e);l.x=m.x+e.clientLeft,l.y=m.y+e.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?K0(o,a):Gt(0),f=i.left+a.scrollLeft-l.x-u.x,p=i.top+a.scrollTop-l.y-u.y;return{x:f,y:p,width:i.width,height:i.height}}function Vd(t){return Pt(t).position==="static"}function Y0(t,e){if(!Xt(t)||Pt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Yt(t)===n&&(n=n.ownerDocument.body),n}function X0(t,e){const n=ut(t);if(Ma(t))return n;if(!Xt(t)){let o=Jn(t);for(;o&&!bo(o);){if(It(o)&&!Vd(o))return o;o=Jn(o)}return n}let r=Y0(t,e);for(;r&&iO(r)&&Vd(r);)r=Y0(r,e);return r&&bo(r)&&Vd(r)&&!Rd(r)?n:r||uO(t)||n}const _O=async function(t){const e=this.getOffsetParent||X0,n=this.getDimensions,r=await n(t.floating);return{reference:xO(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function EO(t){return Pt(t).direction==="rtl"}const TO={convertOffsetParentRelativeRectToViewportRelativeRect:mO,getDocumentElement:Yt,getClippingRect:SO,getOffsetParent:X0,getElementRects:_O,getClientRects:gO,getDimensions:CO,getScale:So,isElement:It,isRTL:EO};function Q0(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function MO(t,e){let n=null,r;const o=Yt(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:f,width:p,height:m}=c;if(a||e(),!p||!m)return;const g=Sa(f),y=Sa(o.clientWidth-(u+p)),k=Sa(o.clientHeight-(f+m)),w=Sa(u),b={rootMargin:-g+"px "+-y+"px "+-k+"px "+-w+"px",threshold:Ar(0,va(1,l))||1};let S=!0;function C(_){const x=_[0].intersectionRatio;if(x!==l){if(!S)return i();x?i(!1,x):r=setTimeout(()=>{i(!1,1e-7)},1e3)}x===1&&!Q0(c,t.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(C,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,b)}n.observe(t)}return i(!0),s}function ek(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=$d(t),u=o||s?[...c?Is(c):[],...Is(e)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const f=c&&a?MO(c,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(w=>{let[v]=w;v&&v.target===c&&m&&(m.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(e)})),n()}),c&&!l&&m.observe(c),m.observe(e));let g,y=l?Or(t):null;l&&k();function k(){const w=Or(t);y&&!Q0(y,w)&&n(),y=w,g=requestAnimationFrame(k)}return n(),()=>{var w;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(w=m)==null||w.disconnect(),m=null,l&&cancelAnimationFrame(g)}}const Ba=nO,Oa=rO,Ia=QB,AO=(t,e,n)=>{const r=new Map,o={platform:TO,...n},s={...o.platform,_c:r};return XB(t,e,{...o,platform:s})};function NO(t){return t!=null&&typeof t=="object"&&"$el"in t}function tk(t){if(NO(t)){const e=t.$el;return Pd(e)&&Br(e)==="#comment"?null:e}return t}function Ps(t){return typeof t=="function"?t():d.unref(t)}function nk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function rk(t,e){const n=nk(t);return Math.round(e*n)/n}function Pa(t,e,n){n===void 0&&(n={});const r=n.whileElementsMounted,o=d.computed(()=>{var x;return(x=Ps(n.open))!=null?x:!0}),s=d.computed(()=>Ps(n.middleware)),i=d.computed(()=>{var x;return(x=Ps(n.placement))!=null?x:"bottom"}),a=d.computed(()=>{var x;return(x=Ps(n.strategy))!=null?x:"absolute"}),l=d.computed(()=>{var x;return(x=Ps(n.transform))!=null?x:!0}),c=d.computed(()=>tk(t.value)),u=d.computed(()=>tk(e.value)),f=d.ref(0),p=d.ref(0),m=d.ref(a.value),g=d.ref(i.value),y=d.shallowRef({}),k=d.ref(!1),w=d.computed(()=>{const x={position:m.value,left:"0",top:"0"};if(!u.value)return x;const T=rk(u.value,f.value),N=rk(u.value,p.value);return l.value?{...x,transform:"translate("+T+"px, "+N+"px)",...nk(u.value)>=1.5&&{willChange:"transform"}}:{position:m.value,left:T+"px",top:N+"px"}});let v;function b(){if(c.value==null||u.value==null)return;const x=o.value;AO(c.value,u.value,{middleware:s.value,placement:i.value,strategy:a.value}).then(T=>{f.value=T.x,p.value=T.y,m.value=T.strategy,g.value=T.placement,y.value=T.middlewareData,k.value=x!==!1})}function S(){typeof v=="function"&&(v(),v=void 0)}function C(){if(S(),r===void 0){b();return}if(c.value!=null&&u.value!=null){v=r(c.value,u.value,b);return}}function _(){o.value||(k.value=!1)}return d.watch([s,i,a,o],b,{flush:"sync"}),d.watch([c,u],C,{flush:"sync"}),d.watch(o,_,{flush:"sync"}),d.getCurrentScope()&&d.onScopeDispose(S),{x:d.shallowReadonly(f),y:d.shallowReadonly(p),strategy:d.shallowReadonly(m),placement:d.shallowReadonly(g),middlewareData:d.shallowReadonly(y),isPositioned:d.shallowReadonly(k),floatingStyles:w,update:b}}const BO=["menu-open"],bt=d.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(t,{emit:e}){const n=t,r=e,o=d.inject("containerRef"),s=d.inject(ph,null),i=d.inject(mh,0),a=Math.random().toString(36).slice(2);d.provide(mh,i+1);const{show:l,hide:c}=Un(),u=d.ref(!1);s&&d.watch(()=>s.value.get(i),b=>{b!==void 0&&b!==a&&u.value&&(u.value=!1)});const f=d.ref(null),p=d.ref(null),{floatingStyles:m}=Pa(f,p,{placement:n.placement,middleware:[Ba(n.offsetPx),Ia(),Oa({padding:8})],whileElementsMounted:ek});function g(){n.disabled||(u.value=!u.value)}function y(){u.value=!1}function k(b){var T,N,I;const S=b.target,C=(T=f.value)==null?void 0:T.contains(S),_=(N=p.value)==null?void 0:N.contains(S),x=(I=S.closest)==null?void 0:I.call(S,".wov-menu-dropdown");!C&&!_&&!x&&y()}function w(){n.title&&f.value&&!u.value&&l(n.title,f.value)}function v(){c()}return d.watch(u,b=>{b?(c(),document.addEventListener("click",k,!0),s&&(s.value.set(i,a),s.value=new Map(s.value)),r("open")):(document.removeEventListener("click",k,!0),(s==null?void 0:s.value.get(i))===a&&(s.value.delete(i),s.value=new Map(s.value)),r("close"))}),d.onUnmounted(()=>{document.removeEventListener("click",k,!0)}),(b,S)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:d.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:S[0]||(S[0]=d.withModifiers(()=>{},["prevent"])),onClick:g,onMouseenter:w,onMouseleave:v},[d.renderSlot(b.$slots,"button",{isOpen:u.value})],42,BO),d.unref(o)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(o)},[u.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"wov-menu-dropdown",style:d.normalizeStyle(d.unref(m))},[d.renderSlot(b.$slots,"dropdown",{close:y})],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)],64))}}),OO={},IO={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function PO(t,e){return d.openBlock(),d.createElementBlock("svg",IO,[...e[0]||(e[0]=[d.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 St=ir(OO,[["render",PO]]),RO={class:"wov-menu-button"},DO=["innerHTML"],zO=["onClick"],$O=["innerHTML"],Ld=d.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=d.shallowRef(null),o=d.computed(()=>{const a=r.value??(e.side==="start"?pe.None:pe.V);return no(a)});n(a=>{let l=null;for(const c of e.entityIds){if(h.hasComponent(a,c,he)){const u=he.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?pe.None:pe.V;return}}if(h.hasComponent(a,c,ue)){const u=ue.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?pe.None:pe.V;return}}}r.value=l});function s(a){r.value=a,n(l=>{for(const c of e.entityIds){if(h.hasComponent(l,c,he)){const u=he.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}if(h.hasComponent(l,c,ue)){const u=ue.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}}})}function i(a){if(!a)return"";const l=e.side==="start";return`<line x1="${l?8:4}" y1="12" x2="${l?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${l?4:20}, 12) scale(${l?"-0.8, 0.8":"0.8"})`}">${a.svg}</g>`}return(a,l)=>(d.openBlock(),d.createBlock(bt,{title:t.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:d.withCtx(()=>[d.createElementVNode("div",RO,[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(o.value)},null,8,DO)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(d.unref(Zl),c=>(d.openBlock(),d.createElementBlock("button",{key:c.kind,class:d.normalizeClass(["wov-menu-option",{"is-active":r.value===c.kind}]),onClick:u=>s(c.kind)},[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(c)},null,8,$O))],10,zO))),128))]),_:1},8,["title"]))}}),VO={class:"wov-menu-button"},LO=["onClick"],ok=d.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],n=t,{nextEditorTick:r}=Ee(),o=d.shallowRef(null);r(i=>{let a=null;for(const l of n.entityIds){if(h.hasComponent(i,l,he)){const c=he.read(i,l);if(a===null)a=c.thickness;else if(c.thickness!==a){o.value=null;return}}if(h.hasComponent(i,l,ue)){const c=ue.getThickness(i,l);if(a===null)a=c;else if(c!==a){o.value=null;return}}}o.value=a});function s(i){o.value=i,r(a=>{for(const l of n.entityIds){if(h.hasComponent(a,l,he)){const c=he.write(a,l);c.thickness=i}h.hasComponent(a,l,ue)&&ue.setThickness(a,l,i)}})}return(i,a)=>(d.openBlock(),d.createBlock(bt,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",VO,[a[0]||(a[0]=d.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"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,l=>d.createElementVNode("button",{key:l.value,class:d.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":o.value===l.value}]),onClick:c=>s(l.value)},d.toDisplayString(l.label),11,LO)),64))]),_:1}))}}),FO=["value"],jO=d.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(n.modelValue??"");d.watch(()=>n.modelValue,u=>{u&&u!==o.value&&(o.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 a(u){let p=u.target.value;if((p.length===6||p.length===7)&&s(p)){const m=i(p);o.value=m,r("update:modelValue",m)}}function l(u){const p=u.target.value;if(p&&s(p)){const m=i(p);o.value=m,r("update:modelValue",m)}else n.modelValue&&(o.value=n.modelValue)}function c(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,p=f.value;if(p&&s(p)){const m=i(p);o.value=m,r("update:modelValue",m),setTimeout(()=>f.select())}}}return(u,f)=>(d.openBlock(),d.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:o.value,onInput:a,onChange:l,onKeydown:c},null,40,FO))}}),sk=d.defineComponent({__name:"ColorSlider",props:{modelValue:{},thumbColor:{},background:{}},emits:["update:modelValue"],setup(t,{expose:e,emit:n}){const r=n,o=d.ref(null),s=d.ref(!1);function i(c){s.value=!0,a(c),window.addEventListener("pointermove",a),window.addEventListener("pointerup",l)}function a(c){if(!o.value)return;const u=o.value.getBoundingClientRect(),f=Math.max(0,Math.min(100,(c.clientY-u.top)/u.height*100));r("update:modelValue",f)}function l(){s.value=!1,window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l)}return e({isDragging:s}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"sliderRef",ref:o,class:"wov-color-slider",onPointerdown:d.withModifiers(i,["prevent"])},[t.background?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-color-slider-gradient",style:d.normalizeStyle({background:t.background})},null,4)):d.createCommentVNode("",!0),d.createElementVNode("div",{class:"wov-color-slider-thumb",style:d.normalizeStyle({top:`${t.modelValue}%`,backgroundColor:t.thumbColor})},null,4)],544))}}),HO={class:"wov-color-picker"},WO={class:"wov-color-picker-area"},ZO={class:"wov-color-picker-selector-gradient"},UO="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",ik=d.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),s=d.ref(null),i=d.ref(null),a=d.ref({x:100,y:0}),l=d.ref(0),c=d.ref(0),u=d.ref(!1),f=d.computed(()=>{var _,x;return u.value||((_=o.value)==null?void 0:_.isDragging)||((x=s.value)==null?void 0:x.isDragging)}),p=d.computed(()=>({h:l.value/100*360,s:a.value.x,v:100-a.value.y,a:(100-c.value)/100*255})),m=d.computed(()=>M0({h:p.value.h,s:100,v:100})),g=d.computed(()=>M0({h:p.value.h,s:p.value.s,v:p.value.v})),y=d.computed(()=>n.withOpacity?A0(p.value):g.value),k=d.computed(()=>`linear-gradient(to top, transparent 0%, ${g.value} 100%)`);function w(_){if(_){const x=T0(_);a.value={x:x.s,y:100-x.v},l.value=x.h/360*100,c.value=100-x.a/255*100}}function v(_){w(_),r("update:modelValue",n.withOpacity?A0(T0(_)):_)}w(n.modelValue),d.watch(()=>n.modelValue,_=>{f.value||w(_)}),d.watch([a,l,c],()=>{f.value&&r("update:modelValue",y.value)});function b(_){u.value=!0,S(_),window.addEventListener("pointermove",S),window.addEventListener("pointerup",C)}function S(_){if(!i.value)return;const x=i.value.getBoundingClientRect(),T=Math.max(0,Math.min(100,(_.clientX-x.left)/x.width*100)),N=Math.max(0,Math.min(100,(_.clientY-x.top)/x.height*100));a.value={x:T,y:N}}function C(){u.value=!1,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",C)}return(_,x)=>(d.openBlock(),d.createElementBlock("div",HO,[d.createVNode(jO,{modelValue:y.value,"onUpdate:modelValue":v},null,8,["modelValue"]),d.createElementVNode("div",WO,[d.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:d.normalizeStyle({backgroundColor:m.value}),onPointerdown:d.withModifiers(b,["prevent"])},[d.createElementVNode("div",ZO,[d.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:d.normalizeStyle({left:`${a.value.x}%`,top:`${a.value.y}%`,backgroundColor:g.value})},null,4)])],36),d.createVNode(sk,{ref_key:"hueSliderRef",ref:o,modelValue:l.value,"onUpdate:modelValue":x[0]||(x[0]=T=>l.value=T),thumbColor:m.value,background:UO},null,8,["modelValue","thumbColor"]),t.withOpacity?(d.openBlock(),d.createBlock(sk,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:c.value,"onUpdate:modelValue":x[1]||(x[1]=T=>c.value=T),thumbColor:g.value,background:k.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):d.createCommentVNode("",!0)])]))}}),KO={class:"wov-color-bubbles-container"},JO={key:1,class:"wov-color-bubbles"},qO=["onClick"],Ra=d.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(t,{emit:e}){const n=t,r=e,o=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=d.computed(()=>{const g=n.palette??o,y=n.withPicker,k=g.length%2===1;return y&&!k||!y&&k?g.slice(0,-1):g}),i=d.ref(!1),a=d.ref(n.currentColor??"#ff0000");function l(g,y){const k=w=>{const v=w.replace(/^#/,"").toLowerCase();return v.length===6?v+"ff":v};return k(g)===k(y)}function c(g){return n.hideHighlight||!n.currentColor?!1:l(n.currentColor,g)}function u(){return n.hideHighlight||!n.currentColor?!1:!s.value.some(g=>l(n.currentColor,g))}function f(g){const y=_d(g);y&&r("change",y)}function p(){!i.value&&n.currentColor&&(a.value=n.currentColor),i.value=!i.value,r("picker-open",i.value)}function m(g){a.value=g;const y=_d(g);y&&r("change",y)}return(g,y)=>(d.openBlock(),d.createElementBlock("div",KO,[i.value?(d.openBlock(),d.createBlock(ik,{key:0,modelValue:a.value,"onUpdate:modelValue":[y[0]||(y[0]=k=>a.value=k),m],withOpacity:t.withOpacity},null,8,["modelValue","withOpacity"])):(d.openBlock(),d.createElementBlock("div",JO,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,k=>(d.openBlock(),d.createElementBlock("div",{key:k,class:d.normalizeClass(["wov-color-bubble",{selected:c(k)}]),style:d.normalizeStyle({backgroundColor:k}),onMousedown:y[1]||(y[1]=d.withModifiers(()=>{},["prevent"])),onClick:w=>f(k)},null,46,qO))),128)),t.withPicker?(d.openBlock(),d.createElementBlock("div",{key:0,class:d.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:y[2]||(y[2]=d.withModifiers(()=>{},["prevent"])),onClick:p},null,34)):d.createCommentVNode("",!0)]))]))}}),GO={class:"wov-color-button"},ak=d.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Color),o=d.computed(()=>{const c=new Set;for(const u of r.value.values())if(u){const f=Ns(u);c.add(f)}return Array.from(c)}),s=d.computed(()=>o.value.length>1),i=d.computed(()=>o.value[0]??null),a=d.computed(()=>{if(o.value.length===0)return{backgroundColor:"#000"};if(o.value.length>=2){const c=o.value[0],u=o.value[1];return{background:`linear-gradient(45deg, ${c} 0%, ${c} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:o.value[0]}});function l(c){const u=Ns(c);n(f=>{for(const p of e.entityIds)h.Color.fromHex(f,p,u)})}return(c,u)=>(d.openBlock(),d.createBlock(bt,{title:"Color"},{button:d.withCtx(()=>[d.createElementVNode("div",GO,[d.createElementVNode("div",{class:"wov-color-swatch",style:d.normalizeStyle(a.value)},null,4),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Ra,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:l},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Co=d.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),{show:s,hide:i}=Un();function a(u){r("click",u)}function l(){n.title&&o.value&&s(n.title,o.value)}function c(){i()}return(u,f)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:"wov-menu-button",onClick:a,onMouseenter:l,onMouseleave:c},[d.renderSlot(u.$slots,"default")],544))}}),Fd=d.defineComponent({__name:"MenuTooltip",setup(t){const{activeTooltip:e,isVisible:n}=Un(),r=d.inject("containerRef"),o=d.ref(null),s=d.computed(()=>{var l;return((l=e.value)==null?void 0:l.anchor)??null}),{floatingStyles:i}=Pa(s,o,{placement:"top",middleware:[Ba(8),Ia({fallbackPlacements:["bottom"]}),Oa({padding:8})]}),a=d.computed(()=>{var l;return n.value&&((l=e.value)==null?void 0:l.text)});return(l,c)=>d.unref(r)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(r)},[d.createVNode(d.Transition,{name:"wov-tooltip-fade"},{default:d.withCtx(()=>{var u;return[a.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:o,class:"wov-menu-tooltip",style:d.normalizeStyle(d.unref(i))},d.toDisplayString((u=d.unref(e))==null?void 0:u.text),5)):d.createCommentVNode("",!0)]}),_:1})],8,["to"])):d.createCommentVNode("",!0)}}),YO={class:"wov-menu-button"},XO=["onClick"],lk=d.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],n=t,{nextEditorTick:r}=Ee(),o=Wn(()=>n.entityIds,Nt),s=d.computed(()=>{let a=null;for(const l of o.value.values())if(l){if(a===null)a=l.thickness;else if(l.thickness!==a)return null}return a});function i(a){r(l=>{for(const c of n.entityIds){const u=Nt.write(l,c);u.thickness=a}})}return(a,l)=>(d.openBlock(),d.createBlock(bt,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",YO,[l[0]||(l[0]=d.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"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,c=>d.createElementVNode("button",{key:c.value,class:d.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===c.value}]),onClick:u=>i(c.value)},d.toDisplayString(c.label),11,XO)),64))]),_:1}))}}),QO={class:"wov-fill-color-button"},eI={class:"wov-fill-dropdown"},tI={key:0,class:"wov-fill-mode-section"},nI=["title","onClick"],rI={viewBox:"0 0 24 24",fill:"none"},oI=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],ck=d.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Shape),o=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=d.computed(()=>{const m=r.value.values().next().value,g=(m==null?void 0:m.fillAlpha)??255;return g===0?"none":g<200?"faded":"solid"}),i=d.computed(()=>{const m=new Set;for(const g of r.value.values())if(g){const y=g.fillAlpha??255;y===0?m.add("none"):y<200?m.add("faded"):m.add("solid")}return m.size>1});function a(m){n(g=>{for(const y of e.entityIds){const k=h.Shape.write(g,y);k.fillAlpha=m}})}const l=d.computed(()=>{const m=new Set;for(const g of r.value.values())if(g){const y=Ns({red:g.fillRed,green:g.fillGreen,blue:g.fillBlue,alpha:g.fillAlpha??255});m.add(y)}return Array.from(m)}),c=d.computed(()=>l.value.length>1),u=d.computed(()=>l.value[0]??"#4a90d9");function f(m){n(g=>{for(const y of e.entityIds){const k=h.Shape.write(g,y);k.fillRed=m.red,k.fillGreen=m.green,k.fillBlue=m.blue,k.fillAlpha=m.alpha}})}const p=d.ref(!1);return(m,g)=>(d.openBlock(),d.createBlock(bt,{title:"Fill Color"},{button:d.withCtx(()=>[d.createElementVNode("div",QO,[g[1]||(g[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[d.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"}),d.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)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",eI,[p.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",tI,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,y=>d.createElementVNode("button",{key:y.mode,class:d.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&y.mode===s.value}]),title:y.label,onClick:k=>a(y.alpha)},[(d.openBlock(),d.createElementBlock("svg",rI,[d.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:y.mode==="none"?"none":"currentColor","fill-opacity":y.mode==="faded"?.4:1,stroke:y.mode==="none"?"currentColor":"none","stroke-width":y.mode==="none"?1.5:0,"stroke-dasharray":y.mode==="none"?"3 3":""},null,8,oI)])),d.createElementVNode("span",null,d.toDisplayString(y.label),1)],10,nI)),64))])),d.createVNode(Ra,{currentColor:u.value,hideHighlight:c.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:g[0]||(g[0]=y=>p.value=y)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),sI={class:"wov-shape-kind-button"},iI={class:"wov-shape-kind-dropdown"},aI=["onClick"],lI={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},cI=["d"],dk=d.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Shape),o=d.computed(()=>{const l=r.value.values().next().value;return(l==null?void 0:l.kind)??"rectangle"}),s=d.computed(()=>{const l=new Set;for(const c of r.value.values())c&&l.add(c.kind);return l.size>1}),i=d.computed(()=>Object.keys(ss).map(l=>({kind:l,label:l.charAt(0).toUpperCase()+l.slice(1)})));function a(l){n(c=>{for(const u of e.entityIds){const f=h.Shape.write(c,u);f.kind=l}})}return(l,c)=>(d.openBlock(),d.createBlock(bt,{title:"Shape Type"},{button:d.withCtx(()=>[d.createElementVNode("div",sI,[c[0]||(c[0]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),d.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",iI,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,u=>(d.openBlock(),d.createElementBlock("button",{key:u.kind,class:d.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===o.value}]),onClick:f=>a(u.kind)},[(d.openBlock(),d.createElementBlock("svg",lI,[d.createElementVNode("path",{d:d.unref(ss)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,cI)])),d.createElementVNode("span",null,d.toDisplayString(u.label),1)],10,aI))),128))])]),_:1}))}}),dI={class:"wov-stroke-style-section"},uI=["title","onClick"],fI={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},hI=["stroke-dasharray","stroke-opacity"],pI=d.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(t,{emit:e}){const n=e,r=[{kind:h.StrokeKind.Solid,label:"Solid"},{kind:h.StrokeKind.Dashed,label:"Dashed"},{kind:h.StrokeKind.None,label:"None"}];function o(i){switch(i){case h.StrokeKind.Dashed:return"6 6";case h.StrokeKind.None:return"";case h.StrokeKind.Solid:default:return""}}function s(i){n("change",i)}return(i,a)=>(d.openBlock(),d.createElementBlock("div",dI,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(r,l=>d.createElementVNode("button",{key:l.kind,class:d.normalizeClass(["wov-stroke-style-option",{"is-active":!t.hasMultipleStyles&&l.kind===t.currentStyle}]),title:l.label,onClick:c=>s(l.kind)},[(d.openBlock(),d.createElementBlock("svg",fI,[d.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":o(l.kind),"stroke-opacity":l.kind===d.unref(h.StrokeKind).None?.3:1},null,8,hI)])),d.createElementVNode("span",null,d.toDisplayString(l.label),1)],10,uI)),64))]))}}),mI={class:"wov-stroke-color-button"},gI={class:"wov-stroke-dropdown"},yI={key:1,class:"wov-stroke-divider"},uk=d.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Shape),o=d.ref(!1),s=d.computed(()=>{const p=new Set;for(const m of r.value.values())if(m){const g=Ns({red:m.strokeRed,green:m.strokeGreen,blue:m.strokeBlue,alpha:255});p.add(g)}return Array.from(p)}),i=d.computed(()=>s.value.length>1),a=d.computed(()=>s.value[0]??"#000000"),l=d.computed(()=>{const p=r.value.values().next().value;return(p==null?void 0:p.strokeKind)??h.StrokeKind.Solid}),c=d.computed(()=>{const p=new Set;for(const m of r.value.values())m&&p.add(m.strokeKind);return p.size>1});function u(p){n(m=>{for(const g of e.entityIds){const y=h.Shape.write(m,g);y.strokeRed=p.red,y.strokeGreen=p.green,y.strokeBlue=p.blue}})}function f(p){n(m=>{for(const g of e.entityIds){const y=h.Shape.write(m,g);y.strokeKind=p}})}return(p,m)=>(d.openBlock(),d.createBlock(bt,{title:"Stroke Color"},{button:d.withCtx(()=>[d.createElementVNode("div",mI,[m[1]||(m[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[d.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)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",gI,[o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createBlock(pI,{key:0,currentStyle:l.value,hasMultipleStyles:c.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",yI)),d.createVNode(Ra,{currentColor:a.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:m[0]||(m[0]=g=>o.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),kI={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},wI={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},vI={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},bI={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},jd=d.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=[h.TextAlignment.Left,h.TextAlignment.Center,h.TextAlignment.Right,h.TextAlignment.Justify];function s(){const i=o.indexOf(n.alignment),a=o[(i+1)%o.length];r.setAlignment(a)}return(i,a)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Text Align",onClick:s},{default:d.withCtx(()=>[d.unref(n).alignment===d.unref(h.TextAlignment).Left?(d.openBlock(),d.createElementBlock("svg",kI,[...a[0]||(a[0]=[d.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)])])):d.unref(n).alignment===d.unref(h.TextAlignment).Center?(d.openBlock(),d.createElementBlock("svg",wI,[...a[1]||(a[1]=[d.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)])])):d.unref(n).alignment===d.unref(h.TextAlignment).Right?(d.openBlock(),d.createElementBlock("svg",vI,[...a[2]||(a[2]=[d.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)])])):(d.openBlock(),d.createElementBlock("svg",bI,[...a[3]||(a[3]=[d.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})):d.createCommentVNode("",!0)}}),Hd=d.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Bold",class:d.normalizeClass({"wov-active":d.unref(n).isBold}),onClick:d.unref(r).toggleBold},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.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"])):d.createCommentVNode("",!0)}});function SI(t,e){return d.getCurrentScope()?(d.onScopeDispose(t,e),!0):!1}const CI=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const xI=Object.prototype.toString,_I=t=>xI.call(t)==="[object Object]",Da=()=>{};function za(t){return Array.isArray(t)?t:[t]}function EI(t){return d.getCurrentInstance()}function TI(t,e=!0,n){EI()?d.onMounted(t,n):e?t():d.nextTick(t)}function MI(t,e,n){return d.watch(t,e,{...n,immediate:!0})}const $a=CI?window:void 0;function Rt(t){var e;const n=d.toValue(t);return(e=n==null?void 0:n.$el)!==null&&e!==void 0?e:n}function Wd(...t){const e=(r,o,s,i)=>(r.addEventListener(o,s,i),()=>r.removeEventListener(o,s,i)),n=d.computed(()=>{const r=za(d.toValue(t[0])).filter(o=>o!=null);return r.every(o=>typeof o!="string")?r:void 0});return MI(()=>{var r,o;return[(r=(o=n.value)===null||o===void 0?void 0:o.map(s=>Rt(s)))!==null&&r!==void 0?r:[$a].filter(s=>s!=null),za(d.toValue(n.value?t[1]:t[0])),za(d.unref(n.value?t[2]:t[1])),d.toValue(n.value?t[3]:t[2])]},([r,o,s,i],a,l)=>{if(!(r!=null&&r.length)||!(o!=null&&o.length)||!(s!=null&&s.length))return;const c=_I(i)?{...i}:i,u=r.flatMap(f=>o.flatMap(p=>s.map(m=>e(f,p,m,c))));l(()=>{u.forEach(f=>f())})},{flush:"post"})}function AI(t,e,n={}){const{window:r=$a,ignore:o=[],capture:s=!0,detectIframe:i=!1,controls:a=!1}=n;if(!r)return a?{stop:Da,cancel:Da,trigger:Da}:Da;let l=!0;const c=k=>d.toValue(o).some(w=>{if(typeof w=="string")return Array.from(r.document.querySelectorAll(w)).some(v=>v===k.target||k.composedPath().includes(v));{const v=Rt(w);return v&&(k.target===v||k.composedPath().includes(v))}});function u(k){const w=d.toValue(k);return w&&w.$.subTree.shapeFlag===16}function f(k,w){const v=d.toValue(k),b=v.$.subTree&&v.$.subTree.children;return b==null||!Array.isArray(b)?!1:b.some(S=>S.el===w.target||w.composedPath().includes(S.el))}const p=k=>{const w=Rt(t);if(k.target!=null&&!(!(w instanceof Element)&&u(t)&&f(t,k))&&!(!w||w===k.target||k.composedPath().includes(w))){if("detail"in k&&k.detail===0&&(l=!c(k)),!l){l=!0;return}e(k)}};let m=!1;const g=[Wd(r,"click",k=>{m||(m=!0,setTimeout(()=>{m=!1},0),p(k))},{passive:!0,capture:s}),Wd(r,"pointerdown",k=>{const w=Rt(t);l=!c(k)&&!!(w&&!k.composedPath().includes(w))},{passive:!0}),i&&Wd(r,"blur",k=>{setTimeout(()=>{var w;const v=Rt(t);((w=r.document.activeElement)===null||w===void 0?void 0:w.tagName)==="IFRAME"&&!(v!=null&&v.contains(r.document.activeElement))&&e(k)},0)},{passive:!0})].filter(Boolean),y=()=>g.forEach(k=>k());return a?{stop:y,cancel:()=>{l=!1},trigger:k=>{l=!0,p(k),l=!1}}:y}function NI(){const t=d.shallowRef(!1),e=d.getCurrentInstance();return e&&d.onMounted(()=>{t.value=!0},e),t}function BI(t){const e=NI();return d.computed(()=>(e.value,!!t()))}function OI(t,e,n={}){const{window:r=$a,...o}=n;let s;const i=BI(()=>r&&"ResizeObserver"in r),a=()=>{s&&(s.disconnect(),s=void 0)},l=d.watch(d.computed(()=>{const u=d.toValue(t);return Array.isArray(u)?u.map(f=>Rt(f)):[Rt(u)]}),u=>{if(a(),i.value&&r){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,o)}},{immediate:!0,flush:"post"}),c=()=>{a(),l()};return SI(c),{isSupported:i,stop:c}}function fk(t,e={width:0,height:0},n={}){const{window:r=$a,box:o="content-box"}=n,s=d.computed(()=>{var f;return(f=Rt(t))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=d.shallowRef(e.width),a=d.shallowRef(e.height),{stop:l}=OI(t,([f])=>{const p=o==="border-box"?f.borderBoxSize:o==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(r&&s.value){const m=Rt(t);if(m){const g=m.getBoundingClientRect();i.value=g.width,a.value=g.height}}else if(p){const m=za(p);i.value=m.reduce((g,{inlineSize:y})=>g+y,0),a.value=m.reduce((g,{blockSize:y})=>g+y,0)}else i.value=f.contentRect.width,a.value=f.contentRect.height},n);TI(()=>{const f=Rt(t);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,a.value="offsetHeight"in f?f.offsetHeight:e.height)});const c=d.watch(()=>Rt(t),f=>{i.value=f?e.width:0,a.value=f?e.height:0});function u(){l(),c()}return{width:i,height:a,stop:u}}function hk(){const t=d.inject(pt);if(!t)throw new Error("useFonts must be used within a WovenCanvas component");return d.computed(()=>{const e=t.getEditor();return e?e.fonts.filter(n=>n.selectable):[]})}const II={class:"wov-font-family-button"},PI={class:"wov-font-family-label"},RI={class:"wov-font-list"},DI=["onClick"],zI=["src","alt"],Zd=d.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=hk(),s=d.computed(()=>o.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=d.computed(()=>n.fontFamily),a=d.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 l(u){r.setFontFamily(u)}function c(u){u.stopPropagation()}return(u,f)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(bt,{key:0,title:"Font Family"},{button:d.withCtx(()=>[d.createElementVNode("div",II,[d.createElementVNode("span",PI,d.toDisplayString(a.value),1),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-family-menu",onWheel:c,onClick:f[0]||(f[0]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",RI,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,p=>(d.openBlock(),d.createElementBlock("div",{key:p.name,class:d.normalizeClass(["wov-font-item",{active:i.value===p.name}]),onClick:m=>l(p.name)},[p.previewImage?(d.openBlock(),d.createElementBlock("img",{key:0,class:"wov-font-preview",src:p.previewImage,alt:p.name},null,8,zI)):(d.openBlock(),d.createElementBlock("span",{key:1,class:"wov-font-name",style:d.normalizeStyle({fontFamily:p.name})},d.toDisplayString(p.displayName),5))],10,DI))),128))])],32)]),_:1})):d.createCommentVNode("",!0)}}),$I={class:"wov-font-size-button"},VI={class:"wov-font-size-label"},LI=["onClick"],FI={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},jI={class:"wov-input-container"},HI=["value"],Ud=d.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=[{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=d.computed(()=>n.fontSize),i=d.computed(()=>{const p=s.value;if(p===null)return"Mixed";const m=o.find(g=>g.value===p);return m?m.label:`${+p.toFixed(1)} px`}),a=d.computed(()=>{const p=s.value;return p===null?"":String(+p.toFixed(1))});function l(p){r.setFontSize(p)}function c(p){const m=p.target,g=Number.parseFloat(m.value);!Number.isNaN(g)&&g>0&&l(g)}function u(p){p.key==="Enter"&&p.target.blur()}function f(p){p.stopPropagation()}return(p,m)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(bt,{key:0,title:"Font Size"},{button:d.withCtx(()=>[d.createElementVNode("div",$I,[d.createElementVNode("span",VI,d.toDisplayString(i.value),1),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:m[0]||(m[0]=d.withModifiers(()=>{},["stop"]))},[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,g=>d.createElementVNode("div",{key:g.value,class:d.normalizeClass(["wov-font-size-option",{active:s.value===g.value}]),onClick:y=>l(g.value)},[s.value===g.value?(d.openBlock(),d.createElementBlock("svg",FI,[...m[1]||(m[1]=[d.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)])])):d.createCommentVNode("",!0),d.createElementVNode("span",{class:"wov-option-label",style:d.normalizeStyle({fontSize:`${g.displayValue}px`})},d.toDisplayString(g.label),5)],10,LI)),64)),m[3]||(m[3]=d.createElementVNode("div",{class:"wov-separator"},null,-1)),d.createElementVNode("div",jI,[d.createElementVNode("input",{class:"wov-custom-input",value:a.value,onInput:c,onKeydown:u,placeholder:"Custom size"},null,40,HI),m[2]||(m[2]=d.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):d.createCommentVNode("",!0)}}),Kd=d.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Italic",class:d.normalizeClass({"wov-active":d.unref(n).isItalic}),onClick:d.unref(r).toggleItalic},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.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"])):d.createCommentVNode("",!0)}}),Jd=d.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Underline",class:d.normalizeClass({"wov-active":d.unref(n).isUnderline}),onClick:d.unref(r).toggleUnderline},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[d.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"])):d.createCommentVNode("",!0)}}),WI={class:"wov-text-color-button"},ZI={class:"wov-text-icon-container"},qd=d.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=d.computed(()=>n.color??"#000000"),s=d.computed(()=>({backgroundColor:o.value}));function i(a){r.setColor(Ns(a))}return(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(bt,{key:0,title:"Text Color"},{button:d.withCtx(()=>[d.createElementVNode("div",WI,[d.createElementVNode("div",ZI,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[d.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)),d.createElementVNode("div",{class:"wov-color-underline",style:d.normalizeStyle(s.value)},null,4)]),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Ra,{currentColor:o.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):d.createCommentVNode("",!0)}}),UI={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"},KI={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"},JI={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"},pk=d.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),{state:r}=qt(()=>e.entityIds),o=[h.VerticalAlignment.Top,h.VerticalAlignment.Center,h.VerticalAlignment.Bottom],s=Wn(()=>e.entityIds,h.VerticalAlign),i=d.computed(()=>{let l=null;for(const c of s.value.values()){const u=(c==null?void 0:c.value)??h.VerticalAlignment.Top;if(l===null)l=u;else if(l!==u)return null}return l});function a(){const l=i.value??h.VerticalAlignment.Top,c=o.indexOf(l),u=o[(c+1)%o.length];n(f=>{for(const p of e.entityIds){const m=h.VerticalAlign.write(f,p);m.value=u}})}return(l,c)=>d.unref(r).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Vertical Align",onClick:a},{default:d.withCtx(()=>[i.value===d.unref(h.VerticalAlignment).Top||i.value===null?(d.openBlock(),d.createElementBlock("svg",UI,[...c[0]||(c[0]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===d.unref(h.VerticalAlignment).Center?(d.openBlock(),d.createElementBlock("svg",KI,[...c[1]||(c[1]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",JI,[...c[2]||(c[2]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):d.createCommentVNode("",!0)}}),qI={class:"wov-text-group-button"},GI={class:"wov-text-group-dropdown"},YI={class:"wov-text-group-row wov-text-group-row-full"},XI={class:"wov-text-group-row"},QI=d.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(t){const e=t,{state:n}=qt(()=>e.entityIds),r=d.inject("containerRef"),{width:o}=fk(r),s=d.computed(()=>o.value>0&&o.value<600),i=d.ref(new Map);return d.provide(ph,i),(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[s.value?(d.openBlock(),d.createBlock(bt,{key:0,title:"Text Formatting",placement:"top"},{button:d.withCtx(()=>[d.createElementVNode("div",qI,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[d.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)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",GI,[d.createElementVNode("div",YI,[d.createVNode(Zd,{entityIds:t.entityIds},null,8,["entityIds"]),l[1]||(l[1]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(Ud,{entityIds:t.entityIds},null,8,["entityIds"])]),d.createElementVNode("div",XI,[d.createVNode(Hd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Kd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Jd,{entityIds:t.entityIds},null,8,["entityIds"]),l[2]||(l[2]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(qd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(jd,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(pk,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)])])]),_:1})):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createVNode(Zd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Ud,{entityIds:t.entityIds},null,8,["entityIds"]),l[3]||(l[3]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(Hd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Kd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Jd,{entityIds:t.entityIds},null,8,["entityIds"]),l[4]||(l[4]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(qd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(jd,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(pk,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)],64))],64)):d.createCommentVNode("",!0)}}),mk=d.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(t){const e=t,n=Ze(h.Camera),r=Ze(h.Grid),o=d.inject("containerRef"),s=d.ref({width:0,height:0});let i=null;const a=d.ref(null);let l=null;typeof document<"u"&&(l=document.createElement("canvas"));function c(k,w,v,b){const S=b/2;k.beginPath(),k.arc(w,v,S,0,Math.PI*2),k.fill()}function u(k,w,v){if(!l)return null;const b=v.dotSize??2,S=k*v.subdivisionStep,C=w*v.subdivisionStep;l.width=S,l.height=C;const _=l.getContext("2d");if(!_)return null;if(_.clearRect(0,0,S,C),_.fillStyle=v.strokeColor,v.subdivisionStep===1)c(_,S/2,C/2,b);else for(let x=0;x<v.subdivisionStep;x++)for(let T=0;T<v.subdivisionStep;T++){const N=(x+.5)*(S/v.subdivisionStep),I=(T+.5)*(C/v.subdivisionStep),K=x===0&&T===0?2*b:b;c(_,N,I,K)}return _.createPattern(l,"repeat")}function f(k,w,v,b,S,C){k.lineWidth=C,k.beginPath(),k.moveTo(w,v),k.lineTo(b,S),k.stroke()}function p(k,w,v){if(!l)return null;const b=v.gridSize??1,S=k*v.subdivisionStep,C=w*v.subdivisionStep;l.width=S,l.height=C;const _=l.getContext("2d");if(!_)return null;if(_.clearRect(0,0,S,C),_.strokeStyle=v.strokeColor,v.subdivisionStep===1)f(_,0,0,S,0,b),f(_,0,0,0,C,b);else{const x=S/v.subdivisionStep,T=C/v.subdivisionStep;for(let N=0;N<=v.subdivisionStep;N++){const I=N*x,V=N%v.subdivisionStep===0;f(_,I,0,I,C,V?3*b:b)}for(let N=0;N<=v.subdivisionStep;N++){const I=N*T,V=N%v.subdivisionStep===0;f(_,0,I,S,I,V?3*b:b)}}return _.createPattern(l,"repeat")}function m(k){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,C=s.value.height,_=n.value.left,x=n.value.top,T=_+S/n.value.zoom,N=x+C/n.value.zoom;let I=w*b,V=v*b,K=0,M=0,$=Number.POSITIVE_INFINITY,Z=Number.POSITIVE_INFINITY;for(;;){I=b*w,V=b*v,K=Math.floor(_/I)*I,M=Math.floor(x/V)*V;const Se=Math.ceil(T/I)*I,Dt=Math.ceil(N/V)*V;if(Z=Math.round((Se-K)/w),$=Math.round((Dt-M)/v),Math.max(Z,$)>200)w*=2,v*=2;else break}const ae=w*n.value.zoom,X=v*n.value.zoom,j=Math.round(ae),q=Math.round(X),te=u(j,q,e.background);if(!te)return;te.setTransform(new DOMMatrix().scale(ae/j,X/q));const fe=(K-_-w/2)*n.value.zoom,ce=(M-x-v/2)*n.value.zoom;k.save(),k.translate(fe,ce),k.fillStyle=te,k.fillRect(0,0,S+I*n.value.zoom,C+V*n.value.zoom),k.restore()}function g(k){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,C=s.value.height,_=n.value.left,x=n.value.top,T=_+S/n.value.zoom,N=x+C/n.value.zoom;let I=w*b,V=v*b,K=0,M=0,$=Number.POSITIVE_INFINITY,Z=Number.POSITIVE_INFINITY;for(;;){I=b*w,V=b*v,K=Math.floor(_/I)*I,M=Math.floor(x/V)*V;const Se=Math.ceil(T/I)*I,Dt=Math.ceil(N/V)*V;if(Z=Math.round((Se-K)/w),$=Math.round((Dt-M)/v),Math.max(Z,$)>200)w*=2,v*=2;else break}const ae=w*n.value.zoom,X=v*n.value.zoom,j=Math.round(ae),q=Math.round(X),te=p(j,q,e.background);if(!te)return;te.setTransform(new DOMMatrix().scale(ae/j,X/q));const fe=(K-_)*n.value.zoom,ce=(M-x)*n.value.zoom;k.save(),k.translate(fe,ce),k.fillStyle=te,k.fillRect(0,0,S+I*n.value.zoom,C+V*n.value.zoom),k.restore()}function y(){const k=a.value;if(!k)return;const w=k.getContext("2d");if(!w)return;const{width:v,height:b}=s.value;v===0||b===0||(k.width=v,k.height=b,w.clearRect(0,0,v,b),w.fillStyle=e.background.color,w.fillRect(0,0,v,b),e.background.kind==="dots"?m(w):e.background.kind==="grid"&&g(w))}return d.watch(()=>[e.background,n.value,r.value,s.value],()=>{y()},{deep:!0}),d.onMounted(()=>{const k=o==null?void 0:o.value;if(k){const w=()=>{s.value={width:k.clientWidth,height:k.clientHeight}};w(),i=new ResizeObserver(w),i.observe(k)}y()}),d.onUnmounted(()=>{i==null||i.disconnect()}),(k,w)=>(d.openBlock(),d.createElementBlock("canvas",{ref_key:"canvasRef",ref:a,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function gk(t,e){if(e.length===0)return new Set;const n=e[0].tag,r=t.blockDefs[n];if(!r)return new Set;const o=new Set(r.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,a=t.blockDefs[i];if(!a){o.clear();break}const l=new Set(a.components.map(c=>c.name));for(const c of o)l.has(c)||o.delete(c)}return o}const yk=d.defineComponent({__name:"FloatingMenuBar",setup(t){const e=d.useSlots(),{reset:n}=Un(),r=d.inject(gh),{selectedIds:o,commonComponents:s}=r,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape"]),a=d.computed(()=>{const c=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&c.push(u)}return c});function l(){n()}return d.onUnmounted(()=>{n()}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:l},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.value,f=>d.renderSlot(c.$slots,`button:${f}`,{key:f,entityIds:d.unref(o)})),128)),d.renderSlot(c.$slots,"button:color",{entityIds:d.unref(o)},()=>[d.unref(s).has("color")?(d.openBlock(),d.createBlock(ak,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:shape",{entityIds:d.unref(o)},()=>[d.unref(s).has("shape")?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[d.createVNode(dk,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(ck,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(uk,{entityIds:d.unref(o)},null,8,["entityIds"])],64)):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:penStroke",{entityIds:d.unref(o)},()=>[d.unref(s).has("penStroke")?(d.openBlock(),d.createBlock(lk,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowThickness",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(ok,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadStart",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(Ld,{key:0,entityIds:d.unref(o),side:"start"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadEnd",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(Ld,{key:0,entityIds:d.unref(o),side:"end"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:text",{entityIds:d.unref(o)},()=>[d.unref(s).has("text")?(d.openBlock(),d.createBlock(QI,{key:0,entityIds:d.unref(o),showVerticalAlign:d.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])):d.createCommentVNode("",!0)]),d.createVNode(Fd)],32))}}),eP={class:"wov-floating-menu-inner"},kk=d.defineComponent({__name:"FloatingMenu",setup(t){const e=d.inject(pt),n=_0([h.Block,Ie]),r=Ze(h.Camera),o=Ze(h.Screen),s=Ze(Tt),i=Bs(),a=d.computed(()=>n.value.map(S=>S.entityId)),l=d.computed(()=>{const S=e==null?void 0:e.getEditor();if(!S||n.value.length===0)return new Set;const C=n.value.map(_=>({tag:_.block.value.tag}));return gk(S,C)});d.provide(gh,{selectedIds:a,commonComponents:l});const c=[0,0,0,0];function u(...S){let C=1/0,_=1/0,x=-1/0,T=-1/0,N=!1;for(const I of S){if(!I)continue;const V=I.getBoundingClientRect();V.width<=0||(N=!0,C=Math.min(C,V.left),_=Math.min(_,V.top),x=Math.max(x,V.right),T=Math.max(T,V.bottom))}return N?{x:C,y:_,left:C,top:_,right:x,bottom:T,width:x-C,height:T-_,toJSON:()=>({})}:null}const f=d.computed(()=>{if(n.value.length===0)return null;const S=r.value;if(!S)return null;let C=null;for(const _ of n.value){const x=_.block.value;E.Rect.getAabb(x.position,x.size,x.rotateZ,c),E.Aabb.translate(c,[-S.left,-S.top]),E.Aabb.scale(c,S.zoom),C===null?C=E.Aabb.clone(c):E.Aabb.union(C,c)}return C}),p=d.inject("containerRef"),m=d.computed(()=>{const S=p==null?void 0:p.value;if(!S)return null;r.value,i.updateCounter.value;const C=i.blockElement.value,_=i.textElement.value,x=u(C,_);if(x)return{getBoundingClientRect:()=>x};const T=f.value;if(!T)return null;const N=S.getBoundingClientRect();return{getBoundingClientRect(){return{x:N.left+T[0],y:N.top+T[1],width:T[2]-T[0],height:T[3]-T[1],top:N.top+T[1],left:N.left+T[0],right:N.left+T[2],bottom:N.top+T[3]}}}}),g=d.ref(null),y={name:"clampToViewport",fn({y:S,rects:C}){const T=window.innerHeight-C.floating.height-8;return{y:Math.max(8,Math.min(S,T))}}},{floatingStyles:k}=Pa(m,g,{placement:"top",middleware:[Ba(12),Ia({fallbackPlacements:["bottom"]}),Oa({padding:8}),y]}),w=d.computed(()=>{const S=f.value,C=o.value;return!S||!C?!0:S[2]<0||S[0]>C.width||S[3]<0||S[1]>C.height}),v=[de.Dragging,de.SelectionBoxDragging],b=d.computed(()=>n.value.length>0&&!w.value&&!v.includes(s.value.state));return(S,C)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-fade"},{default:d.withCtx(()=>[b.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:g,class:"wov-floating-menu",style:d.normalizeStyle(d.unref(k))},[d.createElementVNode("div",eP,[d.renderSlot(S.$slots,"default",{},()=>[d.createVNode(yk)])])],4)):d.createCommentVNode("",!0)]),_:3}))}}),tP={key:0,class:"wov-loading-overlay"},nP={class:"wov-loading-spinner"},wk=d.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(t){const e=d.ref("|"),n=["|","/","-","\\"];let r=null;return d.onMounted(()=>{r=setInterval(()=>{const o=n.indexOf(e.value);e.value=n[(o+1)%n.length]},100)}),d.onUnmounted(()=>{r!==null&&clearInterval(r)}),(o,s)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-loading-fade"},{default:d.withCtx(()=>[t.isLoading?(d.openBlock(),d.createElementBlock("div",tP,[d.createElementVNode("div",nP,d.toDisplayString(e.value),1)])):d.createCommentVNode("",!0)]),_:1}))}}),rP={class:"wov-action-bar"},oP=d.defineComponent({__name:"ActionBar",setup(t){const{getEditor:e}=Ee(),n=d.inject(pt),r=d.ref(!1),o=d.ref(!1);if(n){const l=n.registerTickCallback(c=>{const{store:u}=h.getPluginResources(c,"editing");r.value=u.canUndo(),o.value=u.canRedo()});d.onUnmounted(l)}function s(){const l=e();l==null||l.command(h.Undo)}function i(){const l=e();l==null||l.command(h.Redo)}function a(){const l=e();l==null||l.command(yl)}return(l,c)=>(d.openBlock(),d.createElementBlock("div",rP,[d.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...c[0]||(c[0]=[d.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"},[d.createElementVNode("path",{d:"M3 7v6h6"}),d.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...c[1]||(c[1]=[d.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"},[d.createElementVNode("path",{d:"M21 7v6h-6"}),d.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:a,"aria-label":"Delete"},[...c[2]||(c[2]=[d.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"},[d.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),d.createElementVNode("path",{d:"M3 6h18"}),d.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),Qt=d.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(t){const e=t,n=d.inject(Ul);if(!n)throw new Error("ToolbarButton must be used within a Toolbar component");const r=n,o=d.ref(null),{show:s,hide:i}=Un(),a=d.computed(()=>r.activeTool.value===e.name);function l(){r.setTool(e.name,e.placementSnapshot,e.cursor)}function c(){r.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){r.onToolPointerUp()}function f(){e.tooltip&&o.value&&s(e.tooltip,o.value)}function p(){i()}return(m,g)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:d.normalizeClass(["wov-toolbar-button",{selected:a.value}]),onClick:l,onPointerdown:c,onPointerup:u,onMouseenter:f,onMouseleave:p},[d.renderSlot(m.$slots,"default")],34))}}),sP='<?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>',iP='<?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>',aP='<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>',Ir={Select:"select",Hand:"hand",Crosshair:"crosshair"},vk={[Ir.Select]:{makeSvg:()=>sP,hotspot:[1,0],rotationOffset:0},[Ir.Hand]:{makeSvg:()=>iP,hotspot:[12,12],rotationOffset:0},[Ir.Crosshair]:{makeSvg:()=>aP,hotspot:[12,12],rotationOffset:0}},lP={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},bk=d.defineComponent({__name:"SelectTool",setup(t){const{nextEditorTick:e}=Ee(),{activeTool:n}=Od();return d.watch(n,(r,o)=>{o==="select"&&e(s=>{Xr.spawn(s)})}),(r,o)=>(d.openBlock(),d.createBlock(Qt,{name:"select",tooltip:"Select",cursor:d.unref(Ir).Select},{default:d.withCtx(()=>[(d.openBlock(),d.createElementBlock("svg",lP,[...o[0]||(o[0]=[d.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[d.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"]))}}),Sk=d.defineComponent({__name:"HandTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"hand",tooltip:"Hand",cursor:d.unref(Ir).Hand},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[d.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"]))}}),Ck=d.defineComponent({__name:"StickyNoteTool",setup(t){const e=JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:h.TextAlignment.Center},verticalAlign:{value:h.VerticalAlignment.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Qt,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("path",{d:"M4 4h12v12H4z"}),d.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),xk=d.defineComponent({__name:"ShapeTool",setup(t){const e=JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:h.StrokeKind.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:h.TextAlignment.Center},verticalAlign:{value:h.VerticalAlignment.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Qt,{name:"shape",tooltip:"Shape","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),_k=d.defineComponent({__name:"EraserTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"eraser",tooltip:"Eraser"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[d.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}))}}),Ek=d.defineComponent({__name:"PenTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"pen",tooltip:"Pen"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.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"}),d.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),Tk=d.defineComponent({__name:"TextTool",setup(t){const e=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),n=JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24}});return(r,o)=>(d.openBlock(),d.createBlock(Qt,{name:"text",tooltip:"Text","drag-out-snapshot":d.unref(n),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...o[0]||(o[0]=[d.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"},[d.createElementVNode("path",{d:"M12 4v16"}),d.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),d.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Mk=d.defineComponent({__name:"ElbowArrowTool",setup(t){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:pe.None,endArrowHead:pe.V},connector:{}});return(n,r)=>(d.openBlock(),d.createBlock(Qt,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),Ak=d.defineComponent({__name:"ImageTool",setup(t){const{nextEditorTick:e}=Ee(),{show:n,hide:r}=Un(),{setTool:o}=Od(),{createImageBlock:s}=x0(),i=d.ref(null),a=d.ref(null);function l(){var p;(p=a.value)==null||p.click()}async function c(p){var S;const m=p.target,g=(S=m.files)==null?void 0:S[0];if(!g)return;if(m.value="",!g.type.startsWith("image/")){console.warn("Selected file is not an image");return}const y=await e(),k=h.Camera.read(y),w=h.Screen.read(y),v=k.left+w.width/k.zoom/2,b=k.top+w.height/k.zoom/2;await s(g,v,b),o("select",void 0,Ir.Select)}function u(){i.value&&n("Image",i.value)}function f(){r()}return(p,m)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:l,onMouseenter:u,onMouseleave:f},[m[0]||(m[0]=d.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"},[d.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),d.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),d.createElementVNode("input",{ref_key:"fileInputRef",ref:a,type:"file",accept:"image/*",style:{display:"none"},onChange:c},null,544)],544))}}),cP={class:"wov-toolbar-container"},Nk=d.defineComponent({__name:"Toolbar",setup(t){const e=d.useSlots(),{reset:n}=Un(),{nextEditorTick:r}=Ee(),o=d.ref(null),s=d.ref(null),i=Ze(h.Controls),a=d.computed(()=>i.value.leftMouseTool),l=[bk,Sk,Tk,Ak,xk,Mk,Ck,Ek,_k],c=d.inject("containerRef"),u=d.ref(null),f=d.ref(!1),p=d.ref(null),m=d.ref(null),g=d.ref(1/0),y=d.ref(0),k=d.ref([]),w=d.ref(8),v=d.ref(48),{width:b}=fk(c);function S(){return p.value?Array.from(p.value.children).filter(j=>!j.classList.contains("wov-overflow-button")&&!j.classList.contains("wov-menu-tooltip")):[]}function C(){var fe;const j=S();if(j.length===0)return;y.value=j.length;const q=getComputedStyle(p.value);w.value=parseFloat(q.gap)||8;const te=((fe=m.value)==null?void 0:fe.offsetWidth)||40;v.value=te+w.value,k.value=j.map(ce=>ce.offsetWidth)}function _(){if(k.value.length===0)return;const te=b.value-40-20,fe=w.value,ce=v.value;let Se=0,Dt=0;for(let gn=0;gn<k.value.length;gn++){const Dr=k.value[gn],qn=Se>0?Dr+fe:Dr,Gn=k.value.length-gn-1>0?ce:0;if(Se+qn+Gn<=te)Se+=qn,Dt++;else break}g.value=Math.max(1,Dt)}d.watch(b,()=>{k.value.length>0&&_()}),d.onMounted(()=>{d.nextTick(()=>{C(),_()})});const x=d.computed(()=>g.value<y.value);d.watchEffect(()=>{S().forEach((q,te)=>{q.style.display=te<g.value?"":"none"})}),d.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((q,te)=>{q.style.display=te>=g.value?"":"none"})});const{floatingStyles:T}=Pa(m,u,{placement:"top",middleware:[Ba(16),Ia(),Oa({padding:8})],whileElementsMounted:ek});function N(){f.value=!f.value}function I(){f.value=!1}function V(j){const q=j.target;m.value&&!m.value.contains(q)&&u.value&&!u.value.contains(q)&&I()}d.watch(f,j=>{j?document.addEventListener("click",V,!0):document.removeEventListener("click",V,!0)}),d.watch(x,j=>{j||I()});function K(j,q,te){s.value=q??null,r(fe=>{const ce=h.Controls.write(fe);ce.leftMouseTool=j,ce.heldSnapshot=q??"",te&&h.Cursor.setCursor(fe,te)})}function M(j){r(q=>{const te=h.Controls.write(q);te.leftMouseTool="drag-out",te.heldSnapshot=j})}function $(j,q){o.value=j,s.value=q??null}function Z(){o.value=null,s.value=null}function ae(){n(),o.value&&s.value&&M(s.value),o.value=null,s.value=null}const X={activeTool:a,heldTool:o,setTool:K,dragOutTool:M,onToolPointerDown:$,onToolPointerUp:Z};return d.provide(Ul,X),(j,q)=>(d.openBlock(),d.createElementBlock("div",cP,[d.createVNode(oP),d.createElementVNode("div",{ref_key:"toolsContainerRef",ref:p,class:"wov-toolbar",onMouseleave:ae},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(te,fe)=>d.createVNode(d.resolveDynamicComponent(te),{key:fe})),64)),x.value?(d.openBlock(),d.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:m,class:d.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:N},[...q[0]||(q[0]=[d.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[d.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),d.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):d.createCommentVNode("",!0),d.createVNode(Fd)],544),d.unref(c)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(c)},[f.value&&x.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:d.normalizeStyle(d.unref(T))},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(te,fe)=>d.createVNode(d.resolveDynamicComponent(te),{key:fe})),64))],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)]))}}),dP=d.defineComponent({__name:"ArcArrowTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),uP={class:"wov-user-presence-avatars"},fP=["src","alt"],hP={class:"wov-user-presence-list"},pP=["src","alt"],mP={class:"wov-user-presence-name"},gP=4,Bk=d.defineComponent({__name:"UserPresence",props:{users:{}},setup(t){const e=t,n=d.ref(!1),r=d.ref(null);AI(r,()=>{n.value=!1});function o(a){if(!a)return"?";const l=a.trim().split(/\s+/);return l.length>=2?(l[0][0]+l[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const s=d.computed(()=>e.users.map(a=>({sessionId:a.sessionId,name:a.name,color:a.color,avatar:a.avatar,initials:o(a.name)}))),i=d.computed(()=>s.value.slice(0,gP));return(a,l)=>t.users.length>1?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"containerRef",ref:r,class:"wov-user-presence"},[d.createElementVNode("button",{class:d.normalizeClass(["wov-user-presence-trigger",{"is-open":n.value}]),onClick:l[0]||(l[0]=c=>n.value=!n.value)},[d.createElementVNode("div",uP,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-avatar",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,fP)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4))),128))])],2),n.value?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:l[1]||(l[1]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",hP,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-presence-item"},[d.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,pP)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4),d.createElementVNode("span",mP,d.toDisplayString(c.name),1)]))),128))])],32)):d.createCommentVNode("",!0)],512)):d.createCommentVNode("",!0)}}),Gd=(t,e)=>e.some(n=>t instanceof n);let Ok,Ik;function yP(){return Ok||(Ok=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kP(){return Ik||(Ik=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Yd=new WeakMap,Xd=new WeakMap,Va=new WeakMap;function wP(t){const e=new Promise((n,r)=>{const o=()=>{t.removeEventListener("success",s),t.removeEventListener("error",i)},s=()=>{n(Pr(t.result)),o()},i=()=>{r(t.error),o()};t.addEventListener("success",s),t.addEventListener("error",i)});return Va.set(e,t),e}function vP(t){if(Yd.has(t))return;const e=new Promise((n,r)=>{const o=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",i),t.removeEventListener("abort",i)},s=()=>{n(),o()},i=()=>{r(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",s),t.addEventListener("error",i),t.addEventListener("abort",i)});Yd.set(t,e)}let Qd={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Yd.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Pr(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Pk(t){Qd=t(Qd)}function bP(t){return kP().includes(t)?function(...e){return t.apply(eu(this),e),Pr(this.request)}:function(...e){return Pr(t.apply(eu(this),e))}}function SP(t){return typeof t=="function"?bP(t):(t instanceof IDBTransaction&&vP(t),Gd(t,yP())?new Proxy(t,Qd):t)}function Pr(t){if(t instanceof IDBRequest)return wP(t);if(Xd.has(t))return Xd.get(t);const e=SP(t);return e!==t&&(Xd.set(t,e),Va.set(e,t)),e}const eu=t=>Va.get(t);function CP(t,e,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(t,e),a=Pr(i);return r&&i.addEventListener("upgradeneeded",l=>{r(Pr(i.result),l.oldVersion,l.newVersion,Pr(i.transaction),l)}),n&&i.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),o&&l.addEventListener("versionchange",c=>o(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const xP=["get","getKey","getAll","getAllKeys","count"],_P=["put","add","delete","clear"],tu=new Map;function Rk(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(tu.get(e))return tu.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,o=_P.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(o||xP.includes(n)))return;const s=async function(i,...a){const l=this.transaction(i,o?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[n](...a),o&&l.done]))[0]};return tu.set(e,s),s}Pk(t=>({...t,get:(e,n,r)=>Rk(e,n)||t.get(e,n,r),has:(e,n)=>!!Rk(e,n)||t.has(e,n)}));const EP=["continue","continuePrimaryKey","advance"],Dk={},nu=new WeakMap,zk=new WeakMap,TP={get(t,e){if(!EP.includes(e))return t[e];let n=Dk[e];return n||(n=Dk[e]=function(...r){nu.set(this,zk.get(this)[e](...r))}),n}};async function*MP(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const n=new Proxy(e,TP);for(zk.set(n,e),Va.set(n,eu(e));e;)yield n,e=await(nu.get(n)||e.continue()),nu.delete(n)}function $k(t,e){return e===Symbol.asyncIterator&&Gd(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Gd(t,[IDBIndex,IDBObjectStore])}Pk(t=>({...t,get(e,n,r){return $k(e,n)?MP:t.get(e,n,r)},has(e,n){return $k(e,n)||t.has(e,n)}}));async function ru(t,e){const n=await CP(t,1,{upgrade(r){r.objectStoreNames.contains(e)||r.createObjectStore(e)}});return new AP(n,e)}var AP=class{constructor(t,e){this.db=t,this.storeName=e}async get(t){return this.db.get(this.storeName,t)}async put(t,e){await this.db.put(this.storeName,e,t)}async delete(t){await this.db.delete(this.storeName,t)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),n=await e.getAllKeys(),r=await e.getAll(),o=[];for(let s=0;s<n.length;s++)o.push([n[s],r[s]]);return o}async clear(){const t=this.db.transaction(this.storeName,"readwrite");t.objectStore(this.storeName).clear(),await t.done}close(){this.db.close()}},NP=class{constructor(t){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=t.provider,this.documentId=t.documentId,this.maxRetries=t.provider.maxRetries??3,this.retryDelay=t.provider.retryDelay??5e3}async init(){const t=`wovencanvas-assets-${this.documentId}`,[e,n]=await Promise.all([ru(`${t}-jobs`,"jobs"),ru(`${t}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=n}async upload(t,e,n){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(t,e);const r={identifier:t,metadata:n,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(t,r);const o=URL.createObjectURL(e);return this.blobUrls.set(t,o),new Promise((s,i)=>{this.uploadPromises.set(t,{resolve:s,reject:i}),this.startUpload(t)})}async getDisplayUrl(t){const e=this.blobUrls.get(t);if(e)return e;try{return await this.provider.resolveUrl(t)}catch(n){return console.error(`Failed to resolve URL for ${t}:`,n),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const t=await this.jobsStore.getAllEntries();for(const[e]of t){const n=await this.binariesStore.get(e);if(n){const r=URL.createObjectURL(n);this.blobUrls.set(e,r)}this.startUpload(e)}}hasPendingUpload(t){return this.blobUrls.has(t)}isUploading(t){return this.uploading.has(t)}async cancelUpload(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.reject(new Error("Upload cancelled")),this.uploadPromises.delete(t))}close(){var t,e;for(const n of this.blobUrls.values())URL.revokeObjectURL(n);this.blobUrls.clear(),(t=this.jobsStore)==null||t.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(t){if(!this.jobsStore||!this.binariesStore||this.uploading.has(t))return;this.uploading.add(t);const e=await this.jobsStore.get(t),n=await this.binariesStore.get(t);if(!e||!n){this.uploading.delete(t);return}try{await this.provider.upload(n,t,e.metadata),await this.onUploadSuccess(t)}catch(r){await this.onUploadError(t,e,r)}}async onUploadSuccess(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.resolve(),this.uploadPromises.delete(t))}async onUploadError(t,e,n){if(!this.jobsStore)return;const r=n instanceof Error?n.message:"Unknown error";if(console.error(`Upload failed for ${t}:`,r),this.uploading.delete(t),e.retryCount<this.maxRetries){const o={...e,retryCount:e.retryCount+1};await this.jobsStore.put(t,o),setTimeout(()=>{this.startUpload(t)},this.retryDelay*2**e.retryCount)}else{const o=this.uploadPromises.get(t);o&&(o.reject(new Error(r)),this.uploadPromises.delete(t))}}},BP="wovencanvas-assets",OP="blobs",IP=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(t,e,n){return await(await this.getStore()).put(e,{blob:t,metadata:n}),{}}async resolveUrl(t){const n=await(await this.getStore()).get(t);if(!n)throw new Error(`Asset not found: ${t}`);return URL.createObjectURL(n.blob)}async delete(t){await(await this.getStore()).delete(t)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=ru(BP,OP).then(t=>(this.store=t,t))),this.initPromise)}},Vk=rn.object({minZoom:rn.number().default(.05),maxZoom:rn.number().default(2.7)});Vk.parse({});var Rs=h.defineEditorState("panState",{state:h.field.string().max(16).default("idle"),panStartX:h.field.float64().default(0),panStartY:h.field.float64().default(0),velocityX:h.field.float64().default(0),velocityY:h.field.float64().default(0),targetX:h.field.float64().default(0),targetY:h.field.float64().default(0),expectedLeft:h.field.float64().default(0),expectedTop:h.field.float64().default(0)}),Rr=h.defineCanvasSingleton({name:"pinchState"},{active:h.field.boolean().default(!1),prevDistance:h.field.float64().default(0),prevCenter:h.field.tuple(h.field.float64(),2).default([0,0])}),mn=[0,0],La=[0,0],Ds=[0,0],ou=[0,0],su=[0,0];function PP(t,e,n,r,o,s){r=Math.max(1e-4,r);const i=2/r,a=i*s,l=1/(1+a+.48*a*a+.235*a*a*a);E.Vec2.copy(mn,t),E.Vec2.sub(mn,e);const c=o*r,u=c*c,f=E.Vec2.lengthSq(mn);f>u&&E.Vec2.scale(mn,c/Math.sqrt(f)),E.Vec2.copy(La,t),E.Vec2.sub(La,mn),E.Vec2.set(Ds,(n[0]+i*mn[0])*s,(n[1]+i*mn[1])*s);const p=[(n[0]-i*Ds[0])*l,(n[1]-i*Ds[1])*l],m=[La[0]+(mn[0]+Ds[0])*l,La[1]+(mn[1]+Ds[1])*l];return E.Vec2.copy(ou,e),E.Vec2.sub(ou,t),E.Vec2.copy(su,m),E.Vec2.sub(su,e),E.Vec2.dot(ou,su)>0&&(m[0]=e[0],m[1]=e[1],p[0]=(m[0]-e[0])/s,p[1]=(m[1]-e[1])/s),{position:m,velocity:p}}var iu=.1,Lk=.1,RP=on({guards:{hasVelocity:({event:t})=>{if(t.type!=="pointerUp")return!1;const e=t.velocity;return Math.hypot(e[0],e[1])>Lk},isGlideComplete:({context:t})=>Math.hypot(t.velocityX,t.velocityY)<Lk,cameraWasMoved:({context:t,event:e})=>{const n=h.Camera.read(e.ctx);return n.left!==t.expectedLeft||n.top!==t.expectedTop},isEscapeKey:({event:t})=>t.key===h.Key.Escape},actions:{setDragStart:we({panStartX:({event:t})=>t.worldPosition[0],panStartY:({event:t})=>t.worldPosition[1]}),moveCamera:({context:t,event:e})=>{const n=e,{ctx:r}=n,o=n.worldPosition[0]-t.panStartX,s=n.worldPosition[1]-t.panStartY,i=h.Camera.write(r);i.left-=o,i.top-=s},startGlide:we(({event:t})=>{const e=t,{ctx:n}=e,r=h.Camera.read(n),o=e.cameraZoom,s=-e.velocity[0]/o,i=-e.velocity[1]/o;return{velocityX:s,velocityY:i,targetX:r.left+s*iu,targetY:r.top+i*iu,expectedLeft:r.left,expectedTop:r.top}}),animateGlide:we(({context:t,event:e})=>{const n=e,{ctx:r,delta:o}=n,s=h.Camera.read(r),{position:i,velocity:a}=PP([s.left,s.top],[t.targetX,t.targetY],[t.velocityX,t.velocityY],iu,Number.POSITIVE_INFINITY,o),l=h.Camera.write(r);return l.left=i[0],l.top=i[1],{velocityX:a[0],velocityY:a[1],expectedLeft:i[0],expectedTop:i[1]}}),resetContext:we({panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0})}}).createMachine({id:"pan",initial:"idle",context:{panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0},states:{idle:{on:{pointerDown:{actions:"setDragStart",target:"panning"}}},panning:{entry:"moveCamera",on:{pointerMove:{actions:"moveCamera"},pointerUp:[{guard:"hasVelocity",actions:"startGlide",target:"gliding"},{target:"idle"}],keyDown:{guard:"isEscapeKey",target:"idle"}}},gliding:{on:{frame:[{guard:"cameraWasMoved",actions:"resetContext",target:"idle"},{guard:"isGlideComplete",actions:"resetContext",target:"idle"},{actions:"animateGlide"}],pointerDown:{actions:["resetContext","setDragStart"],target:"panning"}}}}}),DP=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=Rs.read(t).state;if(Rr.read(t).active){e!=="idle"&&Rs.copy(t,Rs.default());return}const r=h.Controls.getButtons(t,"hand"),s=[...h.getPointerInput(t,r)];e==="gliding"&&s.push(h.getFrameInput(t)),s.push(...h.getKeyboardInput(t,[h.Key.Escape])),s.length!==0&&Rs.run(t,RP,s)}),zP=h.defineQuery(t=>t.with(h.Pointer)),$P=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=h.getPluginResources(t,"controls"),n=zP.current(t),r=[];for(let g=0;g<n.length;g++){const y=n[g],k=h.Pointer.read(t,y);k.pointerType===h.PointerType.Touch&&r.push(k.position)}if(r.length!==2){if(Rr.read(t).active){const y=Rr.write(t);y.active=!1}return}const[o,s]=r,i=E.Vec2.distance(o,s),a=E.Vec2.midPoint(o,s),l=Rr.read(t);if(!l.active){const g=Rr.write(t);g.prevDistance=i,g.prevCenter=a,g.active=!0;return}const c=h.Camera.read(t),u=h.Screen.read(t);if(l.prevDistance>0&&i>0){const g=i/l.prevDistance;let y=c.zoom*g;y=Math.min(e.maxZoom,Math.max(e.minZoom,y));const k=u.width/c.zoom,w=u.height/c.zoom,v=u.width/y,b=u.height/y,S=v-k,C=b-w,_=a[0]/u.width,x=a[1]/u.height,T=h.Camera.write(t);T.left-=_*S,T.top-=x*C,T.zoom=y}const f=a[0]-l.prevCenter[0],p=a[1]-l.prevCenter[1];if(f!==0||p!==0){const g=h.Camera.write(t);g.left-=f/g.zoom,g.top-=p/g.zoom}const m=Rr.write(t);m.prevDistance=i,m.prevCenter=a}),VP=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=h.Keyboard.read(t);if(!h.Controls.wheelActive(t,"scroll",e.modDown))return;const r=h.getMouseInput(t).find(l=>l.type==="wheel");if(!r)return;const o=h.Camera.read(t),s=o.left+r.wheelDeltaX/o.zoom,i=o.top+r.wheelDeltaY/o.zoom,a=h.Camera.write(t);a.left=s,a.top=i}),LP=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=h.getPluginResources(t,"controls"),n=h.Keyboard.read(t);if(!h.Controls.wheelActive(t,"zoom",n.modDown))return;const o=h.getMouseInput(t).find(S=>S.type==="wheel");if(!o)return;const s=h.Camera.read(t),i=h.Screen.read(t),a=h.Mouse.read(t);let l=2**(-.8*o.wheelDeltaY/500)*s.zoom;l=Math.min(e.maxZoom,Math.max(e.minZoom,l));const c=i.width/s.zoom,u=i.height/s.zoom,f=i.width/l,p=i.height/l,m=f-c,g=p-u,y=a.position[0]/i.width,k=a.position[1]/i.height,w=s.left-y*m,v=s.top-k*g,b=h.Camera.write(t);b.left=w,b.top=v,b.zoom=l});function FP(t={}){return{name:"controls",resources:Vk.parse(t),singletons:[Rs,Rr],systems:[LP,VP,DP,$P]}}var jP=(t={})=>FP(t);const HP={class:"wov-selection-box"},WP=d.defineComponent({__name:"SelectionBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",HP))}}),ZP={class:"wov-transform-box"},UP=d.defineComponent({__name:"TransformBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",ZP))}}),KP={},JP={class:"wov-transform-handle"};function qP(t,e){return d.openBlock(),d.createElementBlock("div",JP)}const GP=ir(KP,[["render",qP]]),YP=d.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Pe(e.entityId,h.Color),r=Pe(e.entityId,h.VerticalAlign),o=d.ref(null),s={[h.VerticalAlignment.Top]:"flex-start",[h.VerticalAlignment.Center]:"center",[h.VerticalAlignment.Bottom]:"flex-end"},i=d.computed(()=>{var l;return{backgroundColor:n.value?`rgb(${n.value.red}, ${n.value.green}, ${n.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((l=r.value)==null?void 0:l.value)??h.VerticalAlignment.Top]}}),{handleEditEnd:a}=Bd({blockData:e,containerRef:o,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(l,c)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-sticky-note",style:d.normalizeStyle(i.value)},[d.createVNode(wa,d.mergeProps(e,{"block-element":o.value,onEditEnd:d.unref(a)}),null,16,["block-element","onEditEnd"])],4))}}),Fa=at.defineCanvasSingleton({name:"blockPlacementState"},{editedCheckpoint:h.field.string().default("").max(36)}),Fk=h.defineQuery(t=>t.with(h.Edited));function XP(t){var e;if(!t)return null;try{const n=JSON.parse(t);return(e=n.block)!=null&&e.tag?n:(console.warn("Block snapshot missing required tag:",n),null)}catch{return console.warn("Invalid block snapshot JSON:",t),null}}function QP(t,e,n){const r=h.getBlockDef(t,e.block.tag);if(!r)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const o=e.block.size??[100,100],s=n[0]-o[0]/2,i=n[1]-o[1]/2,a=e.block.rank??h.RankBounds.genNext(t),l=h.createEntity(t);"synced"in e||h.addComponent(t,l,h.Synced,{id:crypto.randomUUID()});const c=Object.assign({},e.block,{position:[s,i],size:o,rank:a});h.addComponent(t,l,h.Block,c);for(const f of r.components)if(!(f.name in e))h.addComponent(t,l,f);else{const p=e[f.name];h.addComponent(t,l,f,p)}const{sessionId:u}=h.getResources(t);return h.addComponent(t,l,h.Held,{sessionId:u}),l}function jk(t,e,n,r,o){const s=QP(t,e,n),i=h.Block.read(t,s);if(h.canBlockEdit(t,e.block.tag)&&(h.addComponent(t,s,Ko,{}),o==="placement")){const{store:u}=h.getPluginResources(t,"editing"),f=u.createCheckpoint();if(f){const p=Fa.write(t);p.editedCheckpoint=f}}const a=Tt.write(t);a.state=o==="dragOut"?de.Dragging:de.Pointing,a.dragStart=n,a.draggedEntity=s,a.draggedEntityStart=i.position,a.pointingStartClient=r,a.pointingStartWorld=n,a.isCloning=!1;const l=h.Controls.write(t);l.leftMouseTool="select",l.heldSnapshot="";const c=h.Cursor.write(t);c.cursorKind="select",c.rotation=0}function eR(t){const e=Fa.read(t);if(e.editedCheckpoint){const n=e.editedCheckpoint;Fa.write(t).editedCheckpoint="";const{store:r}=h.getPluginResources(t,"editing");r.onSettled(()=>r.squashToCheckpoint(n),{frames:5})}}const tR=h.defineEditorSystem({phase:"capture"},t=>{Fk.removed(t).length>0&&Fk.current(t).length===0&&eR(t);const e=h.Controls.read(t);if(!e.heldSnapshot)return;const n=h.getPointerInput(t,[h.PointerButton.Left]);if(n.length===0)return;const r=XP(e.heldSnapshot);if(!r)return;if(e.leftMouseTool==="drag-out"){const s=n.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;jk(t,r,s.worldPosition,s.screenPosition,"dragOut")}else{const s=n.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;jk(t,r,s.worldPosition,s.screenPosition,"placement")}}),nR=h.defineEditorSystem({phase:"update"},t=>{const{store:e}=h.getPluginResources(t,"editing");h.on(t,h.Undo,()=>{e.canUndo()&&(bf(t),e.undo())}),h.on(t,h.Redo,()=>{e.canRedo()&&(bf(t),e.redo())})}),rR=[{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 Hk(t){return{name:"editing",resources:{store:t.store},singletons:[Fa],systems:[tR,nR],cursors:vk,fonts:rR,keybinds:[{command:h.Undo.name,key:h.Key.Z,mod:!0},{command:h.Redo.name,key:h.Key.Y,mod:!0},{command:h.Redo.name,key:h.Key.Z,mod:!0,shift:!0}]}}const oR=d.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(t){const e=t,{nextEditorTick:n}=Ee(),{createImageBlock:r}=x0(),o=d.ref(!1);let s=0;const i=d.inject("containerRef");function a(v){var b;(b=v.dataTransfer)!=null&&b.types.some(S=>S==="Files"||S==="text/uri-list"||S==="text/html")&&(s++,s===1&&(o.value=!0))}function l(){s--,s===0&&(o.value=!1)}function c(){s=0,o.value=!1}d.onMounted(()=>{const v=i==null?void 0:i.value;v&&(v.addEventListener("dragenter",a),v.addEventListener("dragleave",l),v.addEventListener("drop",c))}),d.onUnmounted(()=>{const v=i==null?void 0:i.value;v&&(v.removeEventListener("dragenter",a),v.removeEventListener("dragleave",l),v.removeEventListener("drop",c))});function u(v){v.preventDefault(),v.dataTransfer&&(v.dataTransfer.dropEffect="copy")}function f(v){v.preventDefault()}function p(v){v.preventDefault()}async function m(v){if(v.preventDefault(),!v.dataTransfer)return;const b=v.clientX,S=v.clientY,C=Array.from(v.dataTransfer.files).filter(x=>x.type.startsWith("image/"));if(C.length>0){for(const x of C)await k(x,b,S);return}const _=g(v.dataTransfer);_&&await w(_,b,S)}function g(v){const b=v.getData("text/uri-list");if(b){const x=b.split(`
|
|
170
|
+
`):""}),r0=PN,o0=" ",RN=" ",DN=wd.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",vo(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===o0||r[0].text===RN)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?o0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),s0=DN,zN=wd.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),i0=zN,a0=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},$N=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VN=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,LN=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,FN=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jN=As.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return a0("strong",{...vo(this.options.HTMLAttributes,t),children:a0("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[pa({find:$N,type:this.type}),pa({find:LN,type:this.type})]},addPasteRules(){return[ma({find:VN,type:this.type}),ma({find:FN,type:this.type})]}}),l0=jN,HN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,WN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ZN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,UN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,KN=As.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",vo(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[pa({find:HN,type:this.type}),pa({find:ZN,type:this.type})]},addPasteRules(){return[ma({find:WN,type:this.type}),ma({find:UN,type:this.type})]}}),c0=KN,JN=As.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",vo(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const s=o[2].trim();return{type:"underline",raw:o[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),d0=JN,qN=be.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:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!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")}}}),u0=qN,GN=20,f0=(t,e=0)=>{const n=[];return!t.children.length||e>GN||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...f0(r,e+1))}),n},YN=t=>{if(!t.children.length)return;const e=f0(t);e&&e.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},vd=As.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&YN(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",vo(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),XN=be.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="background-color")return a.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),h0=be.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="color")return a.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),QN=be.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),eB=be.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),tB=be.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});be.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(XN.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(h0.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(QN.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(eB.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(tB.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(vd.configure(this.options.textStyle)),t}});var p0=h0;function nB(t={}){return new Oe({view(e){return new rB(e,t)}})}class rB{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let g=m.getBoundingClientRect(),y=f?g.bottom:g.top;f&&p&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*a;r={left:g.left,right:g.right,top:y-k,bottom:y+k}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*i;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),p=f.width/l.offsetWidth,m=f.height/l.offsetHeight;c=f.left-l.scrollLeft*p,u=f.top-l.scrollTop*m}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!s){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Om(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}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 xe extends ie{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return xe.valid(r)?new xe(r):ie.near(r)}content(){return L.empty}eq(e){return e instanceof xe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new xe(e.resolve(n.pos))}getBookmark(){return new bd(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!oB(e)||!sB(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&xe.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(n>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=n;let l=e.doc.resolve(o);if(xe.valid(l))return l}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!G.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*n),r=!1;continue e}break}s=i,o+=n;let a=e.doc.resolve(o);if(xe.valid(a))return a}return null}}}xe.prototype.visible=!1,xe.findFrom=xe.findGapCursorFrom,ie.jsonID("gapcursor",xe);class bd{constructor(e){this.pos=e}map(e){return new bd(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return xe.valid(n)?new xe(n):ie.near(n)}}function m0(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function oB(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||m0(o.type))return!0;if(o.inlineContent)return!1}}return!0}function sB(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||m0(o.type))return!0;if(o.inlineContent)return!1}}return!0}function iB(){return new Oe({props:{decorations:dB,createSelectionBetween(t,e,n){return e.pos==n.pos&&xe.valid(n)?new xe(n):null},handleClick:lB,handleKeyDown:aB,handleDOMEvents:{beforeinput:cB}}})}const aB=wy({ArrowLeft:ga("horiz",-1),ArrowRight:ga("horiz",1),ArrowUp:ga("vert",-1),ArrowDown:ga("vert",1)});function ga(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof re){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=xe.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new xe(c))),!0):!1}}function lB(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!xe.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&G.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new xe(r))),!0)}function cB(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof xe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=B.empty;for(let i=r.length-1;i>=0;i--)o=B.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new L(o,0,0));return s.setSelection(re.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function dB(t){if(!(t.selection instanceof xe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ce.create(t.doc,[nt.widget(t.selection.head,e,{key:"gapcursor"})])}var ya=200,$e=function(){};$e.prototype.append=function(e){return e.length?(e=$e.from(e),!this.length&&e||e.length<ya&&this.leafAppend(e)||this.length<ya&&e.leafPrepend(this)||this.appendInner(e)):this},$e.prototype.prepend=function(e){return e.length?$e.from(e).append(this):this},$e.prototype.appendInner=function(e){return new uB(this,e)},$e.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?$e.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},$e.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},$e.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)},$e.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},n,r),o},$e.from=function(e){return e instanceof $e?e:e&&e.length?new g0(e):$e.empty};var g0=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,a){for(var l=s;l<i;l++)if(o(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,a){for(var l=s-1;l>=i;l--)if(o(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=ya)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=ya)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}($e);$e.empty=new g0([]);var uB=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(s,a),i)===!1||s>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,s)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(s,a)-a,i+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(o,a),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}($e);const fB=500;class Ot{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;n&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){o||(o=this.remapping(r,p+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Jt(f.map));let m=f.step.map(o.slice(s)),g;m&&i.maybeStep(m).doc&&(g=i.mapping.maps[i.mapping.maps.length-1],c.push(new Jt(g,void 0,void 0,c.length+u.length))),s--,g&&o.appendMap(g,s)}else i.maybeStep(f.step);if(f.selection)return a=o?f.selection.map(o.slice(s)):f.selection,l=new Ot(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,n,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new Jt(e.mapping.maps[u],f,n),m;(m=l&&l.merge(p))&&(p=m,u?s.pop():a=a.slice(0,a.length-1)),s.push(p),n&&(i++,n=void 0),o||(l=p)}let c=i-r.depth;return c>pB&&(a=hB(a,c),i-=c),new Ot(a.append(s),i)}remapping(e,n){let r=new ds;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ot(this.items.append(e.map(n=>new Jt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},o);let l=n;this.items.forEach(p=>{let m=s.getMirror(--l);if(m==null)return;i=Math.min(i,m);let g=s.maps[m];if(p.step){let y=e.steps[m].invert(e.docs[m]),k=p.selection&&p.selection.map(s.slice(l+1,m));k&&a++,r.push(new Jt(g,y,k))}else r.push(new Jt(g))},o);let c=[];for(let p=n;p<i;p++)c.push(new Jt(s.maps[p]));let u=this.items.slice(0,o).append(c).append(r),f=new Ot(u,a);return f.emptyItemCount()>fB&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&s++;let f=new Jt(c.invert(),l,u),p,m=o.length-1;(p=o.length&&o[m].merge(f))?o[m]=p:o.push(f)}}else i.map&&r--},this.items.length,0),new Ot($e.from(o.reverse()),s)}}Ot.empty=new Ot($e.empty,0);function hB(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}class Jt{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Jt(n.getMap().invert(),n,this.selection)}}}class Hn{constructor(e,n,r,o,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const pB=20;function mB(t,e,n,r){let o=n.getMeta(Tr),s;if(o)return o.historyState;n.getMeta(kB)&&(t=new Hn(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Tr))return i.getMeta(Tr).redo?new Hn(t.done.addTransform(n,void 0,r,ka(e)),t.undone,y0(n.mapping.maps),t.prevTime,t.prevComposition):new Hn(t.done,t.undone.addTransform(n,void 0,r,ka(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!gB(n,t.prevRanges)),c=i?Sd(t.prevRanges,n.mapping):y0(n.mapping.maps);return new Hn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,ka(e)),Ot.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Hn(t.done.rebased(n,s),t.undone.rebased(n,s),Sd(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Hn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Sd(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function gB(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(n=!0)}),n}function y0(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,s,i)=>e.push(s,i));return e}function Sd(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),s=e.map(t[r+1],-1);o<=s&&n.push(o,s)}return n}function yB(t,e,n){let r=ka(e),o=Tr.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Hn(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(Tr,{redo:n,historyState:l})}let Cd=!1,k0=null;function ka(t){let e=t.plugins;if(k0!=e){Cd=!1,k0=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Cd=!0;break}}return Cd}const Tr=new Qe("history"),kB=new Qe("closeHistory");function wB(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Oe({key:Tr,state:{init(){return new Hn(Ot.empty,Ot.empty,null,0,-1)},apply(e,n,r){return mB(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?v0:r=="historyRedo"?b0:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function w0(t,e){return(n,r)=>{let o=Tr.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=yB(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const v0=w0(!1,!0),b0=w0(!0,!0);be.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Oe({key:new Qe("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),be.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[nB(this.options)]}}),be.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Oe({key:new Qe("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return Ce.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(nt.node(c,c+l.nodeSize,{class:this.options.className}))}),Ce.create(t,s)}}})]}}),be.create({name:"gapCursor",addProseMirrorPlugins(){return[iB()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ke(U(t,"allowGapCursor",n)))!=null?e:null}}});var S0="placeholder";function vB(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}be.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:S0,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${vB(this.options.dataAttribute)}`:`data-${S0}`;return[new Oe({key:new Qe("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,s=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((a,l)=>{const c=o>=l&&o<=l+a.nodeSize,u=!a.isLeaf&&ca(a);if((c||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=nt.node(l,l+a.nodeSize,{class:f.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(p)}return this.options.includeChildren}),Ce.create(e,s)}}})]}}),be.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Oe({key:new Qe("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||zA(n.selection)||t.view.dragging?null:Ce.create(n.doc,[nt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function C0({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}be.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Qe(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new Oe({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,u=e.getState(i),f=a.content.size,p=c.nodes[n];if(u)return l.insert(f,p.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!C0({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!C0({node:i,types:r})}}})]}});var bB=be.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>v0(t,e),redo:()=>({state:t,dispatch:e})=>b0(t,e)}},addProseMirrorPlugins(){return[wB(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()}}});function Wn(t,e){const n=d.inject(pt);if(!n)throw new Error("useComponents must be used within a WovenCanvas component");const r=d.shallowRef(new Map),o=new Map;function s(a){if(o.has(a))return;const l=n.getEditor();if(l){const u=l._getContext();if(h.hasComponent(u,a,e)){const f=new Map(r.value);f.set(a,e.snapshot(u,a)),r.value=f}else{const f=new Map(r.value);f.set(a,null),r.value=f}}const c=n.subscribeComponent(a,e.name,u=>{const f=new Map(r.value);f.set(a,u),r.value=f});o.set(a,c)}function i(a){const l=o.get(a);if(l){l(),o.delete(a);const c=new Map(r.value);c.delete(a),r.value=c}}return d.watch(()=>d.toValue(t),(a,l)=>{const c=new Set(a),u=new Set(l??[]);for(const f of u)c.has(f)||i(f);for(const f of c)u.has(f)||s(f)},{immediate:!0}),d.onUnmounted(()=>{for(const a of o.values())a();o.clear()}),r}function x0(){const t=d.inject(pt);if(!t)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=Ee();function n(s){return new Promise((i,a)=>{const l=new window.Image;l.onload=()=>{i({width:l.naturalWidth,height:l.naturalHeight}),URL.revokeObjectURL(l.src)},l.onerror=()=>{a(new Error("Failed to load image")),URL.revokeObjectURL(l.src)},l.src=URL.createObjectURL(s)})}async function r(s,i,a,l={}){const{maxSize:c=400}=l,u=await n(s),f=await e(),p=Math.min(1,c/Math.max(u.width,u.height));let m=Math.round(u.width*p),g=Math.round(u.height*p);const y=h.Grid.read(f);y.enabled&&(m=Math.max(y.colWidth,Math.round(m/y.colWidth)*y.colWidth),g=Math.max(y.rowHeight,Math.round(g/y.rowHeight)*y.rowHeight));const k=h.createEntity(f);h.addComponent(f,k,h.Block);const w=h.Block.write(f,k);w.tag="image",w.position[0]=i-m/2,w.position[1]=a-g/2,w.size[0]=m,w.size[1]=g,h.Grid.snapPosition(f,w.position);const v=crypto.randomUUID();h.addComponent(f,k,h.Asset);const b=h.Asset.write(f,k);b.identifier=v,b.uploadState=h.UploadState.Pending,h.addComponent(f,k,h.Image);const S=h.Image.write(f,k);return S.width=u.width,S.height=u.height,S.alt=s.name,h.addComponent(f,k,at.Synced,{id:crypto.randomUUID()}),(t==null?void 0:t.getAssetManager())&&o(k,v,s),k}async function o(s,i,a){const l=t==null?void 0:t.getAssetManager();if(l)try{await l.upload(i,a,{filename:a.name,mimeType:a.type});const c=await e(),u=h.Asset.write(c,s);u.uploadState=h.UploadState.Complete}catch{const c=await e(),u=h.Asset.write(c,s);u.uploadState=h.UploadState.Failed}}return{getImageDimensions:n,createImageBlock:r}}function _0(t){const e=d.inject(pt);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const n=d.shallowRef([]),r=h.defineQuery(f=>f.with(...t)),o=new Map;let s=!1;function i(f){const p=e.getEditor();if(!p)return{refs:{},unsubscribes:[]};const m=p._getContext(),g={},y=[];for(const k of t){const w=d.shallowRef(k.snapshot(m,f));g[k.name]=w;const v=e.subscribeComponent(f,k.name,b=>{w.value=b});y.push(v)}return{refs:g,unsubscribes:y}}function a(f){const p=o.get(f);if(p){for(const m of p.unsubscribes)m();o.delete(f)}}function l(){const f=[];for(const[p,m]of o)f.push({entityId:p,...m.refs});return f}function c(f){if(!s){const y=r.current(f);for(const k of y)o.set(k,i(k));n.value=l(),s=!0;return}const p=r.added(f),m=r.removed(f);let g=!1;for(const y of m)a(y),g=!0;for(const y of p)o.has(y)||(o.set(y,i(y)),g=!0);g&&(n.value=l())}const u=e.registerTickCallback(c);return d.onUnmounted(()=>{u();for(const f of o.keys())a(f)}),n}function Ze(t){const e=d.inject(pt);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const n=d.shallowRef(t.default()),r=e.getEditor();if(r){const i=r._getContext();n.value=t.snapshot(i)}const o=e.subscribeSingleton(t.name,i=>{n.value=i??{}});let s=null;return r||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const a=i._getContext();n.value=t.snapshot(a),s==null||s(),s=null}})),d.onUnmounted(()=>{o(),s==null||s()}),n}function xd(t,e,n){if(!t.closest(".wov-block")){const m=t.getBoundingClientRect();return{width:m.width,height:m.height,left:0,top:0}}const o=t.getBoundingClientRect(),s=n.value.left,i=n.value.top,a=new DOMPoint(o.left+o.width/2-s,o.top+o.height/2-i),l=e.value.zoom,c=new DOMMatrix;c.translateSelf(-e.value.left*l,-e.value.top*l),c.scaleSelf(l,l),c.invertSelf();const u=c.transformPoint(a),f=t.offsetWidth,p=t.offsetHeight;return{width:f,height:p,left:u.x-f/2,top:u.y-p/2}}function E0(t){if(t.startsWith("#"))return t.toUpperCase();const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const n=parseInt(e[1],10).toString(16).padStart(2,"0"),r=parseInt(e[2],10).toString(16).padStart(2,"0"),o=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`.toUpperCase()}return t}function Ns(t){const e=Math.round(t.red),n=Math.round(t.green),r=Math.round(t.blue),o=Math.round(t.alpha);return o<255?"#"+[e,n,r,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,n,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function _d(t){t=t.replace(/^#/,"");let e,n,r,o=255;if(t.length===6)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);else if(t.length===8)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16),o=parseInt(t.slice(6,8),16);else return null;return{red:e,green:n,blue:r,alpha:o}}function T0(t){const e=_d(t);if(!e)return{h:0,s:100,v:100,a:255};const n=e.red/255,r=e.green/255,o=e.blue/255,s=Math.max(n,r,o),i=Math.min(n,r,o),a=s-i;let l=0;const c=s===0?0:a/s*100,u=s*100;if(a!==0)switch(s){case n:l=((r-o)/a+(r<o?6:0))*60;break;case r:l=((o-n)/a+2)*60;break;case o:l=((n-r)/a+4)*60;break}return{h:l,s:c,v:u,a:e.alpha}}function M0(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const p=m=>Math.round(m*255).toString(16).padStart(2,"0");return`#${p(o)}${p(s)}${p(i)}`}function A0(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const p=g=>Math.round(g*255).toString(16).padStart(2,"0"),m=Math.round(t.a).toString(16).padStart(2,"0");return t.a<255?`#${p(o)}${p(s)}${p(i)}${m}`:`#${p(o)}${p(s)}${p(i)}`}const st=d.shallowRef(null),Ed=d.shallowRef(null),Td=d.shallowRef(null),Zn=d.ref(0);function Bs(){const t={hasEditor:d.computed(()=>st.value!==null),isBold:d.computed(()=>{var o;return Zn.value,((o=st.value)==null?void 0:o.isActive("bold"))??!1}),isItalic:d.computed(()=>{var o;return Zn.value,((o=st.value)==null?void 0:o.isActive("italic"))??!1}),isUnderline:d.computed(()=>{var o;return Zn.value,((o=st.value)==null?void 0:o.isActive("underline"))??!1}),alignment:d.computed(()=>{Zn.value;const o=st.value;return o?o.isActive({textAlign:"center"})?"center":o.isActive({textAlign:"right"})?"right":o.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:d.computed(()=>{Zn.value;const o=st.value;if(!o)return null;const i=o.getAttributes("textStyle").color??null;return i?E0(i):null})},e={toggleBold(){const o=st.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleBold(),a&&(l=l.setTextSelection(i)),l.run()},toggleItalic(){const o=st.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleItalic(),a&&(l=l.setTextSelection(i)),l.run()},toggleUnderline(){const o=st.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleUnderline(),a&&(l=l.setTextSelection(i)),l.run()},setAlignment(o){const s=st.value;s&&s.chain().selectAll().setTextAlign(o).run()},setColor(o){const s=st.value;if(!s)return;const{from:i,to:a}=s.state.selection;i===a?s.chain().focus().selectAll().setColor(o).setTextSelection(a).run():s.chain().focus().setColor(o).run()}};function n(o,s,i){st.value=o,Td.value=s,Ed.value=i,o.on("selectionUpdate",()=>{Zn.value++}),o.on("transaction",()=>{Zn.value++})}function r(){st.value=null,Td.value=null,Ed.value=null}return{editor:st,blockElement:Ed,textElement:Td,state:t,commands:e,updateCounter:Zn,register:n,unregister:r}}const vt=[r0,s0,i0,vd,p0,l0,c0,d0,u0.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function SB(t){return t.type==="text"&&typeof t.text=="string"}function Mr(t,e){if(SB(t)){e(t);return}if(t.content)for(const n of t.content)Mr(n,e)}function Md(t,e){if(t.type==="paragraph"){e(t);return}if(t.content)for(const n of t.content)Md(n,e)}function CB(t,e){var n;return((n=t.marks)==null?void 0:n.some(r=>r.type===e))??!1}function xB(t){var r,o;const e=(r=t.marks)==null?void 0:r.find(s=>s.type==="textStyle"),n=((o=e==null?void 0:e.attrs)==null?void 0:o.color)??null;return n?E0(n):null}function _B(t,e){if(!t.trim())return!1;const n=jn(t,vt);let r=!1,o=!0,s=0;return Mr(n,i=>{s++,CB(i,e)?r=!0:o=!1}),s===0?!1:o?!0:r?null:!1}function EB(t){if(!t.trim())return"left";const e=jn(t,vt);let n="left";return Md(e,r=>{var s;const o=(s=r.attrs)==null?void 0:s.textAlign;o&&(n=o)}),n}function TB(t){if(!t.trim())return null;const e=jn(t,vt);let n=null;return Mr(e,r=>{n===null&&(n=xB(r))}),n}function Ad(t,e){if(!t.trim())return t;const n=jn(t,vt);return Mr(n,r=>{const o=r.marks??[];o.findIndex(i=>i.type===e)===-1&&(r.marks=[...o,{type:e}])}),aa(n,vt)}function Nd(t,e){if(!t.trim())return t;const n=jn(t,vt);return Mr(n,r=>{const o=r.marks??[];r.marks=o.filter(s=>s.type!==e)}),aa(n,vt)}function MB(t,e){if(!t.trim())return t;const n=jn(t,vt);return Md(n,r=>{r.attrs={...r.attrs,textAlign:e}}),aa(n,vt)}function AB(t,e){if(!t.trim())return t;const n=jn(t,vt);return Mr(n,r=>{const o=r.marks??[],s=o.findIndex(i=>i.type==="textStyle");s!==-1?(o[s]={...o[s],attrs:{...o[s].attrs,color:e}},r.marks=o):r.marks=[...o,{type:"textStyle",attrs:{color:e}}]}),aa(n,vt)}function N0(t){const e=document.querySelector(`[data-entity-id="${t}"]`);if(!e)return null;const n=e.firstElementChild;return n||e.querySelector(".wov-editable-text")}function B0(t,e,n,r){var l;const o=t.cloneNode(!0);o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none",o.style.top="0",o.style.left="0";const s=o.classList.contains("wov-editable-text")?o:o.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${r.fontSizePx}px`,s.style.fontFamily=r.fontFamily);const i=o.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=r.content:s?s.innerHTML=r.content:o.innerHTML=r.content,(l=t.parentElement)==null||l.appendChild(o);const a=xd(o,e,n);return o.remove(),a}function O0(t){const{nextEditorTick:e}=Ee(),n=Wn(t,h.Text),r=Ze(h.Camera),o=Ze(h.Screen),s=Bs(),i={hasTextEntities:d.computed(()=>{for(const p of n.value.values())if(p)return!0;return!1}),hasTextContent:d.computed(()=>{for(const p of n.value.values()){if(!p)continue;const m=p.content?jn(p.content,vt):null;if(m){let g=!1;if(Mr(m,y=>{var k;(k=y.text)!=null&&k.trim()&&(g=!0)}),g)return!0}}return!1}),isBold:d.computed(()=>a("bold")),isItalic:d.computed(()=>a("italic")),isUnderline:d.computed(()=>a("underline")),alignment:d.computed(()=>{let p=null;for(const m of n.value.values()){if(!m)continue;const g=EB(m.content);if(p===null)p=g;else if(p!==g)return null}return p??"left"}),color:d.computed(()=>{let p=null,m=!1;for(const g of n.value.values()){if(!g)continue;const y=TB(g.content);if(!m)p=y,m=!0;else if(p!==y)return null}return p}),fontSize:d.computed(()=>{let p=null,m=!1;for(const g of n.value.values())if(g){if(!m)p=g.fontSizePx,m=!0;else if(p!==g.fontSizePx)return null}return p}),fontFamily:d.computed(()=>{let p=null,m=!1;for(const g of n.value.values())if(g){if(!m)p=g.fontFamily,m=!0;else if(p!==g.fontFamily)return null}return p})};function a(p){let m=null,g=!1;for(const y of n.value.values()){if(!y)continue;const k=_B(y.content,p);if(!g)m=k,g=!0;else if(m!==k)return null}return m}const l={toggleBold(){u(p=>i.isBold.value?Nd(p,"bold"):Ad(p,"bold"))},toggleItalic(){u(p=>i.isItalic.value?Nd(p,"italic"):Ad(p,"italic"))},toggleUnderline(){u(p=>i.isUnderline.value?Nd(p,"underline"):Ad(p,"underline"))},setAlignment(p){f(m=>MB(m,p))},setColor(p){f(m=>AB(m,p))},setFontSize(p){c(m=>({...m,fontSizePx:p}),m=>{m.fontSizePx=p})},setFontFamily(p){c(m=>({...m,fontFamily:p}),m=>{m.fontFamily=p})}};function c(p,m){const g=d.toValue(t),y=[];for(const k of g){const w=n.value.get(k);if(!w)continue;const v=N0(k);if(v){const b=B0(v,r,o,p(w));y.push({entityId:k,...b})}}e(k=>{for(const w of g)m(h.Text.write(k,w));for(const{entityId:w,width:v,height:b,left:S,top:C}of y){const _=h.Block.write(k,w);_.size=[v,b],_.position=[S,C]}d.nextTick(()=>{s.updateCounter.value++})})}function u(p){const m=d.toValue(t),g=[];for(const y of m){const k=n.value.get(y);if(!k)continue;const w=p(k.content),v=N0(y);if(v){const b=B0(v,r,o,{...k,content:w});g.push({entityId:y,content:w,...b})}else g.push({entityId:y,content:w,width:0,height:0,left:0,top:0})}e(y=>{for(const{entityId:k,content:w,width:v,height:b,left:S,top:C}of g){const _=h.Text.write(y,k);if(_.content=w,v>0&&b>0){const x=h.Block.write(y,k);x.size=[v,b],x.position=[S,C]}}})}function f(p){const m=d.toValue(t);e(g=>{for(const y of m){const k=h.Text.write(g,y);k.content=p(k.content)}})}return{state:i,commands:l}}function qt(t){const e=Bs(),n=O0(t),r=e.state.hasEditor;return{state:d.reactive({hasTextToFormat:d.computed(()=>r.value||n.state.hasTextEntities.value),hasEditor:r,hasTextContent:d.computed(()=>n.state.hasTextContent.value),showTextMenuButtons:d.computed(()=>r.value||n.state.hasTextContent.value),isBold:d.computed(()=>r.value?e.state.isBold.value:n.state.isBold.value===!0),isItalic:d.computed(()=>r.value?e.state.isItalic.value:n.state.isItalic.value===!0),isUnderline:d.computed(()=>r.value?e.state.isUnderline.value:n.state.isUnderline.value===!0),alignment:d.computed(()=>r.value?e.state.alignment.value:n.state.alignment.value??"left"),color:d.computed(()=>r.value?e.state.color.value:n.state.color.value),fontSize:d.computed(()=>n.state.fontSize.value),fontFamily:d.computed(()=>n.state.fontFamily.value)}),commands:{toggleBold(){r.value?e.commands.toggleBold():n.commands.toggleBold()},toggleItalic(){r.value?e.commands.toggleItalic():n.commands.toggleItalic()},toggleUnderline(){r.value?e.commands.toggleUnderline():n.commands.toggleUnderline()},setAlignment(i){r.value?e.commands.setAlignment(i):n.commands.setAlignment(i)},setColor(i){r.value?e.commands.setColor(i):n.commands.setColor(i)},setFontSize(i){n.commands.setFontSize(i)},setFontFamily(i){n.commands.setFontFamily(i)}}}}function Bd(t){const e=Ze(h.Camera),n=Ze(h.Screen),r=Ze(xl),o=Ze(Tt),{nextEditorTick:s}=Ee();let i=!1,a=null;function l(u,f){const{entityId:p}=d.toValue(t.blockData),m=d.toValue(t.minWidth)??0,g=d.toValue(t.minHeight)??0,y=Math.max(f.width,m),k=Math.max(f.height,g),w=h.Block.read(u,p),v=Math.abs(w.size[0]-y)>.5,b=Math.abs(w.size[1]-k)>.5;if(!v&&!b)return;const S=h.Block.write(u,p);S.size=[y,k],S.position=[f.left,f.top],r.value.transformBoxId!==null&&vl.spawn(u,{transformBoxId:r.value.transformBoxId})}d.watch(()=>o.value,()=>{s(u=>{const f=NB(u);if(i&&!f){const p=t.containerRef.value;if(!p)return;a=xd(p,e,n),l(u,a),a=null}i=f})},{flush:"sync"});function c(u){const{content:f,...p}=u;s(m=>{const{entityId:g}=d.toValue(t.blockData);if(h.Text.read(m,g).content!==f){const k=h.Text.write(m,g);k.content=f}l(m,p)})}return{handleEditEnd:c}}function NB(t){const e=Tt.read(t);return e.state===de.Dragging&&e.draggedEntity!==null&&h.hasComponent(t,e.draggedEntity,ve)&&ve.read(t,e.draggedEntity).kind===Et.Stretch}function Od(){const t=d.inject(Ul);if(!t)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:t.activeTool,heldTool:t.heldTool,setTool:t.setTool,dragOutTool:t.dragOutTool,onToolPointerDown:t.onToolPointerDown,onToolPointerUp:t.onToolPointerUp,isActive:e=>d.computed(()=>t.activeTool.value===e)}}const BB=500,OB=1500;function I0(){const t=d.ref(null),e=d.ref(!1),n=d.ref(!1);let r=null,o=null;function s(){r&&(clearTimeout(r),r=null),o&&(clearTimeout(o),o=null)}function i(c,u){s(),t.value={text:c,anchor:u},n.value?e.value=!0:r=setTimeout(()=>{e.value=!0,n.value=!0,r=null},BB)}function a(){s(),e.value=!1,t.value=null,n.value&&(o=setTimeout(()=>{n.value=!1,o=null},OB))}function l(){s(),e.value=!1,t.value=null,n.value=!1}return{activeTooltip:d.readonly(t),isVisible:d.readonly(e),isWarmedUp:d.readonly(n),show:i,hide:a,reset:l}}function Un(){const t=d.inject(yh);if(!t)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return t}const IB={key:1},PB=["innerHTML"],RB=50,DB=300,wa=d.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(t,{expose:e,emit:n}){var C;const r=t,o=n,s=Pe(r.entityId,h.Text),i=Ze(h.Camera),a=Ze(h.Screen),l=Bs(),{nextEditorTick:c}=Ee(),u=Ze(h.Mouse),f=d.ref(null);e({editableTextRef:f});const p=d.ref(((C=s.value)==null?void 0:C.content)??""),m=d.shallowRef(null);function g(_,x){var I;const T=s.value;return!T||T.constrainWidth||(((I=x.clipboardData)==null?void 0:I.getData("text/plain"))??"").length>RB&&c(V=>{const K=h.Text.write(V,r.entityId);K.constrainWidth=!0;const M=h.Block.read(V,r.entityId),$=Math.max(M.size[0],DB),Z=h.Block.write(V,r.entityId);Z.size=[$,M.size[1]],h.ResetKeyboard.spawn(V),Xr.spawn(V)}),!1}function y(){var _,x;return new ON({extensions:[r0,s0,i0,vd,p0,l0,c0,d0,u0.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((_=s.value)==null?void 0:_.defaultAlignment)??"left"}),bB],content:((x=s.value)==null?void 0:x.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:g}})}d.watch(()=>r.edited,async _=>{if(_&&f.value){if(m.value=y(),await k(m.value),!r.blockElement)return;l.register(m.value,f.value,r.blockElement)}else m.value&&(l.unregister(),w(m.value),m.value.destroy(),m.value=null)},{immediate:!0});async function k(_){var I;const x=(I=u.value)==null?void 0:I.position,T=a.value;await d.nextTick(),await new Promise(V=>requestAnimationFrame(V));const N=f.value;if(x&&T&&N){const V=x[0]+T.left,K=x[1]+T.top,M=_.view.posAtCoords({left:V,top:K});if(M){_.chain().focus().setTextSelection(M.pos).run();return}}_.commands.focus("start")}function w(_){let x=_.getHTML();const N=x.replace(/<[^>]*>/g,"").trim().length>0;N||(x=""),p.value=x,c(I=>{var Z,ae;const V=h.getBlockDef(I,r.block.tag);if(!N&&((Z=V.editOptions)!=null&&Z.removeWhenTextEmpty)){h.removeEntity(I,r.entityId);return}const K=(ae=f.value)==null?void 0:ae.closest(".wov-block"),M=(K==null?void 0:K.firstElementChild)??f.value;if(!M){console.warn("EditableText: no element to measure");return}const $=xd(M,i,a);o("editEnd",{content:x,...$})})}d.watch(()=>{var _;return(_=s.value)==null?void 0:_.content},_=>{_!==void 0&&(m.value?m.value.getHTML()!==_&&m.value.commands.setContent(_,{emitUpdate:!1}):p.value=_)});const v=d.computed(()=>{const _=s.value;if(!_)return{};const[x,T]=r.block.flip,N=x?-1:1,I=T?-1:1,V=x||T;return{fontFamily:_.fontFamily,fontSize:`${_.fontSizePx}px`,lineHeight:_.lineHeight,letterSpacing:`${_.letterSpacingEm}em`,width:_.constrainWidth?"100%":"fit-content",whiteSpace:_.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:r.edited?"auto":"none",userSelect:r.edited?"auto":"none",transform:V?`scale(${N}, ${I})`:void 0}});function b(_){_.key==="Control"||_.key==="Meta"||_.stopPropagation()}function S(_){r.edited&&_.stopPropagation()}return d.onUnmounted(()=>{m.value&&(l.unregister(),m.value.destroy(),m.value=null)}),(_,x)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:d.normalizeStyle(v.value),onKeydown:b,onPointerdown:S,onPointermove:S,onPointerup:S},[m.value?(d.openBlock(),d.createBlock(d.unref(IN),{key:0,editor:m.value},null,8,["editor"])):(d.openBlock(),d.createElementBlock("div",IB,[d.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:p.value},null,8,PB)]))],36))}}),zB={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},$B=["d","fill","stroke","stroke-width","stroke-dasharray"],P0=d.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Pe(e.entityId,h.Shape),r=Pe(e.entityId,h.VerticalAlign),o=d.ref(null),s={[h.VerticalAlignment.Top]:"flex-start",[h.VerticalAlignment.Center]:"center",[h.VerticalAlignment.Bottom]:"flex-end"},i=d.computed(()=>n.value?`rgba(${n.value.fillRed}, ${n.value.fillGreen}, ${n.value.fillBlue}, ${(n.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),a=d.computed(()=>n.value?n.value.strokeKind===h.StrokeKind.None?"none":`rgba(${n.value.strokeRed}, ${n.value.strokeGreen}, ${n.value.strokeBlue}, ${n.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),l=d.computed(()=>{var y;return((y=n.value)==null?void 0:y.strokeWidth)??2}),c=d.computed(()=>{var y;return((y=n.value)==null?void 0:y.strokeKind)??h.StrokeKind.Solid}),u=d.computed(()=>{var y;return ss[((y=n.value)==null?void 0:y.kind)??"rectangle"]??ss.rectangle}),f=d.computed(()=>{const y=l.value;switch(c.value){case h.StrokeKind.Dashed:return`${y*3} ${y*3}`;case h.StrokeKind.None:return"";case h.StrokeKind.Solid:default:return""}}),p=d.computed(()=>{var y;return{overflow:e.edited?"visible":"hidden",alignItems:s[((y=r.value)==null?void 0:y.value)??h.VerticalAlignment.Top]}}),{nextEditorTick:m}=Ee();function g(y){m(k=>{if(h.Text.read(k,e.entityId).content===y.content)return;const v=h.Text.write(k,e.entityId);v.content=y.content})}return(y,k)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-shape-block"},[(d.openBlock(),d.createElementBlock("svg",zB,[d.createElementVNode("path",{d:u.value,fill:i.value,stroke:a.value,"stroke-width":l.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,$B)])),d.createElementVNode("div",{class:"wov-shape-content",style:d.normalizeStyle(p.value)},[d.createVNode(wa,d.mergeProps(e,{"block-element":o.value,onEditEnd:g}),null,16,["block-element"])],4)],512))}}),VB=["data-text-empty"],R0=d.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=d.ref(null),r=Pe(e.entityId,h.Text),o=d.computed(()=>{var c;return(((c=r.value)==null?void 0:c.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),s=d.computed(()=>{var a;return((a=r.value)==null?void 0:a.constrainWidth)??!1}),{handleEditEnd:i}=Bd({blockData:e,containerRef:n});return(a,l)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:n,class:"wov-text-block","data-text-empty":o.value||void 0,style:d.normalizeStyle({width:s.value?"100%":"fit-content"})},[d.createVNode(wa,d.mergeProps(e,{"block-element":n.value,onEditEnd:d.unref(i)}),null,16,["block-element","onEditEnd"])],12,VB))}}),va=Math.min,Ar=Math.max,ba=Math.round,Sa=Math.floor,Gt=t=>({x:t,y:t}),LB={left:"right",right:"left",bottom:"top",top:"bottom"},FB={start:"end",end:"start"};function D0(t,e,n){return Ar(t,va(e,n))}function Ca(t,e){return typeof t=="function"?t(e):t}function Nr(t){return t.split("-")[0]}function xa(t){return t.split("-")[1]}function z0(t){return t==="x"?"y":"x"}function $0(t){return t==="y"?"height":"width"}const jB=new Set(["top","bottom"]);function Kn(t){return jB.has(Nr(t))?"y":"x"}function V0(t){return z0(Kn(t))}function HB(t,e,n){n===void 0&&(n=!1);const r=xa(t),o=V0(t),s=$0(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=_a(i)),[i,_a(i)]}function WB(t){const e=_a(t);return[Id(t),e,Id(e)]}function Id(t){return t.replace(/start|end/g,e=>FB[e])}const L0=["left","right"],F0=["right","left"],ZB=["top","bottom"],UB=["bottom","top"];function KB(t,e,n){switch(t){case"top":case"bottom":return n?e?F0:L0:e?L0:F0;case"left":case"right":return e?ZB:UB;default:return[]}}function JB(t,e,n,r){const o=xa(t);let s=KB(Nr(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(Id)))),s}function _a(t){return t.replace(/left|right|bottom|top/g,e=>LB[e])}function qB(t){return{top:0,right:0,bottom:0,left:0,...t}}function GB(t){return typeof t!="number"?qB(t):{top:t,right:t,bottom:t,left:t}}function Ea(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function j0(t,e,n){let{reference:r,floating:o}=t;const s=Kn(e),i=V0(e),a=$0(i),l=Nr(e),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(l){case"top":m={x:u,y:r.y-o.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(xa(e)){case"start":m[i]-=p*(n&&c?-1:1);break;case"end":m[i]+=p*(n&&c?-1:1);break}return m}async function YB(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=Ca(e,t),g=GB(m),k=a[p?f==="floating"?"reference":"floating":f],w=Ea(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},C=Ea(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(w.top-C.top+g.top)/S.y,bottom:(C.bottom-w.bottom+g.bottom)/S.y,left:(w.left-C.left+g.left)/S.x,right:(C.right-w.right+g.right)/S.x}}const XB=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:f}=j0(c,r,l),p=r,m={},g=0;for(let k=0;k<a.length;k++){var y;const{name:w,fn:v}=a[k],{x:b,y:S,data:C,reset:_}=await v({x:u,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:c,platform:{...i,detectOverflow:(y=i.detectOverflow)!=null?y:YB},elements:{reference:t,floating:e}});u=b??u,f=S??f,m={...m,[w]:{...m[w],...C}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(c=_.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):_.rects),{x:u,y:f}=j0(c,p,l)),k=-1)}return{x:u,y:f,placement:p,strategy:o,middlewareData:m}},QB=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...k}=Ca(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=Nr(o),v=Kn(a),b=Nr(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=p||(b||!y?[_a(a)]:WB(a)),_=g!=="none";!p&&_&&C.push(...JB(a,y,g,S));const x=[a,...C],T=await l.detectOverflow(e,k),N=[];let I=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&N.push(T[w]),f){const $=HB(o,i,S);N.push(T[$[0]],T[$[1]])}if(I=[...I,{placement:o,overflows:N}],!N.every($=>$<=0)){var V,K;const $=(((V=s.flip)==null?void 0:V.index)||0)+1,Z=x[$];if(Z&&(!(f==="alignment"?v!==Kn(Z):!1)||I.every(j=>Kn(j.placement)===v?j.overflows[0]>0:!0)))return{data:{index:$,overflows:I},reset:{placement:Z}};let ae=(K=I.filter(X=>X.overflows[0]<=0).sort((X,j)=>X.overflows[1]-j.overflows[1])[0])==null?void 0:K.placement;if(!ae)switch(m){case"bestFit":{var M;const X=(M=I.filter(j=>{if(_){const q=Kn(j.placement);return q===v||q==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(q=>q>0).reduce((q,te)=>q+te,0)]).sort((j,q)=>j[1]-q[1])[0])==null?void 0:M[0];X&&(ae=X);break}case"initialPlacement":ae=a;break}if(o!==ae)return{reset:{placement:ae}}}return{}}}},eO=new Set(["left","top"]);async function tO(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Nr(n),a=xa(n),l=Kn(n)==="y",c=eO.has(i)?-1:1,u=s&&l?-1:1,f=Ca(e,t);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),l?{x:m*u,y:p*c}:{x:p*c,y:m*u}}const nO=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await tO(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},rO=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:v,y:b}=w;return{x:v,y:b}}},...c}=Ca(t,e),u={x:n,y:r},f=await s.detectOverflow(e,c),p=Kn(Nr(o)),m=z0(p);let g=u[m],y=u[p];if(i){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",b=g+f[w],S=g-f[v];g=D0(b,g,S)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",b=y+f[w],S=y-f[v];y=D0(b,y,S)}const k=l.fn({...e,[m]:g,[p]:y});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[m]:i,[p]:a}}}}}};function Ta(){return typeof window<"u"}function Br(t){return Pd(t)?(t.nodeName||"").toLowerCase():"#document"}function ut(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Yt(t){var e;return(e=(Pd(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Pd(t){return Ta()?t instanceof Node||t instanceof ut(t).Node:!1}function It(t){return Ta()?t instanceof Element||t instanceof ut(t).Element:!1}function Xt(t){return Ta()?t instanceof HTMLElement||t instanceof ut(t).HTMLElement:!1}function H0(t){return!Ta()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ut(t).ShadowRoot}const oO=new Set(["inline","contents"]);function Os(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=Pt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!oO.has(o)}const sO=new Set(["table","td","th"]);function iO(t){return sO.has(Br(t))}const aO=[":popover-open",":modal"];function Ma(t){return aO.some(e=>{try{return t.matches(e)}catch{return!1}})}const lO=["transform","translate","scale","rotate","perspective"],cO=["transform","translate","scale","rotate","perspective","filter"],dO=["paint","layout","strict","content"];function Rd(t){const e=Dd(),n=It(t)?Pt(t):t;return lO.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||cO.some(r=>(n.willChange||"").includes(r))||dO.some(r=>(n.contain||"").includes(r))}function uO(t){let e=Jn(t);for(;Xt(e)&&!bo(e);){if(Rd(e))return e;if(Ma(e))return null;e=Jn(e)}return null}function Dd(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fO=new Set(["html","body","#document"]);function bo(t){return fO.has(Br(t))}function Pt(t){return ut(t).getComputedStyle(t)}function Aa(t){return It(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Jn(t){if(Br(t)==="html")return t;const e=t.assignedSlot||t.parentNode||H0(t)&&t.host||Yt(t);return H0(e)?e.host:e}function W0(t){const e=Jn(t);return bo(e)?t.ownerDocument?t.ownerDocument.body:t.body:Xt(e)&&Os(e)?e:W0(e)}function Is(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=W0(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=ut(o);if(s){const a=zd(i);return e.concat(i,i.visualViewport||[],Os(o)?o:[],a&&n?Is(a):[])}return e.concat(o,Is(o,[],n))}function zd(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Z0(t){const e=Pt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Xt(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=ba(n)!==s||ba(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function $d(t){return It(t)?t:t.contextElement}function So(t){const e=$d(t);if(!Xt(e))return Gt(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=Z0(e);let i=(s?ba(n.width):n.width)/r,a=(s?ba(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const hO=Gt(0);function U0(t){const e=ut(t);return!Dd()||!e.visualViewport?hO:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function pO(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ut(t)?!1:e}function Or(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=$d(t);let i=Gt(1);e&&(r?It(r)&&(i=So(r)):i=So(t));const a=pO(s,n,r)?U0(s):Gt(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const p=ut(s),m=r&&It(r)?ut(r):r;let g=p,y=zd(g);for(;y&&r&&m!==g;){const k=So(y),w=y.getBoundingClientRect(),v=Pt(y),b=w.left+(y.clientLeft+parseFloat(v.paddingLeft))*k.x,S=w.top+(y.clientTop+parseFloat(v.paddingTop))*k.y;l*=k.x,c*=k.y,u*=k.x,f*=k.y,l+=b,c+=S,g=ut(y),y=zd(g)}}return Ea({width:u,height:f,x:l,y:c})}function Na(t,e){const n=Aa(t).scrollLeft;return e?e.left+n:Or(Yt(t)).left+n}function K0(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Na(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function mO(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=Yt(r),a=e?Ma(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Gt(1);const u=Gt(0),f=Xt(r);if((f||!f&&!s)&&((Br(r)!=="body"||Os(i))&&(l=Aa(r)),Xt(r))){const m=Or(r);c=So(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const p=i&&!f&&!s?K0(i,l):Gt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+p.x,y:n.y*c.y-l.scrollTop*c.y+u.y+p.y}}function gO(t){return Array.from(t.getClientRects())}function yO(t){const e=Yt(t),n=Aa(t),r=t.ownerDocument.body,o=Ar(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Ar(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Na(t);const a=-n.scrollTop;return Pt(r).direction==="rtl"&&(i+=Ar(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const J0=25;function kO(t,e){const n=ut(t),r=Yt(t),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Dd();(!u||u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Na(r);if(c<=0){const u=r.ownerDocument,f=u.body,p=getComputedStyle(f),m=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-m);g<=J0&&(s-=g)}else c<=J0&&(s+=c);return{width:s,height:i,x:a,y:l}}const wO=new Set(["absolute","fixed"]);function vO(t,e){const n=Or(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Xt(t)?So(t):Gt(1),i=t.clientWidth*s.x,a=t.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function q0(t,e,n){let r;if(e==="viewport")r=kO(t,n);else if(e==="document")r=yO(Yt(t));else if(It(e))r=vO(e,n);else{const o=U0(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Ea(r)}function G0(t,e){const n=Jn(t);return n===e||!It(n)||bo(n)?!1:Pt(n).position==="fixed"||G0(n,e)}function bO(t,e){const n=e.get(t);if(n)return n;let r=Is(t,[],!1).filter(a=>It(a)&&Br(a)!=="body"),o=null;const s=Pt(t).position==="fixed";let i=s?Jn(t):t;for(;It(i)&&!bo(i);){const a=Pt(i),l=Rd(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&wO.has(o.position)||Os(i)&&!l&&G0(t,i))?r=r.filter(u=>u!==i):o=a,i=Jn(i)}return e.set(t,r),r}function SO(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?Ma(e)?[]:bO(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=q0(e,u,o);return c.top=Ar(f.top,c.top),c.right=va(f.right,c.right),c.bottom=va(f.bottom,c.bottom),c.left=Ar(f.left,c.left),c},q0(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function CO(t){const{width:e,height:n}=Z0(t);return{width:e,height:n}}function xO(t,e,n){const r=Xt(e),o=Yt(e),s=n==="fixed",i=Or(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Gt(0);function c(){l.x=Na(o)}if(r||!r&&!s)if((Br(e)!=="body"||Os(o))&&(a=Aa(e)),r){const m=Or(e,!0,s,e);l.x=m.x+e.clientLeft,l.y=m.y+e.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?K0(o,a):Gt(0),f=i.left+a.scrollLeft-l.x-u.x,p=i.top+a.scrollTop-l.y-u.y;return{x:f,y:p,width:i.width,height:i.height}}function Vd(t){return Pt(t).position==="static"}function Y0(t,e){if(!Xt(t)||Pt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Yt(t)===n&&(n=n.ownerDocument.body),n}function X0(t,e){const n=ut(t);if(Ma(t))return n;if(!Xt(t)){let o=Jn(t);for(;o&&!bo(o);){if(It(o)&&!Vd(o))return o;o=Jn(o)}return n}let r=Y0(t,e);for(;r&&iO(r)&&Vd(r);)r=Y0(r,e);return r&&bo(r)&&Vd(r)&&!Rd(r)?n:r||uO(t)||n}const _O=async function(t){const e=this.getOffsetParent||X0,n=this.getDimensions,r=await n(t.floating);return{reference:xO(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function EO(t){return Pt(t).direction==="rtl"}const TO={convertOffsetParentRelativeRectToViewportRelativeRect:mO,getDocumentElement:Yt,getClippingRect:SO,getOffsetParent:X0,getElementRects:_O,getClientRects:gO,getDimensions:CO,getScale:So,isElement:It,isRTL:EO};function Q0(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function MO(t,e){let n=null,r;const o=Yt(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:f,width:p,height:m}=c;if(a||e(),!p||!m)return;const g=Sa(f),y=Sa(o.clientWidth-(u+p)),k=Sa(o.clientHeight-(f+m)),w=Sa(u),b={rootMargin:-g+"px "+-y+"px "+-k+"px "+-w+"px",threshold:Ar(0,va(1,l))||1};let S=!0;function C(_){const x=_[0].intersectionRatio;if(x!==l){if(!S)return i();x?i(!1,x):r=setTimeout(()=>{i(!1,1e-7)},1e3)}x===1&&!Q0(c,t.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(C,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,b)}n.observe(t)}return i(!0),s}function ek(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=$d(t),u=o||s?[...c?Is(c):[],...Is(e)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const f=c&&a?MO(c,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(w=>{let[v]=w;v&&v.target===c&&m&&(m.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(e)})),n()}),c&&!l&&m.observe(c),m.observe(e));let g,y=l?Or(t):null;l&&k();function k(){const w=Or(t);y&&!Q0(y,w)&&n(),y=w,g=requestAnimationFrame(k)}return n(),()=>{var w;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(w=m)==null||w.disconnect(),m=null,l&&cancelAnimationFrame(g)}}const Ba=nO,Oa=rO,Ia=QB,AO=(t,e,n)=>{const r=new Map,o={platform:TO,...n},s={...o.platform,_c:r};return XB(t,e,{...o,platform:s})};function NO(t){return t!=null&&typeof t=="object"&&"$el"in t}function tk(t){if(NO(t)){const e=t.$el;return Pd(e)&&Br(e)==="#comment"?null:e}return t}function Ps(t){return typeof t=="function"?t():d.unref(t)}function nk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function rk(t,e){const n=nk(t);return Math.round(e*n)/n}function Pa(t,e,n){n===void 0&&(n={});const r=n.whileElementsMounted,o=d.computed(()=>{var x;return(x=Ps(n.open))!=null?x:!0}),s=d.computed(()=>Ps(n.middleware)),i=d.computed(()=>{var x;return(x=Ps(n.placement))!=null?x:"bottom"}),a=d.computed(()=>{var x;return(x=Ps(n.strategy))!=null?x:"absolute"}),l=d.computed(()=>{var x;return(x=Ps(n.transform))!=null?x:!0}),c=d.computed(()=>tk(t.value)),u=d.computed(()=>tk(e.value)),f=d.ref(0),p=d.ref(0),m=d.ref(a.value),g=d.ref(i.value),y=d.shallowRef({}),k=d.ref(!1),w=d.computed(()=>{const x={position:m.value,left:"0",top:"0"};if(!u.value)return x;const T=rk(u.value,f.value),N=rk(u.value,p.value);return l.value?{...x,transform:"translate("+T+"px, "+N+"px)",...nk(u.value)>=1.5&&{willChange:"transform"}}:{position:m.value,left:T+"px",top:N+"px"}});let v;function b(){if(c.value==null||u.value==null)return;const x=o.value;AO(c.value,u.value,{middleware:s.value,placement:i.value,strategy:a.value}).then(T=>{f.value=T.x,p.value=T.y,m.value=T.strategy,g.value=T.placement,y.value=T.middlewareData,k.value=x!==!1})}function S(){typeof v=="function"&&(v(),v=void 0)}function C(){if(S(),r===void 0){b();return}if(c.value!=null&&u.value!=null){v=r(c.value,u.value,b);return}}function _(){o.value||(k.value=!1)}return d.watch([s,i,a,o],b,{flush:"sync"}),d.watch([c,u],C,{flush:"sync"}),d.watch(o,_,{flush:"sync"}),d.getCurrentScope()&&d.onScopeDispose(S),{x:d.shallowReadonly(f),y:d.shallowReadonly(p),strategy:d.shallowReadonly(m),placement:d.shallowReadonly(g),middlewareData:d.shallowReadonly(y),isPositioned:d.shallowReadonly(k),floatingStyles:w,update:b}}const BO=["menu-open"],bt=d.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(t,{emit:e}){const n=t,r=e,o=d.inject("containerRef"),s=d.inject(ph,null),i=d.inject(mh,0),a=Math.random().toString(36).slice(2);d.provide(mh,i+1);const{show:l,hide:c}=Un(),u=d.ref(!1);s&&d.watch(()=>s.value.get(i),b=>{b!==void 0&&b!==a&&u.value&&(u.value=!1)});const f=d.ref(null),p=d.ref(null),{floatingStyles:m}=Pa(f,p,{placement:n.placement,middleware:[Ba(n.offsetPx),Ia(),Oa({padding:8})],whileElementsMounted:ek});function g(){n.disabled||(u.value=!u.value)}function y(){u.value=!1}function k(b){var T,N,I;const S=b.target,C=(T=f.value)==null?void 0:T.contains(S),_=(N=p.value)==null?void 0:N.contains(S),x=(I=S.closest)==null?void 0:I.call(S,".wov-menu-dropdown");!C&&!_&&!x&&y()}function w(){n.title&&f.value&&!u.value&&l(n.title,f.value)}function v(){c()}return d.watch(u,b=>{b?(c(),document.addEventListener("click",k,!0),s&&(s.value.set(i,a),s.value=new Map(s.value)),r("open")):(document.removeEventListener("click",k,!0),(s==null?void 0:s.value.get(i))===a&&(s.value.delete(i),s.value=new Map(s.value)),r("close"))}),d.onUnmounted(()=>{document.removeEventListener("click",k,!0)}),(b,S)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:d.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:S[0]||(S[0]=d.withModifiers(()=>{},["prevent"])),onClick:g,onMouseenter:w,onMouseleave:v},[d.renderSlot(b.$slots,"button",{isOpen:u.value})],42,BO),d.unref(o)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(o)},[u.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"wov-menu-dropdown",style:d.normalizeStyle(d.unref(m))},[d.renderSlot(b.$slots,"dropdown",{close:y})],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)],64))}}),OO={},IO={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function PO(t,e){return d.openBlock(),d.createElementBlock("svg",IO,[...e[0]||(e[0]=[d.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 St=ir(OO,[["render",PO]]),RO={class:"wov-menu-button"},DO=["innerHTML"],zO=["onClick"],$O=["innerHTML"],Ld=d.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=d.shallowRef(null),o=d.computed(()=>{const a=r.value??(e.side==="start"?pe.None:pe.V);return no(a)});n(a=>{let l=null;for(const c of e.entityIds){if(h.hasComponent(a,c,he)){const u=he.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?pe.None:pe.V;return}}if(h.hasComponent(a,c,ue)){const u=ue.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?pe.None:pe.V;return}}}r.value=l});function s(a){r.value=a,n(l=>{for(const c of e.entityIds){if(h.hasComponent(l,c,he)){const u=he.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}if(h.hasComponent(l,c,ue)){const u=ue.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}}})}function i(a){if(!a)return"";const l=e.side==="start";return`<line x1="${l?8:4}" y1="12" x2="${l?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${l?4:20}, 12) scale(${l?"-0.8, 0.8":"0.8"})`}">${a.svg}</g>`}return(a,l)=>(d.openBlock(),d.createBlock(bt,{title:t.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:d.withCtx(()=>[d.createElementVNode("div",RO,[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(o.value)},null,8,DO)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(d.unref(Zl),c=>(d.openBlock(),d.createElementBlock("button",{key:c.kind,class:d.normalizeClass(["wov-menu-option",{"is-active":r.value===c.kind}]),onClick:u=>s(c.kind)},[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(c)},null,8,$O))],10,zO))),128))]),_:1},8,["title"]))}}),VO={class:"wov-menu-button"},LO=["onClick"],ok=d.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],n=t,{nextEditorTick:r}=Ee(),o=d.shallowRef(null);r(i=>{let a=null;for(const l of n.entityIds){if(h.hasComponent(i,l,he)){const c=he.read(i,l);if(a===null)a=c.thickness;else if(c.thickness!==a){o.value=null;return}}if(h.hasComponent(i,l,ue)){const c=ue.getThickness(i,l);if(a===null)a=c;else if(c!==a){o.value=null;return}}}o.value=a});function s(i){o.value=i,r(a=>{for(const l of n.entityIds){if(h.hasComponent(a,l,he)){const c=he.write(a,l);c.thickness=i}h.hasComponent(a,l,ue)&&ue.setThickness(a,l,i)}})}return(i,a)=>(d.openBlock(),d.createBlock(bt,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",VO,[a[0]||(a[0]=d.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"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,l=>d.createElementVNode("button",{key:l.value,class:d.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":o.value===l.value}]),onClick:c=>s(l.value)},d.toDisplayString(l.label),11,LO)),64))]),_:1}))}}),FO=["value"],jO=d.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(n.modelValue??"");d.watch(()=>n.modelValue,u=>{u&&u!==o.value&&(o.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 a(u){let p=u.target.value;if((p.length===6||p.length===7)&&s(p)){const m=i(p);o.value=m,r("update:modelValue",m)}}function l(u){const p=u.target.value;if(p&&s(p)){const m=i(p);o.value=m,r("update:modelValue",m)}else n.modelValue&&(o.value=n.modelValue)}function c(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,p=f.value;if(p&&s(p)){const m=i(p);o.value=m,r("update:modelValue",m),setTimeout(()=>f.select())}}}return(u,f)=>(d.openBlock(),d.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:o.value,onInput:a,onChange:l,onKeydown:c},null,40,FO))}}),sk=d.defineComponent({__name:"ColorSlider",props:{modelValue:{},thumbColor:{},background:{}},emits:["update:modelValue"],setup(t,{expose:e,emit:n}){const r=n,o=d.ref(null),s=d.ref(!1);function i(c){s.value=!0,a(c),window.addEventListener("pointermove",a),window.addEventListener("pointerup",l)}function a(c){if(!o.value)return;const u=o.value.getBoundingClientRect(),f=Math.max(0,Math.min(100,(c.clientY-u.top)/u.height*100));r("update:modelValue",f)}function l(){s.value=!1,window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l)}return e({isDragging:s}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"sliderRef",ref:o,class:"wov-color-slider",onPointerdown:d.withModifiers(i,["prevent"])},[t.background?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-color-slider-gradient",style:d.normalizeStyle({background:t.background})},null,4)):d.createCommentVNode("",!0),d.createElementVNode("div",{class:"wov-color-slider-thumb",style:d.normalizeStyle({top:`${t.modelValue}%`,backgroundColor:t.thumbColor})},null,4)],544))}}),HO={class:"wov-color-picker"},WO={class:"wov-color-picker-area"},ZO={class:"wov-color-picker-selector-gradient"},UO="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",ik=d.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),s=d.ref(null),i=d.ref(null),a=d.ref({x:100,y:0}),l=d.ref(0),c=d.ref(0),u=d.ref(!1),f=d.computed(()=>{var _,x;return u.value||((_=o.value)==null?void 0:_.isDragging)||((x=s.value)==null?void 0:x.isDragging)}),p=d.computed(()=>({h:l.value/100*360,s:a.value.x,v:100-a.value.y,a:(100-c.value)/100*255})),m=d.computed(()=>M0({h:p.value.h,s:100,v:100})),g=d.computed(()=>M0({h:p.value.h,s:p.value.s,v:p.value.v})),y=d.computed(()=>n.withOpacity?A0(p.value):g.value),k=d.computed(()=>`linear-gradient(to top, transparent 0%, ${g.value} 100%)`);function w(_){if(_){const x=T0(_);a.value={x:x.s,y:100-x.v},l.value=x.h/360*100,c.value=100-x.a/255*100}}function v(_){w(_),r("update:modelValue",n.withOpacity?A0(T0(_)):_)}w(n.modelValue),d.watch(()=>n.modelValue,_=>{f.value||w(_)}),d.watch([a,l,c],()=>{f.value&&r("update:modelValue",y.value)});function b(_){u.value=!0,S(_),window.addEventListener("pointermove",S),window.addEventListener("pointerup",C)}function S(_){if(!i.value)return;const x=i.value.getBoundingClientRect(),T=Math.max(0,Math.min(100,(_.clientX-x.left)/x.width*100)),N=Math.max(0,Math.min(100,(_.clientY-x.top)/x.height*100));a.value={x:T,y:N}}function C(){u.value=!1,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",C)}return(_,x)=>(d.openBlock(),d.createElementBlock("div",HO,[d.createVNode(jO,{modelValue:y.value,"onUpdate:modelValue":v},null,8,["modelValue"]),d.createElementVNode("div",WO,[d.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:d.normalizeStyle({backgroundColor:m.value}),onPointerdown:d.withModifiers(b,["prevent"])},[d.createElementVNode("div",ZO,[d.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:d.normalizeStyle({left:`${a.value.x}%`,top:`${a.value.y}%`,backgroundColor:g.value})},null,4)])],36),d.createVNode(sk,{ref_key:"hueSliderRef",ref:o,modelValue:l.value,"onUpdate:modelValue":x[0]||(x[0]=T=>l.value=T),thumbColor:m.value,background:UO},null,8,["modelValue","thumbColor"]),t.withOpacity?(d.openBlock(),d.createBlock(sk,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:c.value,"onUpdate:modelValue":x[1]||(x[1]=T=>c.value=T),thumbColor:g.value,background:k.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):d.createCommentVNode("",!0)])]))}}),KO={class:"wov-color-bubbles-container"},JO={key:1,class:"wov-color-bubbles"},qO=["onClick"],Ra=d.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(t,{emit:e}){const n=t,r=e,o=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=d.computed(()=>{const g=n.palette??o,y=n.withPicker,k=g.length%2===1;return y&&!k||!y&&k?g.slice(0,-1):g}),i=d.ref(!1),a=d.ref(n.currentColor??"#ff0000");function l(g,y){const k=w=>{const v=w.replace(/^#/,"").toLowerCase();return v.length===6?v+"ff":v};return k(g)===k(y)}function c(g){return n.hideHighlight||!n.currentColor?!1:l(n.currentColor,g)}function u(){return n.hideHighlight||!n.currentColor?!1:!s.value.some(g=>l(n.currentColor,g))}function f(g){const y=_d(g);y&&r("change",y)}function p(){!i.value&&n.currentColor&&(a.value=n.currentColor),i.value=!i.value,r("picker-open",i.value)}function m(g){a.value=g;const y=_d(g);y&&r("change",y)}return(g,y)=>(d.openBlock(),d.createElementBlock("div",KO,[i.value?(d.openBlock(),d.createBlock(ik,{key:0,modelValue:a.value,"onUpdate:modelValue":[y[0]||(y[0]=k=>a.value=k),m],withOpacity:t.withOpacity},null,8,["modelValue","withOpacity"])):(d.openBlock(),d.createElementBlock("div",JO,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,k=>(d.openBlock(),d.createElementBlock("div",{key:k,class:d.normalizeClass(["wov-color-bubble",{selected:c(k)}]),style:d.normalizeStyle({backgroundColor:k}),onMousedown:y[1]||(y[1]=d.withModifiers(()=>{},["prevent"])),onClick:w=>f(k)},null,46,qO))),128)),t.withPicker?(d.openBlock(),d.createElementBlock("div",{key:0,class:d.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:y[2]||(y[2]=d.withModifiers(()=>{},["prevent"])),onClick:p},null,34)):d.createCommentVNode("",!0)]))]))}}),GO={class:"wov-color-button"},ak=d.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Color),o=d.computed(()=>{const c=new Set;for(const u of r.value.values())if(u){const f=Ns(u);c.add(f)}return Array.from(c)}),s=d.computed(()=>o.value.length>1),i=d.computed(()=>o.value[0]??null),a=d.computed(()=>{if(o.value.length===0)return{backgroundColor:"#000"};if(o.value.length>=2){const c=o.value[0],u=o.value[1];return{background:`linear-gradient(45deg, ${c} 0%, ${c} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:o.value[0]}});function l(c){const u=Ns(c);n(f=>{for(const p of e.entityIds)h.Color.fromHex(f,p,u)})}return(c,u)=>(d.openBlock(),d.createBlock(bt,{title:"Color"},{button:d.withCtx(()=>[d.createElementVNode("div",GO,[d.createElementVNode("div",{class:"wov-color-swatch",style:d.normalizeStyle(a.value)},null,4),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Ra,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:l},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Co=d.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),{show:s,hide:i}=Un();function a(u){r("click",u)}function l(){n.title&&o.value&&s(n.title,o.value)}function c(){i()}return(u,f)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:"wov-menu-button",onClick:a,onMouseenter:l,onMouseleave:c},[d.renderSlot(u.$slots,"default")],544))}}),Fd=d.defineComponent({__name:"MenuTooltip",setup(t){const{activeTooltip:e,isVisible:n}=Un(),r=d.inject("containerRef"),o=d.ref(null),s=d.computed(()=>{var l;return((l=e.value)==null?void 0:l.anchor)??null}),{floatingStyles:i}=Pa(s,o,{placement:"top",middleware:[Ba(8),Ia({fallbackPlacements:["bottom"]}),Oa({padding:8})]}),a=d.computed(()=>{var l;return n.value&&((l=e.value)==null?void 0:l.text)});return(l,c)=>d.unref(r)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(r)},[d.createVNode(d.Transition,{name:"wov-tooltip-fade"},{default:d.withCtx(()=>{var u;return[a.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:o,class:"wov-menu-tooltip",style:d.normalizeStyle(d.unref(i))},d.toDisplayString((u=d.unref(e))==null?void 0:u.text),5)):d.createCommentVNode("",!0)]}),_:1})],8,["to"])):d.createCommentVNode("",!0)}}),YO={class:"wov-menu-button"},XO=["onClick"],lk=d.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],n=t,{nextEditorTick:r}=Ee(),o=Wn(()=>n.entityIds,Nt),s=d.computed(()=>{let a=null;for(const l of o.value.values())if(l){if(a===null)a=l.thickness;else if(l.thickness!==a)return null}return a});function i(a){r(l=>{for(const c of n.entityIds){const u=Nt.write(l,c);u.thickness=a}})}return(a,l)=>(d.openBlock(),d.createBlock(bt,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",YO,[l[0]||(l[0]=d.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"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,c=>d.createElementVNode("button",{key:c.value,class:d.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===c.value}]),onClick:u=>i(c.value)},d.toDisplayString(c.label),11,XO)),64))]),_:1}))}}),QO={class:"wov-fill-color-button"},eI={class:"wov-fill-dropdown"},tI={key:0,class:"wov-fill-mode-section"},nI=["title","onClick"],rI={viewBox:"0 0 24 24",fill:"none"},oI=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],ck=d.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Shape),o=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=d.computed(()=>{const m=r.value.values().next().value,g=(m==null?void 0:m.fillAlpha)??255;return g===0?"none":g<200?"faded":"solid"}),i=d.computed(()=>{const m=new Set;for(const g of r.value.values())if(g){const y=g.fillAlpha??255;y===0?m.add("none"):y<200?m.add("faded"):m.add("solid")}return m.size>1});function a(m){n(g=>{for(const y of e.entityIds){const k=h.Shape.write(g,y);k.fillAlpha=m}})}const l=d.computed(()=>{const m=new Set;for(const g of r.value.values())if(g){const y=Ns({red:g.fillRed,green:g.fillGreen,blue:g.fillBlue,alpha:g.fillAlpha??255});m.add(y)}return Array.from(m)}),c=d.computed(()=>l.value.length>1),u=d.computed(()=>l.value[0]??"#4a90d9");function f(m){n(g=>{for(const y of e.entityIds){const k=h.Shape.write(g,y);k.fillRed=m.red,k.fillGreen=m.green,k.fillBlue=m.blue,k.fillAlpha=m.alpha}})}const p=d.ref(!1);return(m,g)=>(d.openBlock(),d.createBlock(bt,{title:"Fill Color"},{button:d.withCtx(()=>[d.createElementVNode("div",QO,[g[1]||(g[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[d.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"}),d.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)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",eI,[p.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",tI,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,y=>d.createElementVNode("button",{key:y.mode,class:d.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&y.mode===s.value}]),title:y.label,onClick:k=>a(y.alpha)},[(d.openBlock(),d.createElementBlock("svg",rI,[d.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:y.mode==="none"?"none":"currentColor","fill-opacity":y.mode==="faded"?.4:1,stroke:y.mode==="none"?"currentColor":"none","stroke-width":y.mode==="none"?1.5:0,"stroke-dasharray":y.mode==="none"?"3 3":""},null,8,oI)])),d.createElementVNode("span",null,d.toDisplayString(y.label),1)],10,nI)),64))])),d.createVNode(Ra,{currentColor:u.value,hideHighlight:c.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:g[0]||(g[0]=y=>p.value=y)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),sI={class:"wov-shape-kind-button"},iI={class:"wov-shape-kind-dropdown"},aI=["onClick"],lI={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},cI=["d"],dk=d.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Shape),o=d.computed(()=>{const l=r.value.values().next().value;return(l==null?void 0:l.kind)??"rectangle"}),s=d.computed(()=>{const l=new Set;for(const c of r.value.values())c&&l.add(c.kind);return l.size>1}),i=d.computed(()=>Object.keys(ss).map(l=>({kind:l,label:l.charAt(0).toUpperCase()+l.slice(1)})));function a(l){n(c=>{for(const u of e.entityIds){const f=h.Shape.write(c,u);f.kind=l}})}return(l,c)=>(d.openBlock(),d.createBlock(bt,{title:"Shape Type"},{button:d.withCtx(()=>[d.createElementVNode("div",sI,[c[0]||(c[0]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),d.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",iI,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,u=>(d.openBlock(),d.createElementBlock("button",{key:u.kind,class:d.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===o.value}]),onClick:f=>a(u.kind)},[(d.openBlock(),d.createElementBlock("svg",lI,[d.createElementVNode("path",{d:d.unref(ss)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,cI)])),d.createElementVNode("span",null,d.toDisplayString(u.label),1)],10,aI))),128))])]),_:1}))}}),dI={class:"wov-stroke-style-section"},uI=["title","onClick"],fI={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},hI=["stroke-dasharray","stroke-opacity"],pI=d.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(t,{emit:e}){const n=e,r=[{kind:h.StrokeKind.Solid,label:"Solid"},{kind:h.StrokeKind.Dashed,label:"Dashed"},{kind:h.StrokeKind.None,label:"None"}];function o(i){switch(i){case h.StrokeKind.Dashed:return"6 6";case h.StrokeKind.None:return"";case h.StrokeKind.Solid:default:return""}}function s(i){n("change",i)}return(i,a)=>(d.openBlock(),d.createElementBlock("div",dI,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(r,l=>d.createElementVNode("button",{key:l.kind,class:d.normalizeClass(["wov-stroke-style-option",{"is-active":!t.hasMultipleStyles&&l.kind===t.currentStyle}]),title:l.label,onClick:c=>s(l.kind)},[(d.openBlock(),d.createElementBlock("svg",fI,[d.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":o(l.kind),"stroke-opacity":l.kind===d.unref(h.StrokeKind).None?.3:1},null,8,hI)])),d.createElementVNode("span",null,d.toDisplayString(l.label),1)],10,uI)),64))]))}}),mI={class:"wov-stroke-color-button"},gI={class:"wov-stroke-dropdown"},yI={key:1,class:"wov-stroke-divider"},uk=d.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),r=Wn(()=>e.entityIds,h.Shape),o=d.ref(!1),s=d.computed(()=>{const p=new Set;for(const m of r.value.values())if(m){const g=Ns({red:m.strokeRed,green:m.strokeGreen,blue:m.strokeBlue,alpha:255});p.add(g)}return Array.from(p)}),i=d.computed(()=>s.value.length>1),a=d.computed(()=>s.value[0]??"#000000"),l=d.computed(()=>{const p=r.value.values().next().value;return(p==null?void 0:p.strokeKind)??h.StrokeKind.Solid}),c=d.computed(()=>{const p=new Set;for(const m of r.value.values())m&&p.add(m.strokeKind);return p.size>1});function u(p){n(m=>{for(const g of e.entityIds){const y=h.Shape.write(m,g);y.strokeRed=p.red,y.strokeGreen=p.green,y.strokeBlue=p.blue}})}function f(p){n(m=>{for(const g of e.entityIds){const y=h.Shape.write(m,g);y.strokeKind=p}})}return(p,m)=>(d.openBlock(),d.createBlock(bt,{title:"Stroke Color"},{button:d.withCtx(()=>[d.createElementVNode("div",mI,[m[1]||(m[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[d.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)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",gI,[o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createBlock(pI,{key:0,currentStyle:l.value,hasMultipleStyles:c.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",yI)),d.createVNode(Ra,{currentColor:a.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:m[0]||(m[0]=g=>o.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),kI={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},wI={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},vI={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},bI={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},jd=d.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=[h.TextAlignment.Left,h.TextAlignment.Center,h.TextAlignment.Right,h.TextAlignment.Justify];function s(){const i=o.indexOf(n.alignment),a=o[(i+1)%o.length];r.setAlignment(a)}return(i,a)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Text Align",onClick:s},{default:d.withCtx(()=>[d.unref(n).alignment===d.unref(h.TextAlignment).Left?(d.openBlock(),d.createElementBlock("svg",kI,[...a[0]||(a[0]=[d.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)])])):d.unref(n).alignment===d.unref(h.TextAlignment).Center?(d.openBlock(),d.createElementBlock("svg",wI,[...a[1]||(a[1]=[d.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)])])):d.unref(n).alignment===d.unref(h.TextAlignment).Right?(d.openBlock(),d.createElementBlock("svg",vI,[...a[2]||(a[2]=[d.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)])])):(d.openBlock(),d.createElementBlock("svg",bI,[...a[3]||(a[3]=[d.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})):d.createCommentVNode("",!0)}}),Hd=d.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Bold",class:d.normalizeClass({"wov-active":d.unref(n).isBold}),onClick:d.unref(r).toggleBold},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.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"])):d.createCommentVNode("",!0)}});function SI(t,e){return d.getCurrentScope()?(d.onScopeDispose(t,e),!0):!1}const CI=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const xI=Object.prototype.toString,_I=t=>xI.call(t)==="[object Object]",Da=()=>{};function za(t){return Array.isArray(t)?t:[t]}function EI(t){return d.getCurrentInstance()}function TI(t,e=!0,n){EI()?d.onMounted(t,n):e?t():d.nextTick(t)}function MI(t,e,n){return d.watch(t,e,{...n,immediate:!0})}const $a=CI?window:void 0;function Rt(t){var e;const n=d.toValue(t);return(e=n==null?void 0:n.$el)!==null&&e!==void 0?e:n}function Wd(...t){const e=(r,o,s,i)=>(r.addEventListener(o,s,i),()=>r.removeEventListener(o,s,i)),n=d.computed(()=>{const r=za(d.toValue(t[0])).filter(o=>o!=null);return r.every(o=>typeof o!="string")?r:void 0});return MI(()=>{var r,o;return[(r=(o=n.value)===null||o===void 0?void 0:o.map(s=>Rt(s)))!==null&&r!==void 0?r:[$a].filter(s=>s!=null),za(d.toValue(n.value?t[1]:t[0])),za(d.unref(n.value?t[2]:t[1])),d.toValue(n.value?t[3]:t[2])]},([r,o,s,i],a,l)=>{if(!(r!=null&&r.length)||!(o!=null&&o.length)||!(s!=null&&s.length))return;const c=_I(i)?{...i}:i,u=r.flatMap(f=>o.flatMap(p=>s.map(m=>e(f,p,m,c))));l(()=>{u.forEach(f=>f())})},{flush:"post"})}function AI(t,e,n={}){const{window:r=$a,ignore:o=[],capture:s=!0,detectIframe:i=!1,controls:a=!1}=n;if(!r)return a?{stop:Da,cancel:Da,trigger:Da}:Da;let l=!0;const c=k=>d.toValue(o).some(w=>{if(typeof w=="string")return Array.from(r.document.querySelectorAll(w)).some(v=>v===k.target||k.composedPath().includes(v));{const v=Rt(w);return v&&(k.target===v||k.composedPath().includes(v))}});function u(k){const w=d.toValue(k);return w&&w.$.subTree.shapeFlag===16}function f(k,w){const v=d.toValue(k),b=v.$.subTree&&v.$.subTree.children;return b==null||!Array.isArray(b)?!1:b.some(S=>S.el===w.target||w.composedPath().includes(S.el))}const p=k=>{const w=Rt(t);if(k.target!=null&&!(!(w instanceof Element)&&u(t)&&f(t,k))&&!(!w||w===k.target||k.composedPath().includes(w))){if("detail"in k&&k.detail===0&&(l=!c(k)),!l){l=!0;return}e(k)}};let m=!1;const g=[Wd(r,"click",k=>{m||(m=!0,setTimeout(()=>{m=!1},0),p(k))},{passive:!0,capture:s}),Wd(r,"pointerdown",k=>{const w=Rt(t);l=!c(k)&&!!(w&&!k.composedPath().includes(w))},{passive:!0}),i&&Wd(r,"blur",k=>{setTimeout(()=>{var w;const v=Rt(t);((w=r.document.activeElement)===null||w===void 0?void 0:w.tagName)==="IFRAME"&&!(v!=null&&v.contains(r.document.activeElement))&&e(k)},0)},{passive:!0})].filter(Boolean),y=()=>g.forEach(k=>k());return a?{stop:y,cancel:()=>{l=!1},trigger:k=>{l=!0,p(k),l=!1}}:y}function NI(){const t=d.shallowRef(!1),e=d.getCurrentInstance();return e&&d.onMounted(()=>{t.value=!0},e),t}function BI(t){const e=NI();return d.computed(()=>(e.value,!!t()))}function OI(t,e,n={}){const{window:r=$a,...o}=n;let s;const i=BI(()=>r&&"ResizeObserver"in r),a=()=>{s&&(s.disconnect(),s=void 0)},l=d.watch(d.computed(()=>{const u=d.toValue(t);return Array.isArray(u)?u.map(f=>Rt(f)):[Rt(u)]}),u=>{if(a(),i.value&&r){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,o)}},{immediate:!0,flush:"post"}),c=()=>{a(),l()};return SI(c),{isSupported:i,stop:c}}function fk(t,e={width:0,height:0},n={}){const{window:r=$a,box:o="content-box"}=n,s=d.computed(()=>{var f;return(f=Rt(t))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=d.shallowRef(e.width),a=d.shallowRef(e.height),{stop:l}=OI(t,([f])=>{const p=o==="border-box"?f.borderBoxSize:o==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(r&&s.value){const m=Rt(t);if(m){const g=m.getBoundingClientRect();i.value=g.width,a.value=g.height}}else if(p){const m=za(p);i.value=m.reduce((g,{inlineSize:y})=>g+y,0),a.value=m.reduce((g,{blockSize:y})=>g+y,0)}else i.value=f.contentRect.width,a.value=f.contentRect.height},n);TI(()=>{const f=Rt(t);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,a.value="offsetHeight"in f?f.offsetHeight:e.height)});const c=d.watch(()=>Rt(t),f=>{i.value=f?e.width:0,a.value=f?e.height:0});function u(){l(),c()}return{width:i,height:a,stop:u}}function hk(){const t=d.inject(pt);if(!t)throw new Error("useFonts must be used within a WovenCanvas component");return d.computed(()=>{const e=t.getEditor();return e?e.fonts.filter(n=>n.selectable):[]})}const II={class:"wov-font-family-button"},PI={class:"wov-font-family-label"},RI={class:"wov-font-list"},DI=["onClick"],zI=["src","alt"],Zd=d.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=hk(),s=d.computed(()=>o.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=d.computed(()=>n.fontFamily),a=d.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 l(u){r.setFontFamily(u)}function c(u){u.stopPropagation()}return(u,f)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(bt,{key:0,title:"Font Family"},{button:d.withCtx(()=>[d.createElementVNode("div",II,[d.createElementVNode("span",PI,d.toDisplayString(a.value),1),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-family-menu",onWheel:c,onClick:f[0]||(f[0]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",RI,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,p=>(d.openBlock(),d.createElementBlock("div",{key:p.name,class:d.normalizeClass(["wov-font-item",{active:i.value===p.name}]),onClick:m=>l(p.name)},[p.previewImage?(d.openBlock(),d.createElementBlock("img",{key:0,class:"wov-font-preview",src:p.previewImage,alt:p.name},null,8,zI)):(d.openBlock(),d.createElementBlock("span",{key:1,class:"wov-font-name",style:d.normalizeStyle({fontFamily:p.name})},d.toDisplayString(p.displayName),5))],10,DI))),128))])],32)]),_:1})):d.createCommentVNode("",!0)}}),$I={class:"wov-font-size-button"},VI={class:"wov-font-size-label"},LI=["onClick"],FI={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},jI={class:"wov-input-container"},HI=["value"],Ud=d.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=[{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=d.computed(()=>n.fontSize),i=d.computed(()=>{const p=s.value;if(p===null)return"Mixed";const m=o.find(g=>g.value===p);return m?m.label:`${+p.toFixed(1)} px`}),a=d.computed(()=>{const p=s.value;return p===null?"":String(+p.toFixed(1))});function l(p){r.setFontSize(p)}function c(p){const m=p.target,g=Number.parseFloat(m.value);!Number.isNaN(g)&&g>0&&l(g)}function u(p){p.key==="Enter"&&p.target.blur()}function f(p){p.stopPropagation()}return(p,m)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(bt,{key:0,title:"Font Size"},{button:d.withCtx(()=>[d.createElementVNode("div",$I,[d.createElementVNode("span",VI,d.toDisplayString(i.value),1),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:m[0]||(m[0]=d.withModifiers(()=>{},["stop"]))},[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,g=>d.createElementVNode("div",{key:g.value,class:d.normalizeClass(["wov-font-size-option",{active:s.value===g.value}]),onClick:y=>l(g.value)},[s.value===g.value?(d.openBlock(),d.createElementBlock("svg",FI,[...m[1]||(m[1]=[d.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)])])):d.createCommentVNode("",!0),d.createElementVNode("span",{class:"wov-option-label",style:d.normalizeStyle({fontSize:`${g.displayValue}px`})},d.toDisplayString(g.label),5)],10,LI)),64)),m[3]||(m[3]=d.createElementVNode("div",{class:"wov-separator"},null,-1)),d.createElementVNode("div",jI,[d.createElementVNode("input",{class:"wov-custom-input",value:a.value,onInput:c,onKeydown:u,placeholder:"Custom size"},null,40,HI),m[2]||(m[2]=d.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):d.createCommentVNode("",!0)}}),Kd=d.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Italic",class:d.normalizeClass({"wov-active":d.unref(n).isItalic}),onClick:d.unref(r).toggleItalic},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.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"])):d.createCommentVNode("",!0)}}),Jd=d.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Underline",class:d.normalizeClass({"wov-active":d.unref(n).isUnderline}),onClick:d.unref(r).toggleUnderline},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[d.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"])):d.createCommentVNode("",!0)}}),WI={class:"wov-text-color-button"},ZI={class:"wov-text-icon-container"},qd=d.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=qt(()=>e.entityIds),o=d.computed(()=>n.color??"#000000"),s=d.computed(()=>({backgroundColor:o.value}));function i(a){r.setColor(Ns(a))}return(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(bt,{key:0,title:"Text Color"},{button:d.withCtx(()=>[d.createElementVNode("div",WI,[d.createElementVNode("div",ZI,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[d.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)),d.createElementVNode("div",{class:"wov-color-underline",style:d.normalizeStyle(s.value)},null,4)]),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Ra,{currentColor:o.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):d.createCommentVNode("",!0)}}),UI={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"},KI={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"},JI={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"},pk=d.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=Ee(),{state:r}=qt(()=>e.entityIds),o=[h.VerticalAlignment.Top,h.VerticalAlignment.Center,h.VerticalAlignment.Bottom],s=Wn(()=>e.entityIds,h.VerticalAlign),i=d.computed(()=>{let l=null;for(const c of s.value.values()){const u=(c==null?void 0:c.value)??h.VerticalAlignment.Top;if(l===null)l=u;else if(l!==u)return null}return l});function a(){const l=i.value??h.VerticalAlignment.Top,c=o.indexOf(l),u=o[(c+1)%o.length];n(f=>{for(const p of e.entityIds){const m=h.VerticalAlign.write(f,p);m.value=u}})}return(l,c)=>d.unref(r).showTextMenuButtons?(d.openBlock(),d.createBlock(Co,{key:0,title:"Vertical Align",onClick:a},{default:d.withCtx(()=>[i.value===d.unref(h.VerticalAlignment).Top||i.value===null?(d.openBlock(),d.createElementBlock("svg",UI,[...c[0]||(c[0]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===d.unref(h.VerticalAlignment).Center?(d.openBlock(),d.createElementBlock("svg",KI,[...c[1]||(c[1]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",JI,[...c[2]||(c[2]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):d.createCommentVNode("",!0)}}),qI={class:"wov-text-group-button"},GI={class:"wov-text-group-dropdown"},YI={class:"wov-text-group-row wov-text-group-row-full"},XI={class:"wov-text-group-row"},QI=d.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(t){const e=t,{state:n}=qt(()=>e.entityIds),r=d.inject("containerRef"),{width:o}=fk(r),s=d.computed(()=>o.value>0&&o.value<600),i=d.ref(new Map);return d.provide(ph,i),(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[s.value?(d.openBlock(),d.createBlock(bt,{key:0,title:"Text Formatting",placement:"top"},{button:d.withCtx(()=>[d.createElementVNode("div",qI,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[d.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)),d.createVNode(St,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",GI,[d.createElementVNode("div",YI,[d.createVNode(Zd,{entityIds:t.entityIds},null,8,["entityIds"]),l[1]||(l[1]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(Ud,{entityIds:t.entityIds},null,8,["entityIds"])]),d.createElementVNode("div",XI,[d.createVNode(Hd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Kd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Jd,{entityIds:t.entityIds},null,8,["entityIds"]),l[2]||(l[2]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(qd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(jd,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(pk,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)])])]),_:1})):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createVNode(Zd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Ud,{entityIds:t.entityIds},null,8,["entityIds"]),l[3]||(l[3]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(Hd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Kd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(Jd,{entityIds:t.entityIds},null,8,["entityIds"]),l[4]||(l[4]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(qd,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(jd,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(pk,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)],64))],64)):d.createCommentVNode("",!0)}}),mk=d.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(t){const e=t,n=Ze(h.Camera),r=Ze(h.Grid),o=d.inject("containerRef"),s=d.ref({width:0,height:0});let i=null;const a=d.ref(null);let l=null;typeof document<"u"&&(l=document.createElement("canvas"));function c(k,w,v,b){const S=b/2;k.beginPath(),k.arc(w,v,S,0,Math.PI*2),k.fill()}function u(k,w,v){if(!l)return null;const b=v.dotSize??2,S=k*v.subdivisionStep,C=w*v.subdivisionStep;if(S<=0||C<=0)return null;l.width=S,l.height=C;const _=l.getContext("2d");if(!_)return null;if(_.clearRect(0,0,S,C),_.fillStyle=v.strokeColor,v.subdivisionStep===1)c(_,S/2,C/2,b);else for(let x=0;x<v.subdivisionStep;x++)for(let T=0;T<v.subdivisionStep;T++){const N=(x+.5)*(S/v.subdivisionStep),I=(T+.5)*(C/v.subdivisionStep),K=x===0&&T===0?2*b:b;c(_,N,I,K)}return _.createPattern(l,"repeat")}function f(k,w,v,b,S,C){k.lineWidth=C,k.beginPath(),k.moveTo(w,v),k.lineTo(b,S),k.stroke()}function p(k,w,v){if(!l)return null;const b=v.gridSize??1,S=k*v.subdivisionStep,C=w*v.subdivisionStep;if(S<=0||C<=0)return null;l.width=S,l.height=C;const _=l.getContext("2d");if(!_)return null;if(_.clearRect(0,0,S,C),_.strokeStyle=v.strokeColor,v.subdivisionStep===1)f(_,0,0,S,0,b),f(_,0,0,0,C,b);else{const x=S/v.subdivisionStep,T=C/v.subdivisionStep;for(let N=0;N<=v.subdivisionStep;N++){const I=N*x,V=N%v.subdivisionStep===0;f(_,I,0,I,C,V?3*b:b)}for(let N=0;N<=v.subdivisionStep;N++){const I=N*T,V=N%v.subdivisionStep===0;f(_,0,I,S,I,V?3*b:b)}}return _.createPattern(l,"repeat")}function m(k){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,C=s.value.height,_=n.value.left,x=n.value.top,T=_+S/n.value.zoom,N=x+C/n.value.zoom;let I=w*b,V=v*b,K=0,M=0,$=Number.POSITIVE_INFINITY,Z=Number.POSITIVE_INFINITY;for(;;){I=b*w,V=b*v,K=Math.floor(_/I)*I,M=Math.floor(x/V)*V;const Se=Math.ceil(T/I)*I,Dt=Math.ceil(N/V)*V;if(Z=Math.round((Se-K)/w),$=Math.round((Dt-M)/v),Math.max(Z,$)>200)w*=2,v*=2;else break}const ae=w*n.value.zoom,X=v*n.value.zoom,j=Math.round(ae),q=Math.round(X),te=u(j,q,e.background);if(!te)return;te.setTransform(new DOMMatrix().scale(ae/j,X/q));const fe=(K-_-w/2)*n.value.zoom,ce=(M-x-v/2)*n.value.zoom;k.save(),k.translate(fe,ce),k.fillStyle=te,k.fillRect(0,0,S+I*n.value.zoom,C+V*n.value.zoom),k.restore()}function g(k){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,C=s.value.height,_=n.value.left,x=n.value.top,T=_+S/n.value.zoom,N=x+C/n.value.zoom;let I=w*b,V=v*b,K=0,M=0,$=Number.POSITIVE_INFINITY,Z=Number.POSITIVE_INFINITY;for(;;){I=b*w,V=b*v,K=Math.floor(_/I)*I,M=Math.floor(x/V)*V;const Se=Math.ceil(T/I)*I,Dt=Math.ceil(N/V)*V;if(Z=Math.round((Se-K)/w),$=Math.round((Dt-M)/v),Math.max(Z,$)>200)w*=2,v*=2;else break}const ae=w*n.value.zoom,X=v*n.value.zoom,j=Math.round(ae),q=Math.round(X),te=p(j,q,e.background);if(!te)return;te.setTransform(new DOMMatrix().scale(ae/j,X/q));const fe=(K-_)*n.value.zoom,ce=(M-x)*n.value.zoom;k.save(),k.translate(fe,ce),k.fillStyle=te,k.fillRect(0,0,S+I*n.value.zoom,C+V*n.value.zoom),k.restore()}function y(){const k=a.value;if(!k)return;const w=k.getContext("2d");if(!w)return;const{width:v,height:b}=s.value;v===0||b===0||(k.width=v,k.height=b,w.clearRect(0,0,v,b),w.fillStyle=e.background.color,w.fillRect(0,0,v,b),e.background.kind==="dots"?m(w):e.background.kind==="grid"&&g(w))}return d.watch(()=>[e.background,n.value,r.value,s.value],()=>{y()},{deep:!0}),d.onMounted(()=>{const k=o==null?void 0:o.value;if(k){const w=()=>{s.value={width:k.clientWidth,height:k.clientHeight}};w(),i=new ResizeObserver(w),i.observe(k)}y()}),d.onUnmounted(()=>{i==null||i.disconnect()}),(k,w)=>(d.openBlock(),d.createElementBlock("canvas",{ref_key:"canvasRef",ref:a,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function gk(t,e){if(e.length===0)return new Set;const n=e[0].tag,r=t.blockDefs[n];if(!r)return new Set;const o=new Set(r.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,a=t.blockDefs[i];if(!a){o.clear();break}const l=new Set(a.components.map(c=>c.name));for(const c of o)l.has(c)||o.delete(c)}return o}const yk=d.defineComponent({__name:"FloatingMenuBar",setup(t){const e=d.useSlots(),{reset:n}=Un(),r=d.inject(gh),{selectedIds:o,commonComponents:s}=r,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape"]),a=d.computed(()=>{const c=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&c.push(u)}return c});function l(){n()}return d.onUnmounted(()=>{n()}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:l},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.value,f=>d.renderSlot(c.$slots,`button:${f}`,{key:f,entityIds:d.unref(o)})),128)),d.renderSlot(c.$slots,"button:color",{entityIds:d.unref(o)},()=>[d.unref(s).has("color")?(d.openBlock(),d.createBlock(ak,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:shape",{entityIds:d.unref(o)},()=>[d.unref(s).has("shape")?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[d.createVNode(dk,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(ck,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(uk,{entityIds:d.unref(o)},null,8,["entityIds"])],64)):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:penStroke",{entityIds:d.unref(o)},()=>[d.unref(s).has("penStroke")?(d.openBlock(),d.createBlock(lk,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowThickness",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(ok,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadStart",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(Ld,{key:0,entityIds:d.unref(o),side:"start"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadEnd",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(Ld,{key:0,entityIds:d.unref(o),side:"end"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:text",{entityIds:d.unref(o)},()=>[d.unref(s).has("text")?(d.openBlock(),d.createBlock(QI,{key:0,entityIds:d.unref(o),showVerticalAlign:d.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])):d.createCommentVNode("",!0)]),d.createVNode(Fd)],32))}}),eP={class:"wov-floating-menu-inner"},kk=d.defineComponent({__name:"FloatingMenu",setup(t){const e=d.inject(pt),n=_0([h.Block,Ie]),r=Ze(h.Camera),o=Ze(h.Screen),s=Ze(Tt),i=Bs(),a=d.computed(()=>n.value.map(S=>S.entityId)),l=d.computed(()=>{const S=e==null?void 0:e.getEditor();if(!S||n.value.length===0)return new Set;const C=n.value.map(_=>({tag:_.block.value.tag}));return gk(S,C)});d.provide(gh,{selectedIds:a,commonComponents:l});const c=[0,0,0,0];function u(...S){let C=1/0,_=1/0,x=-1/0,T=-1/0,N=!1;for(const I of S){if(!I)continue;const V=I.getBoundingClientRect();V.width<=0||(N=!0,C=Math.min(C,V.left),_=Math.min(_,V.top),x=Math.max(x,V.right),T=Math.max(T,V.bottom))}return N?{x:C,y:_,left:C,top:_,right:x,bottom:T,width:x-C,height:T-_,toJSON:()=>({})}:null}const f=d.computed(()=>{if(n.value.length===0)return null;const S=r.value;if(!S)return null;let C=null;for(const _ of n.value){const x=_.block.value;E.Rect.getAabb(x.position,x.size,x.rotateZ,c),E.Aabb.translate(c,[-S.left,-S.top]),E.Aabb.scale(c,S.zoom),C===null?C=E.Aabb.clone(c):E.Aabb.union(C,c)}return C}),p=d.inject("containerRef"),m=d.computed(()=>{const S=p==null?void 0:p.value;if(!S)return null;r.value,i.updateCounter.value;const C=i.blockElement.value,_=i.textElement.value,x=u(C,_);if(x)return{getBoundingClientRect:()=>x};const T=f.value;if(!T)return null;const N=S.getBoundingClientRect();return{getBoundingClientRect(){return{x:N.left+T[0],y:N.top+T[1],width:T[2]-T[0],height:T[3]-T[1],top:N.top+T[1],left:N.left+T[0],right:N.left+T[2],bottom:N.top+T[3]}}}}),g=d.ref(null),y={name:"clampToViewport",fn({y:S,rects:C}){const T=window.innerHeight-C.floating.height-8;return{y:Math.max(8,Math.min(S,T))}}},{floatingStyles:k}=Pa(m,g,{placement:"top",middleware:[Ba(12),Ia({fallbackPlacements:["bottom"]}),Oa({padding:8}),y]}),w=d.computed(()=>{const S=f.value,C=o.value;return!S||!C?!0:S[2]<0||S[0]>C.width||S[3]<0||S[1]>C.height}),v=[de.Dragging,de.SelectionBoxDragging],b=d.computed(()=>n.value.length>0&&!w.value&&!v.includes(s.value.state));return(S,C)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-fade"},{default:d.withCtx(()=>[b.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:g,class:"wov-floating-menu",style:d.normalizeStyle(d.unref(k))},[d.createElementVNode("div",eP,[d.renderSlot(S.$slots,"default",{},()=>[d.createVNode(yk)])])],4)):d.createCommentVNode("",!0)]),_:3}))}}),tP={key:0,class:"wov-loading-overlay"},nP={class:"wov-loading-spinner"},wk=d.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(t){const e=d.ref("|"),n=["|","/","-","\\"];let r=null;return d.onMounted(()=>{r=setInterval(()=>{const o=n.indexOf(e.value);e.value=n[(o+1)%n.length]},100)}),d.onUnmounted(()=>{r!==null&&clearInterval(r)}),(o,s)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-loading-fade"},{default:d.withCtx(()=>[t.isLoading?(d.openBlock(),d.createElementBlock("div",tP,[d.createElementVNode("div",nP,d.toDisplayString(e.value),1)])):d.createCommentVNode("",!0)]),_:1}))}}),rP={class:"wov-action-bar"},oP=d.defineComponent({__name:"ActionBar",setup(t){const{getEditor:e}=Ee(),n=d.inject(pt),r=d.ref(!1),o=d.ref(!1);if(n){const l=n.registerTickCallback(c=>{const{store:u}=h.getPluginResources(c,"editing");r.value=u.canUndo(),o.value=u.canRedo()});d.onUnmounted(l)}function s(){const l=e();l==null||l.command(h.Undo)}function i(){const l=e();l==null||l.command(h.Redo)}function a(){const l=e();l==null||l.command(yl)}return(l,c)=>(d.openBlock(),d.createElementBlock("div",rP,[d.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...c[0]||(c[0]=[d.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"},[d.createElementVNode("path",{d:"M3 7v6h6"}),d.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...c[1]||(c[1]=[d.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"},[d.createElementVNode("path",{d:"M21 7v6h-6"}),d.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:a,"aria-label":"Delete"},[...c[2]||(c[2]=[d.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"},[d.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),d.createElementVNode("path",{d:"M3 6h18"}),d.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),Qt=d.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(t){const e=t,n=d.inject(Ul);if(!n)throw new Error("ToolbarButton must be used within a Toolbar component");const r=n,o=d.ref(null),{show:s,hide:i}=Un(),a=d.computed(()=>r.activeTool.value===e.name);function l(){r.setTool(e.name,e.placementSnapshot,e.cursor)}function c(){r.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){r.onToolPointerUp()}function f(){e.tooltip&&o.value&&s(e.tooltip,o.value)}function p(){i()}return(m,g)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:d.normalizeClass(["wov-toolbar-button",{selected:a.value}]),onClick:l,onPointerdown:c,onPointerup:u,onMouseenter:f,onMouseleave:p},[d.renderSlot(m.$slots,"default")],34))}}),sP='<?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>',iP='<?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>',aP='<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>',Ir={Select:"select",Hand:"hand",Crosshair:"crosshair"},vk={[Ir.Select]:{makeSvg:()=>sP,hotspot:[1,0],rotationOffset:0},[Ir.Hand]:{makeSvg:()=>iP,hotspot:[12,12],rotationOffset:0},[Ir.Crosshair]:{makeSvg:()=>aP,hotspot:[12,12],rotationOffset:0}},lP={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},bk=d.defineComponent({__name:"SelectTool",setup(t){const{nextEditorTick:e}=Ee(),{activeTool:n}=Od();return d.watch(n,(r,o)=>{o==="select"&&e(s=>{Xr.spawn(s)})}),(r,o)=>(d.openBlock(),d.createBlock(Qt,{name:"select",tooltip:"Select",cursor:d.unref(Ir).Select},{default:d.withCtx(()=>[(d.openBlock(),d.createElementBlock("svg",lP,[...o[0]||(o[0]=[d.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[d.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"]))}}),Sk=d.defineComponent({__name:"HandTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"hand",tooltip:"Hand",cursor:d.unref(Ir).Hand},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[d.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"]))}}),Ck=d.defineComponent({__name:"StickyNoteTool",setup(t){const e=JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:h.TextAlignment.Center},verticalAlign:{value:h.VerticalAlignment.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Qt,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("path",{d:"M4 4h12v12H4z"}),d.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),xk=d.defineComponent({__name:"ShapeTool",setup(t){const e=JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:h.StrokeKind.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:h.TextAlignment.Center},verticalAlign:{value:h.VerticalAlignment.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Qt,{name:"shape",tooltip:"Shape","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),_k=d.defineComponent({__name:"EraserTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"eraser",tooltip:"Eraser"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[d.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}))}}),Ek=d.defineComponent({__name:"PenTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"pen",tooltip:"Pen"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.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"}),d.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),Tk=d.defineComponent({__name:"TextTool",setup(t){const e=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),n=JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24}});return(r,o)=>(d.openBlock(),d.createBlock(Qt,{name:"text",tooltip:"Text","drag-out-snapshot":d.unref(n),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...o[0]||(o[0]=[d.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"},[d.createElementVNode("path",{d:"M12 4v16"}),d.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),d.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Mk=d.defineComponent({__name:"ElbowArrowTool",setup(t){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:pe.None,endArrowHead:pe.V},connector:{}});return(n,r)=>(d.openBlock(),d.createBlock(Qt,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),Ak=d.defineComponent({__name:"ImageTool",setup(t){const{nextEditorTick:e}=Ee(),{show:n,hide:r}=Un(),{setTool:o}=Od(),{createImageBlock:s}=x0(),i=d.ref(null),a=d.ref(null);function l(){var p;(p=a.value)==null||p.click()}async function c(p){var S;const m=p.target,g=(S=m.files)==null?void 0:S[0];if(!g)return;if(m.value="",!g.type.startsWith("image/")){console.warn("Selected file is not an image");return}const y=await e(),k=h.Camera.read(y),w=h.Screen.read(y),v=k.left+w.width/k.zoom/2,b=k.top+w.height/k.zoom/2;await s(g,v,b),o("select",void 0,Ir.Select)}function u(){i.value&&n("Image",i.value)}function f(){r()}return(p,m)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:l,onMouseenter:u,onMouseleave:f},[m[0]||(m[0]=d.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"},[d.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),d.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),d.createElementVNode("input",{ref_key:"fileInputRef",ref:a,type:"file",accept:"image/*",style:{display:"none"},onChange:c},null,544)],544))}}),cP={class:"wov-toolbar-container"},Nk=d.defineComponent({__name:"Toolbar",setup(t){const e=d.useSlots(),{reset:n}=Un(),{nextEditorTick:r}=Ee(),o=d.ref(null),s=d.ref(null),i=Ze(h.Controls),a=d.computed(()=>i.value.leftMouseTool),l=[bk,Sk,Tk,Ak,xk,Mk,Ck,Ek,_k],c=d.inject("containerRef"),u=d.ref(null),f=d.ref(!1),p=d.ref(null),m=d.ref(null),g=d.ref(1/0),y=d.ref(0),k=d.ref([]),w=d.ref(8),v=d.ref(48),{width:b}=fk(c);function S(){return p.value?Array.from(p.value.children).filter(j=>!j.classList.contains("wov-overflow-button")&&!j.classList.contains("wov-menu-tooltip")):[]}function C(){var fe;const j=S();if(j.length===0)return;y.value=j.length;const q=getComputedStyle(p.value);w.value=parseFloat(q.gap)||8;const te=((fe=m.value)==null?void 0:fe.offsetWidth)||40;v.value=te+w.value,k.value=j.map(ce=>ce.offsetWidth)}function _(){if(k.value.length===0)return;const te=b.value-40-20,fe=w.value,ce=v.value;let Se=0,Dt=0;for(let gn=0;gn<k.value.length;gn++){const Dr=k.value[gn],qn=Se>0?Dr+fe:Dr,Gn=k.value.length-gn-1>0?ce:0;if(Se+qn+Gn<=te)Se+=qn,Dt++;else break}g.value=Math.max(1,Dt)}d.watch(b,()=>{k.value.length>0&&_()}),d.onMounted(()=>{d.nextTick(()=>{C(),_()})});const x=d.computed(()=>g.value<y.value);d.watchEffect(()=>{S().forEach((q,te)=>{q.style.display=te<g.value?"":"none"})}),d.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((q,te)=>{q.style.display=te>=g.value?"":"none"})});const{floatingStyles:T}=Pa(m,u,{placement:"top",middleware:[Ba(16),Ia(),Oa({padding:8})],whileElementsMounted:ek});function N(){f.value=!f.value}function I(){f.value=!1}function V(j){const q=j.target;m.value&&!m.value.contains(q)&&u.value&&!u.value.contains(q)&&I()}d.watch(f,j=>{j?document.addEventListener("click",V,!0):document.removeEventListener("click",V,!0)}),d.watch(x,j=>{j||I()});function K(j,q,te){s.value=q??null,r(fe=>{const ce=h.Controls.write(fe);ce.leftMouseTool=j,ce.heldSnapshot=q??"",te&&h.Cursor.setCursor(fe,te)})}function M(j){r(q=>{const te=h.Controls.write(q);te.leftMouseTool="drag-out",te.heldSnapshot=j})}function $(j,q){o.value=j,s.value=q??null}function Z(){o.value=null,s.value=null}function ae(){n(),o.value&&s.value&&M(s.value),o.value=null,s.value=null}const X={activeTool:a,heldTool:o,setTool:K,dragOutTool:M,onToolPointerDown:$,onToolPointerUp:Z};return d.provide(Ul,X),(j,q)=>(d.openBlock(),d.createElementBlock("div",cP,[d.createVNode(oP),d.createElementVNode("div",{ref_key:"toolsContainerRef",ref:p,class:"wov-toolbar",onMouseleave:ae},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(te,fe)=>d.createVNode(d.resolveDynamicComponent(te),{key:fe})),64)),x.value?(d.openBlock(),d.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:m,class:d.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:N},[...q[0]||(q[0]=[d.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[d.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),d.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):d.createCommentVNode("",!0),d.createVNode(Fd)],544),d.unref(c)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(c)},[f.value&&x.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:d.normalizeStyle(d.unref(T))},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(te,fe)=>d.createVNode(d.resolveDynamicComponent(te),{key:fe})),64))],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)]))}}),dP=d.defineComponent({__name:"ArcArrowTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Qt,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),uP={class:"wov-user-presence-avatars"},fP=["src","alt"],hP={class:"wov-user-presence-list"},pP=["src","alt"],mP={class:"wov-user-presence-name"},gP=4,Bk=d.defineComponent({__name:"UserPresence",props:{users:{}},setup(t){const e=t,n=d.ref(!1),r=d.ref(null);AI(r,()=>{n.value=!1});function o(a){if(!a)return"?";const l=a.trim().split(/\s+/);return l.length>=2?(l[0][0]+l[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const s=d.computed(()=>e.users.map(a=>({sessionId:a.sessionId,name:a.name,color:a.color,avatar:a.avatar,initials:o(a.name)}))),i=d.computed(()=>s.value.slice(0,gP));return(a,l)=>t.users.length>1?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"containerRef",ref:r,class:"wov-user-presence"},[d.createElementVNode("button",{class:d.normalizeClass(["wov-user-presence-trigger",{"is-open":n.value}]),onClick:l[0]||(l[0]=c=>n.value=!n.value)},[d.createElementVNode("div",uP,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-avatar",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,fP)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4))),128))])],2),n.value?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:l[1]||(l[1]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",hP,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-presence-item"},[d.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,pP)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4),d.createElementVNode("span",mP,d.toDisplayString(c.name),1)]))),128))])],32)):d.createCommentVNode("",!0)],512)):d.createCommentVNode("",!0)}}),Gd=(t,e)=>e.some(n=>t instanceof n);let Ok,Ik;function yP(){return Ok||(Ok=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kP(){return Ik||(Ik=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Yd=new WeakMap,Xd=new WeakMap,Va=new WeakMap;function wP(t){const e=new Promise((n,r)=>{const o=()=>{t.removeEventListener("success",s),t.removeEventListener("error",i)},s=()=>{n(Pr(t.result)),o()},i=()=>{r(t.error),o()};t.addEventListener("success",s),t.addEventListener("error",i)});return Va.set(e,t),e}function vP(t){if(Yd.has(t))return;const e=new Promise((n,r)=>{const o=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",i),t.removeEventListener("abort",i)},s=()=>{n(),o()},i=()=>{r(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",s),t.addEventListener("error",i),t.addEventListener("abort",i)});Yd.set(t,e)}let Qd={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Yd.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Pr(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Pk(t){Qd=t(Qd)}function bP(t){return kP().includes(t)?function(...e){return t.apply(eu(this),e),Pr(this.request)}:function(...e){return Pr(t.apply(eu(this),e))}}function SP(t){return typeof t=="function"?bP(t):(t instanceof IDBTransaction&&vP(t),Gd(t,yP())?new Proxy(t,Qd):t)}function Pr(t){if(t instanceof IDBRequest)return wP(t);if(Xd.has(t))return Xd.get(t);const e=SP(t);return e!==t&&(Xd.set(t,e),Va.set(e,t)),e}const eu=t=>Va.get(t);function CP(t,e,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(t,e),a=Pr(i);return r&&i.addEventListener("upgradeneeded",l=>{r(Pr(i.result),l.oldVersion,l.newVersion,Pr(i.transaction),l)}),n&&i.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),o&&l.addEventListener("versionchange",c=>o(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const xP=["get","getKey","getAll","getAllKeys","count"],_P=["put","add","delete","clear"],tu=new Map;function Rk(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(tu.get(e))return tu.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,o=_P.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(o||xP.includes(n)))return;const s=async function(i,...a){const l=this.transaction(i,o?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[n](...a),o&&l.done]))[0]};return tu.set(e,s),s}Pk(t=>({...t,get:(e,n,r)=>Rk(e,n)||t.get(e,n,r),has:(e,n)=>!!Rk(e,n)||t.has(e,n)}));const EP=["continue","continuePrimaryKey","advance"],Dk={},nu=new WeakMap,zk=new WeakMap,TP={get(t,e){if(!EP.includes(e))return t[e];let n=Dk[e];return n||(n=Dk[e]=function(...r){nu.set(this,zk.get(this)[e](...r))}),n}};async function*MP(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const n=new Proxy(e,TP);for(zk.set(n,e),Va.set(n,eu(e));e;)yield n,e=await(nu.get(n)||e.continue()),nu.delete(n)}function $k(t,e){return e===Symbol.asyncIterator&&Gd(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Gd(t,[IDBIndex,IDBObjectStore])}Pk(t=>({...t,get(e,n,r){return $k(e,n)?MP:t.get(e,n,r)},has(e,n){return $k(e,n)||t.has(e,n)}}));async function ru(t,e){const n=await CP(t,1,{upgrade(r){r.objectStoreNames.contains(e)||r.createObjectStore(e)}});return new AP(n,e)}var AP=class{constructor(t,e){this.db=t,this.storeName=e}async get(t){return this.db.get(this.storeName,t)}async put(t,e){await this.db.put(this.storeName,e,t)}async delete(t){await this.db.delete(this.storeName,t)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),n=await e.getAllKeys(),r=await e.getAll(),o=[];for(let s=0;s<n.length;s++)o.push([n[s],r[s]]);return o}async clear(){const t=this.db.transaction(this.storeName,"readwrite");t.objectStore(this.storeName).clear(),await t.done}close(){this.db.close()}},NP=class{constructor(t){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=t.provider,this.documentId=t.documentId,this.maxRetries=t.provider.maxRetries??3,this.retryDelay=t.provider.retryDelay??5e3}async init(){const t=`wovencanvas-assets-${this.documentId}`,[e,n]=await Promise.all([ru(`${t}-jobs`,"jobs"),ru(`${t}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=n}async upload(t,e,n){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(t,e);const r={identifier:t,metadata:n,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(t,r);const o=URL.createObjectURL(e);return this.blobUrls.set(t,o),new Promise((s,i)=>{this.uploadPromises.set(t,{resolve:s,reject:i}),this.startUpload(t)})}async getDisplayUrl(t){const e=this.blobUrls.get(t);if(e)return e;try{return await this.provider.resolveUrl(t)}catch(n){return console.error(`Failed to resolve URL for ${t}:`,n),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const t=await this.jobsStore.getAllEntries();for(const[e]of t){const n=await this.binariesStore.get(e);if(n){const r=URL.createObjectURL(n);this.blobUrls.set(e,r)}this.startUpload(e)}}hasPendingUpload(t){return this.blobUrls.has(t)}isUploading(t){return this.uploading.has(t)}async cancelUpload(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.reject(new Error("Upload cancelled")),this.uploadPromises.delete(t))}close(){var t,e;for(const n of this.blobUrls.values())URL.revokeObjectURL(n);this.blobUrls.clear(),(t=this.jobsStore)==null||t.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(t){if(!this.jobsStore||!this.binariesStore||this.uploading.has(t))return;this.uploading.add(t);const e=await this.jobsStore.get(t),n=await this.binariesStore.get(t);if(!e||!n){this.uploading.delete(t);return}try{await this.provider.upload(n,t,e.metadata),await this.onUploadSuccess(t)}catch(r){await this.onUploadError(t,e,r)}}async onUploadSuccess(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.resolve(),this.uploadPromises.delete(t))}async onUploadError(t,e,n){if(!this.jobsStore)return;const r=n instanceof Error?n.message:"Unknown error";if(console.error(`Upload failed for ${t}:`,r),this.uploading.delete(t),e.retryCount<this.maxRetries){const o={...e,retryCount:e.retryCount+1};await this.jobsStore.put(t,o),setTimeout(()=>{this.startUpload(t)},this.retryDelay*2**e.retryCount)}else{const o=this.uploadPromises.get(t);o&&(o.reject(new Error(r)),this.uploadPromises.delete(t))}}},BP="wovencanvas-assets",OP="blobs",IP=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(t,e,n){return await(await this.getStore()).put(e,{blob:t,metadata:n}),{}}async resolveUrl(t){const n=await(await this.getStore()).get(t);if(!n)throw new Error(`Asset not found: ${t}`);return URL.createObjectURL(n.blob)}async delete(t){await(await this.getStore()).delete(t)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=ru(BP,OP).then(t=>(this.store=t,t))),this.initPromise)}},Vk=rn.object({minZoom:rn.number().default(.05),maxZoom:rn.number().default(2.7)});Vk.parse({});var Rs=h.defineEditorState("panState",{state:h.field.string().max(16).default("idle"),panStartX:h.field.float64().default(0),panStartY:h.field.float64().default(0),velocityX:h.field.float64().default(0),velocityY:h.field.float64().default(0),targetX:h.field.float64().default(0),targetY:h.field.float64().default(0),expectedLeft:h.field.float64().default(0),expectedTop:h.field.float64().default(0)}),Rr=h.defineCanvasSingleton({name:"pinchState"},{active:h.field.boolean().default(!1),prevDistance:h.field.float64().default(0),prevCenter:h.field.tuple(h.field.float64(),2).default([0,0])}),mn=[0,0],La=[0,0],Ds=[0,0],ou=[0,0],su=[0,0];function PP(t,e,n,r,o,s){r=Math.max(1e-4,r);const i=2/r,a=i*s,l=1/(1+a+.48*a*a+.235*a*a*a);E.Vec2.copy(mn,t),E.Vec2.sub(mn,e);const c=o*r,u=c*c,f=E.Vec2.lengthSq(mn);f>u&&E.Vec2.scale(mn,c/Math.sqrt(f)),E.Vec2.copy(La,t),E.Vec2.sub(La,mn),E.Vec2.set(Ds,(n[0]+i*mn[0])*s,(n[1]+i*mn[1])*s);const p=[(n[0]-i*Ds[0])*l,(n[1]-i*Ds[1])*l],m=[La[0]+(mn[0]+Ds[0])*l,La[1]+(mn[1]+Ds[1])*l];return E.Vec2.copy(ou,e),E.Vec2.sub(ou,t),E.Vec2.copy(su,m),E.Vec2.sub(su,e),E.Vec2.dot(ou,su)>0&&(m[0]=e[0],m[1]=e[1],p[0]=(m[0]-e[0])/s,p[1]=(m[1]-e[1])/s),{position:m,velocity:p}}var iu=.1,Lk=.1,RP=on({guards:{hasVelocity:({event:t})=>{if(t.type!=="pointerUp")return!1;const e=t.velocity;return Math.hypot(e[0],e[1])>Lk},isGlideComplete:({context:t})=>Math.hypot(t.velocityX,t.velocityY)<Lk,cameraWasMoved:({context:t,event:e})=>{const n=h.Camera.read(e.ctx);return n.left!==t.expectedLeft||n.top!==t.expectedTop},isEscapeKey:({event:t})=>t.key===h.Key.Escape},actions:{setDragStart:we({panStartX:({event:t})=>t.worldPosition[0],panStartY:({event:t})=>t.worldPosition[1]}),moveCamera:({context:t,event:e})=>{const n=e,{ctx:r}=n,o=n.worldPosition[0]-t.panStartX,s=n.worldPosition[1]-t.panStartY,i=h.Camera.write(r);i.left-=o,i.top-=s},startGlide:we(({event:t})=>{const e=t,{ctx:n}=e,r=h.Camera.read(n),o=e.cameraZoom,s=-e.velocity[0]/o,i=-e.velocity[1]/o;return{velocityX:s,velocityY:i,targetX:r.left+s*iu,targetY:r.top+i*iu,expectedLeft:r.left,expectedTop:r.top}}),animateGlide:we(({context:t,event:e})=>{const n=e,{ctx:r,delta:o}=n,s=h.Camera.read(r),{position:i,velocity:a}=PP([s.left,s.top],[t.targetX,t.targetY],[t.velocityX,t.velocityY],iu,Number.POSITIVE_INFINITY,o),l=h.Camera.write(r);return l.left=i[0],l.top=i[1],{velocityX:a[0],velocityY:a[1],expectedLeft:i[0],expectedTop:i[1]}}),resetContext:we({panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0})}}).createMachine({id:"pan",initial:"idle",context:{panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0},states:{idle:{on:{pointerDown:{actions:"setDragStart",target:"panning"}}},panning:{entry:"moveCamera",on:{pointerMove:{actions:"moveCamera"},pointerUp:[{guard:"hasVelocity",actions:"startGlide",target:"gliding"},{target:"idle"}],keyDown:{guard:"isEscapeKey",target:"idle"}}},gliding:{on:{frame:[{guard:"cameraWasMoved",actions:"resetContext",target:"idle"},{guard:"isGlideComplete",actions:"resetContext",target:"idle"},{actions:"animateGlide"}],pointerDown:{actions:["resetContext","setDragStart"],target:"panning"}}}}}),DP=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=Rs.read(t).state;if(Rr.read(t).active){e!=="idle"&&Rs.copy(t,Rs.default());return}const r=h.Controls.getButtons(t,"hand"),s=[...h.getPointerInput(t,r)];e==="gliding"&&s.push(h.getFrameInput(t)),s.push(...h.getKeyboardInput(t,[h.Key.Escape])),s.length!==0&&Rs.run(t,RP,s)}),zP=h.defineQuery(t=>t.with(h.Pointer)),$P=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=h.getPluginResources(t,"controls"),n=zP.current(t),r=[];for(let g=0;g<n.length;g++){const y=n[g],k=h.Pointer.read(t,y);k.pointerType===h.PointerType.Touch&&r.push(k.position)}if(r.length!==2){if(Rr.read(t).active){const y=Rr.write(t);y.active=!1}return}const[o,s]=r,i=E.Vec2.distance(o,s),a=E.Vec2.midPoint(o,s),l=Rr.read(t);if(!l.active){const g=Rr.write(t);g.prevDistance=i,g.prevCenter=a,g.active=!0;return}const c=h.Camera.read(t),u=h.Screen.read(t);if(l.prevDistance>0&&i>0){const g=i/l.prevDistance;let y=c.zoom*g;y=Math.min(e.maxZoom,Math.max(e.minZoom,y));const k=u.width/c.zoom,w=u.height/c.zoom,v=u.width/y,b=u.height/y,S=v-k,C=b-w,_=a[0]/u.width,x=a[1]/u.height,T=h.Camera.write(t);T.left-=_*S,T.top-=x*C,T.zoom=y}const f=a[0]-l.prevCenter[0],p=a[1]-l.prevCenter[1];if(f!==0||p!==0){const g=h.Camera.write(t);g.left-=f/g.zoom,g.top-=p/g.zoom}const m=Rr.write(t);m.prevDistance=i,m.prevCenter=a}),VP=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=h.Keyboard.read(t);if(!h.Controls.wheelActive(t,"scroll",e.modDown))return;const r=h.getMouseInput(t).find(l=>l.type==="wheel");if(!r)return;const o=h.Camera.read(t),s=o.left+r.wheelDeltaX/o.zoom,i=o.top+r.wheelDeltaY/o.zoom,a=h.Camera.write(t);a.left=s,a.top=i}),LP=h.defineEditorSystem({phase:"input",priority:-100},t=>{const e=h.getPluginResources(t,"controls"),n=h.Keyboard.read(t);if(!h.Controls.wheelActive(t,"zoom",n.modDown))return;const o=h.getMouseInput(t).find(S=>S.type==="wheel");if(!o)return;const s=h.Camera.read(t),i=h.Screen.read(t),a=h.Mouse.read(t);let l=2**(-.8*o.wheelDeltaY/500)*s.zoom;l=Math.min(e.maxZoom,Math.max(e.minZoom,l));const c=i.width/s.zoom,u=i.height/s.zoom,f=i.width/l,p=i.height/l,m=f-c,g=p-u,y=a.position[0]/i.width,k=a.position[1]/i.height,w=s.left-y*m,v=s.top-k*g,b=h.Camera.write(t);b.left=w,b.top=v,b.zoom=l});function FP(t={}){return{name:"controls",resources:Vk.parse(t),singletons:[Rs,Rr],systems:[LP,VP,DP,$P]}}var jP=(t={})=>FP(t);const HP={class:"wov-selection-box"},WP=d.defineComponent({__name:"SelectionBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",HP))}}),ZP={class:"wov-transform-box"},UP=d.defineComponent({__name:"TransformBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",ZP))}}),KP={},JP={class:"wov-transform-handle"};function qP(t,e){return d.openBlock(),d.createElementBlock("div",JP)}const GP=ir(KP,[["render",qP]]),YP=d.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Pe(e.entityId,h.Color),r=Pe(e.entityId,h.VerticalAlign),o=d.ref(null),s={[h.VerticalAlignment.Top]:"flex-start",[h.VerticalAlignment.Center]:"center",[h.VerticalAlignment.Bottom]:"flex-end"},i=d.computed(()=>{var l;return{backgroundColor:n.value?`rgb(${n.value.red}, ${n.value.green}, ${n.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((l=r.value)==null?void 0:l.value)??h.VerticalAlignment.Top]}}),{handleEditEnd:a}=Bd({blockData:e,containerRef:o,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(l,c)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-sticky-note",style:d.normalizeStyle(i.value)},[d.createVNode(wa,d.mergeProps(e,{"block-element":o.value,onEditEnd:d.unref(a)}),null,16,["block-element","onEditEnd"])],4))}}),Fa=at.defineCanvasSingleton({name:"blockPlacementState"},{editedCheckpoint:h.field.string().default("").max(36)}),Fk=h.defineQuery(t=>t.with(h.Edited));function XP(t){var e;if(!t)return null;try{const n=JSON.parse(t);return(e=n.block)!=null&&e.tag?n:(console.warn("Block snapshot missing required tag:",n),null)}catch{return console.warn("Invalid block snapshot JSON:",t),null}}function QP(t,e,n){const r=h.getBlockDef(t,e.block.tag);if(!r)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const o=e.block.size??[100,100],s=n[0]-o[0]/2,i=n[1]-o[1]/2,a=e.block.rank??h.RankBounds.genNext(t),l=h.createEntity(t);"synced"in e||h.addComponent(t,l,h.Synced,{id:crypto.randomUUID()});const c=Object.assign({},e.block,{position:[s,i],size:o,rank:a});h.addComponent(t,l,h.Block,c);for(const f of r.components)if(!(f.name in e))h.addComponent(t,l,f);else{const p=e[f.name];h.addComponent(t,l,f,p)}const{sessionId:u}=h.getResources(t);return h.addComponent(t,l,h.Held,{sessionId:u}),l}function jk(t,e,n,r,o){const s=QP(t,e,n),i=h.Block.read(t,s);if(h.canBlockEdit(t,e.block.tag)&&(h.addComponent(t,s,Ko,{}),o==="placement")){const{store:u}=h.getPluginResources(t,"editing"),f=u.createCheckpoint();if(f){const p=Fa.write(t);p.editedCheckpoint=f}}const a=Tt.write(t);a.state=o==="dragOut"?de.Dragging:de.Pointing,a.dragStart=n,a.draggedEntity=s,a.draggedEntityStart=i.position,a.pointingStartClient=r,a.pointingStartWorld=n,a.isCloning=!1;const l=h.Controls.write(t);l.leftMouseTool="select",l.heldSnapshot="";const c=h.Cursor.write(t);c.cursorKind="select",c.rotation=0}function eR(t){const e=Fa.read(t);if(e.editedCheckpoint){const n=e.editedCheckpoint;Fa.write(t).editedCheckpoint="";const{store:r}=h.getPluginResources(t,"editing");r.onSettled(()=>r.squashToCheckpoint(n),{frames:5})}}const tR=h.defineEditorSystem({phase:"capture"},t=>{Fk.removed(t).length>0&&Fk.current(t).length===0&&eR(t);const e=h.Controls.read(t);if(!e.heldSnapshot)return;const n=h.getPointerInput(t,[h.PointerButton.Left]);if(n.length===0)return;const r=XP(e.heldSnapshot);if(!r)return;if(e.leftMouseTool==="drag-out"){const s=n.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;jk(t,r,s.worldPosition,s.screenPosition,"dragOut")}else{const s=n.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;jk(t,r,s.worldPosition,s.screenPosition,"placement")}}),nR=h.defineEditorSystem({phase:"update"},t=>{const{store:e}=h.getPluginResources(t,"editing");h.on(t,h.Undo,()=>{e.canUndo()&&(bf(t),e.undo())}),h.on(t,h.Redo,()=>{e.canRedo()&&(bf(t),e.redo())})}),rR=[{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 Hk(t){return{name:"editing",resources:{store:t.store},singletons:[Fa],systems:[tR,nR],cursors:vk,fonts:rR,keybinds:[{command:h.Undo.name,key:h.Key.Z,mod:!0},{command:h.Redo.name,key:h.Key.Y,mod:!0},{command:h.Redo.name,key:h.Key.Z,mod:!0,shift:!0}]}}const oR=d.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(t){const e=t,{nextEditorTick:n}=Ee(),{createImageBlock:r}=x0(),o=d.ref(!1);let s=0;const i=d.inject("containerRef");function a(v){var b;(b=v.dataTransfer)!=null&&b.types.some(S=>S==="Files"||S==="text/uri-list"||S==="text/html")&&(s++,s===1&&(o.value=!0))}function l(){s--,s===0&&(o.value=!1)}function c(){s=0,o.value=!1}d.onMounted(()=>{const v=i==null?void 0:i.value;v&&(v.addEventListener("dragenter",a),v.addEventListener("dragleave",l),v.addEventListener("drop",c))}),d.onUnmounted(()=>{const v=i==null?void 0:i.value;v&&(v.removeEventListener("dragenter",a),v.removeEventListener("dragleave",l),v.removeEventListener("drop",c))});function u(v){v.preventDefault(),v.dataTransfer&&(v.dataTransfer.dropEffect="copy")}function f(v){v.preventDefault()}function p(v){v.preventDefault()}async function m(v){if(v.preventDefault(),!v.dataTransfer)return;const b=v.clientX,S=v.clientY,C=Array.from(v.dataTransfer.files).filter(x=>x.type.startsWith("image/"));if(C.length>0){for(const x of C)await k(x,b,S);return}const _=g(v.dataTransfer);_&&await w(_,b,S)}function g(v){const b=v.getData("text/uri-list");if(b){const x=b.split(`
|
|
171
171
|
`).filter(T=>!T.startsWith("#")).find(T=>y(T));if(x)return x}const S=v.getData("text/html");if(S){const _=S.match(/<img[^>]+src=["']([^"']+)["']/i);if(_!=null&&_[1])return _[1]}const C=v.getData("text/plain");return C&&y(C)?C:null}function y(v){try{const S=new URL(v).pathname.toLowerCase();return/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i.test(S)||v.startsWith("data:image/"),!0}catch{return!1}}async function k(v,b,S){const C=await n(),_=h.Camera.read(C),x=h.Screen.read(C),T=_.left+(b-x.left)/_.zoom,N=_.top+(S-x.top)/_.zoom;await r(v,T,N,{maxSize:e.maxSize})}async function w(v,b,S){try{const C=await fetch(v);if(!C.ok){console.warn("Failed to fetch image from URL:",v);return}const _=await C.blob();if(!_.type.startsWith("image/")){console.warn("URL did not return an image:",v);return}const T=new URL(v).pathname.split("/").pop()||"image",N=new File([_],T,{type:_.type});await k(N,b,S)}catch(C){console.warn("Failed to load image from URL:",v,C)}}return(v,b)=>(d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["wov-image-drop-zone",{"wov-drag-over":o.value}]),onDragover:u,onDragenter:f,onDragleave:p,onDrop:m},null,34))}}),sR={class:"wov-user-cursors"},iR={class:"wov-cursor-svg",viewBox:"0 0 4.35 4.75",width:"20",height:"20"},aR=["fill"],lR="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",cR=d.defineComponent({__name:"UserCursors",props:{users:{},currentSessionId:{},camera:{}},setup(t){const e=t,n=d.computed(()=>e.users.filter(r=>r.sessionId!==e.currentSessionId).map(r=>({...r,screenX:(r.position[0]-e.camera.left)*e.camera.zoom,screenY:(r.position[1]-e.camera.top)*e.camera.zoom})));return(r,o)=>(d.openBlock(),d.createElementBlock("div",sR,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(n.value,s=>(d.openBlock(),d.createElementBlock("div",{key:s.sessionId,class:"wov-user-cursor",style:d.normalizeStyle({transform:`translate(${s.screenX}px, ${s.screenY}px)`})},[(d.openBlock(),d.createElementBlock("svg",iR,[d.createElementVNode("path",{fill:s.color,stroke:"#fff","stroke-miterlimit":"10","stroke-width":".25",d:lR},null,8,aR)])),d.createElementVNode("span",{class:"wov-cursor-label",style:d.normalizeStyle({backgroundColor:s.color})},d.toDisplayString(s.name),5)],4))),128))]))}}),dR={key:0,class:"wov-offline-indicator"},uR=d.defineComponent({__name:"OfflineIndicator",props:{isOnline:{type:Boolean}},setup(t){return(e,n)=>t.isOnline?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",dR,"Working Offline"))}}),fR={key:0,class:"wov-version-mismatch-overlay"},hR=d.defineComponent({__name:"VersionMismatch",props:{versionMismatch:{type:Boolean}},setup(t){function e(){window.location.reload()}return(n,r)=>t.versionMismatch?(d.openBlock(),d.createElementBlock("div",fR,[d.createElementVNode("div",{class:"wov-version-mismatch-dialog"},[r[0]||(r[0]=d.createElementVNode("p",null,"A new version is available.",-1)),r[1]||(r[1]=d.createElementVNode("p",null,"Please refresh the page to continue.",-1)),d.createElementVNode("button",{onClick:e},"Refresh")])])):d.createCommentVNode("",!0)}}),pR=d.defineComponent({__name:"BackToContentButton",setup(t){const{nextEditorTick:e}=Ee(),n=Ze(h.Camera),r=h.defineQuery(l=>l.with(h.Synced,h.Block,h.Aabb)),o=d.ref(0),s=d.inject(pt);if(s){const l=s.registerTickCallback(c=>{r.addedOrRemoved(c).length>0&&(o.value=r.current(c).length)});d.onUnmounted(l)}const i=d.ref(!1);d.watchEffect(()=>{i.value=!n.value.canSeeBlocks&&o.value>0});function a(){e(l=>{const c=r.current(l);if(c.length===0)return;let u=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const _ of c){const x=h.Aabb.read(l,_);u=Math.min(u,x.value[0]),f=Math.min(f,x.value[1]),p=Math.max(p,x.value[2]),m=Math.max(m,x.value[3])}const g=h.Screen.read(l),y=h.Camera.read(l);let k=Math.min(g.width/(p-u),g.height/(m-f));k/=1.1,k=Math.min(k,y.zoom);const w=(u+p)/2,v=(f+m)/2,b=w-g.width/k/2,S=v-g.height/k/2,C=h.Camera.write(l);C.left=b,C.top=S,C.zoom=k})}return(l,c)=>i.value?(d.openBlock(),d.createElementBlock("button",{key:0,class:"wov-back-to-content",onClick:a},[...c[0]||(c[0]=[d.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[d.createElementVNode("path",{d:"M10 12L6 8L10 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),d.createTextVNode(" Back to content ",-1)])])):d.createCommentVNode("",!0)}}),mR=["data-entity-id","data-selected","data-held-by-other","data-hovered"],gR=d.defineComponent({__name:"WovenCanvas",props:{store:{},editor:{},background:{},assetProvider:{},pluginOptions:{},controls:{}},emits:["ready"],setup(t,{emit:e}){var Wk;const n=h.defineQuery(A=>A.tracking(h.Block)),r=h.defineQuery(A=>A.with(h.Block).tracking(h.Connector)),o=h.defineQuery(A=>A.with(h.Block).tracking(Ie)),s=h.defineQuery(A=>A.with(h.Block).tracking(h.Held)),i=h.defineQuery(A=>A.with(h.Block).tracking(h.Hovered)),a=h.defineQuery(A=>A.with(h.Block).tracking(h.Edited)),l=h.defineQuery(A=>A.with(h.Block).tracking(h.Opacity)),c=h.defineQuery(A=>A.tracking(h.User)),u=t,f=e,p=d.ref(null),m=d.shallowRef(null),g=h.UserData.parse(((Wk=u.editor)==null?void 0:Wk.user)??{}),y=new Set,k=new Map,w=d.shallowRef([]),v=new Map,b=new Map,S=new Set,C=new Map,_=d.shallowRef([]),x=d.ref(!0),T=d.ref(!1),N=d.ref(!0),I=d.shallowRef(h.Camera.default());function V(A,se,D){let Y=v.get(A);Y||(Y=new Map,v.set(A,Y));let H=Y.get(se);return H||(H=new Set,Y.set(se,H)),H.add(D),()=>{H.delete(D),H.size===0&&(Y.delete(se),Y.size===0&&v.delete(A))}}function K(A,se,D,Y=!1){const H=v.get(se);if(!H)return;const R=H.get(D.name);if(!R||R.size===0)return;let Me=null;Y||(Me=D.snapshot(A,se));for(const zt of R)zt(Me)}function M(A,se){let D=b.get(A);return D||(D=new Set,b.set(A,D)),D.add(se),()=>{D.delete(se),D.size===0&&b.delete(A)}}function $(A,se){const D=b.get(se.name);if(!D||D.size===0)return;const Y=se.snapshot(A);for(const H of D)H(Y)}function Z(A){return S.add(A),()=>{S.delete(A)}}function ae(){return g.sessionId}function X(A){return k.get(A)??null}const j={hasEntity:A=>y.has(A),getEditor:()=>m.value,getAssetManager:()=>Se,getSessionId:ae,getUserBySessionId:X,subscribeComponent:V,subscribeSingleton:M,registerTickCallback:Z};d.provide(pt,j),d.provide("containerRef",p);const q=I0();d.provide(yh,q);let te=0,fe=null,ce=null,Se=null;async function Dt(){!m.value||!ce||(m.value.nextTick(A=>{Dr(A),qn(A);for(const se of S)se(A);ce&&ce.sync(A)}),await m.value.tick(),fe=requestAnimationFrame(Dt))}let gn=null;d.onMounted(async()=>{var zt,it;if(!p.value)return;gn=()=>{var zr;(zr=p.value)==null||zr.scrollTo(0,0)},p.value.addEventListener("scroll",gn);const A=u.store??{},se={history:!0,...A};A.websocket&&(se.websocket={...A.websocket,onVersionMismatch:zr=>{var yn,zs;T.value=!0,(zs=(yn=A.websocket)==null?void 0:yn.onVersionMismatch)==null||zs.call(yn,zr)},onConnectivityChange:zr=>{var yn,zs;x.value=zr,(zs=(yn=A.websocket)==null?void 0:yn.onConnectivityChange)==null||zs.call(yn,zr)}}),ce=new at.CanvasStore(se);const D=[],Y=u.pluginOptions;(Y==null?void 0:Y.controls)!==!1&&D.push(jP((Y==null?void 0:Y.controls)??{})),(Y==null?void 0:Y.selection)!==!1&&D.push(mb((Y==null?void 0:Y.selection)||void 0)),(Y==null?void 0:Y.eraser)!==!1&&D.push(I_((Y==null?void 0:Y.eraser)||void 0)),(Y==null?void 0:Y.pen)!==!1&&D.push(bE()),(Y==null?void 0:Y.arrows)!==!1&&D.push(TS((Y==null?void 0:Y.arrows)||void 0)),D.push(Hk({store:ce})),(zt=u.editor)!=null&&zt.plugins&&D.push(...u.editor.plugins);const H={...u.editor,user:g,plugins:D,controls:u.controls},R=new h.Editor(p.value,H);await R.initialize(),await ce.initialize({components:R.components,singletons:R.singletons});const Me=((it=A.persistence)==null?void 0:it.documentId)??"default";Se=new NP({provider:u.assetProvider??new IP,documentId:Me}),await Se.init(),await Se.resumePendingUploads(),m.value=R,fe=requestAnimationFrame(Dt),N.value=!1,f("ready",R,ce)}),d.onUnmounted(()=>{var A;fe!==null&&cancelAnimationFrame(fe),Se==null||Se.close(),ce==null||ce.close(),(A=m.value)==null||A.dispose()});function Dr(A){const{events:se,newIndex:D}=A.eventBuffer.readEvents(te);if(te=D,se.length===0)return;const{componentsById:Y,singletonsById:H}=h.getResources(A);for(const{entityId:R,eventType:Me,componentId:zt}of se){if(R===h.SINGLETON_ENTITY_ID){if(Me===h.EventType.CHANGED){const it=H.get(zt);it&&$(A,it)}continue}if(Me===h.EventType.ADDED)y.add(R);else if(Me===h.EventType.REMOVED)y.delete(R),v.delete(R);else if(Me===h.EventType.COMPONENT_ADDED){y.add(R);const it=Y.get(zt);it&&K(A,R,it)}else if(Me===h.EventType.COMPONENT_REMOVED){const it=Y.get(zt);it&&K(A,R,it,!0)}else if(Me===h.EventType.CHANGED){const it=Y.get(zt);it&&K(A,R,it)}}}function qn(A){var Y;let se=!1;for(const H of n.added(A)){const R=h.Block.snapshot(A,H),Me=(Y=m.value)==null?void 0:Y.blockDefs[R.tag],zt=(Me==null?void 0:Me.stratum)??"content";C.set(H,d.ref({entityId:H,block:R,stratum:zt,selected:!1,held:null,hovered:!1,edited:!1,opacity:null,connector:null})),se=!0}for(const H of n.removed(A))C.delete(H),se=!0;for(const H of n.changed(A)){const R=C.get(H);if(R){const Me=h.Block.snapshot(A,H);R.value.block.rank!==Me.rank&&(se=!0),R.value.block=Me}}let D=!1;for(const H of c.addedOrChanged(A)){const R=h.User.snapshot(A,H);k.set(R.sessionId,R),D=!0}for(const H of c.removed(A)){const R=h.User.read(A,H);k.delete(R.sessionId),D=!0}D&&(w.value=Array.from(k.values()));for(const H of o.added(A)){const R=C.get(H);R&&!R.value.selected&&(R.value.selected=!0)}for(const H of o.removed(A)){const R=C.get(H);R&&R.value.selected&&(R.value.selected=!1)}for(const H of s.addedOrChanged(A)){const R=C.get(H);R&&(R.value.held=h.Held.snapshot(A,H))}for(const H of s.removed(A)){const R=C.get(H);R&&R.value.held!==null&&(R.value.held=null)}for(const H of i.added(A)){const R=C.get(H);R&&!R.value.hovered&&(R.value.hovered=!0)}for(const H of i.removed(A)){const R=C.get(H);R&&R.value.hovered&&(R.value.hovered=!1)}for(const H of a.added(A)){const R=C.get(H);R&&!R.value.edited&&(R.value.edited=!0)}for(const H of a.removed(A)){const R=C.get(H);R&&R.value.edited&&(R.value.edited=!1)}for(const H of l.addedOrChanged(A)){const R=C.get(H);R&&(R.value.opacity=h.Opacity.snapshot(A,H))}for(const H of l.removed(A)){const R=C.get(H);R&&R.value.opacity!==null&&(R.value.opacity=null)}for(const H of r.addedOrChanged(A)){const R=C.get(H);R&&(R.value.connector=h.Connector.snapshot(A,H))}for(const H of r.removed(A)){const R=C.get(H);R&&R.value.connector!==null&&(R.value.connector=null)}if(se){const H=Array.from(C.values());H.sort((R,Me)=>R.value.block.rank>Me.value.block.rank?1:-1),_.value=H}}M(h.Camera.name,A=>{A&&(I.value=A)});function ja(A){const se=A.rotateZ!==0,D=A.flip[0],Y=A.flip[1];if(!se&&!D&&!Y)return;const H=[];return se&&H.push(`rotate(${A.rotateZ}rad)`),D&&H.push("scaleX(-1)"),Y&&H.push("scaleY(-1)"),H.join(" ")}function xo(A){const{held:se}=A;if(!se||!se.sessionId||se.sessionId===g.sessionId)return null;const D=X(se.sessionId);return(D==null?void 0:D.color)??null}function Gn(A){const{block:se,stratum:D,opacity:Y}=A,H=xo(A),R=Y!==null?Y.value/255:1;return{position:"absolute",left:`${se.position[0]}px`,top:`${se.position[1]}px`,width:`${se.size[0]}px`,height:`${se.size[1]}px`,zIndex:h.STRATUM_ORDER[D]*1e3,transform:ja(se),opacity:R,pointerEvents:"none",userSelect:"none","--wov-held-by-color":H??void 0,transition:R===1?"opacity 0ms 32ms":void 0}}return(A,se)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:p,class:"wov-root",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},[t.background?d.renderSlot(A.$slots,"background",{key:0,background:t.background},()=>[d.createVNode(mk,{background:t.background},null,8,["background"])]):d.createCommentVNode("",!0),d.createElementVNode("div",{class:"wov-canvas",style:d.normalizeStyle({position:"absolute",transformOrigin:"0 0",transform:`scale(${I.value.zoom}) translate(${-I.value.left}px, ${-I.value.top}px)`,"--wov-zoom":I.value.zoom})},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(_.value,D=>(d.openBlock(),d.createElementBlock("div",{key:D.value.entityId,"data-entity-id":D.value.entityId,style:d.normalizeStyle(Gn(D.value)),"data-selected":D.value.selected||void 0,"data-held-by-other":xo(D.value)!==null||void 0,"data-hovered":D.value.hovered||void 0,class:"wov-block"},[d.renderSlot(A.$slots,`block:${D.value.block.tag}`,d.mergeProps({ref_for:!0},D.value),()=>[D.value.block.tag==="selection-box"?(d.openBlock(),d.createBlock(WP,d.mergeProps({key:0,ref_for:!0},D.value),null,16)):D.value.block.tag==="transform-box"?(d.openBlock(),d.createBlock(UP,d.mergeProps({key:1,ref_for:!0},D.value),null,16)):D.value.block.tag==="transform-handle"?(d.openBlock(),d.createBlock(GP,d.mergeProps({key:2,ref_for:!0},D.value),null,16)):D.value.block.tag==="arrow-handle"?(d.openBlock(),d.createBlock(wh,d.mergeProps({key:3,ref_for:!0},D.value),null,16)):D.value.block.tag==="arrow-terminal"?(d.openBlock(),d.createBlock(vh,d.mergeProps({key:4,ref_for:!0},D.value),null,16)):D.value.block.tag==="sticky-note"?(d.openBlock(),d.createBlock(YP,d.mergeProps({key:5,ref_for:!0},D.value),null,16)):D.value.block.tag==="eraser"?(d.openBlock(),d.createBlock(Pp,d.mergeProps({key:6,ref_for:!0},D.value),null,16)):D.value.block.tag==="pen-stroke"?(d.openBlock(),d.createBlock(Up,d.mergeProps({key:7,ref_for:!0},D.value),null,16)):D.value.block.tag==="arc-arrow"?(d.openBlock(),d.createBlock(kh,d.mergeProps({key:8,ref_for:!0},D.value),null,16)):D.value.block.tag==="elbow-arrow"?(d.openBlock(),d.createBlock(bh,d.mergeProps({key:9,ref_for:!0},D.value),null,16)):D.value.block.tag==="text"?(d.openBlock(),d.createBlock(R0,d.mergeProps({key:10,ref_for:!0},D.value),null,16)):D.value.block.tag==="image"?(d.openBlock(),d.createBlock(Rp,d.mergeProps({key:11,ref_for:!0},D.value),null,16)):D.value.block.tag==="shape"?(d.openBlock(),d.createBlock(P0,d.mergeProps({key:12,ref_for:!0},D.value),null,16)):d.createCommentVNode("",!0)])],12,mR))),128))],4),m.value?d.renderSlot(A.$slots,"user-cursors",{key:1,users:w.value,currentSessionId:d.unref(g).sessionId,camera:I.value},()=>[d.createVNode(cR,{users:w.value,"current-session-id":d.unref(g).sessionId,camera:I.value},null,8,["users","current-session-id","camera"])]):d.createCommentVNode("",!0),m.value?(d.openBlock(),d.createBlock(kk,{key:2},{default:d.withCtx(D=>[d.renderSlot(A.$slots,"floating-menu",d.normalizeProps(d.guardReactiveProps(D)))]),_:3})):d.createCommentVNode("",!0),m.value?d.renderSlot(A.$slots,"user-presence",{key:3,users:w.value},()=>[d.createVNode(Bk,{users:w.value},null,8,["users"])]):d.createCommentVNode("",!0),m.value?d.renderSlot(A.$slots,"toolbar",{key:4},()=>[d.createVNode(Nk)]):d.createCommentVNode("",!0),m.value?d.renderSlot(A.$slots,"default",{key:5}):d.createCommentVNode("",!0),d.renderSlot(A.$slots,"offline-indicator",{isOnline:x.value},()=>[d.createVNode(uR,{"is-online":x.value},null,8,["is-online"])]),d.renderSlot(A.$slots,"version-mismatch",{versionMismatch:T.value},()=>[d.createVNode(hR,{"version-mismatch":T.value},null,8,["version-mismatch"])]),d.renderSlot(A.$slots,"back-to-content",{},()=>[d.createVNode(pR)]),d.renderSlot(A.$slots,"loading",{isLoading:N.value},()=>[d.createVNode(wk,{"is-loading":N.value},null,8,["is-loading"])]),m.value?d.renderSlot(A.$slots,"file-drop-zone",{key:6},()=>[d.createVNode(oR)]):d.createCommentVNode("",!0)],512))}});Object.defineProperty(P,"CanvasComponentDef",{enumerable:!0,get:()=>at.CanvasComponentDef}),Object.defineProperty(P,"CanvasSingletonDef",{enumerable:!0,get:()=>at.CanvasSingletonDef}),Object.defineProperty(P,"CanvasStore",{enumerable:!0,get:()=>at.CanvasStore}),Object.defineProperty(P,"Synced",{enumerable:!0,get:()=>at.Synced}),Object.defineProperty(P,"defineCanvasComponent",{enumerable:!0,get:()=>at.defineCanvasComponent}),Object.defineProperty(P,"defineCanvasSingleton",{enumerable:!0,get:()=>at.defineCanvasSingleton}),P.ARROW_HEADS=Zl,P.ArcArrow=kh,P.ArcArrowTool=dP,P.ArrowHandle=wh,P.ArrowHead=sn,P.ArrowHeadButton=Ld,P.ArrowTerminal=vh,P.ArrowThicknessButton=ok,P.CURSORS=vk,P.CanvasBackground=mk,P.ColorButton=ak,P.ColorPicker=ik,P.CursorKind=Ir,P.EditableText=wa,P.EditingPlugin=Hk,P.ElbowArrow=bh,P.ElbowArrowTool=Mk,P.Eraser=Pp,P.EraserTool=_k,P.FloatingMenu=kk,P.FloatingMenuBar=yk,P.HandTool=Sk,P.IconChevronDown=St,P.ImageBlock=Rp,P.ImageTool=Ak,P.LoadingOverlay=wk,P.MenuButton=Co,P.MenuDropdown=bt,P.MenuTooltip=Fd,P.PenStroke=Up,P.PenStrokeThicknessButton=lk,P.PenTool=Ek,P.SHAPES=ss,P.SelectTool=bk,P.ShapeBlock=P0,P.ShapeFillColorButton=ck,P.ShapeKindButton=dk,P.ShapeStrokeColorButton=uk,P.ShapeTool=xk,P.StickyNoteTool=Ck,P.TextAlignmentButton=jd,P.TextBlock=R0,P.TextBoldButton=Hd,P.TextColorButton=qd,P.TextFontFamilyButton=Zd,P.TextFontSizeButton=Ud,P.TextItalicButton=Kd,P.TextTool=Tk,P.TextUnderlineButton=Jd,P.Toolbar=Nk,P.ToolbarButton=Qt,P.UserPresence=Bk,P.WovenCanvas=gR,P.computeCommonComponents=gk,P.createTooltipContext=I0,P.getArrowHead=no,P.useComponent=Pe,P.useComponents=Wn,P.useEditorContext=Ee,P.useFonts=hk,P.useQuery=_0,P.useSingleton=Ze,P.useTextBatchController=O0,P.useTextEditorController=Bs,P.useTextFormatting=qt,P.useTextStretchBehavior=Bd,P.useToolbar=Od,P.useTooltipSingleton=Un,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@woven-canvas/vue",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Vue 3 components for woven-canvas infinite canvas",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,30 +52,27 @@
|
|
|
52
52
|
"@tiptap/vue-3": "^3.15.3",
|
|
53
53
|
"@vueuse/core": "^14.0.0",
|
|
54
54
|
"perfect-freehand": "^1.2.2",
|
|
55
|
-
"@woven-canvas/asset-sync": "^0.1.1"
|
|
56
|
-
"@woven-canvas/plugin-arrows": "^0.1.2",
|
|
57
|
-
"@woven-canvas/plugin-canvas-controls": "^0.1.2",
|
|
58
|
-
"@woven-canvas/plugin-eraser": "^0.1.2",
|
|
59
|
-
"@woven-canvas/plugin-pen": "^0.1.2",
|
|
60
|
-
"@woven-canvas/plugin-selection": "^0.1.3"
|
|
55
|
+
"@woven-canvas/asset-sync": "^0.1.1"
|
|
61
56
|
},
|
|
62
57
|
"devDependencies": {
|
|
63
58
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
64
59
|
"@vue/test-utils": "^2.4.6",
|
|
65
|
-
"@woven-ecs/canvas-store": "^1.0.5",
|
|
66
|
-
"typescript": "^5.9.3",
|
|
67
60
|
"vite": "^5.4.21",
|
|
68
61
|
"vitest": "^4.0.7",
|
|
69
|
-
"vue-tsc": "^2.2.12"
|
|
70
|
-
"@woven-canvas/math": "^0.1.0"
|
|
62
|
+
"vue-tsc": "^2.2.12"
|
|
71
63
|
},
|
|
72
64
|
"peerDependencies": {
|
|
73
65
|
"@woven-ecs/canvas-store": "^1.0.5",
|
|
74
66
|
"@woven-ecs/core": "^1.0.4",
|
|
75
67
|
"typescript": "^5",
|
|
76
68
|
"vue": "^3",
|
|
69
|
+
"@woven-canvas/core": "^0.1.4",
|
|
70
|
+
"@woven-canvas/plugin-eraser": "^0.1.2",
|
|
71
|
+
"@woven-canvas/plugin-arrows": "^0.1.2",
|
|
77
72
|
"@woven-canvas/math": "^0.1.0",
|
|
78
|
-
"@woven-canvas/
|
|
73
|
+
"@woven-canvas/plugin-pen": "^0.1.2",
|
|
74
|
+
"@woven-canvas/plugin-canvas-controls": "^0.1.2",
|
|
75
|
+
"@woven-canvas/plugin-selection": "^0.1.3"
|
|
79
76
|
},
|
|
80
77
|
"scripts": {
|
|
81
78
|
"dev": "vite",
|