@woven-canvas/vue 1.0.5 → 1.0.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"EmbedTool.vue.d.ts","sourceRoot":"","sources":["../../../src/components/tools/EmbedTool.vue"],"names":[],"mappings":";AAkpCA,wBAKG"}
1
+ {"version":3,"file":"EmbedTool.vue.d.ts","sourceRoot":"","sources":["../../../src/components/tools/EmbedTool.vue"],"names":[],"mappings":";AAmoCA,wBAKG"}
package/build/index.js CHANGED
@@ -22007,12 +22007,10 @@ const xS = /* @__PURE__ */ U({
22007
22007
  "stroke-linejoin": "round"
22008
22008
  }, eC = {
22009
22009
  key: 7,
22010
- viewBox: "0 0 24 24",
22011
- fill: "none",
22012
- stroke: "currentColor",
22013
- "stroke-width": "1.5",
22014
- "stroke-linecap": "round",
22015
- "stroke-linejoin": "round"
22010
+ xmlns: "http://www.w3.org/2000/svg",
22011
+ width: "24",
22012
+ height: "24",
22013
+ viewBox: "0 0 24 24"
22016
22014
  }, tC = { class: "wov-embed-provider-label" }, nC = { class: "wov-embed-panel-header" }, rC = { class: "wov-embed-url-form" }, oC = ["placeholder"], sC = {
22017
22015
  key: 0,
22018
22016
  class: "wov-embed-url-error"
@@ -22307,13 +22305,9 @@ const xS = /* @__PURE__ */ U({
22307
22305
  b("polyline", { points: "16 18 22 12 16 6" }, null, -1),
22308
22306
  b("polyline", { points: "8 6 2 12 8 18" }, null, -1)
22309
22307
  ])])) : B.icon === "tldraw" ? (x(), A("svg", eC, [...E[9] || (E[9] = [
22310
- b("path", { d: "M12 19l7-7 3 3-7 7-3-3z" }, null, -1),
22311
- b("path", { d: "m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z" }, null, -1),
22312
- b("path", { d: "m2 2 7.586 7.586" }, null, -1),
22313
- b("circle", {
22314
- cx: "11",
22315
- cy: "11",
22316
- r: "2"
22308
+ b("path", {
22309
+ fill: "currentColor",
22310
+ d: "M21.474 0H2.526C1.131 0 0 1.18 0 2.637v18.726C0 22.819 1.131 24 2.526 24h18.948C22.869 24 24 22.82 24 21.363V2.637C24 1.181 22.869 0 21.474 0m-11.01 5.388q.595-.607 1.474-.607q.854 0 1.448.607q.595.606.595 1.476c0 .87-.198 1.072-.595 1.476a1.95 1.95 0 0 1-1.448.607q-.879 0-1.474-.607q-.594-.606-.594-1.476c0-.87.198-1.072.594-1.476m3.13 11.49a4.9 4.9 0 0 1-2.018 2.136q-.724.422-1.19-.026q-.438-.422.26-1.002q.387-.29.646-.738q.258-.449.336-.923q.026-.21-.181-.21q-.517-.027-1.06-.581t-.543-1.37q0-.87.594-1.477a2.02 2.02 0 0 1 1.5-.633q.828 0 1.448.633q.62.605.724 1.37q.207 1.424-.517 2.822z"
22317
22311
  }, null, -1)
22318
22312
  ])])) : F("", !0)
22319
22313
  ]),
@@ -103,5 +103,5 @@ ${y}
103
103
  `,Lk="️",Vk="‍",pl="";let is=null,ls=null;function $k(n=[]){const e={};Fe.groups=e;const t=new Fe;is==null&&(is=af(Ik)),ls==null&&(ls=af(Ok)),O(t,"'",qr),O(t,"{",Ro),O(t,"}",Po),O(t,"[",Or),O(t,"]",Rr),O(t,"(",Pr),O(t,")",Dr),O(t,"<",_r),O(t,">",Lr),O(t,"(",Vr),O(t,")",$r),O(t,"「",zr),O(t,"」",Fr),O(t,"『",Hr),O(t,"』",Ur),O(t,"<",jr),O(t,">",Wr),O(t,"&",Kr),O(t,"*",Gr),O(t,"@",Qt),O(t,"`",Yr),O(t,"^",Xr),O(t,":",Zt),O(t,",",ll),O(t,"$",Qr),O(t,".",ht),O(t,"=",Zr),O(t,"!",al),O(t,"-",Qe),O(t,"%",Do),O(t,"|",es),O(t,"+",ts),O(t,"#",ns),O(t,"?",_o),O(t,'"',cl),O(t,"/",pt),O(t,";",dl),O(t,"~",Lo),O(t,"_",rs),O(t,"\\",Jr),O(t,"・",nf);const o=fe(t,Ot,rl,{[Yi]:!0});fe(o,Ot,o);const r=fe(o,It,ef,{[Bo]:!0}),s=fe(o,Vo,tf,{[Io]:!0}),i=fe(t,It,Bt,{[Xi]:!0});fe(i,Ot,r),fe(i,It,i),fe(r,Ot,r),fe(r,It,r);const l=fe(t,Vo,tl,{[Qi]:!0});fe(l,It),fe(l,Ot,s),fe(l,Vo,l),fe(s,Ot,s),fe(s,It),fe(s,Vo,s);const c=O(t,hl,il,{[el]:!0}),d=O(t,sf,sl,{[el]:!0}),u=fe(t,fl,sl,{[el]:!0});O(t,pl,u),O(d,hl,c),O(d,pl,u),fe(d,fl,u),O(u,sf),O(u,hl),fe(u,fl,u),O(u,pl,u);const f=fe(t,ul,of,{[Qu]:!0});O(f,"#"),fe(f,ul,f),O(f,Lk,f);const h=O(f,Vk);O(h,"#"),fe(h,ul,f);const p=[[It,i],[Ot,r]],m=[[It,null],[Vo,l],[Ot,s]];for(let g=0;g<is.length;g++)en(t,is[g],nl,Bt,p);for(let g=0;g<ls.length;g++)en(t,ls[g],ol,tl,m);Sn(nl,{tld:!0,ascii:!0},e),Sn(ol,{utld:!0,alpha:!0},e),en(t,"file",Ir,Bt,p),en(t,"mailto",Ir,Bt,p),en(t,"http",Gn,Bt,p),en(t,"https",Gn,Bt,p),en(t,"ftp",Gn,Bt,p),en(t,"ftps",Gn,Bt,p),Sn(Ir,{scheme:!0,ascii:!0},e),Sn(Gn,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],w=n[g][1]?{[Rk]:!0}:{[Pk]:!0};y.indexOf("-")>=0?w[Zi]=!0:It.test(y)?Ot.test(y)?w[Bo]=!0:w[Xi]=!0:w[Yi]=!0,Zu(t,y,y,w)}return Zu(t,"localhost",Oo,{ascii:!0}),t.jd=new Fe(ss),{start:t,tokens:Object.assign({groups:e},rf)}}function lf(n,e){const t=zk(e.replace(/[A-Z]/g,l=>l.toLowerCase())),o=t.length,r=[];let s=0,i=0;for(;i<o;){let l=n,c=null,d=0,u=null,f=-1,h=-1;for(;i<o&&(c=l.go(t[i]));)l=c,l.accepts()?(f=0,h=0,u=l):f>=0&&(f+=t[i].length,h++),d+=t[i].length,s+=t[i].length,i++;s-=f,i-=h,d-=f,r.push({t:u.t,v:e.slice(s-d,s),s:s-d,e:s})}return r}function zk(n){const e=[],t=n.length;let o=0;for(;o<t;){let r=n.charCodeAt(o),s,i=r<55296||r>56319||o+1===t||(s=n.charCodeAt(o+1))<56320||s>57343?n[o]:n.slice(o,o+2);e.push(i),o+=i.length}return e}function en(n,e,t,o,r){let s;const i=e.length;for(let l=0;l<i-1;l++){const c=e[l];n.j[c]?s=n.j[c]:(s=new Fe(o),s.jr=r.slice(),n.j[c]=s),n=s}return s=new Fe(t),s.jr=r.slice(),n.j[e[i-1]]=s,s}function af(n){const e=[],t=[];let o=0,r="0123456789";for(;o<n.length;){let s=0;for(;r.indexOf(n[o+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let i=parseInt(n.substring(o,o+s),10);i>0;i--)t.pop();o+=s}else t.push(n[o]),o++}return e}const $o={defaultProtocol:"http",events:null,format:cf,formatHref:cf,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ml(n,e=null){let t=Object.assign({},$o);n&&(t=Object.assign(t,n instanceof ml?n.o:n));const o=t.ignoreTags,r=[];for(let s=0;s<o.length;s++)r.push(o[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=r}ml.prototype={o:$o,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const o=e!=null;let r=this.o[n];return r&&(typeof r=="object"?(r=t.t in r?r[t.t]:$o[n],typeof r=="function"&&o&&(r=r(e,t))):typeof r=="function"&&o&&(r=r(e,t.t,t)),r)},getObj(n,e,t){let o=this.o[n];return typeof o=="function"&&e!=null&&(o=o(e,t.t,t)),o},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function cf(n){return n}function df(n,e){this.t="token",this.v=n,this.tk=e}df.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),o=n.get("format",e,this);return t&&o.length>t?o.substring(0,t)+"…":o},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=$o.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),o=n.get("formatHref",t,this),r=n.get("tagName",t,e),s=this.toFormattedString(n),i={},l=n.get("className",t,e),c=n.get("target",t,e),d=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return i.href=o,l&&(i.class=l),c&&(i.target=c),d&&(i.rel=d),u&&Object.assign(i,u),{tagName:r,attributes:i,content:s,eventListeners:f}}};function as(n,e){class t extends df{constructor(r,s){super(r,s),this.t=n}}for(const o in e)t.prototype[o]=e[o];return t.t=n,t}const uf=as("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ff=as("text"),Fk=as("nl"),cs=as("url",{isLink:!0,toHref(n=$o.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Oo&&n[1].t===Zt}}),Ze=n=>new Fe(n);function Hk({groups:n}){const e=n.domain.concat([Kr,Gr,Qt,Jr,Yr,Xr,Qr,Zr,Qe,rl,Do,es,ts,ns,pt,ss,Lo,rs]),t=[qr,Zt,ll,ht,al,Do,_o,cl,dl,_r,Lr,Ro,Po,Rr,Or,Pr,Dr,Vr,$r,zr,Fr,Hr,Ur,jr,Wr],o=[Kr,qr,Gr,Jr,Yr,Xr,Qr,Zr,Qe,Ro,Po,Do,es,ts,ns,_o,pt,ss,Lo,rs],r=Ze(),s=O(r,Lo);J(s,o,s),J(s,n.domain,s);const i=Ze(),l=Ze(),c=Ze();J(r,n.domain,i),J(r,n.scheme,l),J(r,n.slashscheme,c),J(i,o,s),J(i,n.domain,i);const d=O(i,Qt);O(s,Qt,d),O(l,Qt,d),O(c,Qt,d);const u=O(s,ht);J(u,o,s),J(u,n.domain,s);const f=Ze();J(d,n.domain,f),J(f,n.domain,f);const h=O(f,ht);J(h,n.domain,f);const p=Ze(uf);J(h,n.tld,p),J(h,n.utld,p),O(d,Oo,p);const m=O(f,Qe);O(m,Qe,m),J(m,n.domain,f),J(p,n.domain,f),O(p,ht,h),O(p,Qe,m);const g=O(p,Zt);J(g,n.numeric,uf);const y=O(i,Qe),k=O(i,ht);O(y,Qe,y),J(y,n.domain,i),J(k,o,s),J(k,n.domain,i);const w=Ze(cs);J(k,n.tld,w),J(k,n.utld,w),J(w,n.domain,i),J(w,o,s),O(w,ht,k),O(w,Qe,y),O(w,Qt,d);const C=O(w,Zt),x=Ze(cs);J(C,n.numeric,x);const S=Ze(cs),M=Ze();J(S,e,S),J(S,t,M),J(M,e,S),J(M,t,M),O(w,pt,S),O(x,pt,S);const E=O(l,Zt),v=O(c,Zt),T=O(v,pt),D=O(T,pt);J(l,n.domain,i),O(l,ht,k),O(l,Qe,y),J(c,n.domain,i),O(c,ht,k),O(c,Qe,y),J(E,n.domain,S),O(E,pt,S),O(E,_o,S),J(D,n.domain,S),J(D,e,S),O(D,pt,S);const P=[[Ro,Po],[Or,Rr],[Pr,Dr],[_r,Lr],[Vr,$r],[zr,Fr],[Hr,Ur],[jr,Wr]];for(let R=0;R<P.length;R++){const[_,z]=P[R],H=O(S,_);O(M,_,H),O(H,z,S);const Z=Ze(cs);J(H,e,Z);const K=Ze();J(H,t),J(Z,e,Z),J(Z,t,K),J(K,e,Z),J(K,t,K),O(Z,z,S),O(K,z,S)}return O(r,Oo,w),O(r,il,Fk),{start:r,tokens:rf}}function Uk(n,e,t){let o=t.length,r=0,s=[],i=[];for(;r<o;){let l=n,c=null,d=null,u=0,f=null,h=-1;for(;r<o&&!(c=l.go(t[r].t));)i.push(t[r++]);for(;r<o&&(d=c||l.go(t[r].t));)c=null,l=d,l.accepts()?(h=0,f=l):h>=0&&h++,r++,u++;if(h<0)r-=u,r<o&&(i.push(t[r]),r++);else{i.length>0&&(s.push(gl(ff,e,i)),i=[]),r-=h,u-=h;const p=f.t,m=t.slice(r-u,r);s.push(gl(p,e,m))}}return i.length>0&&s.push(gl(ff,e,i)),s}function gl(n,e,t){const o=t[0].s,r=t[t.length-1].e,s=e.slice(o,r);return new n(s,t)}const jk=typeof console<"u"&&console&&console.warn||(()=>{}),Wk="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ie={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Kk(){return Fe.groups={},ie.scanner=null,ie.parser=null,ie.tokenQueue=[],ie.pluginQueue=[],ie.customSchemes=[],ie.initialized=!1,ie}function hf(n,e=!1){if(ie.initialized&&jk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Wk}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
104
104
  1. Must only contain digits, lowercase ASCII letters or "-"
105
105
  2. Cannot start or end with "-"
106
- 3. "-" cannot repeat`);ie.customSchemes.push([n,e])}function qk(){ie.scanner=$k(ie.customSchemes);for(let n=0;n<ie.tokenQueue.length;n++)ie.tokenQueue[n][1]({scanner:ie.scanner});ie.parser=Hk(ie.scanner.tokens);for(let n=0;n<ie.pluginQueue.length;n++)ie.pluginQueue[n][1]({scanner:ie.scanner,parser:ie.parser});return ie.initialized=!0,ie}function yl(n){return ie.initialized||qk(),Uk(ie.parser.start,n,lf(ie.scanner.start,n))}yl.scan=lf;function pf(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const o=new ml(t),r=yl(n),s=[];for(let i=0;i<r.length;i++){const l=r[i];l.isLink&&(!e||l.t===e)&&o.check(l)&&s.push(l.toFormattedObject(o))}return s}var kl="[\0-   ᠎ -\u2029  ]",Gk=new RegExp(kl),Jk=new RegExp(`${kl}$`),Yk=new RegExp(kl,"g");function Xk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Qk(n){return new ue({key:new we("autolink"),appendTransaction:(e,t,o)=>{const r=e.some(d=>d.docChanged)&&!t.doc.eq(o.doc),s=e.some(d=>d.getMeta("preventAutolink"));if(!r||s)return;const{tr:i}=o,l=mu(t.doc,[...e]);if(Mu(l).forEach(({newRange:d})=>{const u=ay(o.doc,d,p=>p.isTextblock);let f,h;if(u.length>1)f=u[0],h=o.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const p=o.doc.textBetween(d.from,d.to," "," ");if(!Jk.test(p))return;f=u[0],h=o.doc.textBetween(f.pos,d.to,void 0," ")}if(f&&h){const p=h.split(Gk).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],g=f.pos+h.lastIndexOf(m);if(!m)return!1;const y=yl(m).map(k=>k.toObject(n.defaultProtocol));if(!Xk(y))return!1;y.filter(k=>k.isLink).map(k=>({...k,from:g+k.start+1,to:g+k.end+1})).filter(k=>o.schema.marks.code?!o.doc.rangeHasMark(k.from,k.to,o.schema.marks.code):!0).filter(k=>n.validate(k.value)).filter(k=>n.shouldAutoLink(k.value)).forEach(k=>{Hi(k.from,k.to,o.doc).some(w=>w.mark.type===n.type)||i.addMark(k.from,k.to,n.type.create({href:k.href}))})}}),!!i.steps.length)return i}})}function Zk(n){return new ue({key:new we("handleClickLink"),props:{handleClick:(e,t,o)=>{var r,s;if(o.button!==0||!e.editable)return!1;let i=null;if(o.target instanceof HTMLAnchorElement)i=o.target;else{const c=o.target;if(!c)return!1;const d=n.editor.view.dom;i=c.closest("a"),i&&!d.contains(i)&&(i=null)}if(!i)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const c=vu(e.state,n.type.name),d=(r=i.href)!=null?r:c.href,u=(s=i.target)!=null?s:c.target;d&&(window.open(d,u),l=!0)}return l}}})}function ew(n){return new ue({key:new we("handlePasteLink"),props:{handlePaste:(e,t,o)=>{const{shouldAutoLink:r}=n,{state:s}=e,{selection:i}=s,{empty:l}=i;if(l)return!1;let c="";o.content.forEach(u=>{c+=u.textContent});const d=pf(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||r!==void 0&&!r(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function En(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(o=>{const r=typeof o=="string"?o:o.scheme;r&&t.push(r)}),!n||n.replace(Yk,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var tw=qn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){hf(n);return}hf(n.scheme,n.optionalSlashes)})},onDestroy(){Kk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!En(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const r=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!En(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!En(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Xt(this.options.HTMLAttributes,n),0]:["a",Xt(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,o,r,s;const i=(o=(t=n.attrs)==null?void 0:t.href)!=null?o:"",l=(s=(r=n.attrs)==null?void 0:r.title)!=null?s:"",c=e.renderChildren(n);return l?`[${c}](${i} "${l}")`:`[${c}](${i})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:o=>!!En(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:o=>!!En(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ao({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:o}=this.options,r=pf(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!En(i,t),protocols:t,defaultProtocol:o}));r.length&&r.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Qk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:o=>this.options.isAllowedUri(o,{defaultValidate:r=>!!En(r,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Zk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(ew({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),mf=tw,nw=se.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),gf=nw,ow=20,yf=(n,e=0)=>{const t=[];return!n.children.length||e>ow||Array.from(n.children).forEach(o=>{o.tagName==="SPAN"?t.push(o):o.children.length&&t.push(...yf(o,e+1))}),t},rw=n=>{if(!n.children.length)return;const e=yf(n);e&&e.forEach(t=>{var o,r;const s=t.getAttribute("style"),i=(r=(o=t.parentElement)==null?void 0:o.closest("span"))==null?void 0:r.getAttribute("style");t.setAttribute("style",`${i};${s}`)})},wl=qn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&rw(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",Xt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,o)=>{if(t.isTextblock)return!0;t.marks.filter(r=>r.type===this.type).some(r=>Object.values(r.attrs).some(s=>!!s))||n.removeMark(o,o+t.nodeSize,this.type)}),!0}}}}),sw=se.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="background-color")return l.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),kf=se.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="color")return l.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),iw=se.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),lw=se.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),aw=se.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});se.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(sw.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push(kf.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(iw.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(lw.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(aw.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(wl.configure(this.options.textStyle)),n}});var wf=kf;function cw(n={}){return new ue({view(e){return new dw(e,n)}})}class dw{constructor(e,t){var o;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(o=t.width)!==null&&o!==void 0?o:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let s=i=>{this[r](i)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,o,r=this.editorView.dom,s=r.getBoundingClientRect(),i=s.width/r.offsetWidth,l=s.height/r.offsetHeight;if(t){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=f?m.bottom:m.top;f&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;o={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!o){let f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;o={left:f.left-h,right:f.left+h,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),h=f.width/c.offsetWidth,p=f.height/c.offsetHeight;d=f.left-c.scrollLeft*h,u=f.top-c.scrollTop*p}this.element.style.left=(o.left-d)/i+"px",this.element.style.top=(o.top-u)/l+"px",this.element.style.width=(o.right-o.left)/i+"px",this.element.style.height=(o.bottom-o.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),o=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=o&&o.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=yc(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class he extends Y{constructor(e){super(e,e)}map(e,t){let o=e.resolve(t.map(this.head));return he.valid(o)?new he(o):Y.near(o)}content(){return $.empty}eq(e){return e instanceof he&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new he(e.resolve(t.pos))}getBookmark(){return new bl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!uw(e)||!fw(e))return!1;let o=t.type.spec.allowGapCursor;if(o!=null)return o;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,o=!1){e:for(;;){if(!o&&he.valid(e))return e;let r=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;r+=t;let c=e.doc.resolve(r);if(he.valid(c))return c}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!q.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),o=!1;continue e}break}s=i,r+=t;let l=e.doc.resolve(r);if(he.valid(l))return l}return null}}}he.prototype.visible=!1,he.findFrom=he.findGapCursorFrom,Y.jsonID("gapcursor",he);class bl{constructor(e){this.pos=e}map(e){return new bl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return he.valid(t)?new he(t):Y.near(t)}}function bf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function uw(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),o=n.node(e);if(t==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||bf(r.type))return!0;if(r.inlineContent)return!1}}return!0}function fw(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),o=n.node(e);if(t==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||bf(r.type))return!0;if(r.inlineContent)return!1}}return!0}function hw(){return new ue({props:{decorations:yw,createSelectionBetween(n,e,t){return e.pos==t.pos&&he.valid(t)?new he(t):null},handleClick:mw,handleKeyDown:pw,handleDOMEvents:{beforeinput:gw}}})}const pw=ru({ArrowLeft:ds("horiz",-1),ArrowRight:ds("horiz",1),ArrowUp:ds("vert",-1),ArrowDown:ds("vert",1)});function ds(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,s){let i=o.selection,l=e>0?i.$to:i.$from,c=i.empty;if(i instanceof G){if(!s.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=o.doc.resolve(e>0?l.after():l.before())}let d=he.findGapCursorFrom(l,e,c);return d?(r&&r(o.tr.setSelection(new he(d))),!0):!1}}function mw(n,e,t){if(!n||!n.editable)return!1;let o=n.state.doc.resolve(e);if(!he.valid(o))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&q.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new he(o))),!0)}function gw(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof he))return!1;let{$from:t}=n.state.selection,o=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!o)return!1;let r=B.empty;for(let i=o.length-1;i>=0;i--)r=B.from(o[i].createAndFill(null,r));let s=n.state.tr.replace(t.pos,t.pos,new $(r,0,0));return s.setSelection(G.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function yw(n){if(!(n.selection instanceof he))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}var us=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<us&&this.leafAppend(e)||this.length<us&&e.leafPrepend(this)||this.appendInner(e)):this},Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this},Ce.prototype.appendInner=function(e){return new kw(this,e)},Ce.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ce.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},Ce.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var r=[];return this.forEach(function(s,i){return r.push(e(s,i))},t,o),r},Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new Cf(e):Ce.empty};var Cf=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,i,l){for(var c=s;c<i;c++)if(r(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,l){for(var c=s-1;c>=i;c--)if(r(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=us)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=us)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Ce);Ce.empty=new Cf([]);var kw=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,r,s,i){var l=this.left.length;if(r<l&&this.left.forEachInner(o,r,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(o,Math.max(r-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,r,s,i){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(o,r-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(o,Math.min(r,l),s,i)===!1)return!1},e.prototype.sliceInner=function(o,r){if(o==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(o,r):o>=s?this.right.slice(o-s,r-s):this.left.slice(o,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(o){var r=this.right.leafAppend(o);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(o){var r=this.left.leafPrepend(o);if(r)return new e(r,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Ce);const ww=500;class ot{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let r,s;t&&(r=this.remapping(o,this.items.length),s=r.maps.length);let i=e.tr,l,c,d=[],u=[];return this.items.forEach((f,h)=>{if(!f.step){r||(r=this.remapping(o,h+1),s=r.maps.length),s--,u.push(f);return}if(r){u.push(new mt(f.map));let p=f.step.map(r.slice(s)),m;p&&i.maybeStep(p).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],d.push(new mt(m,void 0,void 0,d.length+u.length))),s--,m&&r.appendMap(m,s)}else i.maybeStep(f.step);if(f.selection)return l=r?f.selection.map(r.slice(s)):f.selection,c=new ot(this.items.slice(0,o).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:i,selection:l}}addTransform(e,t,o,r){let s=[],i=this.eventCount,l=this.items,c=!r&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),h=new mt(e.mapping.maps[u],f,t),p;(p=c&&c.merge(h))&&(h=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(h),t&&(i++,t=void 0),r||(c=h)}let d=i-o.depth;return d>Cw&&(l=bw(l,d),i-=d),new ot(l.append(s),i)}remapping(e,t){let o=new co;return this.items.forEach((r,s)=>{let i=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?o.maps.length-r.mirrorOffset:void 0;o.appendMap(r.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new ot(this.items.append(e.map(t=>new mt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],r=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},r);let c=t;this.items.forEach(h=>{let p=s.getMirror(--c);if(p==null)return;i=Math.min(i,p);let m=s.maps[p];if(h.step){let g=e.steps[p].invert(e.docs[p]),y=h.selection&&h.selection.map(s.slice(c+1,p));y&&l++,o.push(new mt(m,g,y))}else o.push(new mt(m))},r);let d=[];for(let h=t;h<i;h++)d.push(new mt(s.maps[h]));let u=this.items.slice(0,r).append(d).append(o),f=new ot(u,l);return f.emptyItemCount()>ww&&(f=f.compress(this.items.length-o.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,r=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)r.push(i),i.selection&&s++;else if(i.step){let c=i.step.map(t.slice(o)),d=c&&c.getMap();if(o--,d&&t.appendMap(d,o),c){let u=i.selection&&i.selection.map(t.slice(o));u&&s++;let f=new mt(d.invert(),c,u),h,p=r.length-1;(h=r.length&&r[p].merge(f))?r[p]=h:r.push(f)}}else i.map&&o--},this.items.length,0),new ot(Ce.from(r.reverse()),s)}}ot.empty=new ot(Ce.empty,0);function bw(n,e){let t;return n.forEach((o,r)=>{if(o.selection&&e--==0)return t=r,!1}),n.slice(t)}class mt{constructor(e,t,o,r){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new mt(t.getMap().invert(),t,this.selection)}}}class tn{constructor(e,t,o,r,s){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=r,this.prevComposition=s}}const Cw=20;function xw(n,e,t,o){let r=t.getMeta(vn),s;if(r)return r.historyState;t.getMeta(vw)&&(n=new tn(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(vn))return i.getMeta(vn).redo?new tn(n.done.addTransform(t,void 0,o,fs(e)),n.undone,xf(t.mapping.maps),n.prevTime,n.prevComposition):new tn(n.done,n.undone.addTransform(t,void 0,o,fs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Sw(t,n.prevRanges)),d=i?Cl(n.prevRanges,t.mapping):xf(t.mapping.maps);return new tn(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,fs(e)),ot.empty,d,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new tn(n.done.rebased(t,s),n.undone.rebased(t,s),Cl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new tn(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Cl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Sw(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,r)=>{for(let s=0;s<e.length;s+=2)o<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function xf(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,r,s,i)=>e.push(s,i));return e}function Cl(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let r=e.map(n[o],1),s=e.map(n[o+1],-1);r<=s&&t.push(r,s)}return t}function Ew(n,e,t){let o=fs(e),r=vn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,o);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,o),c=new tn(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(vn,{redo:t,historyState:c})}let xl=!1,Sf=null;function fs(n){let e=n.plugins;if(Sf!=e){xl=!1,Sf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){xl=!0;break}}return xl}const vn=new we("history"),vw=new we("closeHistory");function Mw(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ue({key:vn,state:{init(){return new tn(ot.empty,ot.empty,null,0,-1)},apply(e,t,o){return xw(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,r=o=="historyUndo"?vf:o=="historyRedo"?Mf:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ef(n,e){return(t,o)=>{let r=vn.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(o){let s=Ew(r,t,n);s&&o(e?s.scrollIntoView():s)}return!0}}const vf=Ef(!1,!0),Mf=Ef(!0,!0);se.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const o=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(o)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new ue({key:new we("characterCount"),appendTransaction:(e,t,o)=>{if(n)return;const r=this.options.limit;if(r==null||r===0){n=!0;return}const s=this.storage.characters({node:o.doc});if(s>r){const i=s-r,l=0,c=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const d=o.tr.deleteRange(l,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const o=this.options.limit;if(!e.docChanged||o===0||o===null||o===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=o||r>o&&s>o&&s<=r)return!0;if(r>o&&s>o&&s>r||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-o,d=l-c,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>o)}})]}}),se.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[cw(this.options)]}}),se.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ue({key:new we("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:o}=this.editor,{anchor:r}=e,s=[];if(!t||!o)return ae.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(c.isText)return;if(!(r>=d&&r<=d+c.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((c,d)=>{if(c.isText||!(r>=d&&r<=d+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Ve.node(d,d+c.nodeSize,{class:this.options.className}))}),ae.create(n,s)}}})]}}),se.create({name:"gapCursor",addProseMirrorPlugins(){return[hw()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=re(j(n,"allowGapCursor",t)))!=null?e:null}}});var Tf="placeholder";function Tw(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}se.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Tf,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${Tw(this.options.dataAttribute)}`:`data-${Tf}`;return[new ue({key:new we("placeholder"),props:{decorations:({doc:e,selection:t})=>{const o=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!o)return null;const i=this.editor.isEmpty;return e.descendants((l,c)=>{const d=r>=c&&r<=c+l.nodeSize,u=!l.isLeaf&&vr(l);if((d||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const h=Ve.node(c,c+l.nodeSize,{class:f.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:d}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),ae.create(e,s)}}})]}}),se.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new ue({key:new we("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||wy(t.selection)||n.view.dragging?null:ae.create(t.doc,[Ve.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Nf({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}se.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new we(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",o=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(t).includes(r.name));return[new ue({key:e,appendTransaction:(r,s,i)=>{const{doc:l,tr:c,schema:d}=i,u=e.getState(i),f=l.content.size,h=d.nodes[t];if(u)return c.insert(f,h.create())},state:{init:(r,s)=>{const i=s.tr.doc.lastChild;return!Nf({node:i,types:o})},apply:(r,s)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return s;const i=r.doc.lastChild;return!Nf({node:i,types:o})}}})]}});var Nw=se.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>vf(n,e),redo:()=>({state:n,dispatch:e})=>Mf(n,e)}},addProseMirrorPlugins(){return[Mw(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 Rt(n,e){const t=a.inject(He);if(!t)throw new Error("useComponents must be used within a WovenCanvas component");const o=a.shallowRef(new Map),r=new Map;function s(l){if(r.has(l))return;const c=t.getEditor();if(c){const u=c._getContext();if(b.hasComponent(u,l,e)){const f=new Map(o.value);f.set(l,e.snapshot(u,l)),o.value=f}else{const f=new Map(o.value);f.set(l,null),o.value=f}}const d=t.subscribeComponent(l,e.name,u=>{const f=new Map(o.value);f.set(l,u),o.value=f});r.set(l,d)}function i(l){const c=r.get(l);if(c){c(),r.delete(l);const d=new Map(o.value);d.delete(l),o.value=d}}return a.watch(()=>a.toValue(n),(l,c)=>{const d=new Set(l),u=new Set(c??[]);for(const f of u)d.has(f)||i(f);for(const f of d)u.has(f)||s(f)},{immediate:!0}),a.onUnmounted(()=>{for(const l of r.values())l();r.clear()}),o}function Af(){const n=a.inject(He);if(!n)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=de();function t(s){return new Promise((i,l)=>{const c=new window.Image;c.onload=()=>{i({width:c.naturalWidth,height:c.naturalHeight}),URL.revokeObjectURL(c.src)},c.onerror=()=>{l(new Error("Failed to load image")),URL.revokeObjectURL(c.src)},c.src=URL.createObjectURL(s)})}async function o(s,i,l,c={}){const{maxSize:d=400}=c,u=await t(s),f=await e(),h=Math.min(1,d/Math.max(u.width,u.height));let p=Math.round(u.width*h),m=Math.round(u.height*h);const g=b.Grid.read(f);g.enabled&&(p=Math.max(g.colWidth,Math.round(p/g.colWidth)*g.colWidth),m=Math.max(g.rowHeight,Math.round(m/g.rowHeight)*g.rowHeight));const y=b.createEntity(f);b.addComponent(f,y,b.Block);const k=b.Block.write(f,y);k.tag="image",k.position[0]=i-p/2,k.position[1]=l-m/2,k.size[0]=p,k.size[1]=m,b.Grid.snapPosition(f,k.position);const w=crypto.randomUUID();b.addComponent(f,y,b.Asset);const C=b.Asset.write(f,y);C.identifier=w,C.uploadState=b.UploadState.Pending,b.addComponent(f,y,b.Image);const x=b.Image.write(f,y);return x.width=u.width,x.height=u.height,x.alt=s.name,b.addComponent(f,y,$e.Synced,{id:crypto.randomUUID()}),(n==null?void 0:n.getAssetManager())&&r(y,w,s),y}async function r(s,i,l){const c=n==null?void 0:n.getAssetManager();if(c)try{await c.upload(i,l,{filename:l.name,mimeType:l.type});const d=await e(),u=b.Asset.write(d,s);u.uploadState=b.UploadState.Complete}catch{const d=await e(),u=b.Asset.write(d,s);u.uploadState=b.UploadState.Failed}}return{getImageDimensions:t,createImageBlock:o}}function Bf(n){const e=a.inject(He);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const t=a.shallowRef([]),o=b.defineQuery(f=>f.with(...n)),r=new Map;let s=!1;function i(f){const h=e.getEditor();if(!h)return{refs:{},unsubscribes:[]};const p=h._getContext(),m={},g=[];for(const y of n){const k=a.shallowRef(y.snapshot(p,f));m[y.name]=k;const w=e.subscribeComponent(f,y.name,C=>{k.value=C});g.push(w)}return{refs:m,unsubscribes:g}}function l(f){const h=r.get(f);if(h){for(const p of h.unsubscribes)p();r.delete(f)}}function c(){const f=[];for(const[h,p]of r)f.push({entityId:h,...p.refs});return f}function d(f){if(!s){const g=o.current(f);for(const y of g)r.set(y,i(y));t.value=c(),s=!0;return}const h=o.added(f),p=o.removed(f);let m=!1;for(const g of p)l(g),m=!0;for(const g of h)r.has(g)||(r.set(g,i(g)),m=!0);m&&(t.value=c())}const u=e.registerTickCallback(d);return a.onUnmounted(()=>{u();for(const f of r.keys())l(f)}),t}function Ne(n){const e=a.inject(He);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const t=a.shallowRef(n.default()),o=e.getEditor();if(o){const i=o._getContext();t.value=n.snapshot(i)}const r=e.subscribeSingleton(n.name,i=>{t.value=i??{}});let s=null;return o||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const l=i._getContext();t.value=n.snapshot(l),s==null||s(),s=null}})),a.onUnmounted(()=>{r(),s==null||s()}),t}function Sl(n,e,t){if(!n.closest(".wov-block")){const p=n.getBoundingClientRect();return{width:p.width,height:p.height,left:0,top:0}}const r=n.getBoundingClientRect(),s=t.value.left,i=t.value.top,l=new DOMPoint(r.left+r.width/2-s,r.top+r.height/2-i),c=e.value.zoom,d=new DOMMatrix;d.translateSelf(-e.value.left*c,-e.value.top*c),d.scaleSelf(c,c),d.invertSelf();const u=d.transformPoint(l),f=n.offsetWidth,h=n.offsetHeight;return{width:f,height:h,left:u.x-f/2,top:u.y-h/2}}function If(n){if(n.startsWith("#"))return n.toUpperCase();const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const t=parseInt(e[1],10).toString(16).padStart(2,"0"),o=parseInt(e[2],10).toString(16).padStart(2,"0"),r=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${t}${o}${r}`.toUpperCase()}return n}function zo(n){const e=Math.round(n.red),t=Math.round(n.green),o=Math.round(n.blue),r=Math.round(n.alpha);return r<255?"#"+[e,t,o,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,t,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function El(n){n=n.replace(/^#/,"");let e,t,o,r=255;if(n.length===6)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16);else if(n.length===8)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);else return null;return{red:e,green:t,blue:o,alpha:r}}function Of(n){const e=El(n);if(!e)return{h:0,s:100,v:100,a:255};const t=e.red/255,o=e.green/255,r=e.blue/255,s=Math.max(t,o,r),i=Math.min(t,o,r),l=s-i;let c=0;const d=s===0?0:l/s*100,u=s*100;if(l!==0)switch(s){case t:c=((o-r)/l+(o<r?6:0))*60;break;case o:c=((r-t)/l+2)*60;break;case r:c=((t-o)/l+4)*60;break}return{h:c,s:d,v:u,a:e.alpha}}function Rf(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const h=p=>Math.round(p*255).toString(16).padStart(2,"0");return`#${h(r)}${h(s)}${h(i)}`}function Pf(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const h=m=>Math.round(m*255).toString(16).padStart(2,"0"),p=Math.round(n.a).toString(16).padStart(2,"0");return n.a<255?`#${h(r)}${h(s)}${h(i)}${p}`:`#${h(r)}${h(s)}${h(i)}`}const Ae=a.shallowRef(null),vl=a.shallowRef(null),Ml=a.shallowRef(null),Pt=a.ref(0);function Fo(){const n={hasEditor:a.computed(()=>Ae.value!==null),isBold:a.computed(()=>{var r;return Pt.value,((r=Ae.value)==null?void 0:r.isActive("bold"))??!1}),isItalic:a.computed(()=>{var r;return Pt.value,((r=Ae.value)==null?void 0:r.isActive("italic"))??!1}),isUnderline:a.computed(()=>{var r;return Pt.value,((r=Ae.value)==null?void 0:r.isActive("underline"))??!1}),alignment:a.computed(()=>{Pt.value;const r=Ae.value;return r?r.isActive({textAlign:"center"})?"center":r.isActive({textAlign:"right"})?"right":r.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:a.computed(()=>{Pt.value;const r=Ae.value;if(!r)return null;const i=r.getAttributes("textStyle").color??null;return i?If(i):null}),linkHref:a.computed(()=>{Pt.value;const r=Ae.value;return r?r.getAttributes("link").href??null:null})},e={toggleBold(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection,l=s===i;let c=r.chain().focus();l&&(c=c.selectAll()),c=c.toggleBold(),l&&(c=c.setTextSelection(i)),c.run()},toggleItalic(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection,l=s===i;let c=r.chain().focus();l&&(c=c.selectAll()),c=c.toggleItalic(),l&&(c=c.setTextSelection(i)),c.run()},toggleUnderline(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection,l=s===i;let c=r.chain().focus();l&&(c=c.selectAll()),c=c.toggleUnderline(),l&&(c=c.setTextSelection(i)),c.run()},setAlignment(r){const s=Ae.value;s&&s.chain().selectAll().setTextAlign(r).run()},setColor(r){const s=Ae.value;if(!s)return;const{from:i,to:l}=s.state.selection;i===l?s.chain().focus().selectAll().setColor(r).setTextSelection(l).run():s.chain().focus().setColor(r).run()},setLink(r){const s=Ae.value;if(!s)return;const{from:i,to:l}=s.state.selection;i===l?s.chain().focus().selectAll().setLink({href:r}).setTextSelection(l).run():s.chain().focus().setLink({href:r}).run()},removeLink(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection;s===i?r.chain().focus().selectAll().unsetLink().setTextSelection(i).run():r.chain().focus().unsetLink().run()}};function t(r,s,i){Ae.value=r,Ml.value=s,vl.value=i,r.on("selectionUpdate",()=>{Pt.value++}),r.on("transaction",()=>{Pt.value++})}function o(){Ae.value=null,Ml.value=null,vl.value=null}return{editor:Ae,blockElement:vl,textElement:Ml,state:n,commands:e,updateCounter:Pt,register:t,unregister:o}}const Be=[ju,Ku,qu,wl,wf,Ju,Yu,Xu,mf.configure({openOnClick:!1}),gf.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function Aw(n){return n.type==="text"&&typeof n.text=="string"}function gt(n,e){if(Aw(n)){e(n);return}if(n.content)for(const t of n.content)gt(t,e)}function Tl(n,e){if(n.type==="paragraph"){e(n);return}if(n.content)for(const t of n.content)Tl(t,e)}function Bw(n,e){var t;return((t=n.marks)==null?void 0:t.some(o=>o.type===e))??!1}function Iw(n){var o,r;const e=(o=n.marks)==null?void 0:o.find(s=>s.type==="textStyle"),t=((r=e==null?void 0:e.attrs)==null?void 0:r.color)??null;return t?If(t):null}function Ow(n,e){if(!n.trim())return!1;const t=nt(n,Be);let o=!1,r=!0,s=0;return gt(t,i=>{s++,Bw(i,e)?o=!0:r=!1}),s===0?!1:r?!0:o?null:!1}function Rw(n){if(!n.trim())return"left";const e=nt(n,Be);let t="left";return Tl(e,o=>{var s;const r=(s=o.attrs)==null?void 0:s.textAlign;r&&(t=r)}),t}function Pw(n){if(!n.trim())return null;const e=nt(n,Be);let t=null;return gt(e,o=>{t===null&&(t=Iw(o))}),t}function Nl(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[];r.findIndex(i=>i.type===e)===-1&&(o.marks=[...r,{type:e}])}),Kn(t,Be)}function Al(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[];o.marks=r.filter(s=>s.type!==e)}),Kn(t,Be)}function Dw(n,e){if(!n.trim())return n;const t=nt(n,Be);return Tl(t,o=>{o.attrs={...o.attrs,textAlign:e}}),Kn(t,Be)}function _w(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="textStyle");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,color:e}},o.marks=r):o.marks=[...r,{type:"textStyle",attrs:{color:e}}]}),Kn(t,Be)}function Lw(n){if(!n.trim())return null;const e=nt(n,Be);let t=null;return gt(e,o=>{var r,s;if(t===null){const i=(r=o.marks)==null?void 0:r.find(l=>l.type==="link");(s=i==null?void 0:i.attrs)!=null&&s.href&&(t=i.attrs.href)}}),t}function Vw(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="link");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,href:e}},o.marks=r):o.marks=[...r,{type:"link",attrs:{href:e,target:"_blank",rel:"noopener noreferrer"}}]}),Kn(t,Be)}function $w(n){if(!n.trim())return n;const e=nt(n,Be);return gt(e,t=>{const o=t.marks??[];t.marks=o.filter(r=>r.type!=="link")}),Kn(e,Be)}function Df(n){const e=document.querySelector(`[data-entity-id="${n}"]`);if(!e)return null;const t=e.firstElementChild;return t||e.querySelector(".wov-editable-text")}function _f(n,e,t,o){var c;const r=n.cloneNode(!0);r.style.position="absolute",r.style.visibility="hidden",r.style.pointerEvents="none",r.style.top="0",r.style.left="0";const s=r.classList.contains("wov-editable-text")?r:r.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${o.fontSizePx}px`,s.style.fontFamily=o.fontFamily,s.style.lineHeight=String(o.lineHeight),s.style.letterSpacing=`${o.letterSpacingEm}em`);const i=r.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=o.content:s?s.innerHTML=o.content:r.innerHTML=o.content,(c=n.parentElement)==null||c.appendChild(r);const l=Sl(r,e,t);return r.remove(),l}function Lf(n){const{nextEditorTick:e}=de(),t=Rt(n,b.Text),o=Ne(b.Camera),r=Ne(b.Screen),s=Fo(),i={hasTextEntities:a.computed(()=>{for(const h of t.value.values())if(h)return!0;return!1}),hasTextContent:a.computed(()=>{for(const h of t.value.values()){if(!h)continue;const p=h.content?nt(h.content,Be):null;if(p){let m=!1;if(gt(p,g=>{var y;(y=g.text)!=null&&y.trim()&&(m=!0)}),m)return!0}}return!1}),isBold:a.computed(()=>l("bold")),isItalic:a.computed(()=>l("italic")),isUnderline:a.computed(()=>l("underline")),alignment:a.computed(()=>{let h=null;for(const p of t.value.values()){if(!p)continue;const m=Rw(p.content);if(h===null)h=m;else if(h!==m)return null}return h??"left"}),color:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values()){if(!m)continue;const g=Pw(m.content);if(!p)h=g,p=!0;else if(h!==g)return null}return h}),fontSize:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values())if(m){if(!p)h=m.fontSizePx,p=!0;else if(h!==m.fontSizePx)return null}return h}),fontFamily:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values())if(m){if(!p)h=m.fontFamily,p=!0;else if(h!==m.fontFamily)return null}return h}),linkHref:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values()){if(!m)continue;const g=Lw(m.content);if(!p)h=g,p=!0;else if(h!==g)return null}return h})};function l(h){let p=null,m=!1;for(const g of t.value.values()){if(!g)continue;const y=Ow(g.content,h);if(!m)p=y,m=!0;else if(p!==y)return null}return p}const c={toggleBold(){u(h=>i.isBold.value?Al(h,"bold"):Nl(h,"bold"))},toggleItalic(){u(h=>i.isItalic.value?Al(h,"italic"):Nl(h,"italic"))},toggleUnderline(){u(h=>i.isUnderline.value?Al(h,"underline"):Nl(h,"underline"))},setAlignment(h){f(p=>Dw(p,h))},setColor(h){f(p=>_w(p,h))},setFontSize(h){d(p=>({...p,fontSizePx:h}),p=>{p.fontSizePx=h})},setFontFamily(h){d(p=>({...p,fontFamily:h}),p=>{p.fontFamily=h})},setTextStyle(h){d(p=>({...p,fontFamily:h.fontFamily??p.fontFamily,fontSizePx:h.fontSizePx??p.fontSizePx,lineHeight:h.lineHeight??p.lineHeight,letterSpacingEm:h.letterSpacingEm??p.letterSpacingEm}),p=>{h.fontFamily!==void 0&&(p.fontFamily=h.fontFamily),h.fontSizePx!==void 0&&(p.fontSizePx=h.fontSizePx),h.lineHeight!==void 0&&(p.lineHeight=h.lineHeight),h.letterSpacingEm!==void 0&&(p.letterSpacingEm=h.letterSpacingEm)})},setLink(h){f(p=>Vw(p,h))},removeLink(){f(h=>$w(h))}};function d(h,p){const m=a.toValue(n),g=[];for(const y of m){const k=t.value.get(y);if(!k)continue;const w=Df(y);if(w){const C=_f(w,o,r,h(k));g.push({entityId:y,...C})}}e(y=>{for(const k of m)p(b.Text.write(y,k));for(const{entityId:k,width:w,height:C,left:x,top:S}of g){const M=b.Block.write(y,k);M.size=[w,C],M.position=[x,S]}a.nextTick(()=>{var k;s.updateCounter.value++,(k=s.editor.value)==null||k.commands.focus()})})}function u(h){const p=a.toValue(n),m=[];for(const g of p){const y=t.value.get(g);if(!y)continue;const k=h(y.content),w=Df(g);if(w){const C=_f(w,o,r,{...y,content:k});m.push({entityId:g,content:k,...C})}else m.push({entityId:g,content:k,width:0,height:0,left:0,top:0})}e(g=>{for(const{entityId:y,content:k,width:w,height:C,left:x,top:S}of m){const M=b.Text.write(g,y);if(M.content=k,w>0&&C>0){const E=b.Block.write(g,y);E.size=[w,C],E.position=[x,S]}}})}function f(h){const p=a.toValue(n);e(m=>{for(const g of p){const y=b.Text.write(m,g);y.content=h(y.content)}})}return{state:i,commands:c}}function rt(n){const e=Fo(),t=Lf(n),o=e.state.hasEditor;return{state:a.reactive({hasTextToFormat:a.computed(()=>o.value||t.state.hasTextEntities.value),hasEditor:o,hasTextContent:a.computed(()=>t.state.hasTextContent.value),showTextMenuButtons:a.computed(()=>o.value||t.state.hasTextContent.value),isBold:a.computed(()=>o.value?e.state.isBold.value:t.state.isBold.value===!0),isItalic:a.computed(()=>o.value?e.state.isItalic.value:t.state.isItalic.value===!0),isUnderline:a.computed(()=>o.value?e.state.isUnderline.value:t.state.isUnderline.value===!0),alignment:a.computed(()=>o.value?e.state.alignment.value:t.state.alignment.value??"left"),color:a.computed(()=>o.value?e.state.color.value:t.state.color.value),fontSize:a.computed(()=>t.state.fontSize.value),fontFamily:a.computed(()=>t.state.fontFamily.value),linkHref:a.computed(()=>o.value?e.state.linkHref.value:t.state.linkHref.value)}),commands:{toggleBold(){o.value?e.commands.toggleBold():t.commands.toggleBold()},toggleItalic(){o.value?e.commands.toggleItalic():t.commands.toggleItalic()},toggleUnderline(){o.value?e.commands.toggleUnderline():t.commands.toggleUnderline()},setAlignment(i){o.value?e.commands.setAlignment(i):t.commands.setAlignment(i)},setColor(i){o.value?e.commands.setColor(i):t.commands.setColor(i)},setFontSize(i){t.commands.setFontSize(i)},setFontFamily(i){t.commands.setFontFamily(i)},setTextStyle(i){t.commands.setTextStyle(i)},setLink(i){o.value?e.commands.setLink(i):t.commands.setLink(i)},removeLink(){o.value?e.commands.removeLink():t.commands.removeLink()}}}}function Bl(n){const e=Ne(b.Camera),t=Ne(b.Screen),o=Ne(le.TransformBoxStateSingleton),r=Ne(le.SelectionStateSingleton),{nextEditorTick:s}=de();let i=!1,l=null;function c(u,f){const{entityId:h}=a.toValue(n.blockData),p=a.toValue(n.minWidth)??0,m=a.toValue(n.minHeight)??0,g=Math.max(f.width,p),y=Math.max(f.height,m),k=b.Block.read(u,h),w=Math.abs(k.size[0]-g)>.5,C=Math.abs(k.size[1]-y)>.5;if(!w&&!C)return;const x=b.Block.write(u,h);x.size=[g,y],x.position=[f.left,f.top],o.value.transformBoxId!==null&&le.UpdateTransformBox.spawn(u,{transformBoxId:o.value.transformBoxId})}a.watch(()=>r.value,()=>{s(u=>{const f=zw(u);if(i&&!f){const h=n.containerRef.value;if(!h)return;l=Sl(h,e,t),c(u,l),l=null}i=f})},{flush:"sync"});function d(u){const{content:f,...h}=u;s(p=>{const{entityId:m}=a.toValue(n.blockData);if(b.Text.read(p,m).content!==f){const y=b.Text.write(p,m);y.content=f}c(p,h)})}return{handleEditEnd:d}}function zw(n){const e=le.SelectionStateSingleton.read(n);return e.state===le.SelectionState.Dragging&&e.draggedEntity!==null&&b.hasComponent(n,e.draggedEntity,le.TransformHandle)&&le.TransformHandle.read(n,e.draggedEntity).kind===le.TransformHandleKind.Stretch}function hs(){const n=a.inject(_s);if(!n)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:n.activeTool,heldTool:n.heldTool,setTool:n.setTool,dragOutTool:n.dragOutTool,onToolPointerDown:n.onToolPointerDown,onToolPointerUp:n.onToolPointerUp,isActive:e=>a.computed(()=>n.activeTool.value===e)}}const Fw=500,Hw=1500;function Vf(){const n=a.ref(null),e=a.ref(!1),t=a.ref(!1);let o=null,r=null;function s(){o&&(clearTimeout(o),o=null),r&&(clearTimeout(r),r=null)}function i(d,u){s(),n.value={text:d,anchor:u},t.value?e.value=!0:o=setTimeout(()=>{e.value=!0,t.value=!0,o=null},Fw)}function l(){s(),e.value=!1,n.value=null,t.value&&(r=setTimeout(()=>{t.value=!1,r=null},Hw))}function c(){s(),e.value=!1,n.value=null,t.value=!1}return{activeTooltip:a.readonly(n),isVisible:a.readonly(e),isWarmedUp:a.readonly(t),show:i,hide:l,reset:c}}function Dt(){const n=a.inject(aa);if(!n)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return n}const Uw={key:1},jw=["innerHTML"],$f=50,Ww=300,ps=a.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(n,{expose:e,emit:t}){var E;const o=n,r=t,s=pe(o.entityId,b.Text),i=Ne(b.Camera),l=Ne(b.Screen),c=Fo(),{nextEditorTick:d}=de(),u=Ne(b.Mouse),f=a.ref(null);e({editableTextRef:f});const h=a.ref(((E=s.value)==null?void 0:E.content)??""),p=a.shallowRef(null);function m(){d(v=>{const T=b.Text.write(v,o.entityId);T.constrainWidth=!0;const D=b.Block.read(v,o.entityId),P=Math.max(D.size[0],Ww),R=b.Block.write(v,o.entityId);R.size=[P,D.size[1]],b.ResetKeyboard.spawn(v),le.DeselectAll.spawn(v)})}function g(v,T){var z,H,Z;const D=s.value;if(!D)return!1;const P=((z=T.clipboardData)==null?void 0:z.getData("text/html"))??"",R=((H=T.clipboardData)==null?void 0:H.getData("text/plain"))??"";return P.includes("data-pm-slice")?(!D.constrainWidth&&R.length>$f&&m(),!1):(T.preventDefault(),(Z=p.value)==null||Z.commands.insertContent(R,{parseOptions:{preserveWhitespace:!0}}),!D.constrainWidth&&R.length>$f&&m(),!0)}function y(){var v,T;return new pk({extensions:[ju,Ku,qu,wl,wf,Ju,Yu,Xu,mf.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),gf.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((v=s.value)==null?void 0:v.defaultAlignment)??"left"}),Nw],content:((T=s.value)==null?void 0:T.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:g}})}a.watch(()=>o.edited,async v=>{if(v&&f.value){if(p.value=y(),await k(p.value),!o.blockElement)return;c.register(p.value,f.value,o.blockElement)}else p.value&&(c.unregister(),w(p.value),p.value.destroy(),p.value=null)},{immediate:!0});async function k(v){var R;const T=(R=u.value)==null?void 0:R.position,D=l.value;await a.nextTick(),await new Promise(_=>requestAnimationFrame(_));const P=f.value;if(T&&D&&P){const _=T[0]+D.left,z=T[1]+D.top,H=v.view.posAtCoords({left:_,top:z});if(H){v.chain().focus().setTextSelection(H.pos).run();return}}v.commands.focus("start")}function w(v){let T=v.getHTML();const P=T.replace(/<[^>]*>/g,"").trim().length>0;P||(T=""),h.value=T,d(R=>{var K,W;const _=b.getBlockDef(R,o.block.tag);if(!P&&((K=_.editOptions)!=null&&K.removeWhenTextEmpty)){b.removeEntity(R,o.entityId);return}const z=(W=f.value)==null?void 0:W.closest(".wov-block"),H=(z==null?void 0:z.firstElementChild)??f.value;if(!H){console.warn("EditableText: no element to measure");return}const Z=Sl(H,i,l);r("editEnd",{content:T,...Z})})}a.watch(()=>{var v;return(v=s.value)==null?void 0:v.content},v=>{v!==void 0&&(p.value?p.value.getHTML()!==v&&p.value.commands.setContent(v,{emitUpdate:!1}):h.value=v)});const C=a.computed(()=>{const v=s.value;if(!v)return{};const[T,D]=o.block.flip,P=T?-1:1,R=D?-1:1,_=T||D;return{fontFamily:v.fontFamily,fontSize:`${v.fontSizePx}px`,lineHeight:v.lineHeight,letterSpacing:`${v.letterSpacingEm}em`,width:v.constrainWidth?"100%":"fit-content",whiteSpace:v.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:o.edited?"auto":"none",userSelect:o.edited?"auto":"none",transform:_?`scale(${P}, ${R})`:void 0}});function x(v){v.key==="Control"||v.key==="Meta"||v.stopPropagation()}function S(v){o.edited&&v.stopPropagation()}function M(v){if(o.edited)return;const T=v.target.closest("a");if(!T)return;const D=T.getAttribute("href");D&&(v.preventDefault(),v.stopPropagation(),window.open(D,"_blank","noopener,noreferrer"))}return a.onUnmounted(()=>{p.value&&(c.unregister(),p.value.destroy(),p.value=null)}),(v,T)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:a.normalizeStyle(C.value),onKeydown:x,onPointerdown:S,onPointermove:S,onPointerup:S,onClick:M},[p.value?(a.openBlock(),a.createBlock(a.unref(mk),{key:0,editor:p.value},null,8,["editor"])):(a.openBlock(),a.createElementBlock("div",Uw,[a.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:h.value},null,8,jw)]))],36))}}),Kw={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},qw=["d","fill","stroke","stroke-width","stroke-dasharray"],zf=a.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=pe(e.entityId,b.Shape),o=pe(e.entityId,b.VerticalAlign),r=a.ref(null),s={[b.VerticalAlignment.Top]:"flex-start",[b.VerticalAlignment.Center]:"center",[b.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>t.value?`rgba(${t.value.fillRed}, ${t.value.fillGreen}, ${t.value.fillBlue}, ${(t.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),l=a.computed(()=>t.value?t.value.strokeKind===b.StrokeKind.None?"none":`rgba(${t.value.strokeRed}, ${t.value.strokeGreen}, ${t.value.strokeBlue}, ${t.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),c=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeWidth)??2}),d=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeKind)??b.StrokeKind.Solid}),u=a.computed(()=>{var g;return ro[((g=t.value)==null?void 0:g.kind)??"rectangle"]??ro.rectangle}),f=a.computed(()=>{const g=c.value;switch(d.value){case b.StrokeKind.Dashed:return`${g*3} ${g*3}`;case b.StrokeKind.None:return"";case b.StrokeKind.Solid:default:return""}}),h=a.computed(()=>{var g;return{overflow:e.edited?"visible":"hidden",alignItems:s[((g=o.value)==null?void 0:g.value)??b.VerticalAlignment.Top]}}),{nextEditorTick:p}=de();function m(g){p(y=>{if(b.Text.read(y,e.entityId).content===g.content)return;const w=b.Text.write(y,e.entityId);w.content=g.content})}return(g,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-shape-block"},[(a.openBlock(),a.createElementBlock("svg",Kw,[a.createElementVNode("path",{d:u.value,fill:i.value,stroke:l.value,"stroke-width":c.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,qw)])),a.createElementVNode("div",{class:"wov-shape-content",style:a.normalizeStyle(h.value)},[a.createVNode(ps,a.mergeProps(e,{"block-element":r.value,onEditEnd:m}),null,16,["block-element"])],4)],512))}}),Gw={class:"wov-tape-block"},Jw={key:0,class:"wov-tape-placeholder"},Ff=a.defineComponent({__name:"TapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},async setup(n){let e,t;const o=n,r=a.inject(He);if(!r)throw new Error("TapeBlock must be used within a WovenCanvas component");const s=r,i=pe(o.entityId,b.Asset),l=s.getAssetManager(),c=i.value;let d=null;l&&(c!=null&&c.identifier)&&(d=([e,t]=a.withAsyncContext(()=>l.getDisplayUrl(c.identifier)),e=await e,t(),e));const u=a.ref(d),f=a.ref(!d),h=a.ref(!1);let p=!0;a.onUnmounted(()=>{p=!1});async function m(){const g=s.getAssetManager();if(!g)return;const y=i.value;if(!y||!y.identifier){f.value=!1;return}try{f.value=!0,h.value=!1;const k=await g.getDisplayUrl(y.identifier);if(!p)return;k?(u.value=k,f.value=!1):y.uploadState===b.UploadState.Failed&&(h.value=!0,f.value=!1)}catch(k){if(!p)return;console.error("Failed to get tape display URL:",k),h.value=!0,f.value=!1}}return a.watch(()=>i.value,()=>{m()},{immediate:!0}),a.onMounted(()=>{m()}),(g,y)=>(a.openBlock(),a.createElementBlock("div",Gw,[f.value&&!u.value?(a.openBlock(),a.createElementBlock("div",Jw)):u.value?(a.openBlock(),a.createElementBlock("div",{key:1,class:"wov-tape-image",style:a.normalizeStyle({backgroundImage:`url(${u.value})`})},null,4)):a.createCommentVNode("",!0)]))}}),Yw=["data-text-empty"],Hf=a.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=pe(e.entityId,b.Text),r=a.computed(()=>{var d;return(((d=o.value)==null?void 0:d.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),s=a.computed(()=>{var l;return((l=o.value)==null?void 0:l.constrainWidth)??!1}),{handleEditEnd:i}=Bl({blockData:e,containerRef:t});return(l,c)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-text-block","data-text-empty":r.value||void 0,style:a.normalizeStyle({width:s.value?"100%":"fit-content"})},[a.createVNode(ps,a.mergeProps(e,{"block-element":t.value,onEditEnd:a.unref(i)}),null,16,["block-element","onEditEnd"])],12,Yw))}}),ms=Math.min,Mn=Math.max,gs=Math.round,ys=Math.floor,yt=n=>({x:n,y:n}),Xw={left:"right",right:"left",bottom:"top",top:"bottom"},Qw={start:"end",end:"start"};function Uf(n,e,t){return Mn(n,ms(e,t))}function ks(n,e){return typeof n=="function"?n(e):n}function Tn(n){return n.split("-")[0]}function ws(n){return n.split("-")[1]}function jf(n){return n==="x"?"y":"x"}function Wf(n){return n==="y"?"height":"width"}const Zw=new Set(["top","bottom"]);function nn(n){return Zw.has(Tn(n))?"y":"x"}function Kf(n){return jf(nn(n))}function eb(n,e,t){t===void 0&&(t=!1);const o=ws(n),r=Kf(n),s=Wf(r);let i=r==="x"?o===(t?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=bs(i)),[i,bs(i)]}function tb(n){const e=bs(n);return[Il(n),e,Il(e)]}function Il(n){return n.replace(/start|end/g,e=>Qw[e])}const qf=["left","right"],Gf=["right","left"],nb=["top","bottom"],ob=["bottom","top"];function rb(n,e,t){switch(n){case"top":case"bottom":return t?e?Gf:qf:e?qf:Gf;case"left":case"right":return e?nb:ob;default:return[]}}function sb(n,e,t,o){const r=ws(n);let s=rb(Tn(n),t==="start",o);return r&&(s=s.map(i=>i+"-"+r),e&&(s=s.concat(s.map(Il)))),s}function bs(n){return n.replace(/left|right|bottom|top/g,e=>Xw[e])}function ib(n){return{top:0,right:0,bottom:0,left:0,...n}}function lb(n){return typeof n!="number"?ib(n):{top:n,right:n,bottom:n,left:n}}function Cs(n){const{x:e,y:t,width:o,height:r}=n;return{width:o,height:r,top:t,left:e,right:e+o,bottom:t+r,x:e,y:t}}function Jf(n,e,t){let{reference:o,floating:r}=n;const s=nn(e),i=Kf(e),l=Wf(i),c=Tn(e),d=s==="y",u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,h=o[l]/2-r[l]/2;let p;switch(c){case"top":p={x:u,y:o.y-r.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:f};break;case"left":p={x:o.x-r.width,y:f};break;default:p={x:o.x,y:o.y}}switch(ws(e)){case"start":p[i]-=h*(t&&d?-1:1);break;case"end":p[i]+=h*(t&&d?-1:1);break}return p}async function ab(n,e){var t;e===void 0&&(e={});const{x:o,y:r,platform:s,rects:i,elements:l,strategy:c}=n,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=ks(e,n),m=lb(p),y=l[h?f==="floating"?"reference":"floating":f],k=Cs(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(y)))==null||t?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),w=f==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=Cs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:C,strategy:c}):w);return{top:(k.top-S.top+m.top)/x.y,bottom:(S.bottom-k.bottom+m.bottom)/x.y,left:(k.left-S.left+m.left)/x.x,right:(S.right-k.right+m.right)/x.x}}const cb=async(n,e,t)=>{const{placement:o="bottom",strategy:r="absolute",middleware:s=[],platform:i}=t,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let d=await i.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:f}=Jf(d,o,c),h=o,p={},m=0;for(let y=0;y<l.length;y++){var g;const{name:k,fn:w}=l[y],{x:C,y:x,data:S,reset:M}=await w({x:u,y:f,initialPlacement:o,placement:h,strategy:r,middlewareData:p,rects:d,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:ab},elements:{reference:n,floating:e}});u=C??u,f=x??f,p={...p,[k]:{...p[k],...S}},M&&m<=50&&(m++,typeof M=="object"&&(M.placement&&(h=M.placement),M.rects&&(d=M.rects===!0?await i.getElementRects({reference:n,floating:e,strategy:r}):M.rects),{x:u,y:f}=Jf(d,h,c)),y=-1)}return{x:u,y:f,placement:h,strategy:r,middlewareData:p}},db=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,o;const{placement:r,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=ks(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const k=Tn(r),w=nn(l),C=Tn(l)===l,x=await(c.isRTL==null?void 0:c.isRTL(d.floating)),S=h||(C||!g?[bs(l)]:tb(l)),M=m!=="none";!h&&M&&S.push(...sb(l,g,m,x));const E=[l,...S],v=await c.detectOverflow(e,y),T=[];let D=((o=s.flip)==null?void 0:o.overflows)||[];if(u&&T.push(v[k]),f){const z=eb(r,i,x);T.push(v[z[0]],v[z[1]])}if(D=[...D,{placement:r,overflows:T}],!T.every(z=>z<=0)){var P,R;const z=(((P=s.flip)==null?void 0:P.index)||0)+1,H=E[z];if(H&&(!(f==="alignment"?w!==nn(H):!1)||D.every(W=>nn(W.placement)===w?W.overflows[0]>0:!0)))return{data:{index:z,overflows:D},reset:{placement:H}};let Z=(R=D.filter(K=>K.overflows[0]<=0).sort((K,W)=>K.overflows[1]-W.overflows[1])[0])==null?void 0:R.placement;if(!Z)switch(p){case"bestFit":{var _;const K=(_=D.filter(W=>{if(M){const U=nn(W.placement);return U===w||U==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(U=>U>0).reduce((U,X)=>U+X,0)]).sort((W,U)=>W[1]-U[1])[0])==null?void 0:_[0];K&&(Z=K);break}case"initialPlacement":Z=l;break}if(r!==Z)return{reset:{placement:Z}}}return{}}}},ub=new Set(["left","top"]);async function fb(n,e){const{placement:t,platform:o,elements:r}=n,s=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Tn(t),l=ws(t),c=nn(t)==="y",d=ub.has(i)?-1:1,u=s&&c?-1:1,f=ks(e,n);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*u,y:h*d}:{x:h*d,y:p*u}}const hb=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,o;const{x:r,y:s,placement:i,middlewareData:l}=e,c=await fb(e,n);return i===((t=l.offset)==null?void 0:t.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:i}}}}},pb=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:o,placement:r,platform:s}=e,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:k=>{let{x:w,y:C}=k;return{x:w,y:C}}},...d}=ks(n,e),u={x:t,y:o},f=await s.detectOverflow(e,d),h=nn(Tn(r)),p=jf(h);let m=u[p],g=u[h];if(i){const k=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=m+f[k],x=m-f[w];m=Uf(C,m,x)}if(l){const k=h==="y"?"top":"left",w=h==="y"?"bottom":"right",C=g+f[k],x=g-f[w];g=Uf(C,g,x)}const y=c.fn({...e,[p]:m,[h]:g});return{...y,data:{x:y.x-t,y:y.y-o,enabled:{[p]:i,[h]:l}}}}}};function xs(){return typeof window<"u"}function Nn(n){return Ol(n)?(n.nodeName||"").toLowerCase():"#document"}function We(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function kt(n){var e;return(e=(Ol(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Ol(n){return xs()?n instanceof Node||n instanceof We(n).Node:!1}function st(n){return xs()?n instanceof Element||n instanceof We(n).Element:!1}function wt(n){return xs()?n instanceof HTMLElement||n instanceof We(n).HTMLElement:!1}function Yf(n){return!xs()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof We(n).ShadowRoot}const mb=new Set(["inline","contents"]);function Ho(n){const{overflow:e,overflowX:t,overflowY:o,display:r}=it(n);return/auto|scroll|overlay|hidden|clip/.test(e+o+t)&&!mb.has(r)}const gb=new Set(["table","td","th"]);function yb(n){return gb.has(Nn(n))}const kb=[":popover-open",":modal"];function Ss(n){return kb.some(e=>{try{return n.matches(e)}catch{return!1}})}const wb=["transform","translate","scale","rotate","perspective"],bb=["transform","translate","scale","rotate","perspective","filter"],Cb=["paint","layout","strict","content"];function Rl(n){const e=Pl(),t=st(n)?it(n):n;return wb.some(o=>t[o]?t[o]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||bb.some(o=>(t.willChange||"").includes(o))||Cb.some(o=>(t.contain||"").includes(o))}function xb(n){let e=on(n);for(;wt(e)&&!Jn(e);){if(Rl(e))return e;if(Ss(e))return null;e=on(e)}return null}function Pl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Sb=new Set(["html","body","#document"]);function Jn(n){return Sb.has(Nn(n))}function it(n){return We(n).getComputedStyle(n)}function Es(n){return st(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function on(n){if(Nn(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Yf(n)&&n.host||kt(n);return Yf(e)?e.host:e}function Xf(n){const e=on(n);return Jn(e)?n.ownerDocument?n.ownerDocument.body:n.body:wt(e)&&Ho(e)?e:Xf(e)}function Uo(n,e,t){var o;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Xf(n),s=r===((o=n.ownerDocument)==null?void 0:o.body),i=We(r);if(s){const l=Dl(i);return e.concat(i,i.visualViewport||[],Ho(r)?r:[],l&&t?Uo(l):[])}return e.concat(r,Uo(r,[],t))}function Dl(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Qf(n){const e=it(n);let t=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=wt(n),s=r?n.offsetWidth:t,i=r?n.offsetHeight:o,l=gs(t)!==s||gs(o)!==i;return l&&(t=s,o=i),{width:t,height:o,$:l}}function _l(n){return st(n)?n:n.contextElement}function Yn(n){const e=_l(n);if(!wt(e))return yt(1);const t=e.getBoundingClientRect(),{width:o,height:r,$:s}=Qf(e);let i=(s?gs(t.width):t.width)/o,l=(s?gs(t.height):t.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Eb=yt(0);function Zf(n){const e=We(n);return!Pl()||!e.visualViewport?Eb:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function vb(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==We(n)?!1:e}function An(n,e,t,o){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=_l(n);let i=yt(1);e&&(o?st(o)&&(i=Yn(o)):i=Yn(n));const l=vb(s,t,o)?Zf(s):yt(0);let c=(r.left+l.x)/i.x,d=(r.top+l.y)/i.y,u=r.width/i.x,f=r.height/i.y;if(s){const h=We(s),p=o&&st(o)?We(o):o;let m=h,g=Dl(m);for(;g&&o&&p!==m;){const y=Yn(g),k=g.getBoundingClientRect(),w=it(g),C=k.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,x=k.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,d*=y.y,u*=y.x,f*=y.y,c+=C,d+=x,m=We(g),g=Dl(m)}}return Cs({width:u,height:f,x:c,y:d})}function vs(n,e){const t=Es(n).scrollLeft;return e?e.left+t:An(kt(n)).left+t}function eh(n,e){const t=n.getBoundingClientRect(),o=t.left+e.scrollLeft-vs(n,t),r=t.top+e.scrollTop;return{x:o,y:r}}function Mb(n){let{elements:e,rect:t,offsetParent:o,strategy:r}=n;const s=r==="fixed",i=kt(o),l=e?Ss(e.floating):!1;if(o===i||l&&s)return t;let c={scrollLeft:0,scrollTop:0},d=yt(1);const u=yt(0),f=wt(o);if((f||!f&&!s)&&((Nn(o)!=="body"||Ho(i))&&(c=Es(o)),wt(o))){const p=An(o);d=Yn(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}const h=i&&!f&&!s?eh(i,c):yt(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-c.scrollLeft*d.x+u.x+h.x,y:t.y*d.y-c.scrollTop*d.y+u.y+h.y}}function Tb(n){return Array.from(n.getClientRects())}function Nb(n){const e=kt(n),t=Es(n),o=n.ownerDocument.body,r=Mn(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=Mn(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let i=-t.scrollLeft+vs(n);const l=-t.scrollTop;return it(o).direction==="rtl"&&(i+=Mn(e.clientWidth,o.clientWidth)-r),{width:r,height:s,x:i,y:l}}const th=25;function Ab(n,e){const t=We(n),o=kt(n),r=t.visualViewport;let s=o.clientWidth,i=o.clientHeight,l=0,c=0;if(r){s=r.width,i=r.height;const u=Pl();(!u||u&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}const d=vs(o);if(d<=0){const u=o.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(o.clientWidth-f.clientWidth-p);m<=th&&(s-=m)}else d<=th&&(s+=d);return{width:s,height:i,x:l,y:c}}const Bb=new Set(["absolute","fixed"]);function Ib(n,e){const t=An(n,!0,e==="fixed"),o=t.top+n.clientTop,r=t.left+n.clientLeft,s=wt(n)?Yn(n):yt(1),i=n.clientWidth*s.x,l=n.clientHeight*s.y,c=r*s.x,d=o*s.y;return{width:i,height:l,x:c,y:d}}function nh(n,e,t){let o;if(e==="viewport")o=Ab(n,t);else if(e==="document")o=Nb(kt(n));else if(st(e))o=Ib(e,t);else{const r=Zf(n);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Cs(o)}function oh(n,e){const t=on(n);return t===e||!st(t)||Jn(t)?!1:it(t).position==="fixed"||oh(t,e)}function Ob(n,e){const t=e.get(n);if(t)return t;let o=Uo(n,[],!1).filter(l=>st(l)&&Nn(l)!=="body"),r=null;const s=it(n).position==="fixed";let i=s?on(n):n;for(;st(i)&&!Jn(i);){const l=it(i),c=Rl(i);!c&&l.position==="fixed"&&(r=null),(s?!c&&!r:!c&&l.position==="static"&&!!r&&Bb.has(r.position)||Ho(i)&&!c&&oh(n,i))?o=o.filter(u=>u!==i):r=l,i=on(i)}return e.set(n,o),o}function Rb(n){let{element:e,boundary:t,rootBoundary:o,strategy:r}=n;const i=[...t==="clippingAncestors"?Ss(e)?[]:Ob(e,this._c):[].concat(t),o],l=i[0],c=i.reduce((d,u)=>{const f=nh(e,u,r);return d.top=Mn(f.top,d.top),d.right=ms(f.right,d.right),d.bottom=ms(f.bottom,d.bottom),d.left=Mn(f.left,d.left),d},nh(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Pb(n){const{width:e,height:t}=Qf(n);return{width:e,height:t}}function Db(n,e,t){const o=wt(e),r=kt(e),s=t==="fixed",i=An(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=yt(0);function d(){c.x=vs(r)}if(o||!o&&!s)if((Nn(e)!=="body"||Ho(r))&&(l=Es(e)),o){const p=An(e,!0,s,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else r&&d();s&&!o&&r&&d();const u=r&&!o&&!s?eh(r,l):yt(0),f=i.left+l.scrollLeft-c.x-u.x,h=i.top+l.scrollTop-c.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function Ll(n){return it(n).position==="static"}function rh(n,e){if(!wt(n)||it(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return kt(n)===t&&(t=t.ownerDocument.body),t}function sh(n,e){const t=We(n);if(Ss(n))return t;if(!wt(n)){let r=on(n);for(;r&&!Jn(r);){if(st(r)&&!Ll(r))return r;r=on(r)}return t}let o=rh(n,e);for(;o&&yb(o)&&Ll(o);)o=rh(o,e);return o&&Jn(o)&&Ll(o)&&!Rl(o)?t:o||xb(n)||t}const _b=async function(n){const e=this.getOffsetParent||sh,t=this.getDimensions,o=await t(n.floating);return{reference:Db(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Lb(n){return it(n).direction==="rtl"}const Vb={convertOffsetParentRelativeRectToViewportRelativeRect:Mb,getDocumentElement:kt,getClippingRect:Rb,getOffsetParent:sh,getElementRects:_b,getClientRects:Tb,getDimensions:Pb,getScale:Yn,isElement:st,isRTL:Lb};function ih(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function $b(n,e){let t=null,o;const r=kt(n);function s(){var l;clearTimeout(o),(l=t)==null||l.disconnect(),t=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=n.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=d;if(l||e(),!h||!p)return;const m=ys(f),g=ys(r.clientWidth-(u+h)),y=ys(r.clientHeight-(f+p)),k=ys(u),C={rootMargin:-m+"px "+-g+"px "+-y+"px "+-k+"px",threshold:Mn(0,ms(1,c))||1};let x=!0;function S(M){const E=M[0].intersectionRatio;if(E!==c){if(!x)return i();E?i(!1,E):o=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!ih(d,n.getBoundingClientRect())&&i(),x=!1}try{t=new IntersectionObserver(S,{...C,root:r.ownerDocument})}catch{t=new IntersectionObserver(S,C)}t.observe(n)}return i(!0),s}function Ms(n,e,t,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,d=_l(n),u=r||s?[...d?Uo(d):[],...Uo(e)]:[];u.forEach(k=>{r&&k.addEventListener("scroll",t,{passive:!0}),s&&k.addEventListener("resize",t)});const f=d&&l?$b(d,t):null;let h=-1,p=null;i&&(p=new ResizeObserver(k=>{let[w]=k;w&&w.target===d&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(e)})),t()}),d&&!c&&p.observe(d),p.observe(e));let m,g=c?An(n):null;c&&y();function y(){const k=An(n);g&&!ih(g,k)&&t(),g=k,m=requestAnimationFrame(y)}return t(),()=>{var k;u.forEach(w=>{r&&w.removeEventListener("scroll",t),s&&w.removeEventListener("resize",t)}),f==null||f(),(k=p)==null||k.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const Xn=hb,Qn=pb,Zn=db,zb=(n,e,t)=>{const o=new Map,r={platform:Vb,...t},s={...r.platform,_c:o};return cb(n,e,{...r,platform:s})};function Fb(n){return n!=null&&typeof n=="object"&&"$el"in n}function lh(n){if(Fb(n)){const e=n.$el;return Ol(e)&&Nn(e)==="#comment"?null:e}return n}function jo(n){return typeof n=="function"?n():a.unref(n)}function ah(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function ch(n,e){const t=ah(n);return Math.round(e*t)/t}function eo(n,e,t){t===void 0&&(t={});const o=t.whileElementsMounted,r=a.computed(()=>{var E;return(E=jo(t.open))!=null?E:!0}),s=a.computed(()=>jo(t.middleware)),i=a.computed(()=>{var E;return(E=jo(t.placement))!=null?E:"bottom"}),l=a.computed(()=>{var E;return(E=jo(t.strategy))!=null?E:"absolute"}),c=a.computed(()=>{var E;return(E=jo(t.transform))!=null?E:!0}),d=a.computed(()=>lh(n.value)),u=a.computed(()=>lh(e.value)),f=a.ref(0),h=a.ref(0),p=a.ref(l.value),m=a.ref(i.value),g=a.shallowRef({}),y=a.ref(!1),k=a.computed(()=>{const E={position:p.value,left:"0",top:"0"};if(!u.value)return E;const v=ch(u.value,f.value),T=ch(u.value,h.value);return c.value?{...E,transform:"translate("+v+"px, "+T+"px)",...ah(u.value)>=1.5&&{willChange:"transform"}}:{position:p.value,left:v+"px",top:T+"px"}});let w;function C(){if(d.value==null||u.value==null)return;const E=r.value;zb(d.value,u.value,{middleware:s.value,placement:i.value,strategy:l.value}).then(v=>{f.value=v.x,h.value=v.y,p.value=v.strategy,m.value=v.placement,g.value=v.middlewareData,y.value=E!==!1})}function x(){typeof w=="function"&&(w(),w=void 0)}function S(){if(x(),o===void 0){C();return}if(d.value!=null&&u.value!=null){w=o(d.value,u.value,C);return}}function M(){r.value||(y.value=!1)}return a.watch([s,i,l,r],C,{flush:"sync"}),a.watch([d,u],S,{flush:"sync"}),a.watch(r,M,{flush:"sync"}),a.getCurrentScope()&&a.onScopeDispose(x),{x:a.shallowReadonly(f),y:a.shallowReadonly(h),strategy:a.shallowReadonly(p),placement:a.shallowReadonly(m),middlewareData:a.shallowReadonly(g),isPositioned:a.shallowReadonly(y),floatingStyles:k,update:C}}const Hb=["menu-open"],Ke=a.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(n,{emit:e}){const t=n,o=e,r=a.inject("containerRef"),s=a.inject(sa,null),i=a.inject(ia,0),l=Math.random().toString(36).slice(2);a.provide(ia,i+1);const{show:c,hide:d}=Dt(),u=a.ref(!1);s&&a.watch(()=>s.value.get(i),C=>{C!==void 0&&C!==l&&u.value&&(u.value=!1)});const f=a.ref(null),h=a.ref(null),{floatingStyles:p}=eo(f,h,{placement:t.placement,middleware:[Xn(t.offsetPx),Zn(),Qn({padding:8})],whileElementsMounted:Ms});function m(){t.disabled||(u.value=!u.value)}function g(){u.value=!1}function y(C){var v,T,D;const x=C.target,S=(v=f.value)==null?void 0:v.contains(x),M=(T=h.value)==null?void 0:T.contains(x),E=(D=x.closest)==null?void 0:D.call(x,".wov-menu-dropdown");!S&&!M&&!E&&g()}function k(){t.title&&f.value&&!u.value&&c(t.title,f.value)}function w(){d()}return a.watch(u,C=>{C?(d(),document.addEventListener("click",y,!0),s&&(s.value.set(i,l),s.value=new Map(s.value)),o("open")):(document.removeEventListener("click",y,!0),(s==null?void 0:s.value.get(i))===l&&(s.value.delete(i),s.value=new Map(s.value)),o("close"))}),a.onUnmounted(()=>{document.removeEventListener("click",y,!0)}),(C,x)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:a.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:x[0]||(x[0]=a.withModifiers(()=>{},["prevent"])),onClick:m,onMouseenter:k,onMouseleave:w},[a.renderSlot(C.$slots,"button",{isOpen:u.value})],42,Hb),a.unref(r)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(r)},[u.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"wov-menu-dropdown",style:a.normalizeStyle(a.unref(p))},[a.renderSlot(C.$slots,"dropdown",{close:g})],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),Ub={},jb={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function Wb(n,e){return a.openBlock(),a.createElementBlock("svg",jb,[...e[0]||(e[0]=[a.createElementVNode("path",{d:"M233.4 278.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 210.7 86.6 41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"},null,-1)])])}const qe=an(Ub,[["render",Wb]]),Kb={class:"wov-menu-button"},qb=["innerHTML"],Gb=["onClick"],Jb=["innerHTML"],Vl=a.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=a.shallowRef(null),r=a.computed(()=>{const l=o.value??(e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V);return On(l)});t(l=>{let c=null;for(const d of e.entityIds){if(b.hasComponent(l,d,ee.ElbowArrow)){const u=ee.ElbowArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V;return}}if(b.hasComponent(l,d,ee.ArcArrow)){const u=ee.ArcArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V;return}}}o.value=c});function s(l){o.value=l,t(c=>{for(const d of e.entityIds){if(b.hasComponent(c,d,ee.ElbowArrow)){const u=ee.ElbowArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}if(b.hasComponent(c,d,ee.ArcArrow)){const u=ee.ArcArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}}})}function i(l){if(!l)return"";const c=e.side==="start";return`<line x1="${c?8:4}" y1="12" x2="${c?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${c?4:20}, 12) scale(${c?"-0.8, 0.8":"0.8"})`}">${l.svg}</g>`}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:n.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:a.withCtx(()=>[a.createElementVNode("div",Kb,[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(r.value)},null,8,qb)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(a.unref(Ds),d=>(a.openBlock(),a.createElementBlock("button",{key:d.kind,class:a.normalizeClass(["wov-menu-option",{"is-active":o.value===d.kind}]),onClick:u=>s(d.kind)},[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(d)},null,8,Jb))],10,Gb))),128))]),_:1},8,["title"]))}}),Yb={class:"wov-menu-button"},Xb=["onClick"],dh=a.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],t=n,{nextEditorTick:o}=de(),r=a.shallowRef(null);o(i=>{let l=null;for(const c of t.entityIds){if(b.hasComponent(i,c,ee.ElbowArrow)){const d=ee.ElbowArrow.read(i,c);if(l===null)l=d.thickness;else if(d.thickness!==l){r.value=null;return}}if(b.hasComponent(i,c,ee.ArcArrow)){const d=ee.ArcArrow.getThickness(i,c);if(l===null)l=d;else if(d!==l){r.value=null;return}}}r.value=l});function s(i){r.value=i,o(l=>{for(const c of t.entityIds){if(b.hasComponent(l,c,ee.ElbowArrow)){const d=ee.ElbowArrow.write(l,c);d.thickness=i}b.hasComponent(l,c,ee.ArcArrow)&&ee.ArcArrow.setThickness(l,c,i)}})}return(i,l)=>(a.openBlock(),a.createBlock(Ke,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",Yb,[l[0]||(l[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,c=>a.createElementVNode("button",{key:c.value,class:a.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":r.value===c.value}]),onClick:d=>s(c.value)},a.toDisplayString(c.label),11,Xb)),64))]),_:1}))}}),Qb=["value"],Zb=a.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(t.modelValue??"");a.watch(()=>t.modelValue,u=>{u&&u!==r.value&&(r.value=u)});function s(u){const f=u.startsWith("#")?u:`#${u}`;return/^#[0-9A-Fa-f]{6}$/.test(f)}function i(u){return(u.startsWith("#")?u:`#${u}`).toLowerCase()}function l(u){let h=u.target.value;if((h.length===6||h.length===7)&&s(h)){const p=i(h);r.value=p,o("update:modelValue",p)}}function c(u){const h=u.target.value;if(h&&s(h)){const p=i(h);r.value=p,o("update:modelValue",p)}else t.modelValue&&(r.value=t.modelValue)}function d(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,h=f.value;if(h&&s(h)){const p=i(h);r.value=p,o("update:modelValue",p),setTimeout(()=>f.select())}}}return(u,f)=>(a.openBlock(),a.createElementBlock("input",{id:"wov-color-input",class:"wov-color-input",type:"text",size:"1","aria-label":"Hex color value",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",value:r.value,onInput:l,onChange:c,onKeydown:d},null,40,Qb))}}),uh=a.defineComponent({__name:"ColorSlider",props:{modelValue:{},thumbColor:{},background:{}},emits:["update:modelValue"],setup(n,{expose:e,emit:t}){const o=t,r=a.ref(null),s=a.ref(!1);function i(d){s.value=!0,l(d),window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)}function l(d){if(!r.value)return;const u=r.value.getBoundingClientRect(),f=Math.max(0,Math.min(100,(d.clientY-u.top)/u.height*100));o("update:modelValue",f)}function c(){s.value=!1,window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)}return e({isDragging:s}),(d,u)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"sliderRef",ref:r,class:"wov-color-slider",onPointerdown:a.withModifiers(i,["prevent"])},[n.background?(a.openBlock(),a.createElementBlock("div",{key:0,class:"wov-color-slider-gradient",style:a.normalizeStyle({background:n.background})},null,4)):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"wov-color-slider-thumb",style:a.normalizeStyle({top:`${n.modelValue}%`,backgroundColor:n.thumbColor})},null,4)],544))}}),e2={class:"wov-color-picker"},t2={class:"wov-color-picker-area"},n2={class:"wov-color-picker-selector-gradient"},o2="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",fh=a.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),s=a.ref(null),i=a.ref(null),l=a.ref({x:100,y:0}),c=a.ref(0),d=a.ref(0),u=a.ref(!1),f=a.computed(()=>{var M,E;return u.value||((M=r.value)==null?void 0:M.isDragging)||((E=s.value)==null?void 0:E.isDragging)}),h=a.computed(()=>({h:c.value/100*360,s:l.value.x,v:100-l.value.y,a:(100-d.value)/100*255})),p=a.computed(()=>Rf({h:h.value.h,s:100,v:100})),m=a.computed(()=>Rf({h:h.value.h,s:h.value.s,v:h.value.v})),g=a.computed(()=>t.withOpacity?Pf(h.value):m.value),y=a.computed(()=>`linear-gradient(to top, transparent 0%, ${m.value} 100%)`);function k(M){if(M){const E=Of(M);l.value={x:E.s,y:100-E.v},c.value=E.h/360*100,d.value=100-E.a/255*100}}function w(M){k(M),o("update:modelValue",t.withOpacity?Pf(Of(M)):M)}k(t.modelValue),a.watch(()=>t.modelValue,M=>{f.value||k(M)}),a.watch([l,c,d],()=>{f.value&&o("update:modelValue",g.value)});function C(M){u.value=!0,x(M),window.addEventListener("pointermove",x),window.addEventListener("pointerup",S)}function x(M){if(!i.value)return;const E=i.value.getBoundingClientRect(),v=Math.max(0,Math.min(100,(M.clientX-E.left)/E.width*100)),T=Math.max(0,Math.min(100,(M.clientY-E.top)/E.height*100));l.value={x:v,y:T}}function S(){u.value=!1,window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",S)}return(M,E)=>(a.openBlock(),a.createElementBlock("div",e2,[a.createVNode(Zb,{modelValue:g.value,"onUpdate:modelValue":w},null,8,["modelValue"]),a.createElementVNode("div",t2,[a.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:a.normalizeStyle({backgroundColor:p.value}),onPointerdown:a.withModifiers(C,["prevent"])},[a.createElementVNode("div",n2,[a.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:a.normalizeStyle({left:`${l.value.x}%`,top:`${l.value.y}%`,backgroundColor:m.value})},null,4)])],36),a.createVNode(uh,{ref_key:"hueSliderRef",ref:r,modelValue:c.value,"onUpdate:modelValue":E[0]||(E[0]=v=>c.value=v),thumbColor:p.value,background:o2},null,8,["modelValue","thumbColor"]),n.withOpacity?(a.openBlock(),a.createBlock(uh,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:d.value,"onUpdate:modelValue":E[1]||(E[1]=v=>d.value=v),thumbColor:m.value,background:y.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):a.createCommentVNode("",!0)])]))}}),r2={class:"wov-color-bubbles-container"},s2={key:1,class:"wov-color-bubbles"},i2=["onClick"],Ts=a.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(n,{emit:e}){const t=n,o=e,r=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=a.computed(()=>{const m=t.palette??r,g=t.withPicker,y=m.length%2===1;return g&&!y||!g&&y?m.slice(0,-1):m}),i=a.ref(!1),l=a.ref(t.currentColor??"#ff0000");function c(m,g){const y=k=>{const w=k.replace(/^#/,"").toLowerCase();return w.length===6?w+"ff":w};return y(m)===y(g)}function d(m){return t.hideHighlight||!t.currentColor?!1:c(t.currentColor,m)}function u(){return t.hideHighlight||!t.currentColor?!1:!s.value.some(m=>c(t.currentColor,m))}function f(m){const g=El(m);g&&o("change",g)}function h(){!i.value&&t.currentColor&&(l.value=t.currentColor),i.value=!i.value,o("picker-open",i.value)}function p(m){l.value=m;const g=El(m);g&&o("change",g)}return(m,g)=>(a.openBlock(),a.createElementBlock("div",r2,[i.value?(a.openBlock(),a.createBlock(fh,{key:0,modelValue:l.value,"onUpdate:modelValue":[g[0]||(g[0]=y=>l.value=y),p],withOpacity:n.withOpacity},null,8,["modelValue","withOpacity"])):(a.openBlock(),a.createElementBlock("div",s2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,y=>(a.openBlock(),a.createElementBlock("div",{key:y,class:a.normalizeClass(["wov-color-bubble",{selected:d(y)}]),style:a.normalizeStyle({backgroundColor:y}),onMousedown:g[1]||(g[1]=a.withModifiers(()=>{},["prevent"])),onClick:k=>f(y)},null,46,i2))),128)),n.withPicker?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:g[2]||(g[2]=a.withModifiers(()=>{},["prevent"])),onClick:h},null,34)):a.createCommentVNode("",!0)]))]))}}),l2={class:"wov-color-button"},hh=a.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Color),r=a.computed(()=>{const d=new Set;for(const u of o.value.values())if(u){const f=zo(u);d.add(f)}return Array.from(d)}),s=a.computed(()=>r.value.length>1),i=a.computed(()=>r.value[0]??null),l=a.computed(()=>{if(r.value.length===0)return{backgroundColor:"#000"};if(r.value.length>=2){const d=r.value[0],u=r.value[1];return{background:`linear-gradient(45deg, ${d} 0%, ${d} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:r.value[0]}});function c(d){const u=zo(d);t(f=>{for(const h of e.entityIds)b.Color.fromHex(f,h,u)})}return(d,u)=>(a.openBlock(),a.createBlock(Ke,{title:"Color"},{button:a.withCtx(()=>[a.createElementVNode("div",l2,[a.createElementVNode("div",{class:"wov-color-swatch",style:a.normalizeStyle(l.value)},null,4),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(Ts,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:c},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Bn=a.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),{show:s,hide:i}=Dt();function l(u){o("click",u)}function c(){t.title&&r.value&&s(t.title,r.value)}function d(){i()}return(u,f)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:"wov-menu-button",onClick:l,onMouseenter:c,onMouseleave:d},[a.renderSlot(u.$slots,"default")],544))}}),$l=a.defineComponent({__name:"MenuTooltip",setup(n){const{activeTooltip:e,isVisible:t}=Dt(),o=a.inject("containerRef"),r=a.ref(null),s=a.computed(()=>{var c;return((c=e.value)==null?void 0:c.anchor)??null}),{floatingStyles:i}=eo(s,r,{placement:"top",middleware:[Xn(8),Zn({fallbackPlacements:["bottom"]}),Qn({padding:8})]}),l=a.computed(()=>{var c;return t.value&&((c=e.value)==null?void 0:c.text)});return(c,d)=>a.unref(o)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(o)},[a.createVNode(a.Transition,{name:"wov-tooltip-fade"},{default:a.withCtx(()=>{var u;return[l.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:r,class:"wov-menu-tooltip",style:a.normalizeStyle(a.unref(i))},a.toDisplayString((u=a.unref(e))==null?void 0:u.text),5)):a.createCommentVNode("",!0)]}),_:1})],8,["to"])):a.createCommentVNode("",!0)}}),a2={class:"wov-menu-button"},c2=["onClick"],ph=a.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],t=n,{nextEditorTick:o}=de(),r=Rt(()=>t.entityIds,qo.PenStroke),s=a.computed(()=>{let l=null;for(const c of r.value.values())if(c){if(l===null)l=c.thickness;else if(c.thickness!==l)return null}return l});function i(l){o(c=>{for(const d of t.entityIds){const u=qo.PenStroke.write(c,d);u.thickness=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",a2,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("button",{key:d.value,class:a.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===d.value}]),onClick:u=>i(d.value)},a.toDisplayString(d.label),11,c2)),64))]),_:1}))}}),d2={class:"wov-fill-color-button"},u2={class:"wov-fill-dropdown"},f2={key:0,class:"wov-fill-mode-section"},h2=["title","onClick"],p2={viewBox:"0 0 24 24",fill:"none"},m2=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],mh=a.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Shape),r=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=a.computed(()=>{const p=o.value.values().next().value,m=(p==null?void 0:p.fillAlpha)??255;return m===0?"none":m<200?"faded":"solid"}),i=a.computed(()=>{const p=new Set;for(const m of o.value.values())if(m){const g=m.fillAlpha??255;g===0?p.add("none"):g<200?p.add("faded"):p.add("solid")}return p.size>1});function l(p){t(m=>{for(const g of e.entityIds){const y=b.Shape.write(m,g);y.fillAlpha=p}})}const c=a.computed(()=>{const p=new Set;for(const m of o.value.values())if(m){const g=zo({red:m.fillRed,green:m.fillGreen,blue:m.fillBlue,alpha:m.fillAlpha??255});p.add(g)}return Array.from(p)}),d=a.computed(()=>c.value.length>1),u=a.computed(()=>c.value[0]??"#4a90d9");function f(p){t(m=>{for(const g of e.entityIds){const y=b.Shape.write(m,g);y.fillRed=p.red,y.fillGreen=p.green,y.fillBlue=p.blue,y.fillAlpha=p.alpha}})}const h=a.ref(!1);return(p,m)=>(a.openBlock(),a.createBlock(Ke,{title:"Fill Color"},{button:a.withCtx(()=>[a.createElementVNode("div",d2,[m[1]||(m[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M5.879,2.625L14.121,2.625C15.906,2.625 17.375,4.094 17.375,5.879L17.375,14.121C17.375,15.906 15.906,17.375 14.121,17.375L5.88,17.375C4.095,17.375 2.626,15.906 2.626,14.121L2.626,5.88C2.626,4.095 4.095,2.626 5.88,2.626L5.879,2.625Z","stroke-width":"1.25"}),a.createElementVNode("path",{d:"M2.779,14.655L14.543,2.871M10.238,17.308L17.318,10.229M2.876,9.577L9.853,2.6M5.397,17.239L17.16,5.476","stroke-width":"1.25"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",u2,[h.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",f2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,g=>a.createElementVNode("button",{key:g.mode,class:a.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&g.mode===s.value}]),title:g.label,onClick:y=>l(g.alpha)},[(a.openBlock(),a.createElementBlock("svg",p2,[a.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:g.mode==="none"?"none":"currentColor","fill-opacity":g.mode==="faded"?.4:1,stroke:g.mode==="none"?"currentColor":"none","stroke-width":g.mode==="none"?1.5:0,"stroke-dasharray":g.mode==="none"?"3 3":""},null,8,m2)])),a.createElementVNode("span",null,a.toDisplayString(g.label),1)],10,h2)),64))])),a.createVNode(Ts,{currentColor:u.value,hideHighlight:d.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:m[0]||(m[0]=g=>h.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),g2={class:"wov-shape-kind-button"},y2={class:"wov-shape-kind-dropdown"},k2=["onClick"],w2={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},b2=["d"],gh=a.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Shape),r=a.computed(()=>{const c=o.value.values().next().value;return(c==null?void 0:c.kind)??"rectangle"}),s=a.computed(()=>{const c=new Set;for(const d of o.value.values())d&&c.add(d.kind);return c.size>1}),i=a.computed(()=>Object.keys(ro).map(c=>({kind:c,label:c.charAt(0).toUpperCase()+c.slice(1)})));function l(c){t(d=>{for(const u of e.entityIds){const f=b.Shape.write(d,u);f.kind=c}})}return(c,d)=>(a.openBlock(),a.createBlock(Ke,{title:"Shape Type"},{button:a.withCtx(()=>[a.createElementVNode("div",g2,[d[0]||(d[0]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),a.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",y2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,u=>(a.openBlock(),a.createElementBlock("button",{key:u.kind,class:a.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===r.value}]),onClick:f=>l(u.kind)},[(a.openBlock(),a.createElementBlock("svg",w2,[a.createElementVNode("path",{d:a.unref(ro)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,b2)])),a.createElementVNode("span",null,a.toDisplayString(u.label),1)],10,k2))),128))])]),_:1}))}}),C2={class:"wov-stroke-style-section"},x2=["title","onClick"],S2={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},E2=["stroke-dasharray","stroke-opacity"],v2=a.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(n,{emit:e}){const t=e,o=[{kind:b.StrokeKind.Solid,label:"Solid"},{kind:b.StrokeKind.Dashed,label:"Dashed"},{kind:b.StrokeKind.None,label:"None"}];function r(i){switch(i){case b.StrokeKind.Dashed:return"6 6";case b.StrokeKind.None:return"";case b.StrokeKind.Solid:default:return""}}function s(i){t("change",i)}return(i,l)=>(a.openBlock(),a.createElementBlock("div",C2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(o,c=>a.createElementVNode("button",{key:c.kind,class:a.normalizeClass(["wov-stroke-style-option",{"is-active":!n.hasMultipleStyles&&c.kind===n.currentStyle}]),title:c.label,onClick:d=>s(c.kind)},[(a.openBlock(),a.createElementBlock("svg",S2,[a.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":r(c.kind),"stroke-opacity":c.kind===a.unref(b.StrokeKind).None?.3:1},null,8,E2)])),a.createElementVNode("span",null,a.toDisplayString(c.label),1)],10,x2)),64))]))}}),M2={class:"wov-stroke-color-button"},T2={class:"wov-stroke-dropdown"},N2={key:1,class:"wov-stroke-divider"},yh=a.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Shape),r=a.ref(!1),s=a.computed(()=>{const h=new Set;for(const p of o.value.values())if(p){const m=zo({red:p.strokeRed,green:p.strokeGreen,blue:p.strokeBlue,alpha:255});h.add(m)}return Array.from(h)}),i=a.computed(()=>s.value.length>1),l=a.computed(()=>s.value[0]??"#000000"),c=a.computed(()=>{const h=o.value.values().next().value;return(h==null?void 0:h.strokeKind)??b.StrokeKind.Solid}),d=a.computed(()=>{const h=new Set;for(const p of o.value.values())p&&h.add(p.strokeKind);return h.size>1});function u(h){t(p=>{for(const m of e.entityIds){const g=b.Shape.write(p,m);g.strokeRed=h.red,g.strokeGreen=h.green,g.strokeBlue=h.blue}})}function f(h){t(p=>{for(const m of e.entityIds){const g=b.Shape.write(p,m);g.strokeKind=h}})}return(h,p)=>(a.openBlock(),a.createBlock(Ke,{title:"Stroke Color"},{button:a.withCtx(()=>[a.createElementVNode("div",M2,[p[1]||(p[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43","stroke-width":"1.25"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",T2,[r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createBlock(v2,{key:0,currentStyle:c.value,hasMultipleStyles:d.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",N2)),a.createVNode(Ts,{currentColor:l.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:p[0]||(p[0]=m=>r.value=m)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),A2={class:"wov-tape-image-button"},B2={class:"wov-tape-image-bubbles"},I2=["onClick"],kh=a.defineComponent({__name:"TapeImageButton",props:{entityIds:{}},setup(n){const e=[{name:"Masking Tape",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media"},{name:"Transparent",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F522899b7-0ae9-4303-bdca-71105d835210.png?generation=1715183195130528&alt=media"},{name:"Arabic",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F3658d208-67e9-48a4-865b-44842187b523.png?generation=1715183192038109&alt=media"},{name:"Balloons",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7d836c56-ae9a-44e6-a624-e6a49286dcde.png?generation=1715183193267076&alt=media"},{name:"Flowers",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2Fc1a1b89a-543f-4817-8afa-76544e94d776.png?generation=1715183194007112&alt=media"}],t=n,{nextEditorTick:o}=de(),r=Rt(()=>t.entityIds,b.Asset),s=a.computed(()=>{for(const l of r.value.values())if(l!=null&&l.identifier)return l.identifier;return null});function i(l){o(c=>{for(const d of t.entityIds){const u=b.Asset.write(c,d);u.identifier=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:"Tape Style"},{button:a.withCtx(()=>[a.createElementVNode("div",A2,[a.createElementVNode("div",{class:"wov-tape-image-swatch",style:a.normalizeStyle(s.value?{backgroundImage:`url(${s.value})`}:{})},null,4),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",B2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("div",{key:d.url,class:a.normalizeClass(["wov-tape-image-bubble",{selected:s.value===d.url}]),style:a.normalizeStyle({backgroundImage:`url(${d.url})`}),onMousedown:c[0]||(c[0]=a.withModifiers(()=>{},["prevent"])),onClick:u=>i(d.url)},null,46,I2)),64))])]),_:1}))}}),O2={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},R2={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},P2={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},D2={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},zl=a.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=[b.TextAlignment.Left,b.TextAlignment.Center,b.TextAlignment.Right,b.TextAlignment.Justify];function s(){const i=r.indexOf(t.alignment),l=r[(i+1)%r.length];o.setAlignment(l)}return(i,l)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Text Align",onClick:s},{default:a.withCtx(()=>[a.unref(t).alignment===a.unref(b.TextAlignment).Left?(a.openBlock(),a.createElementBlock("svg",O2,[...l[0]||(l[0]=[a.createElementVNode("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):a.unref(t).alignment===a.unref(b.TextAlignment).Center?(a.openBlock(),a.createElementBlock("svg",R2,[...l[1]||(l[1]=[a.createElementVNode("path",{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},null,-1)])])):a.unref(t).alignment===a.unref(b.TextAlignment).Right?(a.openBlock(),a.createElementBlock("svg",P2,[...l[2]||(l[2]=[a.createElementVNode("path",{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",D2,[...l[3]||(l[3]=[a.createElementVNode("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),Fl=a.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Bold",class:a.normalizeClass({"wov-active":a.unref(t).isBold}),onClick:a.unref(o).toggleBold},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}});function _2(n,e){return a.getCurrentScope()?(a.onScopeDispose(n,e),!0):!1}const L2=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const V2=Object.prototype.toString,$2=n=>V2.call(n)==="[object Object]",Ns=()=>{};function As(n){return Array.isArray(n)?n:[n]}function z2(n){return a.getCurrentInstance()}function F2(n,e=!0,t){z2()?a.onMounted(n,t):e?n():a.nextTick(n)}function H2(n,e,t){return a.watch(n,e,{...t,immediate:!0})}const Bs=L2?window:void 0;function lt(n){var e;const t=a.toValue(n);return(e=t==null?void 0:t.$el)!==null&&e!==void 0?e:t}function Hl(...n){const e=(o,r,s,i)=>(o.addEventListener(r,s,i),()=>o.removeEventListener(r,s,i)),t=a.computed(()=>{const o=As(a.toValue(n[0])).filter(r=>r!=null);return o.every(r=>typeof r!="string")?o:void 0});return H2(()=>{var o,r;return[(o=(r=t.value)===null||r===void 0?void 0:r.map(s=>lt(s)))!==null&&o!==void 0?o:[Bs].filter(s=>s!=null),As(a.toValue(t.value?n[1]:n[0])),As(a.unref(t.value?n[2]:n[1])),a.toValue(t.value?n[3]:n[2])]},([o,r,s,i],l,c)=>{if(!(o!=null&&o.length)||!(r!=null&&r.length)||!(s!=null&&s.length))return;const d=$2(i)?{...i}:i,u=o.flatMap(f=>r.flatMap(h=>s.map(p=>e(f,h,p,d))));c(()=>{u.forEach(f=>f())})},{flush:"post"})}function U2(n,e,t={}){const{window:o=Bs,ignore:r=[],capture:s=!0,detectIframe:i=!1,controls:l=!1}=t;if(!o)return l?{stop:Ns,cancel:Ns,trigger:Ns}:Ns;let c=!0;const d=y=>a.toValue(r).some(k=>{if(typeof k=="string")return Array.from(o.document.querySelectorAll(k)).some(w=>w===y.target||y.composedPath().includes(w));{const w=lt(k);return w&&(y.target===w||y.composedPath().includes(w))}});function u(y){const k=a.toValue(y);return k&&k.$.subTree.shapeFlag===16}function f(y,k){const w=a.toValue(y),C=w.$.subTree&&w.$.subTree.children;return C==null||!Array.isArray(C)?!1:C.some(x=>x.el===k.target||k.composedPath().includes(x.el))}const h=y=>{const k=lt(n);if(y.target!=null&&!(!(k instanceof Element)&&u(n)&&f(n,y))&&!(!k||k===y.target||y.composedPath().includes(k))){if("detail"in y&&y.detail===0&&(c=!d(y)),!c){c=!0;return}e(y)}};let p=!1;const m=[Hl(o,"click",y=>{p||(p=!0,setTimeout(()=>{p=!1},0),h(y))},{passive:!0,capture:s}),Hl(o,"pointerdown",y=>{const k=lt(n);c=!d(y)&&!!(k&&!y.composedPath().includes(k))},{passive:!0}),i&&Hl(o,"blur",y=>{setTimeout(()=>{var k;const w=lt(n);((k=o.document.activeElement)===null||k===void 0?void 0:k.tagName)==="IFRAME"&&!(w!=null&&w.contains(o.document.activeElement))&&e(y)},0)},{passive:!0})].filter(Boolean),g=()=>m.forEach(y=>y());return l?{stop:g,cancel:()=>{c=!1},trigger:y=>{c=!0,h(y),c=!1}}:g}function j2(){const n=a.shallowRef(!1),e=a.getCurrentInstance();return e&&a.onMounted(()=>{n.value=!0},e),n}function W2(n){const e=j2();return a.computed(()=>(e.value,!!n()))}function K2(n,e,t={}){const{window:o=Bs,...r}=t;let s;const i=W2(()=>o&&"ResizeObserver"in o),l=()=>{s&&(s.disconnect(),s=void 0)},c=a.watch(a.computed(()=>{const u=a.toValue(n);return Array.isArray(u)?u.map(f=>lt(f)):[lt(u)]}),u=>{if(l(),i.value&&o){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,r)}},{immediate:!0,flush:"post"}),d=()=>{l(),c()};return _2(d),{isSupported:i,stop:d}}function wh(n,e={width:0,height:0},t={}){const{window:o=Bs,box:r="content-box"}=t,s=a.computed(()=>{var f;return(f=lt(n))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=a.shallowRef(e.width),l=a.shallowRef(e.height),{stop:c}=K2(n,([f])=>{const h=r==="border-box"?f.borderBoxSize:r==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(o&&s.value){const p=lt(n);if(p){const m=p.getBoundingClientRect();i.value=m.width,l.value=m.height}}else if(h){const p=As(h);i.value=p.reduce((m,{inlineSize:g})=>m+g,0),l.value=p.reduce((m,{blockSize:g})=>m+g,0)}else i.value=f.contentRect.width,l.value=f.contentRect.height},t);F2(()=>{const f=lt(n);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,l.value="offsetHeight"in f?f.offsetHeight:e.height)});const d=a.watch(()=>lt(n),f=>{i.value=f?e.width:0,l.value=f?e.height:0});function u(){c(),d()}return{width:i,height:l,stop:u}}function bh(){const n=a.inject(He);if(!n)throw new Error("useFonts must be used within a WovenCanvas component");return a.computed(()=>{const e=n.getEditor();return e?e.fonts.filter(t=>t.selectable):[]})}const q2={class:"wov-font-family-button"},G2={class:"wov-font-family-label"},J2={class:"wov-font-list"},Y2=["onClick"],X2=["src","alt"],Ul=a.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=bh(),s=a.computed(()=>r.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=a.computed(()=>t.fontFamily),l=a.computed(()=>{const u=i.value;if(u===null)return"Mixed";const f=s.value.find(h=>h.name===u);return(f==null?void 0:f.displayName)??u});function c(u){o.setFontFamily(u)}function d(u){u.stopPropagation()}return(u,f)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Font Family"},{button:a.withCtx(()=>[a.createElementVNode("div",q2,[a.createElementVNode("span",G2,a.toDisplayString(l.value),1),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-family-menu",onWheel:d,onClick:f[0]||(f[0]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",J2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,h=>(a.openBlock(),a.createElementBlock("div",{key:h.name,class:a.normalizeClass(["wov-font-item",{active:i.value===h.name}]),onClick:p=>c(h.name)},[h.previewImage?(a.openBlock(),a.createElementBlock("img",{key:0,class:"wov-font-preview",src:h.previewImage,alt:h.name},null,8,X2)):(a.openBlock(),a.createElementBlock("span",{key:1,class:"wov-font-name",style:a.normalizeStyle({fontFamily:h.name})},a.toDisplayString(h.displayName),5))],10,Y2))),128))])],32)]),_:1})):a.createCommentVNode("",!0)}}),Q2={class:"wov-font-size-button"},Z2={class:"wov-font-size-label"},eC=["onClick"],tC={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},nC={class:"wov-input-container"},oC=["value"],jl=a.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=[{label:"Small",value:16,displayValue:10},{label:"Medium",value:24,displayValue:12},{label:"Large",value:40,displayValue:16},{label:"Huge",value:96,displayValue:20}],s=a.computed(()=>t.fontSize),i=a.computed(()=>{const h=s.value;if(h===null)return"Mixed";const p=r.find(m=>m.value===h);return p?p.label:`${+h.toFixed(1)} px`}),l=a.computed(()=>{const h=s.value;return h===null?"":String(+h.toFixed(1))});function c(h){o.setFontSize(h)}function d(h){const p=h.target,m=Number.parseFloat(p.value);!Number.isNaN(m)&&m>0&&c(m)}function u(h){h.key==="Enter"&&h.target.blur()}function f(h){h.stopPropagation()}return(h,p)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Font Size"},{button:a.withCtx(()=>[a.createElementVNode("div",Q2,[a.createElementVNode("span",Z2,a.toDisplayString(i.value),1),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:p[0]||(p[0]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,m=>a.createElementVNode("div",{key:m.value,class:a.normalizeClass(["wov-font-size-option",{active:s.value===m.value}]),onClick:g=>c(m.value)},[s.value===m.value?(a.openBlock(),a.createElementBlock("svg",tC,[...p[1]||(p[1]=[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},null,-1)])])):a.createCommentVNode("",!0),a.createElementVNode("span",{class:"wov-option-label",style:a.normalizeStyle({fontSize:`${m.displayValue}px`})},a.toDisplayString(m.label),5)],10,eC)),64)),p[3]||(p[3]=a.createElementVNode("div",{class:"wov-separator"},null,-1)),a.createElementVNode("div",nC,[a.createElementVNode("input",{class:"wov-custom-input",value:l.value,onInput:d,onKeydown:u,placeholder:"Custom size"},null,40,oC),p[2]||(p[2]=a.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):a.createCommentVNode("",!0)}}),Wl=a.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Italic",class:a.normalizeClass({"wov-active":a.unref(t).isItalic}),onClick:a.unref(o).toggleItalic},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),Kl=a.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Underline",class:a.normalizeClass({"wov-active":a.unref(t).isUnderline}),onClick:a.unref(o).toggleUnderline},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),rC={class:"wov-link-input-container"},sC=["onKeydown"],ql=a.defineComponent({__name:"TextLinkButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=a.ref(!1),s=a.ref(""),i=a.ref(null),l=a.ref(null),c=a.ref(null),d=a.inject("containerRef"),{floatingStyles:u}=eo(l,c,{placement:"top",middleware:[Xn(8),Zn(),Qn({padding:8})],whileElementsMounted:Ms});function f(){s.value=t.linkHref??"",r.value=!0,a.nextTick(()=>{var g,y;(g=i.value)==null||g.focus(),(y=i.value)==null||y.select()})}function h(){const g=s.value.trim();g?o.setLink(g):o.removeLink(),r.value=!1}function p(){o.removeLink(),s.value="",r.value=!1}function m(g){var k,w;const y=g.target;!((k=l.value)!=null&&k.contains(y))&&!((w=c.value)!=null&&w.contains(y))&&(r.value=!1)}return a.watch(r,g=>{g?document.addEventListener("click",m,!0):document.removeEventListener("click",m,!0)}),(g,y)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:l},[a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Link",class:a.normalizeClass({"wov-active":a.unref(t).linkHref!==null}),onClick:f},{default:a.withCtx(()=>[...y[3]||(y[3]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 7-34.4-7.4-44.6s-34.4-7-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372.1 74 321.1 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.8l-1.1 1.6c-10.3 14.4-7 34.4 7.4 44.6s34.4 7 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})],-1)])]),_:1},8,["class"])):a.createCommentVNode("",!0)],512),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[r.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:c,class:"wov-link-input-dropdown",style:a.normalizeStyle(a.unref(u)),onKeydown:y[2]||(y[2]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",rC,[a.withDirectives(a.createElementVNode("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":y[0]||(y[0]=k=>s.value=k),class:"wov-link-input",placeholder:"Paste or type URL",onKeydown:[a.withKeys(a.withModifiers(h,["prevent"]),["enter"]),y[1]||(y[1]=a.withKeys(a.withModifiers(k=>r.value=!1,["prevent"]),["esc"]))]},null,40,sC),[[a.vModelText,s.value]]),s.value||a.unref(t).linkHref?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-link-action-button",title:"Remove link",onClick:p},[...y[4]||(y[4]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 12.5 32.8 0 45.3s32.8 12.5 45.3 0L237.3 256 342.6 150.6z"})],-1)])])):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-link-action-button",title:"Apply link",onClick:h},[...y[5]||(y[5]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})],-1)])])])],36)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),iC={class:"wov-text-color-button"},lC={class:"wov-text-icon-container"},Gl=a.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=a.computed(()=>t.color??"#000000"),s=a.computed(()=>({backgroundColor:r.value}));function i(l){o.setColor(zo(l))}return(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Text Color"},{button:a.withCtx(()=>[a.createElementVNode("div",iC,[a.createElementVNode("div",lC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createElementVNode("div",{class:"wov-color-underline",style:a.normalizeStyle(s.value)},null,4)]),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(Ts,{currentColor:r.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):a.createCommentVNode("",!0)}}),aC={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-start-icon lucide-align-vertical-justify-start"},cC={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"},dC={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"},Ch=a.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),{state:o}=rt(()=>e.entityIds),r=[b.VerticalAlignment.Top,b.VerticalAlignment.Center,b.VerticalAlignment.Bottom],s=Rt(()=>e.entityIds,b.VerticalAlign),i=a.computed(()=>{let c=null;for(const d of s.value.values()){const u=(d==null?void 0:d.value)??b.VerticalAlignment.Top;if(c===null)c=u;else if(c!==u)return null}return c});function l(){const c=i.value??b.VerticalAlignment.Top,d=r.indexOf(c),u=r[(d+1)%r.length];t(f=>{for(const h of e.entityIds){const p=b.VerticalAlign.write(f,h);p.value=u}})}return(c,d)=>a.unref(o).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Vertical Align",onClick:l},{default:a.withCtx(()=>[i.value===a.unref(b.VerticalAlignment).Top||i.value===null?(a.openBlock(),a.createElementBlock("svg",aC,[...d[0]||(d[0]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===a.unref(b.VerticalAlignment).Center?(a.openBlock(),a.createElementBlock("svg",cC,[...d[1]||(d[1]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",dC,[...d[2]||(d[2]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),uC={class:"wov-text-group-button"},fC={class:"wov-text-group-dropdown"},hC={class:"wov-text-group-row wov-text-group-row-full"},pC={class:"wov-text-group-row"},mC=a.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(n){const e=n,{state:t}=rt(()=>e.entityIds),o=a.inject("containerRef"),{width:r}=wh(o),s=a.computed(()=>r.value>0&&r.value<600),i=a.ref(new Map);return a.provide(sa,i),(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[s.value?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Text Formatting",placement:"top"},{button:a.withCtx(()=>[a.createElementVNode("div",uC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",fC,[a.createElementVNode("div",hC,[a.createVNode(Ul,{entityIds:n.entityIds},null,8,["entityIds"]),c[1]||(c[1]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(jl,{entityIds:n.entityIds},null,8,["entityIds"])]),a.createElementVNode("div",pC,[a.createVNode(Fl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Wl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Kl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(ql,{entityIds:n.entityIds},null,8,["entityIds"]),c[2]||(c[2]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(Gl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(zl,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Ch,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)])])]),_:1})):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createVNode(Ul,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(jl,{entityIds:n.entityIds},null,8,["entityIds"]),c[3]||(c[3]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Fl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Wl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Kl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(ql,{entityIds:n.entityIds},null,8,["entityIds"]),c[4]||(c[4]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Gl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(zl,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Ch,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)],64))],64)):a.createCommentVNode("",!0)}}),xh=a.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(n){const e=n,t={kind:"none",color:"#f4f4f4",strokeColor:"#a1a1a1",subdivisionStep:5},o=a.computed(()=>({...t,...e.background})),r=Ne(b.Camera),s=Ne(b.Grid),i=a.inject("containerRef"),l=a.ref({width:0,height:0});let c=null;const d=a.ref(null);let u=null;typeof document<"u"&&(u=document.createElement("canvas"));function f(w,C,x,S){const M=S/2;w.beginPath(),w.arc(C,x,M,0,Math.PI*2),w.fill()}function h(w,C,x){if(!u)return null;const S=x.dotSize??2,M=w*x.subdivisionStep,E=C*x.subdivisionStep;if(M<=0||E<=0)return null;u.width=M,u.height=E;const v=u.getContext("2d");if(!v)return null;if(v.clearRect(0,0,M,E),v.fillStyle=x.strokeColor,x.subdivisionStep===1)f(v,M/2,E/2,S);else for(let T=0;T<x.subdivisionStep;T++)for(let D=0;D<x.subdivisionStep;D++){const P=(T+.5)*(M/x.subdivisionStep),R=(D+.5)*(E/x.subdivisionStep),z=T===0&&D===0?2*S:S;f(v,P,R,z)}return v.createPattern(u,"repeat")}function p(w,C,x,S,M,E){w.lineWidth=E,w.beginPath(),w.moveTo(C,x),w.lineTo(S,M),w.stroke()}function m(w,C,x){if(!u)return null;const S=x.gridSize??1,M=w*x.subdivisionStep,E=C*x.subdivisionStep;if(M<=0||E<=0)return null;u.width=M,u.height=E;const v=u.getContext("2d");if(!v)return null;if(v.clearRect(0,0,M,E),v.strokeStyle=x.strokeColor,x.subdivisionStep===1)p(v,0,0,M,0,S),p(v,0,0,0,E,S);else{const T=M/x.subdivisionStep,D=E/x.subdivisionStep;for(let P=0;P<=x.subdivisionStep;P++){const R=P*T,_=P%x.subdivisionStep===0;p(v,R,0,R,E,_?3*S:S)}for(let P=0;P<=x.subdivisionStep;P++){const R=P*D,_=P%x.subdivisionStep===0;p(v,0,R,M,R,_?3*S:S)}}return v.createPattern(u,"repeat")}function g(w){let C=s.value.colWidth,x=s.value.rowHeight;const S=o.value.subdivisionStep,M=l.value.width,E=l.value.height,v=r.value.left,T=r.value.top,D=v+M/r.value.zoom,P=T+E/r.value.zoom;let R=C*S,_=x*S,z=0,H=0,Z=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY;for(;;){R=S*C,_=S*x,z=Math.floor(v/R)*R,H=Math.floor(T/_)*_;const et=Math.ceil(D/R)*R,ge=Math.ceil(P/_)*_;if(K=Math.round((et-z)/C),Z=Math.round((ge-H)/x),Math.max(K,Z)>200)C*=2,x*=2;else break}const W=C*r.value.zoom,U=x*r.value.zoom,X=Math.max(1,Math.round(W)),te=Math.max(1,Math.round(U)),ne=h(X,te,o.value);if(!ne)return;ne.setTransform(new DOMMatrix().scale(W/X,U/te));const Ie=(z-v-C/2)*r.value.zoom,ce=(H-T-x/2)*r.value.zoom;w.save(),w.translate(Ie,ce),w.fillStyle=ne,w.fillRect(0,0,M+R*r.value.zoom,E+_*r.value.zoom),w.restore()}function y(w){let C=s.value.colWidth,x=s.value.rowHeight;const S=o.value.subdivisionStep,M=l.value.width,E=l.value.height,v=r.value.left,T=r.value.top,D=v+M/r.value.zoom,P=T+E/r.value.zoom;let R=C*S,_=x*S,z=0,H=0,Z=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY;for(;;){R=S*C,_=S*x,z=Math.floor(v/R)*R,H=Math.floor(T/_)*_;const et=Math.ceil(D/R)*R,ge=Math.ceil(P/_)*_;if(K=Math.round((et-z)/C),Z=Math.round((ge-H)/x),Math.max(K,Z)>200)C*=2,x*=2;else break}const W=C*r.value.zoom,U=x*r.value.zoom,X=Math.max(1,Math.round(W)),te=Math.max(1,Math.round(U)),ne=m(X,te,o.value);if(!ne)return;ne.setTransform(new DOMMatrix().scale(W/X,U/te));const Ie=(z-v)*r.value.zoom,ce=(H-T)*r.value.zoom;w.save(),w.translate(Ie,ce),w.fillStyle=ne,w.fillRect(0,0,M+R*r.value.zoom,E+_*r.value.zoom),w.restore()}function k(){const w=d.value;if(!w)return;const C=w.getContext("2d");if(!C)return;const{width:x,height:S}=l.value;x===0||S===0||(w.width=x,w.height=S,C.clearRect(0,0,x,S),C.fillStyle=o.value.color,C.fillRect(0,0,x,S),o.value.kind==="dots"?g(C):o.value.kind==="grid"&&y(C))}return a.watch(()=>[o.value,r.value,s.value,l.value],()=>{k()},{deep:!0}),a.onMounted(()=>{const w=i==null?void 0:i.value;if(w){const C=()=>{l.value={width:w.clientWidth,height:w.clientHeight}};C(),c=new ResizeObserver(C),c.observe(w)}k()}),a.onUnmounted(()=>{c==null||c.disconnect()}),(w,C)=>(a.openBlock(),a.createElementBlock("canvas",{ref_key:"canvasRef",ref:d,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function Sh(n,e){if(e.length===0)return new Set;const t=e[0].tag,o=n.blockDefs[t];if(!o)return new Set;const r=new Set(o.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,l=n.blockDefs[i];if(!l){r.clear();break}const c=new Set(l.components.map(d=>d.name));for(const d of r)c.has(d)||r.delete(d)}return r}const Eh=a.defineComponent({__name:"FloatingMenuBar",setup(n){const e=a.useSlots(),{reset:t}=Dt(),o=a.inject(la),{selectedIds:r,commonComponents:s}=o,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape","tape"]),l=a.computed(()=>{const d=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&d.push(u)}return d});function c(){t()}return a.onUnmounted(()=>{t()}),(d,u)=>(a.openBlock(),a.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:c},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(l.value,f=>a.renderSlot(d.$slots,`button:${f}`,{key:f,entityIds:a.unref(r)})),128)),a.unref(s).has("color")?a.renderSlot(d.$slots,"button:color",{key:0,entityIds:a.unref(r)},()=>[a.createVNode(hh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("shape")?a.renderSlot(d.$slots,"button:shape",{key:1,entityIds:a.unref(r)},()=>[a.createVNode(gh,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(mh,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(yh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("penStroke")?a.renderSlot(d.$slots,"button:penStroke",{key:2,entityIds:a.unref(r)},()=>[a.createVNode(ph,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("elbowArrow")||a.unref(s).has("arcArrow")?(a.openBlock(),a.createElementBlock(a.Fragment,{key:3},[a.renderSlot(d.$slots,"button:arrowThickness",{entityIds:a.unref(r)},()=>[a.createVNode(dh,{entityIds:a.unref(r)},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadStart",{entityIds:a.unref(r)},()=>[a.createVNode(Vl,{entityIds:a.unref(r),side:"start"},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadEnd",{entityIds:a.unref(r)},()=>[a.createVNode(Vl,{entityIds:a.unref(r),side:"end"},null,8,["entityIds"])])],64)):a.createCommentVNode("",!0),a.unref(s).has("tape")?a.renderSlot(d.$slots,"button:tape",{key:4,entityIds:a.unref(r)},()=>[a.createVNode(kh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("text")?a.renderSlot(d.$slots,"button:text",{key:5,entityIds:a.unref(r)},()=>[a.createVNode(mC,{entityIds:a.unref(r),showVerticalAlign:a.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])]):a.createCommentVNode("",!0),a.createVNode($l)],32))}}),gC={class:"wov-floating-menu-inner"},vh=a.defineComponent({__name:"FloatingMenu",setup(n){const e=a.inject(He),t=Bf([b.Block,le.Selected]),o=Ne(b.Camera),r=Ne(b.Screen),s=Ne(le.SelectionStateSingleton),i=Fo(),l=a.computed(()=>t.value.map(x=>x.entityId)),c=a.computed(()=>{const x=e==null?void 0:e.getEditor();if(!x||t.value.length===0)return new Set;const S=t.value.map(M=>({tag:M.block.value.tag}));return Sh(x,S)});a.provide(la,{selectedIds:l,commonComponents:c});const d=[0,0,0,0];function u(...x){let S=1/0,M=1/0,E=-1/0,v=-1/0,T=!1;for(const D of x){if(!D)continue;const P=D.getBoundingClientRect();P.width<=0||(T=!0,S=Math.min(S,P.left),M=Math.min(M,P.top),E=Math.max(E,P.right),v=Math.max(v,P.bottom))}return T?{x:S,y:M,left:S,top:M,right:E,bottom:v,width:E-S,height:v-M,toJSON:()=>({})}:null}const f=a.computed(()=>{if(t.value.length===0)return null;const x=o.value;if(!x)return null;let S=null;for(const M of t.value){const E=M.block.value;De.Rect.getAabb(E.position,E.size,E.rotateZ,d),De.Aabb.translate(d,[-x.left,-x.top]),De.Aabb.scale(d,x.zoom),S===null?S=De.Aabb.clone(d):De.Aabb.union(S,d)}return S}),h=a.inject("containerRef"),p=a.computed(()=>{const x=h==null?void 0:h.value;if(!x)return null;o.value,i.updateCounter.value;const S=i.blockElement.value,M=i.textElement.value,E=u(S,M);if(E)return{getBoundingClientRect:()=>E};const v=f.value;if(!v)return null;const T=x.getBoundingClientRect();return{getBoundingClientRect(){return{x:T.left+v[0],y:T.top+v[1],width:v[2]-v[0],height:v[3]-v[1],top:T.top+v[1],left:T.left+v[0],right:T.left+v[2],bottom:T.top+v[3]}}}}),m=a.ref(null),g={name:"clampToViewport",fn({y:x,rects:S}){const v=window.innerHeight-S.floating.height-8;return{y:Math.max(8,Math.min(x,v))}}},{floatingStyles:y}=eo(p,m,{placement:"top",middleware:[Xn(12),Zn({fallbackPlacements:["bottom"]}),Qn({padding:8}),g]}),k=a.computed(()=>{const x=f.value,S=r.value;return!x||!S?!0:x[2]<0||x[0]>S.width||x[3]<0||x[1]>S.height}),w=[le.SelectionState.Dragging,le.SelectionState.SelectionBoxDragging],C=a.computed(()=>t.value.length>0&&!k.value&&!w.includes(s.value.state));return(x,S)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-fade"},{default:a.withCtx(()=>[C.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:m,class:"wov-floating-menu",style:a.normalizeStyle(a.unref(y))},[a.createElementVNode("div",gC,[a.renderSlot(x.$slots,"default",{},()=>[a.createVNode(Eh)])])],4)):a.createCommentVNode("",!0)]),_:3}))}}),yC={key:0,class:"wov-loading-overlay"},kC={class:"wov-loading-spinner"},Mh=a.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(n){const e=a.ref("|"),t=["|","/","-","\\"];let o=null;return a.onMounted(()=>{o=setInterval(()=>{const r=t.indexOf(e.value);e.value=t[(r+1)%t.length]},100)}),a.onUnmounted(()=>{o!==null&&clearInterval(o)}),(r,s)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-loading-fade"},{default:a.withCtx(()=>[n.isLoading?(a.openBlock(),a.createElementBlock("div",yC,[a.createElementVNode("div",kC,a.toDisplayString(e.value),1)])):a.createCommentVNode("",!0)]),_:1}))}}),to="editing",wC={class:"wov-action-bar"},bC=a.defineComponent({__name:"ActionBar",setup(n){const{getEditor:e}=de(),t=a.inject(He),o=a.ref(!1),r=a.ref(!1);if(t){const c=t.registerTickCallback(d=>{const{store:u}=b.getPluginResources(d,to);o.value=u.canUndo(),r.value=u.canRedo()});a.onUnmounted(c)}function s(){const c=e();c==null||c.command(b.Undo)}function i(){const c=e();c==null||c.command(b.Redo)}function l(){const c=e();c==null||c.command(le.RemoveSelected)}return(c,d)=>(a.openBlock(),a.createElementBlock("div",wC,[a.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...d[0]||(d[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-undo-icon lucide-undo"},[a.createElementVNode("path",{d:"M3 7v6h6"}),a.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...d[1]||(d[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-redo-icon lucide-redo"},[a.createElementVNode("path",{d:"M21 7v6h-6"}),a.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:l,"aria-label":"Delete"},[...d[2]||(d[2]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-trash-icon lucide-trash"},[a.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),a.createElementVNode("path",{d:"M3 6h18"}),a.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),at=a.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(n){const e=n,t=a.inject(_s);if(!t)throw new Error("ToolbarButton must be used within a Toolbar component");const o=t,r=a.ref(null),{show:s,hide:i}=Dt(),l=a.computed(()=>o.activeTool.value===e.name);function c(){o.setTool(e.name,e.placementSnapshot,e.cursor)}function d(){o.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){o.onToolPointerUp()}function f(){e.tooltip&&r.value&&s(e.tooltip,r.value)}function h(){i()}return(p,m)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:a.normalizeClass(["wov-toolbar-button",{selected:l.value}]),onClick:c,onPointerdown:d,onPointerup:u,onMouseenter:f,onMouseleave:h},[a.renderSlot(p.$slots,"default")],34))}}),CC='<?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>',xC='<?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>',SC='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 8v-2a2 2 0 0 1 2 -2h2" /><path d="M4 16v2a2 2 0 0 0 2 2h2" /><path d="M16 4h2a2 2 0 0 1 2 2v2" /><path d="M16 20h2a2 2 0 0 0 2 -2v-2" /><path d="M9 12l6 0" /><path d="M12 9l0 6" /></svg>',rn={Select:"select",Hand:"hand",Crosshair:"crosshair"},Th={[rn.Select]:{makeSvg:()=>CC,hotspot:[1,0],rotationOffset:0},[rn.Hand]:{makeSvg:()=>xC,hotspot:[12,12],rotationOffset:0},[rn.Crosshair]:{makeSvg:()=>SC,hotspot:[12,12],rotationOffset:0}},EC={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},Nh=a.defineComponent({__name:"SelectTool",setup(n){const{nextEditorTick:e}=de(),{activeTool:t}=hs();return a.watch(t,(o,r)=>{r==="select"&&e(s=>{le.DeselectAll.spawn(s)})}),(o,r)=>(a.openBlock(),a.createBlock(at,{name:"select",tooltip:"Select",cursor:a.unref(rn).Select},{default:a.withCtx(()=>[(a.openBlock(),a.createElementBlock("svg",EC,[...r[0]||(r[0]=[a.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-width":"0.5",d:"M2.39,2.88C2.38,2.885 2.34,2.9 2.33,2.91C2.32,2.91 2.298,2.939 2.28,2.97L1.51,4.41C1.44,4.54 1.41,4.6 1.37,4.61C1.34,4.62 1.3,4.61 1.27,4.6C1.24,4.58 1.22,4.51 1.18,4.37L0.16,0.41C0.13,0.28 0.11,0.22 0.13,0.18C0.15,0.15 0.17,0.13 0.21,0.12C0.25,0.12 0.31,0.14 0.42,0.2L4.01,2.14C4.14,2.21 4.2,2.24 4.21,2.28C4.22,2.31 4.21,2.35 4.2,2.38C4.18,2.41 4.11,2.43 3.97,2.47L2.39,2.88Z"})],-1)])]))]),_:1},8,["cursor"]))}}),Ah=a.defineComponent({__name:"HandTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"hand",tooltip:"Hand",cursor:a.unref(rn).Hand},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4.47,11.39v3.18M4.47,11.39V3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92M4.47,11.39c0-1.06-.86-1.87-1.92-1.87s-1.92.86-1.92,1.87v2.53c0,5.25,4.35,9.45,9.65,9.45s9.65-4.24,9.65-9.45v-6.32c0-1.06-.86-1.92-1.92-1.92s-1.92.86-1.92,1.92M8.36,3.81v6.97M8.36,3.81v-1.26c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v1.26M12.2,3.81v6.97M12.2,3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v3.79M16.09,7.6v3.18"})],-1)])]),_:1},8,["cursor"]))}}),Bh=a.defineComponent({__name:"StickyNoteTool",setup(n){const e=JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:b.TextAlignment.Center},verticalAlign:{value:b.VerticalAlignment.Center}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":a.unref(e),"placement-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M4 4h12v12H4z"}),a.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Ih=a.defineComponent({__name:"ShapeTool",setup(n){const e=JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:b.StrokeKind.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:b.TextAlignment.Center},verticalAlign:{value:b.VerticalAlignment.Center}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"shape",tooltip:"Shape","drag-out-snapshot":a.unref(e),"placement-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Oh=a.defineComponent({__name:"EraserTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"eraser",tooltip:"Eraser"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[a.createElementVNode("path",{d:"M210.5 480L333.5 480L398.8 414.7L225.3 241.2L98.6 367.9L210.6 479.9zM256 544L210.5 544C193.5 544 177.2 537.3 165.2 525.3L49 409C38.1 398.1 32 383.4 32 368C32 352.6 38.1 337.9 49 327L295 81C305.9 70.1 320.6 64 336 64C351.4 64 366.1 70.1 377 81L559 263C569.9 273.9 576 288.6 576 304C576 319.4 569.9 334.1 559 345L424 480L544 480C561.7 480 576 494.3 576 512C576 529.7 561.7 544 544 544L256 544z"})],-1)])]),_:1}))}}),Rh=a.defineComponent({__name:"PenTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"pen",tooltip:"Pen"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M13.586 3.586a2 2 0 1 1 2.828 2.828l-8.793 8.793-3.536.707.707-3.536 8.794-8.792Z","stroke-linecap":"round","stroke-linejoin":"round"}),a.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),Ph=a.defineComponent({__name:"TextTool",setup(n){const e=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),t=JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24}});return(o,r)=>(a.openBlock(),a.createBlock(at,{name:"text",tooltip:"Text","drag-out-snapshot":a.unref(t),"placement-snapshot":a.unref(e)},{default:a.withCtx(()=>[...r[0]||(r[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-type-icon lucide-type"},[a.createElementVNode("path",{d:"M12 4v16"}),a.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),a.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Dh=a.defineComponent({__name:"ElbowArrowTool",setup(n){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:ee.ArrowHeadKind.None,endArrowHead:ee.ArrowHeadKind.V},connector:{}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),_h=a.defineComponent({__name:"ImageTool",setup(n){const{nextEditorTick:e}=de(),{show:t,hide:o}=Dt(),{setTool:r}=hs(),{createImageBlock:s}=Af(),i=a.ref(null),l=a.ref(null);function c(){var h;(h=l.value)==null||h.click()}async function d(h){var x;const p=h.target,m=(x=p.files)==null?void 0:x[0];if(!m)return;if(p.value="",!m.type.startsWith("image/")){console.warn("Selected file is not an image");return}const g=await e(),y=b.Camera.read(g),k=b.Screen.read(g),w=y.left+k.width/y.zoom/2,C=y.top+k.height/y.zoom/2;await s(m,w,C),r("select",void 0,rn.Select)}function u(){i.value&&t("Image",i.value)}function f(){o()}return(h,p)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:c,onMouseenter:u,onMouseleave:f},[p[0]||(p[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),a.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),a.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),a.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",accept:"image/*",style:{display:"none"},onChange:d},null,544)],544))}}),vC={class:"wov-embed-provider-grid"},MC=["onClick"],TC={class:"wov-embed-provider-icon"},NC={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},AC={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},BC={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},IC={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},OC={key:4,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},RC={key:5,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},PC={key:6,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},DC={key:7,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},_C={class:"wov-embed-provider-label"},LC={class:"wov-embed-panel-header"},VC={class:"wov-embed-url-form"},$C=["placeholder"],zC={key:0,class:"wov-embed-url-error"},Lh=a.defineComponent({__name:"EmbedTool",setup(n){const{nextEditorTick:e}=de(),{show:t,hide:o}=Dt(),{setTool:r}=hs(),s=a.ref(null),i=a.ref(null),l=a.ref(null),c=a.ref(!1),d=a.ref(null),u=a.ref(""),f=a.ref(""),h=a.inject("containerRef"),{floatingStyles:p}=eo(s,i,{placement:"top",middleware:[Xn(16),Zn(),Qn({padding:8})],whileElementsMounted:Ms}),m=[{value:b.EmbedProvider.Youtube,label:"YouTube",icon:"youtube"},{value:b.EmbedProvider.Spotify,label:"Spotify",icon:"spotify"},{value:b.EmbedProvider.GoogleMaps,label:"Google Maps",icon:"map"},{value:b.EmbedProvider.GoogleCalendar,label:"Google Calendar",icon:"calendar"},{value:b.EmbedProvider.GoogleSlides,label:"Google Slides",icon:"slides"},{value:b.EmbedProvider.Figma,label:"Figma",icon:"figma"},{value:b.EmbedProvider.GithubGist,label:"GitHub Gist",icon:"gist"},{value:b.EmbedProvider.Tldraw,label:"tldraw",icon:"tldraw"}],g=a.computed(()=>{if(!d.value)return"Paste a URL...";switch(d.value){case b.EmbedProvider.Youtube:return"https://www.youtube.com/watch?v=...";case b.EmbedProvider.Spotify:return"https://open.spotify.com/track/...";case b.EmbedProvider.GoogleMaps:return"https://www.google.com/maps/...";case b.EmbedProvider.GoogleCalendar:return"https://calendar.google.com/...";case b.EmbedProvider.GoogleSlides:return"https://docs.google.com/presentation/...";case b.EmbedProvider.Figma:return"https://www.figma.com/...";case b.EmbedProvider.GithubGist:return"https://gist.github.com/...";case b.EmbedProvider.Tldraw:return"https://www.tldraw.com/...";default:return"Paste a URL..."}});function y(){c.value=!c.value,d.value=null,u.value="",f.value=""}function k(v){d.value=v,u.value="",f.value="",a.nextTick(()=>{var T;(T=l.value)==null||T.focus()})}function w(){d.value=null,u.value="",f.value=""}async function C(){const v=u.value.trim();if(!v){f.value="Please enter a URL";return}try{new URL(v)}catch{f.value="Please enter a valid URL";return}const T=d.value??b.detectEmbedProvider(v),D=b.validateEmbedUrl(v,T);if(D){f.value=D;return}const P=b.resolveEmbedUrl(v,T);let R=480,_=320;switch(T){case b.EmbedProvider.Youtube:R=560,_=315;break;case b.EmbedProvider.Spotify:R=352,_=152;break;case b.EmbedProvider.GoogleMaps:R=600,_=450;break;case b.EmbedProvider.GoogleCalendar:R=600,_=500;break;case b.EmbedProvider.GoogleSlides:R=640,_=389;break;case b.EmbedProvider.Figma:R=600,_=400;break;case b.EmbedProvider.GithubGist:R=500,_=300;break;case b.EmbedProvider.Tldraw:R=600,_=400;break}const z=await e(),H=b.Camera.read(z),Z=b.Screen.read(z),K=H.left+Z.width/H.zoom/2,W=H.top+Z.height/H.zoom/2,U=b.Grid.read(z);U.enabled&&(R=Math.max(U.colWidth,Math.round(R/U.colWidth)*U.colWidth),_=Math.max(U.rowHeight,Math.round(_/U.rowHeight)*U.rowHeight));const X=b.createEntity(z);b.addComponent(z,X,b.Block);const te=b.Block.write(z,X);te.tag="embed",te.position[0]=K-R/2,te.position[1]=W-_/2,te.size[0]=R,te.size[1]=_,b.Grid.snapPosition(z,te.position),b.addComponent(z,X,b.Embed);const ne=b.Embed.write(z,X);ne.url=v,ne.embedUrl=P,ne.provider=T,b.addComponent(z,X,$e.Synced,{id:crypto.randomUUID()}),c.value=!1,d.value=null,u.value="",r("select",void 0,rn.Select)}function x(v){v.key==="Enter"?(v.preventDefault(),C()):v.key==="Escape"&&(v.preventDefault(),d.value?w():c.value=!1)}function S(v){const T=v.target;s.value&&!s.value.contains(T)&&i.value&&!i.value.contains(T)&&(c.value=!1)}a.watch(c,v=>{v?document.addEventListener("click",S,!0):document.removeEventListener("click",S,!0)});function M(){s.value&&t("Embed",s.value)}function E(){o()}return(v,T)=>{var D;return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("button",{ref_key:"buttonRef",ref:s,class:a.normalizeClass(["wov-toolbar-button",{"menu-open":c.value}]),onClick:y,onMouseenter:M,onMouseleave:E},[...T[1]||(T[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.createElementVNode("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)])],34),a.unref(h)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(h)},[c.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"wov-embed-panel",style:a.normalizeStyle(a.unref(p))},[d.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createElementVNode("div",LC,[a.createElementVNode("button",{class:"wov-embed-back-button",onClick:w},[...T[11]||(T[11]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("polyline",{points:"15 18 9 12 15 6"})],-1)])]),a.createElementVNode("span",null,a.toDisplayString((D=m.find(P=>P.value===d.value))==null?void 0:D.label),1)]),a.createElementVNode("div",VC,[a.withDirectives(a.createElementVNode("input",{ref_key:"urlInputRef",ref:l,"onUpdate:modelValue":T[0]||(T[0]=P=>u.value=P),type:"text",placeholder:g.value,class:"wov-embed-url-input",onKeydown:x},null,40,$C),[[a.vModelText,u.value]]),f.value?(a.openBlock(),a.createElementBlock("div",zC,a.toDisplayString(f.value),1)):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-embed-submit-button",onClick:C}," Embed ")])],64)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[T[10]||(T[10]=a.createElementVNode("div",{class:"wov-embed-panel-header"},"Add embed",-1)),a.createElementVNode("div",vC,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(m,P=>a.createElementVNode("button",{key:P.value,class:"wov-embed-provider-button",onClick:R=>k(P.value)},[a.createElementVNode("span",TC,[P.icon==="youtube"?(a.openBlock(),a.createElementBlock("svg",NC,[...T[2]||(T[2]=[a.createElementVNode("path",{d:"M2.5 17V7a2 2 0 0 1 2-2h15a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2z"},null,-1),a.createElementVNode("path",{d:"m10 15 5-3-5-3z"},null,-1)])])):P.icon==="spotify"?(a.openBlock(),a.createElementBlock("svg",AC,[...T[3]||(T[3]=[a.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),a.createElementVNode("path",{d:"M8 11.973c2.5-1.473 5.5-.973 7.5.527"},null,-1),a.createElementVNode("path",{d:"M9 15c1.5-1 4-.5 5.5.5"},null,-1),a.createElementVNode("path",{d:"M7 9c3-2 7-1 10 1"},null,-1)])])):P.icon==="map"?(a.openBlock(),a.createElementBlock("svg",BC,[...T[4]||(T[4]=[a.createElementVNode("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"},null,-1),a.createElementVNode("circle",{cx:"12",cy:"9",r:"2.5"},null,-1)])])):P.icon==="calendar"?(a.openBlock(),a.createElementBlock("svg",IC,[...T[5]||(T[5]=[a.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"16",y1:"2",x2:"16",y2:"6"},null,-1),a.createElementVNode("line",{x1:"8",y1:"2",x2:"8",y2:"6"},null,-1),a.createElementVNode("line",{x1:"3",y1:"10",x2:"21",y2:"10"},null,-1)])])):P.icon==="slides"?(a.openBlock(),a.createElementBlock("svg",OC,[...T[6]||(T[6]=[a.createElementVNode("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"8",y1:"21",x2:"16",y2:"21"},null,-1),a.createElementVNode("line",{x1:"12",y1:"17",x2:"12",y2:"21"},null,-1)])])):P.icon==="figma"?(a.openBlock(),a.createElementBlock("svg",RC,[...T[7]||(T[7]=[a.createElementVNode("path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z"},null,-1),a.createElementVNode("path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z"},null,-1),a.createElementVNode("path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z"},null,-1)])])):P.icon==="gist"?(a.openBlock(),a.createElementBlock("svg",PC,[...T[8]||(T[8]=[a.createElementVNode("polyline",{points:"16 18 22 12 16 6"},null,-1),a.createElementVNode("polyline",{points:"8 6 2 12 8 18"},null,-1)])])):P.icon==="tldraw"?(a.openBlock(),a.createElementBlock("svg",DC,[...T[9]||(T[9]=[a.createElementVNode("path",{d:"M12 19l7-7 3 3-7 7-3-3z"},null,-1),a.createElementVNode("path",{d:"m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"},null,-1),a.createElementVNode("path",{d:"m2 2 7.586 7.586"},null,-1),a.createElementVNode("circle",{cx:"11",cy:"11",r:"2"},null,-1)])])):a.createCommentVNode("",!0)]),a.createElementVNode("span",_C,a.toDisplayString(P.label),1)],8,MC)),64))])],64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64)}}}),FC="https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media",Vh=a.defineComponent({__name:"TapeTool",setup(n){const e=JSON.stringify({block:{tag:"tape",size:[200,30]},tape:{thickness:30},asset:{identifier:FC,uploadState:"complete"}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"tape",tooltip:"Tape","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"1",y:"7",width:"18",height:"6",rx:"1",fill:"none",stroke:"currentColor"}),a.createElementVNode("line",{x1:"5",y1:"7",x2:"3",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"9",y1:"7",x2:"7",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"13",y1:"7",x2:"11",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"17",y1:"7",x2:"15",y2:"13",opacity:"0.4"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),HC={class:"wov-toolbar-container"},$h=a.defineComponent({__name:"Toolbar",setup(n){const e=a.useSlots(),{reset:t}=Dt(),{nextEditorTick:o}=de(),r=a.ref(null),s=a.ref(null),i=Ne(b.Controls),l=a.computed(()=>i.value.leftMouseTool),c=[Nh,Ah,Ph,_h,Lh,Ih,Dh,Bh,Vh,Rh,Oh],d=a.inject("containerRef"),u=a.ref(null),f=a.ref(!1),h=a.ref(null),p=a.ref(null),m=a.ref(1/0),g=a.ref(0),y=a.ref([]),k=a.ref(8),w=a.ref(48),{width:C}=wh(d);function x(){return h.value?Array.from(h.value.children).filter(W=>!W.classList.contains("wov-overflow-button")&&!W.classList.contains("wov-menu-tooltip")):[]}function S(){var te;const W=x();if(W.length===0)return;g.value=W.length;const U=getComputedStyle(h.value);k.value=parseFloat(U.gap)||8;const X=((te=p.value)==null?void 0:te.offsetWidth)||40;w.value=X+k.value,y.value=W.map(ne=>ne.offsetWidth)}function M(){if(y.value.length===0)return;const X=C.value-40-20,te=k.value,ne=w.value;let Ie=0,ce=0;for(let et=0;et<y.value.length;et++){const ge=y.value[et],sn=Ie>0?ge+te:ge,bt=y.value.length-et-1>0?ne:0;if(Ie+sn+bt<=X)Ie+=sn,ce++;else break}m.value=Math.max(1,ce)}a.watch(C,()=>{y.value.length>0&&M()}),a.onMounted(()=>{a.nextTick(()=>{S(),M()})});const E=a.computed(()=>m.value<g.value);a.watchEffect(()=>{x().forEach((U,X)=>{U.style.display=X<m.value?"":"none"})}),a.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((U,X)=>{U.style.display=X>=m.value?"":"none"})});const{floatingStyles:v}=eo(p,u,{placement:"top",middleware:[Xn(16),Zn(),Qn({padding:8})],whileElementsMounted:Ms});function T(){f.value=!f.value}function D(){f.value=!1}function P(W){const U=W.target;p.value&&!p.value.contains(U)&&u.value&&!u.value.contains(U)&&D()}a.watch(f,W=>{W?document.addEventListener("click",P,!0):document.removeEventListener("click",P,!0)}),a.watch(E,W=>{W||D()});function R(W,U,X){s.value=U??null,o(te=>{const ne=b.Controls.write(te);ne.leftMouseTool=W,ne.heldSnapshot=U??"",X&&b.Cursor.setCursor(te,X)})}function _(W){o(U=>{const X=b.Controls.write(U);X.leftMouseTool="drag-out",X.heldSnapshot=W})}function z(W,U){r.value=W,s.value=U??null}function H(){r.value=null,s.value=null}function Z(){t(),r.value&&s.value&&_(s.value),r.value=null,s.value=null}const K={activeTool:l,heldTool:r,setTool:R,dragOutTool:_,onToolPointerDown:z,onToolPointerUp:H};return a.provide(_s,K),(W,U)=>(a.openBlock(),a.createElementBlock("div",HC,[a.createVNode(bC),a.createElementVNode("div",{ref_key:"toolsContainerRef",ref:h,class:"wov-toolbar",onMouseleave:Z},[a.unref(e).default?a.renderSlot(W.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(X,te)=>a.createVNode(a.resolveDynamicComponent(X),{key:te})),64)),E.value?(a.openBlock(),a.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:p,class:a.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:T},[...U[0]||(U[0]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[a.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):a.createCommentVNode("",!0),a.createVNode($l)],544),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[f.value&&E.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:a.normalizeStyle(a.unref(v))},[a.unref(e).default?a.renderSlot(W.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(X,te)=>a.createVNode(a.resolveDynamicComponent(X),{key:te})),64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)]))}}),UC=a.defineComponent({__name:"ArcArrowTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),jC={class:"wov-user-presence-avatars"},WC=["src","alt"],KC={class:"wov-user-presence-list"},qC=["src","alt"],GC={class:"wov-user-presence-name"},JC=4,zh=a.defineComponent({__name:"UserPresence",props:{users:{}},setup(n){const e=n,t=a.ref(!1),o=a.ref(null);U2(o,()=>{t.value=!1});function r(l){if(!l)return"?";const c=l.trim().split(/\s+/);return c.length>=2?(c[0][0]+c[1][0]).toUpperCase():l.slice(0,2).toUpperCase()}const s=a.computed(()=>e.users.map(l=>({sessionId:l.sessionId,name:l.name,color:l.color,avatar:l.avatar,initials:r(l.name)}))),i=a.computed(()=>s.value.slice(0,JC));return(l,c)=>n.users.length>1?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"containerRef",ref:o,class:"wov-user-presence"},[a.createElementVNode("button",{class:a.normalizeClass(["wov-user-presence-trigger",{"is-open":t.value}]),onClick:c[0]||(c[0]=d=>t.value=!t.value)},[a.createElementVNode("div",jC,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-avatar",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,WC)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4))),128))])],2),t.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:c[1]||(c[1]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",KC,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-presence-item"},[a.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,qC)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4),a.createElementVNode("span",GC,a.toDisplayString(d.name),1)]))),128))])],32)):a.createCommentVNode("",!0)],512)):a.createCommentVNode("",!0)}}),Jl=(n,e)=>e.some(t=>n instanceof t);let Fh,Hh;function YC(){return Fh||(Fh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function XC(){return Hh||(Hh=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Yl=new WeakMap,Xl=new WeakMap,Is=new WeakMap;function QC(n){const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("success",s),n.removeEventListener("error",i)},s=()=>{t(In(n.result)),r()},i=()=>{o(n.error),r()};n.addEventListener("success",s),n.addEventListener("error",i)});return Is.set(e,n),e}function ZC(n){if(Yl.has(n))return;const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",i),n.removeEventListener("abort",i)},s=()=>{t(),r()},i=()=>{o(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",s),n.addEventListener("error",i),n.addEventListener("abort",i)});Yl.set(n,e)}let Ql={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Yl.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return In(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Uh(n){Ql=n(Ql)}function ex(n){return XC().includes(n)?function(...e){return n.apply(Zl(this),e),In(this.request)}:function(...e){return In(n.apply(Zl(this),e))}}function tx(n){return typeof n=="function"?ex(n):(n instanceof IDBTransaction&&ZC(n),Jl(n,YC())?new Proxy(n,Ql):n)}function In(n){if(n instanceof IDBRequest)return QC(n);if(Xl.has(n))return Xl.get(n);const e=tx(n);return e!==n&&(Xl.set(n,e),Is.set(e,n)),e}const Zl=n=>Is.get(n);function nx(n,e,{blocked:t,upgrade:o,blocking:r,terminated:s}={}){const i=indexedDB.open(n,e),l=In(i);return o&&i.addEventListener("upgradeneeded",c=>{o(In(i.result),c.oldVersion,c.newVersion,In(i.transaction),c)}),t&&i.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),l.then(c=>{s&&c.addEventListener("close",()=>s()),r&&c.addEventListener("versionchange",d=>r(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const ox=["get","getKey","getAll","getAllKeys","count"],rx=["put","add","delete","clear"],ea=new Map;function jh(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(ea.get(e))return ea.get(e);const t=e.replace(/FromIndex$/,""),o=e!==t,r=rx.includes(t);if(!(t in(o?IDBIndex:IDBObjectStore).prototype)||!(r||ox.includes(t)))return;const s=async function(i,...l){const c=this.transaction(i,r?"readwrite":"readonly");let d=c.store;return o&&(d=d.index(l.shift())),(await Promise.all([d[t](...l),r&&c.done]))[0]};return ea.set(e,s),s}Uh(n=>({...n,get:(e,t,o)=>jh(e,t)||n.get(e,t,o),has:(e,t)=>!!jh(e,t)||n.has(e,t)}));const sx=["continue","continuePrimaryKey","advance"],Wh={},ta=new WeakMap,Kh=new WeakMap,ix={get(n,e){if(!sx.includes(e))return n[e];let t=Wh[e];return t||(t=Wh[e]=function(...o){ta.set(this,Kh.get(this)[e](...o))}),t}};async function*lx(...n){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...n)),!e)return;e=e;const t=new Proxy(e,ix);for(Kh.set(t,e),Is.set(t,Zl(e));e;)yield t,e=await(ta.get(t)||e.continue()),ta.delete(t)}function qh(n,e){return e===Symbol.asyncIterator&&Jl(n,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Jl(n,[IDBIndex,IDBObjectStore])}Uh(n=>({...n,get(e,t,o){return qh(e,t)?lx:n.get(e,t,o)},has(e,t){return qh(e,t)||n.has(e,t)}}));async function na(n,e){const t=await nx(n,1,{upgrade(o){o.objectStoreNames.contains(e)||o.createObjectStore(e)}});return new ax(t,e)}var ax=class{constructor(n,e){this.db=n,this.storeName=e}async get(n){return this.db.get(this.storeName,n)}async put(n,e){await this.db.put(this.storeName,e,n)}async delete(n){await this.db.delete(this.storeName,n)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),t=await e.getAllKeys(),o=await e.getAll(),r=[];for(let s=0;s<t.length;s++)r.push([t[s],o[s]]);return r}async clear(){const n=this.db.transaction(this.storeName,"readwrite");n.objectStore(this.storeName).clear(),await n.done}close(){this.db.close()}},cx=class{constructor(n){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=n.provider,this.documentId=n.documentId,this.maxRetries=n.provider.maxRetries??3,this.retryDelay=n.provider.retryDelay??5e3}async init(){const n=`wovencanvas-assets-${this.documentId}`,[e,t]=await Promise.all([na(`${n}-jobs`,"jobs"),na(`${n}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=t}async upload(n,e,t){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(n,e);const o={identifier:n,metadata:t,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(n,o);const r=URL.createObjectURL(e);return this.blobUrls.set(n,r),new Promise((s,i)=>{this.uploadPromises.set(n,{resolve:s,reject:i}),this.startUpload(n)})}async getDisplayUrl(n){if(!n)return null;const e=this.blobUrls.get(n);if(e)return e;try{return await this.provider.resolveUrl(n)}catch(t){return console.error(`Failed to resolve URL for ${n}:`,t),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const n=await this.jobsStore.getAllEntries();for(const[e]of n){const t=await this.binariesStore.get(e);if(t){const o=URL.createObjectURL(t);this.blobUrls.set(e,o)}this.startUpload(e)}}hasPendingUpload(n){return this.blobUrls.has(n)}isUploading(n){return this.uploading.has(n)}async cancelUpload(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.reject(new Error("Upload cancelled")),this.uploadPromises.delete(n))}close(){var n,e;for(const t of this.blobUrls.values())URL.revokeObjectURL(t);this.blobUrls.clear(),(n=this.jobsStore)==null||n.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(n){if(!this.jobsStore||!this.binariesStore||this.uploading.has(n))return;this.uploading.add(n);const e=await this.jobsStore.get(n),t=await this.binariesStore.get(n);if(!e||!t){this.uploading.delete(n);return}try{await this.provider.upload(t,n,e.metadata),await this.onUploadSuccess(n)}catch(o){await this.onUploadError(n,e,o)}}async onUploadSuccess(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.resolve(),this.uploadPromises.delete(n))}async onUploadError(n,e,t){if(!this.jobsStore)return;const o=t instanceof Error?t.message:"Unknown error";if(console.error(`Upload failed for ${n}:`,o),this.uploading.delete(n),e.retryCount<this.maxRetries){const r={...e,retryCount:e.retryCount+1};await this.jobsStore.put(n,r),setTimeout(()=>{this.startUpload(n)},this.retryDelay*2**e.retryCount)}else{const r=this.uploadPromises.get(n);r&&(r.reject(new Error(o)),this.uploadPromises.delete(n))}}},dx="wovencanvas-assets",ux="blobs",fx=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(n,e,t){return await(await this.getStore()).put(e,{blob:n,metadata:t}),{}}async resolveUrl(n){if(n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/"))return n;const t=await(await this.getStore()).get(n);if(!t)throw new Error(`Asset not found: ${n}`);return URL.createObjectURL(t.blob)}async delete(n){await(await this.getStore()).delete(n)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=na(dx,ux).then(n=>(this.store=n,n))),this.initPromise)}};const hx={class:"wov-selection-box"},px=a.defineComponent({__name:"SelectionBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",hx))}}),mx={class:"wov-transform-box"},gx=a.defineComponent({__name:"TransformBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",mx))}}),yx={},kx={class:"wov-transform-handle"};function wx(n,e){return a.openBlock(),a.createElementBlock("div",kx)}const bx=an(yx,[["render",wx]]),Cx=a.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=pe(e.entityId,b.Color),o=pe(e.entityId,b.VerticalAlign),r=a.ref(null),s={[b.VerticalAlignment.Top]:"flex-start",[b.VerticalAlignment.Center]:"center",[b.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>{var c;return{backgroundColor:t.value?`rgb(${t.value.red}, ${t.value.green}, ${t.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((c=o.value)==null?void 0:c.value)??b.VerticalAlignment.Top]}}),{handleEditEnd:l}=Bl({blockData:e,containerRef:r,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(c,d)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-sticky-note",style:a.normalizeStyle(i.value)},[a.createVNode(ps,a.mergeProps(e,{"block-element":r.value,onEditEnd:a.unref(l)}),null,16,["block-element","onEditEnd"])],4))}}),Os=$e.defineCanvasSingleton({name:"blockPlacementState"},{editedCheckpoint:b.field.string().default("").max(36)}),Gh=b.defineQuery(n=>n.with(b.Edited));function xx(n){var e;if(!n)return null;try{const t=JSON.parse(n);return(e=t.block)!=null&&e.tag?t:(console.warn("Block snapshot missing required tag:",t),null)}catch{return console.warn("Invalid block snapshot JSON:",n),null}}function Sx(n,e,t){const o=b.getBlockDef(n,e.block.tag);if(!o)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const r=e.block.size??[100,100],s=[t[0]-r[0]/2,t[1]-r[1]/2];b.Grid.snapPosition(n,s);const[i,l]=s,c=e.block.rank??b.RankBounds.genNext(n),d=b.createEntity(n);"synced"in e||b.addComponent(n,d,b.Synced,{id:crypto.randomUUID()});const u=Object.assign({},e.block,{position:[i,l],size:r,rank:c});b.addComponent(n,d,b.Block,u);for(const h of o.components)if(!(h.name in e))b.addComponent(n,d,h);else{const p=e[h.name];b.addComponent(n,d,h,p)}const{sessionId:f}=b.getResources(n);return b.addComponent(n,d,b.Held,{sessionId:f}),d}function Jh(n,e,t,o,r){const s=Sx(n,e,t),i=b.Block.read(n,s);if(b.canBlockEdit(n,e.block.tag)&&(b.addComponent(n,s,le.EditAfterPlacing,{}),r==="placement")){const{store:u}=b.getPluginResources(n,to),f=u.createCheckpoint();if(f){const h=Os.write(n);h.editedCheckpoint=f}}const l=le.SelectionStateSingleton.write(n);l.state=r==="dragOut"?le.SelectionState.Dragging:le.SelectionState.Pointing,l.dragStart=t,l.draggedEntity=s,l.draggedEntityStart=i.position,l.pointingStartClient=o,l.pointingStartWorld=t,l.isCloning=!1;const c=b.Controls.write(n);c.leftMouseTool="select",c.heldSnapshot="";const d=b.Cursor.write(n);d.cursorKind="select",d.rotation=0}function Ex(n){const e=Os.read(n);if(e.editedCheckpoint){const t=e.editedCheckpoint;Os.write(n).editedCheckpoint="";const{store:o}=b.getPluginResources(n,to);o.onSettled(()=>o.squashToCheckpoint(t),{frames:5})}}const vx=b.defineEditorSystem({phase:"capture"},n=>{Gh.removed(n).length>0&&Gh.current(n).length===0&&Ex(n);const e=b.Controls.read(n);if(!e.heldSnapshot)return;const t=b.getPointerInput(n,[b.PointerButton.Left]);if(t.length===0)return;const o=xx(e.heldSnapshot);if(!o)return;if(e.leftMouseTool==="drag-out"){const s=t.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;Jh(n,o,s.worldPosition,s.screenPosition,"dragOut")}else{const s=t.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;Jh(n,o,s.worldPosition,s.screenPosition,"placement")}}),Mx=b.defineEditorSystem({phase:"update"},n=>{const{store:e}=b.getPluginResources(n,to);b.on(n,b.Undo,()=>{e.canUndo()&&(le.deselectAll(n),e.undo())}),b.on(n,b.Redo,()=>{e.canRedo()&&(le.deselectAll(n),e.redo())})}),Tx=[{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 Yh(n){return{name:to,resources:{store:n.store},singletons:[Os],systems:[vx,Mx],cursors:Th,fonts:Tx,keybinds:[{command:b.Undo.name,key:b.Key.Z,mod:!0},{command:b.Redo.name,key:b.Key.Y,mod:!0},{command:b.Redo.name,key:b.Key.Z,mod:!0,shift:!0}]}}const Nx=a.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(n){const e=n,{nextEditorTick:t}=de(),{createImageBlock:o}=Af(),r=a.ref(!1);let s=0;const i=a.inject("containerRef");function l(w){var C;(C=w.dataTransfer)!=null&&C.types.some(x=>x==="Files"||x==="text/uri-list"||x==="text/html")&&(s++,s===1&&(r.value=!0))}function c(){s--,s===0&&(r.value=!1)}function d(){s=0,r.value=!1}a.onMounted(()=>{const w=i==null?void 0:i.value;w&&(w.addEventListener("dragenter",l),w.addEventListener("dragleave",c),w.addEventListener("drop",d))}),a.onUnmounted(()=>{const w=i==null?void 0:i.value;w&&(w.removeEventListener("dragenter",l),w.removeEventListener("dragleave",c),w.removeEventListener("drop",d))});function u(w){w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="copy")}function f(w){w.preventDefault()}function h(w){w.preventDefault()}async function p(w){if(w.preventDefault(),!w.dataTransfer)return;const C=w.clientX,x=w.clientY,S=Array.from(w.dataTransfer.files).filter(E=>E.type.startsWith("image/"));if(S.length>0){for(const E of S)await y(E,C,x);return}const M=m(w.dataTransfer);M&&await k(M,C,x)}function m(w){const C=w.getData("text/uri-list");if(C){const E=C.split(`
106
+ 3. "-" cannot repeat`);ie.customSchemes.push([n,e])}function qk(){ie.scanner=$k(ie.customSchemes);for(let n=0;n<ie.tokenQueue.length;n++)ie.tokenQueue[n][1]({scanner:ie.scanner});ie.parser=Hk(ie.scanner.tokens);for(let n=0;n<ie.pluginQueue.length;n++)ie.pluginQueue[n][1]({scanner:ie.scanner,parser:ie.parser});return ie.initialized=!0,ie}function yl(n){return ie.initialized||qk(),Uk(ie.parser.start,n,lf(ie.scanner.start,n))}yl.scan=lf;function pf(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const o=new ml(t),r=yl(n),s=[];for(let i=0;i<r.length;i++){const l=r[i];l.isLink&&(!e||l.t===e)&&o.check(l)&&s.push(l.toFormattedObject(o))}return s}var kl="[\0-   ᠎ -\u2029  ]",Gk=new RegExp(kl),Jk=new RegExp(`${kl}$`),Yk=new RegExp(kl,"g");function Xk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Qk(n){return new ue({key:new we("autolink"),appendTransaction:(e,t,o)=>{const r=e.some(d=>d.docChanged)&&!t.doc.eq(o.doc),s=e.some(d=>d.getMeta("preventAutolink"));if(!r||s)return;const{tr:i}=o,l=mu(t.doc,[...e]);if(Mu(l).forEach(({newRange:d})=>{const u=ay(o.doc,d,p=>p.isTextblock);let f,h;if(u.length>1)f=u[0],h=o.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const p=o.doc.textBetween(d.from,d.to," "," ");if(!Jk.test(p))return;f=u[0],h=o.doc.textBetween(f.pos,d.to,void 0," ")}if(f&&h){const p=h.split(Gk).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],g=f.pos+h.lastIndexOf(m);if(!m)return!1;const y=yl(m).map(k=>k.toObject(n.defaultProtocol));if(!Xk(y))return!1;y.filter(k=>k.isLink).map(k=>({...k,from:g+k.start+1,to:g+k.end+1})).filter(k=>o.schema.marks.code?!o.doc.rangeHasMark(k.from,k.to,o.schema.marks.code):!0).filter(k=>n.validate(k.value)).filter(k=>n.shouldAutoLink(k.value)).forEach(k=>{Hi(k.from,k.to,o.doc).some(w=>w.mark.type===n.type)||i.addMark(k.from,k.to,n.type.create({href:k.href}))})}}),!!i.steps.length)return i}})}function Zk(n){return new ue({key:new we("handleClickLink"),props:{handleClick:(e,t,o)=>{var r,s;if(o.button!==0||!e.editable)return!1;let i=null;if(o.target instanceof HTMLAnchorElement)i=o.target;else{const c=o.target;if(!c)return!1;const d=n.editor.view.dom;i=c.closest("a"),i&&!d.contains(i)&&(i=null)}if(!i)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const c=vu(e.state,n.type.name),d=(r=i.href)!=null?r:c.href,u=(s=i.target)!=null?s:c.target;d&&(window.open(d,u),l=!0)}return l}}})}function ew(n){return new ue({key:new we("handlePasteLink"),props:{handlePaste:(e,t,o)=>{const{shouldAutoLink:r}=n,{state:s}=e,{selection:i}=s,{empty:l}=i;if(l)return!1;let c="";o.content.forEach(u=>{c+=u.textContent});const d=pf(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||r!==void 0&&!r(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function En(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(o=>{const r=typeof o=="string"?o:o.scheme;r&&t.push(r)}),!n||n.replace(Yk,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var tw=qn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){hf(n);return}hf(n.scheme,n.optionalSlashes)})},onDestroy(){Kk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!En(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const r=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!En(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!En(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Xt(this.options.HTMLAttributes,n),0]:["a",Xt(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,o,r,s;const i=(o=(t=n.attrs)==null?void 0:t.href)!=null?o:"",l=(s=(r=n.attrs)==null?void 0:r.title)!=null?s:"",c=e.renderChildren(n);return l?`[${c}](${i} "${l}")`:`[${c}](${i})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:o=>!!En(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:o=>!!En(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ao({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:o}=this.options,r=pf(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!En(i,t),protocols:t,defaultProtocol:o}));r.length&&r.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Qk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:o=>this.options.isAllowedUri(o,{defaultValidate:r=>!!En(r,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Zk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(ew({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),mf=tw,nw=se.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),gf=nw,ow=20,yf=(n,e=0)=>{const t=[];return!n.children.length||e>ow||Array.from(n.children).forEach(o=>{o.tagName==="SPAN"?t.push(o):o.children.length&&t.push(...yf(o,e+1))}),t},rw=n=>{if(!n.children.length)return;const e=yf(n);e&&e.forEach(t=>{var o,r;const s=t.getAttribute("style"),i=(r=(o=t.parentElement)==null?void 0:o.closest("span"))==null?void 0:r.getAttribute("style");t.setAttribute("style",`${i};${s}`)})},wl=qn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&rw(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",Xt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,o)=>{if(t.isTextblock)return!0;t.marks.filter(r=>r.type===this.type).some(r=>Object.values(r.attrs).some(s=>!!s))||n.removeMark(o,o+t.nodeSize,this.type)}),!0}}}}),sw=se.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="background-color")return l.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),kf=se.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const o=t.split(";").map(r=>r.trim()).filter(Boolean);for(let r=o.length-1;r>=0;r-=1){const s=o[r].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(i==="color")return l.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),iw=se.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),lw=se.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),aw=se.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});se.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(sw.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push(kf.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(iw.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(lw.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(aw.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(wl.configure(this.options.textStyle)),n}});var wf=kf;function cw(n={}){return new ue({view(e){return new dw(e,n)}})}class dw{constructor(e,t){var o;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(o=t.width)!==null&&o!==void 0?o:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let s=i=>{this[r](i)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,o,r=this.editorView.dom,s=r.getBoundingClientRect(),i=s.width/r.offsetWidth,l=s.height/r.offsetHeight;if(t){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=f?m.bottom:m.top;f&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;o={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!o){let f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;o={left:f.left-h,right:f.left+h,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),h=f.width/c.offsetWidth,p=f.height/c.offsetHeight;d=f.left-c.scrollLeft*h,u=f.top-c.scrollTop*p}this.element.style.left=(o.left-d)/i+"px",this.element.style.top=(o.top-u)/l+"px",this.element.style.width=(o.right-o.left)/i+"px",this.element.style.height=(o.bottom-o.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),o=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=o&&o.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=yc(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class he extends Y{constructor(e){super(e,e)}map(e,t){let o=e.resolve(t.map(this.head));return he.valid(o)?new he(o):Y.near(o)}content(){return $.empty}eq(e){return e instanceof he&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new he(e.resolve(t.pos))}getBookmark(){return new bl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!uw(e)||!fw(e))return!1;let o=t.type.spec.allowGapCursor;if(o!=null)return o;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,o=!1){e:for(;;){if(!o&&he.valid(e))return e;let r=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;r+=t;let c=e.doc.resolve(r);if(he.valid(c))return c}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!q.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),o=!1;continue e}break}s=i,r+=t;let l=e.doc.resolve(r);if(he.valid(l))return l}return null}}}he.prototype.visible=!1,he.findFrom=he.findGapCursorFrom,Y.jsonID("gapcursor",he);class bl{constructor(e){this.pos=e}map(e){return new bl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return he.valid(t)?new he(t):Y.near(t)}}function bf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function uw(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),o=n.node(e);if(t==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||bf(r.type))return!0;if(r.inlineContent)return!1}}return!0}function fw(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),o=n.node(e);if(t==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||bf(r.type))return!0;if(r.inlineContent)return!1}}return!0}function hw(){return new ue({props:{decorations:yw,createSelectionBetween(n,e,t){return e.pos==t.pos&&he.valid(t)?new he(t):null},handleClick:mw,handleKeyDown:pw,handleDOMEvents:{beforeinput:gw}}})}const pw=ru({ArrowLeft:ds("horiz",-1),ArrowRight:ds("horiz",1),ArrowUp:ds("vert",-1),ArrowDown:ds("vert",1)});function ds(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,s){let i=o.selection,l=e>0?i.$to:i.$from,c=i.empty;if(i instanceof G){if(!s.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=o.doc.resolve(e>0?l.after():l.before())}let d=he.findGapCursorFrom(l,e,c);return d?(r&&r(o.tr.setSelection(new he(d))),!0):!1}}function mw(n,e,t){if(!n||!n.editable)return!1;let o=n.state.doc.resolve(e);if(!he.valid(o))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&q.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new he(o))),!0)}function gw(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof he))return!1;let{$from:t}=n.state.selection,o=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!o)return!1;let r=B.empty;for(let i=o.length-1;i>=0;i--)r=B.from(o[i].createAndFill(null,r));let s=n.state.tr.replace(t.pos,t.pos,new $(r,0,0));return s.setSelection(G.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function yw(n){if(!(n.selection instanceof he))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}var us=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<us&&this.leafAppend(e)||this.length<us&&e.leafPrepend(this)||this.appendInner(e)):this},Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this},Ce.prototype.appendInner=function(e){return new kw(this,e)},Ce.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ce.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},Ce.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var r=[];return this.forEach(function(s,i){return r.push(e(s,i))},t,o),r},Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new Cf(e):Ce.empty};var Cf=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,i,l){for(var c=s;c<i;c++)if(r(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,l){for(var c=s-1;c>=i;c--)if(r(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=us)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=us)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Ce);Ce.empty=new Cf([]);var kw=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,r,s,i){var l=this.left.length;if(r<l&&this.left.forEachInner(o,r,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(o,Math.max(r-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,r,s,i){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(o,r-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(o,Math.min(r,l),s,i)===!1)return!1},e.prototype.sliceInner=function(o,r){if(o==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(o,r):o>=s?this.right.slice(o-s,r-s):this.left.slice(o,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(o){var r=this.right.leafAppend(o);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(o){var r=this.left.leafPrepend(o);if(r)return new e(r,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Ce);const ww=500;class ot{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let r,s;t&&(r=this.remapping(o,this.items.length),s=r.maps.length);let i=e.tr,l,c,d=[],u=[];return this.items.forEach((f,h)=>{if(!f.step){r||(r=this.remapping(o,h+1),s=r.maps.length),s--,u.push(f);return}if(r){u.push(new mt(f.map));let p=f.step.map(r.slice(s)),m;p&&i.maybeStep(p).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],d.push(new mt(m,void 0,void 0,d.length+u.length))),s--,m&&r.appendMap(m,s)}else i.maybeStep(f.step);if(f.selection)return l=r?f.selection.map(r.slice(s)):f.selection,c=new ot(this.items.slice(0,o).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:i,selection:l}}addTransform(e,t,o,r){let s=[],i=this.eventCount,l=this.items,c=!r&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),h=new mt(e.mapping.maps[u],f,t),p;(p=c&&c.merge(h))&&(h=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(h),t&&(i++,t=void 0),r||(c=h)}let d=i-o.depth;return d>Cw&&(l=bw(l,d),i-=d),new ot(l.append(s),i)}remapping(e,t){let o=new co;return this.items.forEach((r,s)=>{let i=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?o.maps.length-r.mirrorOffset:void 0;o.appendMap(r.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new ot(this.items.append(e.map(t=>new mt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],r=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},r);let c=t;this.items.forEach(h=>{let p=s.getMirror(--c);if(p==null)return;i=Math.min(i,p);let m=s.maps[p];if(h.step){let g=e.steps[p].invert(e.docs[p]),y=h.selection&&h.selection.map(s.slice(c+1,p));y&&l++,o.push(new mt(m,g,y))}else o.push(new mt(m))},r);let d=[];for(let h=t;h<i;h++)d.push(new mt(s.maps[h]));let u=this.items.slice(0,r).append(d).append(o),f=new ot(u,l);return f.emptyItemCount()>ww&&(f=f.compress(this.items.length-o.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,r=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)r.push(i),i.selection&&s++;else if(i.step){let c=i.step.map(t.slice(o)),d=c&&c.getMap();if(o--,d&&t.appendMap(d,o),c){let u=i.selection&&i.selection.map(t.slice(o));u&&s++;let f=new mt(d.invert(),c,u),h,p=r.length-1;(h=r.length&&r[p].merge(f))?r[p]=h:r.push(f)}}else i.map&&o--},this.items.length,0),new ot(Ce.from(r.reverse()),s)}}ot.empty=new ot(Ce.empty,0);function bw(n,e){let t;return n.forEach((o,r)=>{if(o.selection&&e--==0)return t=r,!1}),n.slice(t)}class mt{constructor(e,t,o,r){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new mt(t.getMap().invert(),t,this.selection)}}}class tn{constructor(e,t,o,r,s){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=r,this.prevComposition=s}}const Cw=20;function xw(n,e,t,o){let r=t.getMeta(vn),s;if(r)return r.historyState;t.getMeta(vw)&&(n=new tn(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(vn))return i.getMeta(vn).redo?new tn(n.done.addTransform(t,void 0,o,fs(e)),n.undone,xf(t.mapping.maps),n.prevTime,n.prevComposition):new tn(n.done,n.undone.addTransform(t,void 0,o,fs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Sw(t,n.prevRanges)),d=i?Cl(n.prevRanges,t.mapping):xf(t.mapping.maps);return new tn(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,fs(e)),ot.empty,d,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new tn(n.done.rebased(t,s),n.undone.rebased(t,s),Cl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new tn(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Cl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Sw(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,r)=>{for(let s=0;s<e.length;s+=2)o<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function xf(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,r,s,i)=>e.push(s,i));return e}function Cl(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let r=e.map(n[o],1),s=e.map(n[o+1],-1);r<=s&&t.push(r,s)}return t}function Ew(n,e,t){let o=fs(e),r=vn.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,o);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,o),c=new tn(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(vn,{redo:t,historyState:c})}let xl=!1,Sf=null;function fs(n){let e=n.plugins;if(Sf!=e){xl=!1,Sf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){xl=!0;break}}return xl}const vn=new we("history"),vw=new we("closeHistory");function Mw(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ue({key:vn,state:{init(){return new tn(ot.empty,ot.empty,null,0,-1)},apply(e,t,o){return xw(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,r=o=="historyUndo"?vf:o=="historyRedo"?Mf:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ef(n,e){return(t,o)=>{let r=vn.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(o){let s=Ew(r,t,n);s&&o(e?s.scrollIntoView():s)}return!0}}const vf=Ef(!1,!0),Mf=Ef(!0,!0);se.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const o=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(o)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new ue({key:new we("characterCount"),appendTransaction:(e,t,o)=>{if(n)return;const r=this.options.limit;if(r==null||r===0){n=!0;return}const s=this.storage.characters({node:o.doc});if(s>r){const i=s-r,l=0,c=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const d=o.tr.deleteRange(l,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const o=this.options.limit;if(!e.docChanged||o===0||o===null||o===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=o||r>o&&s>o&&s<=r)return!0;if(r>o&&s>o&&s>r||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-o,d=l-c,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>o)}})]}}),se.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[cw(this.options)]}}),se.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ue({key:new we("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:o}=this.editor,{anchor:r}=e,s=[];if(!t||!o)return ae.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(c.isText)return;if(!(r>=d&&r<=d+c.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((c,d)=>{if(c.isText||!(r>=d&&r<=d+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Ve.node(d,d+c.nodeSize,{class:this.options.className}))}),ae.create(n,s)}}})]}}),se.create({name:"gapCursor",addProseMirrorPlugins(){return[hw()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=re(j(n,"allowGapCursor",t)))!=null?e:null}}});var Tf="placeholder";function Tw(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}se.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Tf,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${Tw(this.options.dataAttribute)}`:`data-${Tf}`;return[new ue({key:new we("placeholder"),props:{decorations:({doc:e,selection:t})=>{const o=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!o)return null;const i=this.editor.isEmpty;return e.descendants((l,c)=>{const d=r>=c&&r<=c+l.nodeSize,u=!l.isLeaf&&vr(l);if((d||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const h=Ve.node(c,c+l.nodeSize,{class:f.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:d}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),ae.create(e,s)}}})]}}),se.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new ue({key:new we("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||wy(t.selection)||n.view.dragging?null:ae.create(t.doc,[Ve.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Nf({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}se.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new we(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",o=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(t).includes(r.name));return[new ue({key:e,appendTransaction:(r,s,i)=>{const{doc:l,tr:c,schema:d}=i,u=e.getState(i),f=l.content.size,h=d.nodes[t];if(u)return c.insert(f,h.create())},state:{init:(r,s)=>{const i=s.tr.doc.lastChild;return!Nf({node:i,types:o})},apply:(r,s)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return s;const i=r.doc.lastChild;return!Nf({node:i,types:o})}}})]}});var Nw=se.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>vf(n,e),redo:()=>({state:n,dispatch:e})=>Mf(n,e)}},addProseMirrorPlugins(){return[Mw(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 Rt(n,e){const t=a.inject(He);if(!t)throw new Error("useComponents must be used within a WovenCanvas component");const o=a.shallowRef(new Map),r=new Map;function s(l){if(r.has(l))return;const c=t.getEditor();if(c){const u=c._getContext();if(b.hasComponent(u,l,e)){const f=new Map(o.value);f.set(l,e.snapshot(u,l)),o.value=f}else{const f=new Map(o.value);f.set(l,null),o.value=f}}const d=t.subscribeComponent(l,e.name,u=>{const f=new Map(o.value);f.set(l,u),o.value=f});r.set(l,d)}function i(l){const c=r.get(l);if(c){c(),r.delete(l);const d=new Map(o.value);d.delete(l),o.value=d}}return a.watch(()=>a.toValue(n),(l,c)=>{const d=new Set(l),u=new Set(c??[]);for(const f of u)d.has(f)||i(f);for(const f of d)u.has(f)||s(f)},{immediate:!0}),a.onUnmounted(()=>{for(const l of r.values())l();r.clear()}),o}function Af(){const n=a.inject(He);if(!n)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=de();function t(s){return new Promise((i,l)=>{const c=new window.Image;c.onload=()=>{i({width:c.naturalWidth,height:c.naturalHeight}),URL.revokeObjectURL(c.src)},c.onerror=()=>{l(new Error("Failed to load image")),URL.revokeObjectURL(c.src)},c.src=URL.createObjectURL(s)})}async function o(s,i,l,c={}){const{maxSize:d=400}=c,u=await t(s),f=await e(),h=Math.min(1,d/Math.max(u.width,u.height));let p=Math.round(u.width*h),m=Math.round(u.height*h);const g=b.Grid.read(f);g.enabled&&(p=Math.max(g.colWidth,Math.round(p/g.colWidth)*g.colWidth),m=Math.max(g.rowHeight,Math.round(m/g.rowHeight)*g.rowHeight));const y=b.createEntity(f);b.addComponent(f,y,b.Block);const k=b.Block.write(f,y);k.tag="image",k.position[0]=i-p/2,k.position[1]=l-m/2,k.size[0]=p,k.size[1]=m,b.Grid.snapPosition(f,k.position);const w=crypto.randomUUID();b.addComponent(f,y,b.Asset);const C=b.Asset.write(f,y);C.identifier=w,C.uploadState=b.UploadState.Pending,b.addComponent(f,y,b.Image);const x=b.Image.write(f,y);return x.width=u.width,x.height=u.height,x.alt=s.name,b.addComponent(f,y,$e.Synced,{id:crypto.randomUUID()}),(n==null?void 0:n.getAssetManager())&&r(y,w,s),y}async function r(s,i,l){const c=n==null?void 0:n.getAssetManager();if(c)try{await c.upload(i,l,{filename:l.name,mimeType:l.type});const d=await e(),u=b.Asset.write(d,s);u.uploadState=b.UploadState.Complete}catch{const d=await e(),u=b.Asset.write(d,s);u.uploadState=b.UploadState.Failed}}return{getImageDimensions:t,createImageBlock:o}}function Bf(n){const e=a.inject(He);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const t=a.shallowRef([]),o=b.defineQuery(f=>f.with(...n)),r=new Map;let s=!1;function i(f){const h=e.getEditor();if(!h)return{refs:{},unsubscribes:[]};const p=h._getContext(),m={},g=[];for(const y of n){const k=a.shallowRef(y.snapshot(p,f));m[y.name]=k;const w=e.subscribeComponent(f,y.name,C=>{k.value=C});g.push(w)}return{refs:m,unsubscribes:g}}function l(f){const h=r.get(f);if(h){for(const p of h.unsubscribes)p();r.delete(f)}}function c(){const f=[];for(const[h,p]of r)f.push({entityId:h,...p.refs});return f}function d(f){if(!s){const g=o.current(f);for(const y of g)r.set(y,i(y));t.value=c(),s=!0;return}const h=o.added(f),p=o.removed(f);let m=!1;for(const g of p)l(g),m=!0;for(const g of h)r.has(g)||(r.set(g,i(g)),m=!0);m&&(t.value=c())}const u=e.registerTickCallback(d);return a.onUnmounted(()=>{u();for(const f of r.keys())l(f)}),t}function Ne(n){const e=a.inject(He);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const t=a.shallowRef(n.default()),o=e.getEditor();if(o){const i=o._getContext();t.value=n.snapshot(i)}const r=e.subscribeSingleton(n.name,i=>{t.value=i??{}});let s=null;return o||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const l=i._getContext();t.value=n.snapshot(l),s==null||s(),s=null}})),a.onUnmounted(()=>{r(),s==null||s()}),t}function Sl(n,e,t){if(!n.closest(".wov-block")){const p=n.getBoundingClientRect();return{width:p.width,height:p.height,left:0,top:0}}const r=n.getBoundingClientRect(),s=t.value.left,i=t.value.top,l=new DOMPoint(r.left+r.width/2-s,r.top+r.height/2-i),c=e.value.zoom,d=new DOMMatrix;d.translateSelf(-e.value.left*c,-e.value.top*c),d.scaleSelf(c,c),d.invertSelf();const u=d.transformPoint(l),f=n.offsetWidth,h=n.offsetHeight;return{width:f,height:h,left:u.x-f/2,top:u.y-h/2}}function If(n){if(n.startsWith("#"))return n.toUpperCase();const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const t=parseInt(e[1],10).toString(16).padStart(2,"0"),o=parseInt(e[2],10).toString(16).padStart(2,"0"),r=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${t}${o}${r}`.toUpperCase()}return n}function zo(n){const e=Math.round(n.red),t=Math.round(n.green),o=Math.round(n.blue),r=Math.round(n.alpha);return r<255?"#"+[e,t,o,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,t,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function El(n){n=n.replace(/^#/,"");let e,t,o,r=255;if(n.length===6)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16);else if(n.length===8)e=parseInt(n.slice(0,2),16),t=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);else return null;return{red:e,green:t,blue:o,alpha:r}}function Of(n){const e=El(n);if(!e)return{h:0,s:100,v:100,a:255};const t=e.red/255,o=e.green/255,r=e.blue/255,s=Math.max(t,o,r),i=Math.min(t,o,r),l=s-i;let c=0;const d=s===0?0:l/s*100,u=s*100;if(l!==0)switch(s){case t:c=((o-r)/l+(o<r?6:0))*60;break;case o:c=((r-t)/l+2)*60;break;case r:c=((t-o)/l+4)*60;break}return{h:c,s:d,v:u,a:e.alpha}}function Rf(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const h=p=>Math.round(p*255).toString(16).padStart(2,"0");return`#${h(r)}${h(s)}${h(i)}`}function Pf(n){const e=n.h/360,t=n.s/100,o=n.v/100;let r=0,s=0,i=0;const l=Math.floor(e*6),c=e*6-l,d=o*(1-t),u=o*(1-c*t),f=o*(1-(1-c)*t);switch(l%6){case 0:r=o,s=f,i=d;break;case 1:r=u,s=o,i=d;break;case 2:r=d,s=o,i=f;break;case 3:r=d,s=u,i=o;break;case 4:r=f,s=d,i=o;break;case 5:r=o,s=d,i=u;break}const h=m=>Math.round(m*255).toString(16).padStart(2,"0"),p=Math.round(n.a).toString(16).padStart(2,"0");return n.a<255?`#${h(r)}${h(s)}${h(i)}${p}`:`#${h(r)}${h(s)}${h(i)}`}const Ae=a.shallowRef(null),vl=a.shallowRef(null),Ml=a.shallowRef(null),Pt=a.ref(0);function Fo(){const n={hasEditor:a.computed(()=>Ae.value!==null),isBold:a.computed(()=>{var r;return Pt.value,((r=Ae.value)==null?void 0:r.isActive("bold"))??!1}),isItalic:a.computed(()=>{var r;return Pt.value,((r=Ae.value)==null?void 0:r.isActive("italic"))??!1}),isUnderline:a.computed(()=>{var r;return Pt.value,((r=Ae.value)==null?void 0:r.isActive("underline"))??!1}),alignment:a.computed(()=>{Pt.value;const r=Ae.value;return r?r.isActive({textAlign:"center"})?"center":r.isActive({textAlign:"right"})?"right":r.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:a.computed(()=>{Pt.value;const r=Ae.value;if(!r)return null;const i=r.getAttributes("textStyle").color??null;return i?If(i):null}),linkHref:a.computed(()=>{Pt.value;const r=Ae.value;return r?r.getAttributes("link").href??null:null})},e={toggleBold(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection,l=s===i;let c=r.chain().focus();l&&(c=c.selectAll()),c=c.toggleBold(),l&&(c=c.setTextSelection(i)),c.run()},toggleItalic(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection,l=s===i;let c=r.chain().focus();l&&(c=c.selectAll()),c=c.toggleItalic(),l&&(c=c.setTextSelection(i)),c.run()},toggleUnderline(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection,l=s===i;let c=r.chain().focus();l&&(c=c.selectAll()),c=c.toggleUnderline(),l&&(c=c.setTextSelection(i)),c.run()},setAlignment(r){const s=Ae.value;s&&s.chain().selectAll().setTextAlign(r).run()},setColor(r){const s=Ae.value;if(!s)return;const{from:i,to:l}=s.state.selection;i===l?s.chain().focus().selectAll().setColor(r).setTextSelection(l).run():s.chain().focus().setColor(r).run()},setLink(r){const s=Ae.value;if(!s)return;const{from:i,to:l}=s.state.selection;i===l?s.chain().focus().selectAll().setLink({href:r}).setTextSelection(l).run():s.chain().focus().setLink({href:r}).run()},removeLink(){const r=Ae.value;if(!r)return;const{from:s,to:i}=r.state.selection;s===i?r.chain().focus().selectAll().unsetLink().setTextSelection(i).run():r.chain().focus().unsetLink().run()}};function t(r,s,i){Ae.value=r,Ml.value=s,vl.value=i,r.on("selectionUpdate",()=>{Pt.value++}),r.on("transaction",()=>{Pt.value++})}function o(){Ae.value=null,Ml.value=null,vl.value=null}return{editor:Ae,blockElement:vl,textElement:Ml,state:n,commands:e,updateCounter:Pt,register:t,unregister:o}}const Be=[ju,Ku,qu,wl,wf,Ju,Yu,Xu,mf.configure({openOnClick:!1}),gf.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function Aw(n){return n.type==="text"&&typeof n.text=="string"}function gt(n,e){if(Aw(n)){e(n);return}if(n.content)for(const t of n.content)gt(t,e)}function Tl(n,e){if(n.type==="paragraph"){e(n);return}if(n.content)for(const t of n.content)Tl(t,e)}function Bw(n,e){var t;return((t=n.marks)==null?void 0:t.some(o=>o.type===e))??!1}function Iw(n){var o,r;const e=(o=n.marks)==null?void 0:o.find(s=>s.type==="textStyle"),t=((r=e==null?void 0:e.attrs)==null?void 0:r.color)??null;return t?If(t):null}function Ow(n,e){if(!n.trim())return!1;const t=nt(n,Be);let o=!1,r=!0,s=0;return gt(t,i=>{s++,Bw(i,e)?o=!0:r=!1}),s===0?!1:r?!0:o?null:!1}function Rw(n){if(!n.trim())return"left";const e=nt(n,Be);let t="left";return Tl(e,o=>{var s;const r=(s=o.attrs)==null?void 0:s.textAlign;r&&(t=r)}),t}function Pw(n){if(!n.trim())return null;const e=nt(n,Be);let t=null;return gt(e,o=>{t===null&&(t=Iw(o))}),t}function Nl(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[];r.findIndex(i=>i.type===e)===-1&&(o.marks=[...r,{type:e}])}),Kn(t,Be)}function Al(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[];o.marks=r.filter(s=>s.type!==e)}),Kn(t,Be)}function Dw(n,e){if(!n.trim())return n;const t=nt(n,Be);return Tl(t,o=>{o.attrs={...o.attrs,textAlign:e}}),Kn(t,Be)}function _w(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="textStyle");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,color:e}},o.marks=r):o.marks=[...r,{type:"textStyle",attrs:{color:e}}]}),Kn(t,Be)}function Lw(n){if(!n.trim())return null;const e=nt(n,Be);let t=null;return gt(e,o=>{var r,s;if(t===null){const i=(r=o.marks)==null?void 0:r.find(l=>l.type==="link");(s=i==null?void 0:i.attrs)!=null&&s.href&&(t=i.attrs.href)}}),t}function Vw(n,e){if(!n.trim())return n;const t=nt(n,Be);return gt(t,o=>{const r=o.marks??[],s=r.findIndex(i=>i.type==="link");s!==-1?(r[s]={...r[s],attrs:{...r[s].attrs,href:e}},o.marks=r):o.marks=[...r,{type:"link",attrs:{href:e,target:"_blank",rel:"noopener noreferrer"}}]}),Kn(t,Be)}function $w(n){if(!n.trim())return n;const e=nt(n,Be);return gt(e,t=>{const o=t.marks??[];t.marks=o.filter(r=>r.type!=="link")}),Kn(e,Be)}function Df(n){const e=document.querySelector(`[data-entity-id="${n}"]`);if(!e)return null;const t=e.firstElementChild;return t||e.querySelector(".wov-editable-text")}function _f(n,e,t,o){var c;const r=n.cloneNode(!0);r.style.position="absolute",r.style.visibility="hidden",r.style.pointerEvents="none",r.style.top="0",r.style.left="0";const s=r.classList.contains("wov-editable-text")?r:r.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${o.fontSizePx}px`,s.style.fontFamily=o.fontFamily,s.style.lineHeight=String(o.lineHeight),s.style.letterSpacing=`${o.letterSpacingEm}em`);const i=r.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=o.content:s?s.innerHTML=o.content:r.innerHTML=o.content,(c=n.parentElement)==null||c.appendChild(r);const l=Sl(r,e,t);return r.remove(),l}function Lf(n){const{nextEditorTick:e}=de(),t=Rt(n,b.Text),o=Ne(b.Camera),r=Ne(b.Screen),s=Fo(),i={hasTextEntities:a.computed(()=>{for(const h of t.value.values())if(h)return!0;return!1}),hasTextContent:a.computed(()=>{for(const h of t.value.values()){if(!h)continue;const p=h.content?nt(h.content,Be):null;if(p){let m=!1;if(gt(p,g=>{var y;(y=g.text)!=null&&y.trim()&&(m=!0)}),m)return!0}}return!1}),isBold:a.computed(()=>l("bold")),isItalic:a.computed(()=>l("italic")),isUnderline:a.computed(()=>l("underline")),alignment:a.computed(()=>{let h=null;for(const p of t.value.values()){if(!p)continue;const m=Rw(p.content);if(h===null)h=m;else if(h!==m)return null}return h??"left"}),color:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values()){if(!m)continue;const g=Pw(m.content);if(!p)h=g,p=!0;else if(h!==g)return null}return h}),fontSize:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values())if(m){if(!p)h=m.fontSizePx,p=!0;else if(h!==m.fontSizePx)return null}return h}),fontFamily:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values())if(m){if(!p)h=m.fontFamily,p=!0;else if(h!==m.fontFamily)return null}return h}),linkHref:a.computed(()=>{let h=null,p=!1;for(const m of t.value.values()){if(!m)continue;const g=Lw(m.content);if(!p)h=g,p=!0;else if(h!==g)return null}return h})};function l(h){let p=null,m=!1;for(const g of t.value.values()){if(!g)continue;const y=Ow(g.content,h);if(!m)p=y,m=!0;else if(p!==y)return null}return p}const c={toggleBold(){u(h=>i.isBold.value?Al(h,"bold"):Nl(h,"bold"))},toggleItalic(){u(h=>i.isItalic.value?Al(h,"italic"):Nl(h,"italic"))},toggleUnderline(){u(h=>i.isUnderline.value?Al(h,"underline"):Nl(h,"underline"))},setAlignment(h){f(p=>Dw(p,h))},setColor(h){f(p=>_w(p,h))},setFontSize(h){d(p=>({...p,fontSizePx:h}),p=>{p.fontSizePx=h})},setFontFamily(h){d(p=>({...p,fontFamily:h}),p=>{p.fontFamily=h})},setTextStyle(h){d(p=>({...p,fontFamily:h.fontFamily??p.fontFamily,fontSizePx:h.fontSizePx??p.fontSizePx,lineHeight:h.lineHeight??p.lineHeight,letterSpacingEm:h.letterSpacingEm??p.letterSpacingEm}),p=>{h.fontFamily!==void 0&&(p.fontFamily=h.fontFamily),h.fontSizePx!==void 0&&(p.fontSizePx=h.fontSizePx),h.lineHeight!==void 0&&(p.lineHeight=h.lineHeight),h.letterSpacingEm!==void 0&&(p.letterSpacingEm=h.letterSpacingEm)})},setLink(h){f(p=>Vw(p,h))},removeLink(){f(h=>$w(h))}};function d(h,p){const m=a.toValue(n),g=[];for(const y of m){const k=t.value.get(y);if(!k)continue;const w=Df(y);if(w){const C=_f(w,o,r,h(k));g.push({entityId:y,...C})}}e(y=>{for(const k of m)p(b.Text.write(y,k));for(const{entityId:k,width:w,height:C,left:x,top:S}of g){const M=b.Block.write(y,k);M.size=[w,C],M.position=[x,S]}a.nextTick(()=>{var k;s.updateCounter.value++,(k=s.editor.value)==null||k.commands.focus()})})}function u(h){const p=a.toValue(n),m=[];for(const g of p){const y=t.value.get(g);if(!y)continue;const k=h(y.content),w=Df(g);if(w){const C=_f(w,o,r,{...y,content:k});m.push({entityId:g,content:k,...C})}else m.push({entityId:g,content:k,width:0,height:0,left:0,top:0})}e(g=>{for(const{entityId:y,content:k,width:w,height:C,left:x,top:S}of m){const M=b.Text.write(g,y);if(M.content=k,w>0&&C>0){const E=b.Block.write(g,y);E.size=[w,C],E.position=[x,S]}}})}function f(h){const p=a.toValue(n);e(m=>{for(const g of p){const y=b.Text.write(m,g);y.content=h(y.content)}})}return{state:i,commands:c}}function rt(n){const e=Fo(),t=Lf(n),o=e.state.hasEditor;return{state:a.reactive({hasTextToFormat:a.computed(()=>o.value||t.state.hasTextEntities.value),hasEditor:o,hasTextContent:a.computed(()=>t.state.hasTextContent.value),showTextMenuButtons:a.computed(()=>o.value||t.state.hasTextContent.value),isBold:a.computed(()=>o.value?e.state.isBold.value:t.state.isBold.value===!0),isItalic:a.computed(()=>o.value?e.state.isItalic.value:t.state.isItalic.value===!0),isUnderline:a.computed(()=>o.value?e.state.isUnderline.value:t.state.isUnderline.value===!0),alignment:a.computed(()=>o.value?e.state.alignment.value:t.state.alignment.value??"left"),color:a.computed(()=>o.value?e.state.color.value:t.state.color.value),fontSize:a.computed(()=>t.state.fontSize.value),fontFamily:a.computed(()=>t.state.fontFamily.value),linkHref:a.computed(()=>o.value?e.state.linkHref.value:t.state.linkHref.value)}),commands:{toggleBold(){o.value?e.commands.toggleBold():t.commands.toggleBold()},toggleItalic(){o.value?e.commands.toggleItalic():t.commands.toggleItalic()},toggleUnderline(){o.value?e.commands.toggleUnderline():t.commands.toggleUnderline()},setAlignment(i){o.value?e.commands.setAlignment(i):t.commands.setAlignment(i)},setColor(i){o.value?e.commands.setColor(i):t.commands.setColor(i)},setFontSize(i){t.commands.setFontSize(i)},setFontFamily(i){t.commands.setFontFamily(i)},setTextStyle(i){t.commands.setTextStyle(i)},setLink(i){o.value?e.commands.setLink(i):t.commands.setLink(i)},removeLink(){o.value?e.commands.removeLink():t.commands.removeLink()}}}}function Bl(n){const e=Ne(b.Camera),t=Ne(b.Screen),o=Ne(le.TransformBoxStateSingleton),r=Ne(le.SelectionStateSingleton),{nextEditorTick:s}=de();let i=!1,l=null;function c(u,f){const{entityId:h}=a.toValue(n.blockData),p=a.toValue(n.minWidth)??0,m=a.toValue(n.minHeight)??0,g=Math.max(f.width,p),y=Math.max(f.height,m),k=b.Block.read(u,h),w=Math.abs(k.size[0]-g)>.5,C=Math.abs(k.size[1]-y)>.5;if(!w&&!C)return;const x=b.Block.write(u,h);x.size=[g,y],x.position=[f.left,f.top],o.value.transformBoxId!==null&&le.UpdateTransformBox.spawn(u,{transformBoxId:o.value.transformBoxId})}a.watch(()=>r.value,()=>{s(u=>{const f=zw(u);if(i&&!f){const h=n.containerRef.value;if(!h)return;l=Sl(h,e,t),c(u,l),l=null}i=f})},{flush:"sync"});function d(u){const{content:f,...h}=u;s(p=>{const{entityId:m}=a.toValue(n.blockData);if(b.Text.read(p,m).content!==f){const y=b.Text.write(p,m);y.content=f}c(p,h)})}return{handleEditEnd:d}}function zw(n){const e=le.SelectionStateSingleton.read(n);return e.state===le.SelectionState.Dragging&&e.draggedEntity!==null&&b.hasComponent(n,e.draggedEntity,le.TransformHandle)&&le.TransformHandle.read(n,e.draggedEntity).kind===le.TransformHandleKind.Stretch}function hs(){const n=a.inject(_s);if(!n)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:n.activeTool,heldTool:n.heldTool,setTool:n.setTool,dragOutTool:n.dragOutTool,onToolPointerDown:n.onToolPointerDown,onToolPointerUp:n.onToolPointerUp,isActive:e=>a.computed(()=>n.activeTool.value===e)}}const Fw=500,Hw=1500;function Vf(){const n=a.ref(null),e=a.ref(!1),t=a.ref(!1);let o=null,r=null;function s(){o&&(clearTimeout(o),o=null),r&&(clearTimeout(r),r=null)}function i(d,u){s(),n.value={text:d,anchor:u},t.value?e.value=!0:o=setTimeout(()=>{e.value=!0,t.value=!0,o=null},Fw)}function l(){s(),e.value=!1,n.value=null,t.value&&(r=setTimeout(()=>{t.value=!1,r=null},Hw))}function c(){s(),e.value=!1,n.value=null,t.value=!1}return{activeTooltip:a.readonly(n),isVisible:a.readonly(e),isWarmedUp:a.readonly(t),show:i,hide:l,reset:c}}function Dt(){const n=a.inject(aa);if(!n)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return n}const Uw={key:1},jw=["innerHTML"],$f=50,Ww=300,ps=a.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(n,{expose:e,emit:t}){var E;const o=n,r=t,s=pe(o.entityId,b.Text),i=Ne(b.Camera),l=Ne(b.Screen),c=Fo(),{nextEditorTick:d}=de(),u=Ne(b.Mouse),f=a.ref(null);e({editableTextRef:f});const h=a.ref(((E=s.value)==null?void 0:E.content)??""),p=a.shallowRef(null);function m(){d(v=>{const T=b.Text.write(v,o.entityId);T.constrainWidth=!0;const D=b.Block.read(v,o.entityId),P=Math.max(D.size[0],Ww),R=b.Block.write(v,o.entityId);R.size=[P,D.size[1]],b.ResetKeyboard.spawn(v),le.DeselectAll.spawn(v)})}function g(v,T){var z,H,Z;const D=s.value;if(!D)return!1;const P=((z=T.clipboardData)==null?void 0:z.getData("text/html"))??"",R=((H=T.clipboardData)==null?void 0:H.getData("text/plain"))??"";return P.includes("data-pm-slice")?(!D.constrainWidth&&R.length>$f&&m(),!1):(T.preventDefault(),(Z=p.value)==null||Z.commands.insertContent(R,{parseOptions:{preserveWhitespace:!0}}),!D.constrainWidth&&R.length>$f&&m(),!0)}function y(){var v,T;return new pk({extensions:[ju,Ku,qu,wl,wf,Ju,Yu,Xu,mf.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),gf.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((v=s.value)==null?void 0:v.defaultAlignment)??"left"}),Nw],content:((T=s.value)==null?void 0:T.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:g}})}a.watch(()=>o.edited,async v=>{if(v&&f.value){if(p.value=y(),await k(p.value),!o.blockElement)return;c.register(p.value,f.value,o.blockElement)}else p.value&&(c.unregister(),w(p.value),p.value.destroy(),p.value=null)},{immediate:!0});async function k(v){var R;const T=(R=u.value)==null?void 0:R.position,D=l.value;await a.nextTick(),await new Promise(_=>requestAnimationFrame(_));const P=f.value;if(T&&D&&P){const _=T[0]+D.left,z=T[1]+D.top,H=v.view.posAtCoords({left:_,top:z});if(H){v.chain().focus().setTextSelection(H.pos).run();return}}v.commands.focus("start")}function w(v){let T=v.getHTML();const P=T.replace(/<[^>]*>/g,"").trim().length>0;P||(T=""),h.value=T,d(R=>{var K,W;const _=b.getBlockDef(R,o.block.tag);if(!P&&((K=_.editOptions)!=null&&K.removeWhenTextEmpty)){b.removeEntity(R,o.entityId);return}const z=(W=f.value)==null?void 0:W.closest(".wov-block"),H=(z==null?void 0:z.firstElementChild)??f.value;if(!H){console.warn("EditableText: no element to measure");return}const Z=Sl(H,i,l);r("editEnd",{content:T,...Z})})}a.watch(()=>{var v;return(v=s.value)==null?void 0:v.content},v=>{v!==void 0&&(p.value?p.value.getHTML()!==v&&p.value.commands.setContent(v,{emitUpdate:!1}):h.value=v)});const C=a.computed(()=>{const v=s.value;if(!v)return{};const[T,D]=o.block.flip,P=T?-1:1,R=D?-1:1,_=T||D;return{fontFamily:v.fontFamily,fontSize:`${v.fontSizePx}px`,lineHeight:v.lineHeight,letterSpacing:`${v.letterSpacingEm}em`,width:v.constrainWidth?"100%":"fit-content",whiteSpace:v.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:o.edited?"auto":"none",userSelect:o.edited?"auto":"none",transform:_?`scale(${P}, ${R})`:void 0}});function x(v){v.key==="Control"||v.key==="Meta"||v.stopPropagation()}function S(v){o.edited&&v.stopPropagation()}function M(v){if(o.edited)return;const T=v.target.closest("a");if(!T)return;const D=T.getAttribute("href");D&&(v.preventDefault(),v.stopPropagation(),window.open(D,"_blank","noopener,noreferrer"))}return a.onUnmounted(()=>{p.value&&(c.unregister(),p.value.destroy(),p.value=null)}),(v,T)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:a.normalizeStyle(C.value),onKeydown:x,onPointerdown:S,onPointermove:S,onPointerup:S,onClick:M},[p.value?(a.openBlock(),a.createBlock(a.unref(mk),{key:0,editor:p.value},null,8,["editor"])):(a.openBlock(),a.createElementBlock("div",Uw,[a.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:h.value},null,8,jw)]))],36))}}),Kw={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},qw=["d","fill","stroke","stroke-width","stroke-dasharray"],zf=a.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=pe(e.entityId,b.Shape),o=pe(e.entityId,b.VerticalAlign),r=a.ref(null),s={[b.VerticalAlignment.Top]:"flex-start",[b.VerticalAlignment.Center]:"center",[b.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>t.value?`rgba(${t.value.fillRed}, ${t.value.fillGreen}, ${t.value.fillBlue}, ${(t.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),l=a.computed(()=>t.value?t.value.strokeKind===b.StrokeKind.None?"none":`rgba(${t.value.strokeRed}, ${t.value.strokeGreen}, ${t.value.strokeBlue}, ${t.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),c=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeWidth)??2}),d=a.computed(()=>{var g;return((g=t.value)==null?void 0:g.strokeKind)??b.StrokeKind.Solid}),u=a.computed(()=>{var g;return ro[((g=t.value)==null?void 0:g.kind)??"rectangle"]??ro.rectangle}),f=a.computed(()=>{const g=c.value;switch(d.value){case b.StrokeKind.Dashed:return`${g*3} ${g*3}`;case b.StrokeKind.None:return"";case b.StrokeKind.Solid:default:return""}}),h=a.computed(()=>{var g;return{overflow:e.edited?"visible":"hidden",alignItems:s[((g=o.value)==null?void 0:g.value)??b.VerticalAlignment.Top]}}),{nextEditorTick:p}=de();function m(g){p(y=>{if(b.Text.read(y,e.entityId).content===g.content)return;const w=b.Text.write(y,e.entityId);w.content=g.content})}return(g,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-shape-block"},[(a.openBlock(),a.createElementBlock("svg",Kw,[a.createElementVNode("path",{d:u.value,fill:i.value,stroke:l.value,"stroke-width":c.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,qw)])),a.createElementVNode("div",{class:"wov-shape-content",style:a.normalizeStyle(h.value)},[a.createVNode(ps,a.mergeProps(e,{"block-element":r.value,onEditEnd:m}),null,16,["block-element"])],4)],512))}}),Gw={class:"wov-tape-block"},Jw={key:0,class:"wov-tape-placeholder"},Ff=a.defineComponent({__name:"TapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},async setup(n){let e,t;const o=n,r=a.inject(He);if(!r)throw new Error("TapeBlock must be used within a WovenCanvas component");const s=r,i=pe(o.entityId,b.Asset),l=s.getAssetManager(),c=i.value;let d=null;l&&(c!=null&&c.identifier)&&(d=([e,t]=a.withAsyncContext(()=>l.getDisplayUrl(c.identifier)),e=await e,t(),e));const u=a.ref(d),f=a.ref(!d),h=a.ref(!1);let p=!0;a.onUnmounted(()=>{p=!1});async function m(){const g=s.getAssetManager();if(!g)return;const y=i.value;if(!y||!y.identifier){f.value=!1;return}try{f.value=!0,h.value=!1;const k=await g.getDisplayUrl(y.identifier);if(!p)return;k?(u.value=k,f.value=!1):y.uploadState===b.UploadState.Failed&&(h.value=!0,f.value=!1)}catch(k){if(!p)return;console.error("Failed to get tape display URL:",k),h.value=!0,f.value=!1}}return a.watch(()=>i.value,()=>{m()},{immediate:!0}),a.onMounted(()=>{m()}),(g,y)=>(a.openBlock(),a.createElementBlock("div",Gw,[f.value&&!u.value?(a.openBlock(),a.createElementBlock("div",Jw)):u.value?(a.openBlock(),a.createElementBlock("div",{key:1,class:"wov-tape-image",style:a.normalizeStyle({backgroundImage:`url(${u.value})`})},null,4)):a.createCommentVNode("",!0)]))}}),Yw=["data-text-empty"],Hf=a.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=a.ref(null),o=pe(e.entityId,b.Text),r=a.computed(()=>{var d;return(((d=o.value)==null?void 0:d.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),s=a.computed(()=>{var l;return((l=o.value)==null?void 0:l.constrainWidth)??!1}),{handleEditEnd:i}=Bl({blockData:e,containerRef:t});return(l,c)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:t,class:"wov-text-block","data-text-empty":r.value||void 0,style:a.normalizeStyle({width:s.value?"100%":"fit-content"})},[a.createVNode(ps,a.mergeProps(e,{"block-element":t.value,onEditEnd:a.unref(i)}),null,16,["block-element","onEditEnd"])],12,Yw))}}),ms=Math.min,Mn=Math.max,gs=Math.round,ys=Math.floor,yt=n=>({x:n,y:n}),Xw={left:"right",right:"left",bottom:"top",top:"bottom"},Qw={start:"end",end:"start"};function Uf(n,e,t){return Mn(n,ms(e,t))}function ks(n,e){return typeof n=="function"?n(e):n}function Tn(n){return n.split("-")[0]}function ws(n){return n.split("-")[1]}function jf(n){return n==="x"?"y":"x"}function Wf(n){return n==="y"?"height":"width"}const Zw=new Set(["top","bottom"]);function nn(n){return Zw.has(Tn(n))?"y":"x"}function Kf(n){return jf(nn(n))}function eb(n,e,t){t===void 0&&(t=!1);const o=ws(n),r=Kf(n),s=Wf(r);let i=r==="x"?o===(t?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=bs(i)),[i,bs(i)]}function tb(n){const e=bs(n);return[Il(n),e,Il(e)]}function Il(n){return n.replace(/start|end/g,e=>Qw[e])}const qf=["left","right"],Gf=["right","left"],nb=["top","bottom"],ob=["bottom","top"];function rb(n,e,t){switch(n){case"top":case"bottom":return t?e?Gf:qf:e?qf:Gf;case"left":case"right":return e?nb:ob;default:return[]}}function sb(n,e,t,o){const r=ws(n);let s=rb(Tn(n),t==="start",o);return r&&(s=s.map(i=>i+"-"+r),e&&(s=s.concat(s.map(Il)))),s}function bs(n){return n.replace(/left|right|bottom|top/g,e=>Xw[e])}function ib(n){return{top:0,right:0,bottom:0,left:0,...n}}function lb(n){return typeof n!="number"?ib(n):{top:n,right:n,bottom:n,left:n}}function Cs(n){const{x:e,y:t,width:o,height:r}=n;return{width:o,height:r,top:t,left:e,right:e+o,bottom:t+r,x:e,y:t}}function Jf(n,e,t){let{reference:o,floating:r}=n;const s=nn(e),i=Kf(e),l=Wf(i),c=Tn(e),d=s==="y",u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,h=o[l]/2-r[l]/2;let p;switch(c){case"top":p={x:u,y:o.y-r.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:f};break;case"left":p={x:o.x-r.width,y:f};break;default:p={x:o.x,y:o.y}}switch(ws(e)){case"start":p[i]-=h*(t&&d?-1:1);break;case"end":p[i]+=h*(t&&d?-1:1);break}return p}async function ab(n,e){var t;e===void 0&&(e={});const{x:o,y:r,platform:s,rects:i,elements:l,strategy:c}=n,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=ks(e,n),m=lb(p),y=l[h?f==="floating"?"reference":"floating":f],k=Cs(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(y)))==null||t?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),w=f==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=Cs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:C,strategy:c}):w);return{top:(k.top-S.top+m.top)/x.y,bottom:(S.bottom-k.bottom+m.bottom)/x.y,left:(k.left-S.left+m.left)/x.x,right:(S.right-k.right+m.right)/x.x}}const cb=async(n,e,t)=>{const{placement:o="bottom",strategy:r="absolute",middleware:s=[],platform:i}=t,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let d=await i.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:f}=Jf(d,o,c),h=o,p={},m=0;for(let y=0;y<l.length;y++){var g;const{name:k,fn:w}=l[y],{x:C,y:x,data:S,reset:M}=await w({x:u,y:f,initialPlacement:o,placement:h,strategy:r,middlewareData:p,rects:d,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:ab},elements:{reference:n,floating:e}});u=C??u,f=x??f,p={...p,[k]:{...p[k],...S}},M&&m<=50&&(m++,typeof M=="object"&&(M.placement&&(h=M.placement),M.rects&&(d=M.rects===!0?await i.getElementRects({reference:n,floating:e,strategy:r}):M.rects),{x:u,y:f}=Jf(d,h,c)),y=-1)}return{x:u,y:f,placement:h,strategy:r,middlewareData:p}},db=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,o;const{placement:r,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=ks(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const k=Tn(r),w=nn(l),C=Tn(l)===l,x=await(c.isRTL==null?void 0:c.isRTL(d.floating)),S=h||(C||!g?[bs(l)]:tb(l)),M=m!=="none";!h&&M&&S.push(...sb(l,g,m,x));const E=[l,...S],v=await c.detectOverflow(e,y),T=[];let D=((o=s.flip)==null?void 0:o.overflows)||[];if(u&&T.push(v[k]),f){const z=eb(r,i,x);T.push(v[z[0]],v[z[1]])}if(D=[...D,{placement:r,overflows:T}],!T.every(z=>z<=0)){var P,R;const z=(((P=s.flip)==null?void 0:P.index)||0)+1,H=E[z];if(H&&(!(f==="alignment"?w!==nn(H):!1)||D.every(W=>nn(W.placement)===w?W.overflows[0]>0:!0)))return{data:{index:z,overflows:D},reset:{placement:H}};let Z=(R=D.filter(K=>K.overflows[0]<=0).sort((K,W)=>K.overflows[1]-W.overflows[1])[0])==null?void 0:R.placement;if(!Z)switch(p){case"bestFit":{var _;const K=(_=D.filter(W=>{if(M){const U=nn(W.placement);return U===w||U==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(U=>U>0).reduce((U,X)=>U+X,0)]).sort((W,U)=>W[1]-U[1])[0])==null?void 0:_[0];K&&(Z=K);break}case"initialPlacement":Z=l;break}if(r!==Z)return{reset:{placement:Z}}}return{}}}},ub=new Set(["left","top"]);async function fb(n,e){const{placement:t,platform:o,elements:r}=n,s=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Tn(t),l=ws(t),c=nn(t)==="y",d=ub.has(i)?-1:1,u=s&&c?-1:1,f=ks(e,n);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*u,y:h*d}:{x:h*d,y:p*u}}const hb=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,o;const{x:r,y:s,placement:i,middlewareData:l}=e,c=await fb(e,n);return i===((t=l.offset)==null?void 0:t.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:i}}}}},pb=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:o,placement:r,platform:s}=e,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:k=>{let{x:w,y:C}=k;return{x:w,y:C}}},...d}=ks(n,e),u={x:t,y:o},f=await s.detectOverflow(e,d),h=nn(Tn(r)),p=jf(h);let m=u[p],g=u[h];if(i){const k=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=m+f[k],x=m-f[w];m=Uf(C,m,x)}if(l){const k=h==="y"?"top":"left",w=h==="y"?"bottom":"right",C=g+f[k],x=g-f[w];g=Uf(C,g,x)}const y=c.fn({...e,[p]:m,[h]:g});return{...y,data:{x:y.x-t,y:y.y-o,enabled:{[p]:i,[h]:l}}}}}};function xs(){return typeof window<"u"}function Nn(n){return Ol(n)?(n.nodeName||"").toLowerCase():"#document"}function We(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function kt(n){var e;return(e=(Ol(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Ol(n){return xs()?n instanceof Node||n instanceof We(n).Node:!1}function st(n){return xs()?n instanceof Element||n instanceof We(n).Element:!1}function wt(n){return xs()?n instanceof HTMLElement||n instanceof We(n).HTMLElement:!1}function Yf(n){return!xs()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof We(n).ShadowRoot}const mb=new Set(["inline","contents"]);function Ho(n){const{overflow:e,overflowX:t,overflowY:o,display:r}=it(n);return/auto|scroll|overlay|hidden|clip/.test(e+o+t)&&!mb.has(r)}const gb=new Set(["table","td","th"]);function yb(n){return gb.has(Nn(n))}const kb=[":popover-open",":modal"];function Ss(n){return kb.some(e=>{try{return n.matches(e)}catch{return!1}})}const wb=["transform","translate","scale","rotate","perspective"],bb=["transform","translate","scale","rotate","perspective","filter"],Cb=["paint","layout","strict","content"];function Rl(n){const e=Pl(),t=st(n)?it(n):n;return wb.some(o=>t[o]?t[o]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||bb.some(o=>(t.willChange||"").includes(o))||Cb.some(o=>(t.contain||"").includes(o))}function xb(n){let e=on(n);for(;wt(e)&&!Jn(e);){if(Rl(e))return e;if(Ss(e))return null;e=on(e)}return null}function Pl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Sb=new Set(["html","body","#document"]);function Jn(n){return Sb.has(Nn(n))}function it(n){return We(n).getComputedStyle(n)}function Es(n){return st(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function on(n){if(Nn(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Yf(n)&&n.host||kt(n);return Yf(e)?e.host:e}function Xf(n){const e=on(n);return Jn(e)?n.ownerDocument?n.ownerDocument.body:n.body:wt(e)&&Ho(e)?e:Xf(e)}function Uo(n,e,t){var o;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Xf(n),s=r===((o=n.ownerDocument)==null?void 0:o.body),i=We(r);if(s){const l=Dl(i);return e.concat(i,i.visualViewport||[],Ho(r)?r:[],l&&t?Uo(l):[])}return e.concat(r,Uo(r,[],t))}function Dl(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Qf(n){const e=it(n);let t=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=wt(n),s=r?n.offsetWidth:t,i=r?n.offsetHeight:o,l=gs(t)!==s||gs(o)!==i;return l&&(t=s,o=i),{width:t,height:o,$:l}}function _l(n){return st(n)?n:n.contextElement}function Yn(n){const e=_l(n);if(!wt(e))return yt(1);const t=e.getBoundingClientRect(),{width:o,height:r,$:s}=Qf(e);let i=(s?gs(t.width):t.width)/o,l=(s?gs(t.height):t.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Eb=yt(0);function Zf(n){const e=We(n);return!Pl()||!e.visualViewport?Eb:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function vb(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==We(n)?!1:e}function An(n,e,t,o){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=_l(n);let i=yt(1);e&&(o?st(o)&&(i=Yn(o)):i=Yn(n));const l=vb(s,t,o)?Zf(s):yt(0);let c=(r.left+l.x)/i.x,d=(r.top+l.y)/i.y,u=r.width/i.x,f=r.height/i.y;if(s){const h=We(s),p=o&&st(o)?We(o):o;let m=h,g=Dl(m);for(;g&&o&&p!==m;){const y=Yn(g),k=g.getBoundingClientRect(),w=it(g),C=k.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,x=k.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,d*=y.y,u*=y.x,f*=y.y,c+=C,d+=x,m=We(g),g=Dl(m)}}return Cs({width:u,height:f,x:c,y:d})}function vs(n,e){const t=Es(n).scrollLeft;return e?e.left+t:An(kt(n)).left+t}function eh(n,e){const t=n.getBoundingClientRect(),o=t.left+e.scrollLeft-vs(n,t),r=t.top+e.scrollTop;return{x:o,y:r}}function Mb(n){let{elements:e,rect:t,offsetParent:o,strategy:r}=n;const s=r==="fixed",i=kt(o),l=e?Ss(e.floating):!1;if(o===i||l&&s)return t;let c={scrollLeft:0,scrollTop:0},d=yt(1);const u=yt(0),f=wt(o);if((f||!f&&!s)&&((Nn(o)!=="body"||Ho(i))&&(c=Es(o)),wt(o))){const p=An(o);d=Yn(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}const h=i&&!f&&!s?eh(i,c):yt(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-c.scrollLeft*d.x+u.x+h.x,y:t.y*d.y-c.scrollTop*d.y+u.y+h.y}}function Tb(n){return Array.from(n.getClientRects())}function Nb(n){const e=kt(n),t=Es(n),o=n.ownerDocument.body,r=Mn(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=Mn(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let i=-t.scrollLeft+vs(n);const l=-t.scrollTop;return it(o).direction==="rtl"&&(i+=Mn(e.clientWidth,o.clientWidth)-r),{width:r,height:s,x:i,y:l}}const th=25;function Ab(n,e){const t=We(n),o=kt(n),r=t.visualViewport;let s=o.clientWidth,i=o.clientHeight,l=0,c=0;if(r){s=r.width,i=r.height;const u=Pl();(!u||u&&e==="fixed")&&(l=r.offsetLeft,c=r.offsetTop)}const d=vs(o);if(d<=0){const u=o.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(o.clientWidth-f.clientWidth-p);m<=th&&(s-=m)}else d<=th&&(s+=d);return{width:s,height:i,x:l,y:c}}const Bb=new Set(["absolute","fixed"]);function Ib(n,e){const t=An(n,!0,e==="fixed"),o=t.top+n.clientTop,r=t.left+n.clientLeft,s=wt(n)?Yn(n):yt(1),i=n.clientWidth*s.x,l=n.clientHeight*s.y,c=r*s.x,d=o*s.y;return{width:i,height:l,x:c,y:d}}function nh(n,e,t){let o;if(e==="viewport")o=Ab(n,t);else if(e==="document")o=Nb(kt(n));else if(st(e))o=Ib(e,t);else{const r=Zf(n);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Cs(o)}function oh(n,e){const t=on(n);return t===e||!st(t)||Jn(t)?!1:it(t).position==="fixed"||oh(t,e)}function Ob(n,e){const t=e.get(n);if(t)return t;let o=Uo(n,[],!1).filter(l=>st(l)&&Nn(l)!=="body"),r=null;const s=it(n).position==="fixed";let i=s?on(n):n;for(;st(i)&&!Jn(i);){const l=it(i),c=Rl(i);!c&&l.position==="fixed"&&(r=null),(s?!c&&!r:!c&&l.position==="static"&&!!r&&Bb.has(r.position)||Ho(i)&&!c&&oh(n,i))?o=o.filter(u=>u!==i):r=l,i=on(i)}return e.set(n,o),o}function Rb(n){let{element:e,boundary:t,rootBoundary:o,strategy:r}=n;const i=[...t==="clippingAncestors"?Ss(e)?[]:Ob(e,this._c):[].concat(t),o],l=i[0],c=i.reduce((d,u)=>{const f=nh(e,u,r);return d.top=Mn(f.top,d.top),d.right=ms(f.right,d.right),d.bottom=ms(f.bottom,d.bottom),d.left=Mn(f.left,d.left),d},nh(e,l,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Pb(n){const{width:e,height:t}=Qf(n);return{width:e,height:t}}function Db(n,e,t){const o=wt(e),r=kt(e),s=t==="fixed",i=An(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=yt(0);function d(){c.x=vs(r)}if(o||!o&&!s)if((Nn(e)!=="body"||Ho(r))&&(l=Es(e)),o){const p=An(e,!0,s,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else r&&d();s&&!o&&r&&d();const u=r&&!o&&!s?eh(r,l):yt(0),f=i.left+l.scrollLeft-c.x-u.x,h=i.top+l.scrollTop-c.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function Ll(n){return it(n).position==="static"}function rh(n,e){if(!wt(n)||it(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return kt(n)===t&&(t=t.ownerDocument.body),t}function sh(n,e){const t=We(n);if(Ss(n))return t;if(!wt(n)){let r=on(n);for(;r&&!Jn(r);){if(st(r)&&!Ll(r))return r;r=on(r)}return t}let o=rh(n,e);for(;o&&yb(o)&&Ll(o);)o=rh(o,e);return o&&Jn(o)&&Ll(o)&&!Rl(o)?t:o||xb(n)||t}const _b=async function(n){const e=this.getOffsetParent||sh,t=this.getDimensions,o=await t(n.floating);return{reference:Db(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Lb(n){return it(n).direction==="rtl"}const Vb={convertOffsetParentRelativeRectToViewportRelativeRect:Mb,getDocumentElement:kt,getClippingRect:Rb,getOffsetParent:sh,getElementRects:_b,getClientRects:Tb,getDimensions:Pb,getScale:Yn,isElement:st,isRTL:Lb};function ih(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function $b(n,e){let t=null,o;const r=kt(n);function s(){var l;clearTimeout(o),(l=t)==null||l.disconnect(),t=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=n.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=d;if(l||e(),!h||!p)return;const m=ys(f),g=ys(r.clientWidth-(u+h)),y=ys(r.clientHeight-(f+p)),k=ys(u),C={rootMargin:-m+"px "+-g+"px "+-y+"px "+-k+"px",threshold:Mn(0,ms(1,c))||1};let x=!0;function S(M){const E=M[0].intersectionRatio;if(E!==c){if(!x)return i();E?i(!1,E):o=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!ih(d,n.getBoundingClientRect())&&i(),x=!1}try{t=new IntersectionObserver(S,{...C,root:r.ownerDocument})}catch{t=new IntersectionObserver(S,C)}t.observe(n)}return i(!0),s}function Ms(n,e,t,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,d=_l(n),u=r||s?[...d?Uo(d):[],...Uo(e)]:[];u.forEach(k=>{r&&k.addEventListener("scroll",t,{passive:!0}),s&&k.addEventListener("resize",t)});const f=d&&l?$b(d,t):null;let h=-1,p=null;i&&(p=new ResizeObserver(k=>{let[w]=k;w&&w.target===d&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(e)})),t()}),d&&!c&&p.observe(d),p.observe(e));let m,g=c?An(n):null;c&&y();function y(){const k=An(n);g&&!ih(g,k)&&t(),g=k,m=requestAnimationFrame(y)}return t(),()=>{var k;u.forEach(w=>{r&&w.removeEventListener("scroll",t),s&&w.removeEventListener("resize",t)}),f==null||f(),(k=p)==null||k.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const Xn=hb,Qn=pb,Zn=db,zb=(n,e,t)=>{const o=new Map,r={platform:Vb,...t},s={...r.platform,_c:o};return cb(n,e,{...r,platform:s})};function Fb(n){return n!=null&&typeof n=="object"&&"$el"in n}function lh(n){if(Fb(n)){const e=n.$el;return Ol(e)&&Nn(e)==="#comment"?null:e}return n}function jo(n){return typeof n=="function"?n():a.unref(n)}function ah(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function ch(n,e){const t=ah(n);return Math.round(e*t)/t}function eo(n,e,t){t===void 0&&(t={});const o=t.whileElementsMounted,r=a.computed(()=>{var E;return(E=jo(t.open))!=null?E:!0}),s=a.computed(()=>jo(t.middleware)),i=a.computed(()=>{var E;return(E=jo(t.placement))!=null?E:"bottom"}),l=a.computed(()=>{var E;return(E=jo(t.strategy))!=null?E:"absolute"}),c=a.computed(()=>{var E;return(E=jo(t.transform))!=null?E:!0}),d=a.computed(()=>lh(n.value)),u=a.computed(()=>lh(e.value)),f=a.ref(0),h=a.ref(0),p=a.ref(l.value),m=a.ref(i.value),g=a.shallowRef({}),y=a.ref(!1),k=a.computed(()=>{const E={position:p.value,left:"0",top:"0"};if(!u.value)return E;const v=ch(u.value,f.value),T=ch(u.value,h.value);return c.value?{...E,transform:"translate("+v+"px, "+T+"px)",...ah(u.value)>=1.5&&{willChange:"transform"}}:{position:p.value,left:v+"px",top:T+"px"}});let w;function C(){if(d.value==null||u.value==null)return;const E=r.value;zb(d.value,u.value,{middleware:s.value,placement:i.value,strategy:l.value}).then(v=>{f.value=v.x,h.value=v.y,p.value=v.strategy,m.value=v.placement,g.value=v.middlewareData,y.value=E!==!1})}function x(){typeof w=="function"&&(w(),w=void 0)}function S(){if(x(),o===void 0){C();return}if(d.value!=null&&u.value!=null){w=o(d.value,u.value,C);return}}function M(){r.value||(y.value=!1)}return a.watch([s,i,l,r],C,{flush:"sync"}),a.watch([d,u],S,{flush:"sync"}),a.watch(r,M,{flush:"sync"}),a.getCurrentScope()&&a.onScopeDispose(x),{x:a.shallowReadonly(f),y:a.shallowReadonly(h),strategy:a.shallowReadonly(p),placement:a.shallowReadonly(m),middlewareData:a.shallowReadonly(g),isPositioned:a.shallowReadonly(y),floatingStyles:k,update:C}}const Hb=["menu-open"],Ke=a.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(n,{emit:e}){const t=n,o=e,r=a.inject("containerRef"),s=a.inject(sa,null),i=a.inject(ia,0),l=Math.random().toString(36).slice(2);a.provide(ia,i+1);const{show:c,hide:d}=Dt(),u=a.ref(!1);s&&a.watch(()=>s.value.get(i),C=>{C!==void 0&&C!==l&&u.value&&(u.value=!1)});const f=a.ref(null),h=a.ref(null),{floatingStyles:p}=eo(f,h,{placement:t.placement,middleware:[Xn(t.offsetPx),Zn(),Qn({padding:8})],whileElementsMounted:Ms});function m(){t.disabled||(u.value=!u.value)}function g(){u.value=!1}function y(C){var v,T,D;const x=C.target,S=(v=f.value)==null?void 0:v.contains(x),M=(T=h.value)==null?void 0:T.contains(x),E=(D=x.closest)==null?void 0:D.call(x,".wov-menu-dropdown");!S&&!M&&!E&&g()}function k(){t.title&&f.value&&!u.value&&c(t.title,f.value)}function w(){d()}return a.watch(u,C=>{C?(d(),document.addEventListener("click",y,!0),s&&(s.value.set(i,l),s.value=new Map(s.value)),o("open")):(document.removeEventListener("click",y,!0),(s==null?void 0:s.value.get(i))===l&&(s.value.delete(i),s.value=new Map(s.value)),o("close"))}),a.onUnmounted(()=>{document.removeEventListener("click",y,!0)}),(C,x)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:a.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:x[0]||(x[0]=a.withModifiers(()=>{},["prevent"])),onClick:m,onMouseenter:k,onMouseleave:w},[a.renderSlot(C.$slots,"button",{isOpen:u.value})],42,Hb),a.unref(r)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(r)},[u.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"wov-menu-dropdown",style:a.normalizeStyle(a.unref(p))},[a.renderSlot(C.$slots,"dropdown",{close:g})],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),Ub={},jb={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function Wb(n,e){return a.openBlock(),a.createElementBlock("svg",jb,[...e[0]||(e[0]=[a.createElementVNode("path",{d:"M233.4 278.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 210.7 86.6 41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"},null,-1)])])}const qe=an(Ub,[["render",Wb]]),Kb={class:"wov-menu-button"},qb=["innerHTML"],Gb=["onClick"],Jb=["innerHTML"],Vl=a.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=a.shallowRef(null),r=a.computed(()=>{const l=o.value??(e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V);return On(l)});t(l=>{let c=null;for(const d of e.entityIds){if(b.hasComponent(l,d,ee.ElbowArrow)){const u=ee.ElbowArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V;return}}if(b.hasComponent(l,d,ee.ArcArrow)){const u=ee.ArcArrow.read(l,d),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(c===null)c=f;else if(f!==c){o.value=e.side==="start"?ee.ArrowHeadKind.None:ee.ArrowHeadKind.V;return}}}o.value=c});function s(l){o.value=l,t(c=>{for(const d of e.entityIds){if(b.hasComponent(c,d,ee.ElbowArrow)){const u=ee.ElbowArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}if(b.hasComponent(c,d,ee.ArcArrow)){const u=ee.ArcArrow.write(c,d);e.side==="start"?u.startArrowHead=l:u.endArrowHead=l}}})}function i(l){if(!l)return"";const c=e.side==="start";return`<line x1="${c?8:4}" y1="12" x2="${c?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${c?4:20}, 12) scale(${c?"-0.8, 0.8":"0.8"})`}">${l.svg}</g>`}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:n.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:a.withCtx(()=>[a.createElementVNode("div",Kb,[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(r.value)},null,8,qb)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(a.unref(Ds),d=>(a.openBlock(),a.createElementBlock("button",{key:d.kind,class:a.normalizeClass(["wov-menu-option",{"is-active":o.value===d.kind}]),onClick:u=>s(d.kind)},[(a.openBlock(),a.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(d)},null,8,Jb))],10,Gb))),128))]),_:1},8,["title"]))}}),Yb={class:"wov-menu-button"},Xb=["onClick"],dh=a.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],t=n,{nextEditorTick:o}=de(),r=a.shallowRef(null);o(i=>{let l=null;for(const c of t.entityIds){if(b.hasComponent(i,c,ee.ElbowArrow)){const d=ee.ElbowArrow.read(i,c);if(l===null)l=d.thickness;else if(d.thickness!==l){r.value=null;return}}if(b.hasComponent(i,c,ee.ArcArrow)){const d=ee.ArcArrow.getThickness(i,c);if(l===null)l=d;else if(d!==l){r.value=null;return}}}r.value=l});function s(i){r.value=i,o(l=>{for(const c of t.entityIds){if(b.hasComponent(l,c,ee.ElbowArrow)){const d=ee.ElbowArrow.write(l,c);d.thickness=i}b.hasComponent(l,c,ee.ArcArrow)&&ee.ArcArrow.setThickness(l,c,i)}})}return(i,l)=>(a.openBlock(),a.createBlock(Ke,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",Yb,[l[0]||(l[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,c=>a.createElementVNode("button",{key:c.value,class:a.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":r.value===c.value}]),onClick:d=>s(c.value)},a.toDisplayString(c.label),11,Xb)),64))]),_:1}))}}),Qb=["value"],Zb=a.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(t.modelValue??"");a.watch(()=>t.modelValue,u=>{u&&u!==r.value&&(r.value=u)});function s(u){const f=u.startsWith("#")?u:`#${u}`;return/^#[0-9A-Fa-f]{6}$/.test(f)}function i(u){return(u.startsWith("#")?u:`#${u}`).toLowerCase()}function l(u){let h=u.target.value;if((h.length===6||h.length===7)&&s(h)){const p=i(h);r.value=p,o("update:modelValue",p)}}function c(u){const h=u.target.value;if(h&&s(h)){const p=i(h);r.value=p,o("update:modelValue",p)}else t.modelValue&&(r.value=t.modelValue)}function d(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,h=f.value;if(h&&s(h)){const p=i(h);r.value=p,o("update:modelValue",p),setTimeout(()=>f.select())}}}return(u,f)=>(a.openBlock(),a.createElementBlock("input",{id:"wov-color-input",class:"wov-color-input",type:"text",size:"1","aria-label":"Hex color value",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",value:r.value,onInput:l,onChange:c,onKeydown:d},null,40,Qb))}}),uh=a.defineComponent({__name:"ColorSlider",props:{modelValue:{},thumbColor:{},background:{}},emits:["update:modelValue"],setup(n,{expose:e,emit:t}){const o=t,r=a.ref(null),s=a.ref(!1);function i(d){s.value=!0,l(d),window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)}function l(d){if(!r.value)return;const u=r.value.getBoundingClientRect(),f=Math.max(0,Math.min(100,(d.clientY-u.top)/u.height*100));o("update:modelValue",f)}function c(){s.value=!1,window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)}return e({isDragging:s}),(d,u)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"sliderRef",ref:r,class:"wov-color-slider",onPointerdown:a.withModifiers(i,["prevent"])},[n.background?(a.openBlock(),a.createElementBlock("div",{key:0,class:"wov-color-slider-gradient",style:a.normalizeStyle({background:n.background})},null,4)):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"wov-color-slider-thumb",style:a.normalizeStyle({top:`${n.modelValue}%`,backgroundColor:n.thumbColor})},null,4)],544))}}),e2={class:"wov-color-picker"},t2={class:"wov-color-picker-area"},n2={class:"wov-color-picker-selector-gradient"},o2="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",fh=a.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),s=a.ref(null),i=a.ref(null),l=a.ref({x:100,y:0}),c=a.ref(0),d=a.ref(0),u=a.ref(!1),f=a.computed(()=>{var M,E;return u.value||((M=r.value)==null?void 0:M.isDragging)||((E=s.value)==null?void 0:E.isDragging)}),h=a.computed(()=>({h:c.value/100*360,s:l.value.x,v:100-l.value.y,a:(100-d.value)/100*255})),p=a.computed(()=>Rf({h:h.value.h,s:100,v:100})),m=a.computed(()=>Rf({h:h.value.h,s:h.value.s,v:h.value.v})),g=a.computed(()=>t.withOpacity?Pf(h.value):m.value),y=a.computed(()=>`linear-gradient(to top, transparent 0%, ${m.value} 100%)`);function k(M){if(M){const E=Of(M);l.value={x:E.s,y:100-E.v},c.value=E.h/360*100,d.value=100-E.a/255*100}}function w(M){k(M),o("update:modelValue",t.withOpacity?Pf(Of(M)):M)}k(t.modelValue),a.watch(()=>t.modelValue,M=>{f.value||k(M)}),a.watch([l,c,d],()=>{f.value&&o("update:modelValue",g.value)});function C(M){u.value=!0,x(M),window.addEventListener("pointermove",x),window.addEventListener("pointerup",S)}function x(M){if(!i.value)return;const E=i.value.getBoundingClientRect(),v=Math.max(0,Math.min(100,(M.clientX-E.left)/E.width*100)),T=Math.max(0,Math.min(100,(M.clientY-E.top)/E.height*100));l.value={x:v,y:T}}function S(){u.value=!1,window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",S)}return(M,E)=>(a.openBlock(),a.createElementBlock("div",e2,[a.createVNode(Zb,{modelValue:g.value,"onUpdate:modelValue":w},null,8,["modelValue"]),a.createElementVNode("div",t2,[a.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:a.normalizeStyle({backgroundColor:p.value}),onPointerdown:a.withModifiers(C,["prevent"])},[a.createElementVNode("div",n2,[a.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:a.normalizeStyle({left:`${l.value.x}%`,top:`${l.value.y}%`,backgroundColor:m.value})},null,4)])],36),a.createVNode(uh,{ref_key:"hueSliderRef",ref:r,modelValue:c.value,"onUpdate:modelValue":E[0]||(E[0]=v=>c.value=v),thumbColor:p.value,background:o2},null,8,["modelValue","thumbColor"]),n.withOpacity?(a.openBlock(),a.createBlock(uh,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:d.value,"onUpdate:modelValue":E[1]||(E[1]=v=>d.value=v),thumbColor:m.value,background:y.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):a.createCommentVNode("",!0)])]))}}),r2={class:"wov-color-bubbles-container"},s2={key:1,class:"wov-color-bubbles"},i2=["onClick"],Ts=a.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(n,{emit:e}){const t=n,o=e,r=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=a.computed(()=>{const m=t.palette??r,g=t.withPicker,y=m.length%2===1;return g&&!y||!g&&y?m.slice(0,-1):m}),i=a.ref(!1),l=a.ref(t.currentColor??"#ff0000");function c(m,g){const y=k=>{const w=k.replace(/^#/,"").toLowerCase();return w.length===6?w+"ff":w};return y(m)===y(g)}function d(m){return t.hideHighlight||!t.currentColor?!1:c(t.currentColor,m)}function u(){return t.hideHighlight||!t.currentColor?!1:!s.value.some(m=>c(t.currentColor,m))}function f(m){const g=El(m);g&&o("change",g)}function h(){!i.value&&t.currentColor&&(l.value=t.currentColor),i.value=!i.value,o("picker-open",i.value)}function p(m){l.value=m;const g=El(m);g&&o("change",g)}return(m,g)=>(a.openBlock(),a.createElementBlock("div",r2,[i.value?(a.openBlock(),a.createBlock(fh,{key:0,modelValue:l.value,"onUpdate:modelValue":[g[0]||(g[0]=y=>l.value=y),p],withOpacity:n.withOpacity},null,8,["modelValue","withOpacity"])):(a.openBlock(),a.createElementBlock("div",s2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,y=>(a.openBlock(),a.createElementBlock("div",{key:y,class:a.normalizeClass(["wov-color-bubble",{selected:d(y)}]),style:a.normalizeStyle({backgroundColor:y}),onMousedown:g[1]||(g[1]=a.withModifiers(()=>{},["prevent"])),onClick:k=>f(y)},null,46,i2))),128)),n.withPicker?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:g[2]||(g[2]=a.withModifiers(()=>{},["prevent"])),onClick:h},null,34)):a.createCommentVNode("",!0)]))]))}}),l2={class:"wov-color-button"},hh=a.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Color),r=a.computed(()=>{const d=new Set;for(const u of o.value.values())if(u){const f=zo(u);d.add(f)}return Array.from(d)}),s=a.computed(()=>r.value.length>1),i=a.computed(()=>r.value[0]??null),l=a.computed(()=>{if(r.value.length===0)return{backgroundColor:"#000"};if(r.value.length>=2){const d=r.value[0],u=r.value[1];return{background:`linear-gradient(45deg, ${d} 0%, ${d} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:r.value[0]}});function c(d){const u=zo(d);t(f=>{for(const h of e.entityIds)b.Color.fromHex(f,h,u)})}return(d,u)=>(a.openBlock(),a.createBlock(Ke,{title:"Color"},{button:a.withCtx(()=>[a.createElementVNode("div",l2,[a.createElementVNode("div",{class:"wov-color-swatch",style:a.normalizeStyle(l.value)},null,4),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(Ts,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:c},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Bn=a.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(n,{emit:e}){const t=n,o=e,r=a.ref(null),{show:s,hide:i}=Dt();function l(u){o("click",u)}function c(){t.title&&r.value&&s(t.title,r.value)}function d(){i()}return(u,f)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:"wov-menu-button",onClick:l,onMouseenter:c,onMouseleave:d},[a.renderSlot(u.$slots,"default")],544))}}),$l=a.defineComponent({__name:"MenuTooltip",setup(n){const{activeTooltip:e,isVisible:t}=Dt(),o=a.inject("containerRef"),r=a.ref(null),s=a.computed(()=>{var c;return((c=e.value)==null?void 0:c.anchor)??null}),{floatingStyles:i}=eo(s,r,{placement:"top",middleware:[Xn(8),Zn({fallbackPlacements:["bottom"]}),Qn({padding:8})]}),l=a.computed(()=>{var c;return t.value&&((c=e.value)==null?void 0:c.text)});return(c,d)=>a.unref(o)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(o)},[a.createVNode(a.Transition,{name:"wov-tooltip-fade"},{default:a.withCtx(()=>{var u;return[l.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:r,class:"wov-menu-tooltip",style:a.normalizeStyle(a.unref(i))},a.toDisplayString((u=a.unref(e))==null?void 0:u.text),5)):a.createCommentVNode("",!0)]}),_:1})],8,["to"])):a.createCommentVNode("",!0)}}),a2={class:"wov-menu-button"},c2=["onClick"],ph=a.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(n){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],t=n,{nextEditorTick:o}=de(),r=Rt(()=>t.entityIds,qo.PenStroke),s=a.computed(()=>{let l=null;for(const c of r.value.values())if(c){if(l===null)l=c.thickness;else if(c.thickness!==l)return null}return l});function i(l){o(c=>{for(const d of t.entityIds){const u=qo.PenStroke.write(c,d);u.thickness=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:"Thickness"},{button:a.withCtx(()=>[a.createElementVNode("div",a2,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[a.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),a.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),a.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("button",{key:d.value,class:a.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===d.value}]),onClick:u=>i(d.value)},a.toDisplayString(d.label),11,c2)),64))]),_:1}))}}),d2={class:"wov-fill-color-button"},u2={class:"wov-fill-dropdown"},f2={key:0,class:"wov-fill-mode-section"},h2=["title","onClick"],p2={viewBox:"0 0 24 24",fill:"none"},m2=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],mh=a.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Shape),r=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=a.computed(()=>{const p=o.value.values().next().value,m=(p==null?void 0:p.fillAlpha)??255;return m===0?"none":m<200?"faded":"solid"}),i=a.computed(()=>{const p=new Set;for(const m of o.value.values())if(m){const g=m.fillAlpha??255;g===0?p.add("none"):g<200?p.add("faded"):p.add("solid")}return p.size>1});function l(p){t(m=>{for(const g of e.entityIds){const y=b.Shape.write(m,g);y.fillAlpha=p}})}const c=a.computed(()=>{const p=new Set;for(const m of o.value.values())if(m){const g=zo({red:m.fillRed,green:m.fillGreen,blue:m.fillBlue,alpha:m.fillAlpha??255});p.add(g)}return Array.from(p)}),d=a.computed(()=>c.value.length>1),u=a.computed(()=>c.value[0]??"#4a90d9");function f(p){t(m=>{for(const g of e.entityIds){const y=b.Shape.write(m,g);y.fillRed=p.red,y.fillGreen=p.green,y.fillBlue=p.blue,y.fillAlpha=p.alpha}})}const h=a.ref(!1);return(p,m)=>(a.openBlock(),a.createBlock(Ke,{title:"Fill Color"},{button:a.withCtx(()=>[a.createElementVNode("div",d2,[m[1]||(m[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M5.879,2.625L14.121,2.625C15.906,2.625 17.375,4.094 17.375,5.879L17.375,14.121C17.375,15.906 15.906,17.375 14.121,17.375L5.88,17.375C4.095,17.375 2.626,15.906 2.626,14.121L2.626,5.88C2.626,4.095 4.095,2.626 5.88,2.626L5.879,2.625Z","stroke-width":"1.25"}),a.createElementVNode("path",{d:"M2.779,14.655L14.543,2.871M10.238,17.308L17.318,10.229M2.876,9.577L9.853,2.6M5.397,17.239L17.16,5.476","stroke-width":"1.25"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",u2,[h.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",f2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,g=>a.createElementVNode("button",{key:g.mode,class:a.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&g.mode===s.value}]),title:g.label,onClick:y=>l(g.alpha)},[(a.openBlock(),a.createElementBlock("svg",p2,[a.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:g.mode==="none"?"none":"currentColor","fill-opacity":g.mode==="faded"?.4:1,stroke:g.mode==="none"?"currentColor":"none","stroke-width":g.mode==="none"?1.5:0,"stroke-dasharray":g.mode==="none"?"3 3":""},null,8,m2)])),a.createElementVNode("span",null,a.toDisplayString(g.label),1)],10,h2)),64))])),a.createVNode(Ts,{currentColor:u.value,hideHighlight:d.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:m[0]||(m[0]=g=>h.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),g2={class:"wov-shape-kind-button"},y2={class:"wov-shape-kind-dropdown"},k2=["onClick"],w2={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},b2=["d"],gh=a.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Shape),r=a.computed(()=>{const c=o.value.values().next().value;return(c==null?void 0:c.kind)??"rectangle"}),s=a.computed(()=>{const c=new Set;for(const d of o.value.values())d&&c.add(d.kind);return c.size>1}),i=a.computed(()=>Object.keys(ro).map(c=>({kind:c,label:c.charAt(0).toUpperCase()+c.slice(1)})));function l(c){t(d=>{for(const u of e.entityIds){const f=b.Shape.write(d,u);f.kind=c}})}return(c,d)=>(a.openBlock(),a.createBlock(Ke,{title:"Shape Type"},{button:a.withCtx(()=>[a.createElementVNode("div",g2,[d[0]||(d[0]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),a.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",y2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,u=>(a.openBlock(),a.createElementBlock("button",{key:u.kind,class:a.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===r.value}]),onClick:f=>l(u.kind)},[(a.openBlock(),a.createElementBlock("svg",w2,[a.createElementVNode("path",{d:a.unref(ro)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,b2)])),a.createElementVNode("span",null,a.toDisplayString(u.label),1)],10,k2))),128))])]),_:1}))}}),C2={class:"wov-stroke-style-section"},x2=["title","onClick"],S2={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},E2=["stroke-dasharray","stroke-opacity"],v2=a.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(n,{emit:e}){const t=e,o=[{kind:b.StrokeKind.Solid,label:"Solid"},{kind:b.StrokeKind.Dashed,label:"Dashed"},{kind:b.StrokeKind.None,label:"None"}];function r(i){switch(i){case b.StrokeKind.Dashed:return"6 6";case b.StrokeKind.None:return"";case b.StrokeKind.Solid:default:return""}}function s(i){t("change",i)}return(i,l)=>(a.openBlock(),a.createElementBlock("div",C2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(o,c=>a.createElementVNode("button",{key:c.kind,class:a.normalizeClass(["wov-stroke-style-option",{"is-active":!n.hasMultipleStyles&&c.kind===n.currentStyle}]),title:c.label,onClick:d=>s(c.kind)},[(a.openBlock(),a.createElementBlock("svg",S2,[a.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":r(c.kind),"stroke-opacity":c.kind===a.unref(b.StrokeKind).None?.3:1},null,8,E2)])),a.createElementVNode("span",null,a.toDisplayString(c.label),1)],10,x2)),64))]))}}),M2={class:"wov-stroke-color-button"},T2={class:"wov-stroke-dropdown"},N2={key:1,class:"wov-stroke-divider"},yh=a.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),o=Rt(()=>e.entityIds,b.Shape),r=a.ref(!1),s=a.computed(()=>{const h=new Set;for(const p of o.value.values())if(p){const m=zo({red:p.strokeRed,green:p.strokeGreen,blue:p.strokeBlue,alpha:255});h.add(m)}return Array.from(h)}),i=a.computed(()=>s.value.length>1),l=a.computed(()=>s.value[0]??"#000000"),c=a.computed(()=>{const h=o.value.values().next().value;return(h==null?void 0:h.strokeKind)??b.StrokeKind.Solid}),d=a.computed(()=>{const h=new Set;for(const p of o.value.values())p&&h.add(p.strokeKind);return h.size>1});function u(h){t(p=>{for(const m of e.entityIds){const g=b.Shape.write(p,m);g.strokeRed=h.red,g.strokeGreen=h.green,g.strokeBlue=h.blue}})}function f(h){t(p=>{for(const m of e.entityIds){const g=b.Shape.write(p,m);g.strokeKind=h}})}return(h,p)=>(a.openBlock(),a.createBlock(Ke,{title:"Stroke Color"},{button:a.withCtx(()=>[a.createElementVNode("div",M2,[p[1]||(p[1]=a.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43","stroke-width":"1.25"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",T2,[r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createBlock(v2,{key:0,currentStyle:c.value,hasMultipleStyles:d.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),r.value?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",N2)),a.createVNode(Ts,{currentColor:l.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:p[0]||(p[0]=m=>r.value=m)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),A2={class:"wov-tape-image-button"},B2={class:"wov-tape-image-bubbles"},I2=["onClick"],kh=a.defineComponent({__name:"TapeImageButton",props:{entityIds:{}},setup(n){const e=[{name:"Masking Tape",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media"},{name:"Transparent",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F522899b7-0ae9-4303-bdca-71105d835210.png?generation=1715183195130528&alt=media"},{name:"Arabic",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F3658d208-67e9-48a4-865b-44842187b523.png?generation=1715183192038109&alt=media"},{name:"Balloons",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7d836c56-ae9a-44e6-a624-e6a49286dcde.png?generation=1715183193267076&alt=media"},{name:"Flowers",url:"https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2Fc1a1b89a-543f-4817-8afa-76544e94d776.png?generation=1715183194007112&alt=media"}],t=n,{nextEditorTick:o}=de(),r=Rt(()=>t.entityIds,b.Asset),s=a.computed(()=>{for(const l of r.value.values())if(l!=null&&l.identifier)return l.identifier;return null});function i(l){o(c=>{for(const d of t.entityIds){const u=b.Asset.write(c,d);u.identifier=l}})}return(l,c)=>(a.openBlock(),a.createBlock(Ke,{title:"Tape Style"},{button:a.withCtx(()=>[a.createElementVNode("div",A2,[a.createElementVNode("div",{class:"wov-tape-image-swatch",style:a.normalizeStyle(s.value?{backgroundImage:`url(${s.value})`}:{})},null,4),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",B2,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(e,d=>a.createElementVNode("div",{key:d.url,class:a.normalizeClass(["wov-tape-image-bubble",{selected:s.value===d.url}]),style:a.normalizeStyle({backgroundImage:`url(${d.url})`}),onMousedown:c[0]||(c[0]=a.withModifiers(()=>{},["prevent"])),onClick:u=>i(d.url)},null,46,I2)),64))])]),_:1}))}}),O2={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},R2={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},P2={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},D2={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},zl=a.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=[b.TextAlignment.Left,b.TextAlignment.Center,b.TextAlignment.Right,b.TextAlignment.Justify];function s(){const i=r.indexOf(t.alignment),l=r[(i+1)%r.length];o.setAlignment(l)}return(i,l)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Text Align",onClick:s},{default:a.withCtx(()=>[a.unref(t).alignment===a.unref(b.TextAlignment).Left?(a.openBlock(),a.createElementBlock("svg",O2,[...l[0]||(l[0]=[a.createElementVNode("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):a.unref(t).alignment===a.unref(b.TextAlignment).Center?(a.openBlock(),a.createElementBlock("svg",R2,[...l[1]||(l[1]=[a.createElementVNode("path",{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},null,-1)])])):a.unref(t).alignment===a.unref(b.TextAlignment).Right?(a.openBlock(),a.createElementBlock("svg",P2,[...l[2]||(l[2]=[a.createElementVNode("path",{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",D2,[...l[3]||(l[3]=[a.createElementVNode("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),Fl=a.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Bold",class:a.normalizeClass({"wov-active":a.unref(t).isBold}),onClick:a.unref(o).toggleBold},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}});function _2(n,e){return a.getCurrentScope()?(a.onScopeDispose(n,e),!0):!1}const L2=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const V2=Object.prototype.toString,$2=n=>V2.call(n)==="[object Object]",Ns=()=>{};function As(n){return Array.isArray(n)?n:[n]}function z2(n){return a.getCurrentInstance()}function F2(n,e=!0,t){z2()?a.onMounted(n,t):e?n():a.nextTick(n)}function H2(n,e,t){return a.watch(n,e,{...t,immediate:!0})}const Bs=L2?window:void 0;function lt(n){var e;const t=a.toValue(n);return(e=t==null?void 0:t.$el)!==null&&e!==void 0?e:t}function Hl(...n){const e=(o,r,s,i)=>(o.addEventListener(r,s,i),()=>o.removeEventListener(r,s,i)),t=a.computed(()=>{const o=As(a.toValue(n[0])).filter(r=>r!=null);return o.every(r=>typeof r!="string")?o:void 0});return H2(()=>{var o,r;return[(o=(r=t.value)===null||r===void 0?void 0:r.map(s=>lt(s)))!==null&&o!==void 0?o:[Bs].filter(s=>s!=null),As(a.toValue(t.value?n[1]:n[0])),As(a.unref(t.value?n[2]:n[1])),a.toValue(t.value?n[3]:n[2])]},([o,r,s,i],l,c)=>{if(!(o!=null&&o.length)||!(r!=null&&r.length)||!(s!=null&&s.length))return;const d=$2(i)?{...i}:i,u=o.flatMap(f=>r.flatMap(h=>s.map(p=>e(f,h,p,d))));c(()=>{u.forEach(f=>f())})},{flush:"post"})}function U2(n,e,t={}){const{window:o=Bs,ignore:r=[],capture:s=!0,detectIframe:i=!1,controls:l=!1}=t;if(!o)return l?{stop:Ns,cancel:Ns,trigger:Ns}:Ns;let c=!0;const d=y=>a.toValue(r).some(k=>{if(typeof k=="string")return Array.from(o.document.querySelectorAll(k)).some(w=>w===y.target||y.composedPath().includes(w));{const w=lt(k);return w&&(y.target===w||y.composedPath().includes(w))}});function u(y){const k=a.toValue(y);return k&&k.$.subTree.shapeFlag===16}function f(y,k){const w=a.toValue(y),C=w.$.subTree&&w.$.subTree.children;return C==null||!Array.isArray(C)?!1:C.some(x=>x.el===k.target||k.composedPath().includes(x.el))}const h=y=>{const k=lt(n);if(y.target!=null&&!(!(k instanceof Element)&&u(n)&&f(n,y))&&!(!k||k===y.target||y.composedPath().includes(k))){if("detail"in y&&y.detail===0&&(c=!d(y)),!c){c=!0;return}e(y)}};let p=!1;const m=[Hl(o,"click",y=>{p||(p=!0,setTimeout(()=>{p=!1},0),h(y))},{passive:!0,capture:s}),Hl(o,"pointerdown",y=>{const k=lt(n);c=!d(y)&&!!(k&&!y.composedPath().includes(k))},{passive:!0}),i&&Hl(o,"blur",y=>{setTimeout(()=>{var k;const w=lt(n);((k=o.document.activeElement)===null||k===void 0?void 0:k.tagName)==="IFRAME"&&!(w!=null&&w.contains(o.document.activeElement))&&e(y)},0)},{passive:!0})].filter(Boolean),g=()=>m.forEach(y=>y());return l?{stop:g,cancel:()=>{c=!1},trigger:y=>{c=!0,h(y),c=!1}}:g}function j2(){const n=a.shallowRef(!1),e=a.getCurrentInstance();return e&&a.onMounted(()=>{n.value=!0},e),n}function W2(n){const e=j2();return a.computed(()=>(e.value,!!n()))}function K2(n,e,t={}){const{window:o=Bs,...r}=t;let s;const i=W2(()=>o&&"ResizeObserver"in o),l=()=>{s&&(s.disconnect(),s=void 0)},c=a.watch(a.computed(()=>{const u=a.toValue(n);return Array.isArray(u)?u.map(f=>lt(f)):[lt(u)]}),u=>{if(l(),i.value&&o){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,r)}},{immediate:!0,flush:"post"}),d=()=>{l(),c()};return _2(d),{isSupported:i,stop:d}}function wh(n,e={width:0,height:0},t={}){const{window:o=Bs,box:r="content-box"}=t,s=a.computed(()=>{var f;return(f=lt(n))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=a.shallowRef(e.width),l=a.shallowRef(e.height),{stop:c}=K2(n,([f])=>{const h=r==="border-box"?f.borderBoxSize:r==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(o&&s.value){const p=lt(n);if(p){const m=p.getBoundingClientRect();i.value=m.width,l.value=m.height}}else if(h){const p=As(h);i.value=p.reduce((m,{inlineSize:g})=>m+g,0),l.value=p.reduce((m,{blockSize:g})=>m+g,0)}else i.value=f.contentRect.width,l.value=f.contentRect.height},t);F2(()=>{const f=lt(n);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,l.value="offsetHeight"in f?f.offsetHeight:e.height)});const d=a.watch(()=>lt(n),f=>{i.value=f?e.width:0,l.value=f?e.height:0});function u(){c(),d()}return{width:i,height:l,stop:u}}function bh(){const n=a.inject(He);if(!n)throw new Error("useFonts must be used within a WovenCanvas component");return a.computed(()=>{const e=n.getEditor();return e?e.fonts.filter(t=>t.selectable):[]})}const q2={class:"wov-font-family-button"},G2={class:"wov-font-family-label"},J2={class:"wov-font-list"},Y2=["onClick"],X2=["src","alt"],Ul=a.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=bh(),s=a.computed(()=>r.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=a.computed(()=>t.fontFamily),l=a.computed(()=>{const u=i.value;if(u===null)return"Mixed";const f=s.value.find(h=>h.name===u);return(f==null?void 0:f.displayName)??u});function c(u){o.setFontFamily(u)}function d(u){u.stopPropagation()}return(u,f)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Font Family"},{button:a.withCtx(()=>[a.createElementVNode("div",q2,[a.createElementVNode("span",G2,a.toDisplayString(l.value),1),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-family-menu",onWheel:d,onClick:f[0]||(f[0]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",J2,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,h=>(a.openBlock(),a.createElementBlock("div",{key:h.name,class:a.normalizeClass(["wov-font-item",{active:i.value===h.name}]),onClick:p=>c(h.name)},[h.previewImage?(a.openBlock(),a.createElementBlock("img",{key:0,class:"wov-font-preview",src:h.previewImage,alt:h.name},null,8,X2)):(a.openBlock(),a.createElementBlock("span",{key:1,class:"wov-font-name",style:a.normalizeStyle({fontFamily:h.name})},a.toDisplayString(h.displayName),5))],10,Y2))),128))])],32)]),_:1})):a.createCommentVNode("",!0)}}),Q2={class:"wov-font-size-button"},Z2={class:"wov-font-size-label"},eC=["onClick"],tC={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},nC={class:"wov-input-container"},oC=["value"],jl=a.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=[{label:"Small",value:16,displayValue:10},{label:"Medium",value:24,displayValue:12},{label:"Large",value:40,displayValue:16},{label:"Huge",value:96,displayValue:20}],s=a.computed(()=>t.fontSize),i=a.computed(()=>{const h=s.value;if(h===null)return"Mixed";const p=r.find(m=>m.value===h);return p?p.label:`${+h.toFixed(1)} px`}),l=a.computed(()=>{const h=s.value;return h===null?"":String(+h.toFixed(1))});function c(h){o.setFontSize(h)}function d(h){const p=h.target,m=Number.parseFloat(p.value);!Number.isNaN(m)&&m>0&&c(m)}function u(h){h.key==="Enter"&&h.target.blur()}function f(h){h.stopPropagation()}return(h,p)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Font Size"},{button:a.withCtx(()=>[a.createElementVNode("div",Q2,[a.createElementVNode("span",Z2,a.toDisplayString(i.value),1),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:p[0]||(p[0]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(r,m=>a.createElementVNode("div",{key:m.value,class:a.normalizeClass(["wov-font-size-option",{active:s.value===m.value}]),onClick:g=>c(m.value)},[s.value===m.value?(a.openBlock(),a.createElementBlock("svg",tC,[...p[1]||(p[1]=[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},null,-1)])])):a.createCommentVNode("",!0),a.createElementVNode("span",{class:"wov-option-label",style:a.normalizeStyle({fontSize:`${m.displayValue}px`})},a.toDisplayString(m.label),5)],10,eC)),64)),p[3]||(p[3]=a.createElementVNode("div",{class:"wov-separator"},null,-1)),a.createElementVNode("div",nC,[a.createElementVNode("input",{class:"wov-custom-input",value:l.value,onInput:d,onKeydown:u,placeholder:"Custom size"},null,40,oC),p[2]||(p[2]=a.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):a.createCommentVNode("",!0)}}),Wl=a.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Italic",class:a.normalizeClass({"wov-active":a.unref(t).isItalic}),onClick:a.unref(o).toggleItalic},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),Kl=a.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds);return(r,s)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Underline",class:a.normalizeClass({"wov-active":a.unref(t).isUnderline}),onClick:a.unref(o).toggleUnderline},{default:a.withCtx(()=>[...s[0]||(s[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):a.createCommentVNode("",!0)}}),rC={class:"wov-link-input-container"},sC=["onKeydown"],ql=a.defineComponent({__name:"TextLinkButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=a.ref(!1),s=a.ref(""),i=a.ref(null),l=a.ref(null),c=a.ref(null),d=a.inject("containerRef"),{floatingStyles:u}=eo(l,c,{placement:"top",middleware:[Xn(8),Zn(),Qn({padding:8})],whileElementsMounted:Ms});function f(){s.value=t.linkHref??"",r.value=!0,a.nextTick(()=>{var g,y;(g=i.value)==null||g.focus(),(y=i.value)==null||y.select()})}function h(){const g=s.value.trim();g?o.setLink(g):o.removeLink(),r.value=!1}function p(){o.removeLink(),s.value="",r.value=!1}function m(g){var k,w;const y=g.target;!((k=l.value)!=null&&k.contains(y))&&!((w=c.value)!=null&&w.contains(y))&&(r.value=!1)}return a.watch(r,g=>{g?document.addEventListener("click",m,!0):document.removeEventListener("click",m,!0)}),(g,y)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",{ref_key:"buttonRef",ref:l},[a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Link",class:a.normalizeClass({"wov-active":a.unref(t).linkHref!==null}),onClick:f},{default:a.withCtx(()=>[...y[3]||(y[3]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 7-34.4-7.4-44.6s-34.4-7-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372.1 74 321.1 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.8l-1.1 1.6c-10.3 14.4-7 34.4 7.4 44.6s34.4 7 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})],-1)])]),_:1},8,["class"])):a.createCommentVNode("",!0)],512),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[r.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:c,class:"wov-link-input-dropdown",style:a.normalizeStyle(a.unref(u)),onKeydown:y[2]||(y[2]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",rC,[a.withDirectives(a.createElementVNode("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":y[0]||(y[0]=k=>s.value=k),class:"wov-link-input",placeholder:"Paste or type URL",onKeydown:[a.withKeys(a.withModifiers(h,["prevent"]),["enter"]),y[1]||(y[1]=a.withKeys(a.withModifiers(k=>r.value=!1,["prevent"]),["esc"]))]},null,40,sC),[[a.vModelText,s.value]]),s.value||a.unref(t).linkHref?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-link-action-button",title:"Remove link",onClick:p},[...y[4]||(y[4]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 12.5 32.8 0 45.3s32.8 12.5 45.3 0L237.3 256 342.6 150.6z"})],-1)])])):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-link-action-button",title:"Apply link",onClick:h},[...y[5]||(y[5]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[a.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})],-1)])])])],36)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64))}}),iC={class:"wov-text-color-button"},lC={class:"wov-text-icon-container"},Gl=a.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(n){const e=n,{state:t,commands:o}=rt(()=>e.entityIds),r=a.computed(()=>t.color??"#000000"),s=a.computed(()=>({backgroundColor:r.value}));function i(l){o.setColor(zo(l))}return(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Text Color"},{button:a.withCtx(()=>[a.createElementVNode("div",iC,[a.createElementVNode("div",lC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createElementVNode("div",{class:"wov-color-underline",style:a.normalizeStyle(s.value)},null,4)]),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createVNode(Ts,{currentColor:r.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):a.createCommentVNode("",!0)}}),aC={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-start-icon lucide-align-vertical-justify-start"},cC={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"},dC={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"},Ch=a.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(n){const e=n,{nextEditorTick:t}=de(),{state:o}=rt(()=>e.entityIds),r=[b.VerticalAlignment.Top,b.VerticalAlignment.Center,b.VerticalAlignment.Bottom],s=Rt(()=>e.entityIds,b.VerticalAlign),i=a.computed(()=>{let c=null;for(const d of s.value.values()){const u=(d==null?void 0:d.value)??b.VerticalAlignment.Top;if(c===null)c=u;else if(c!==u)return null}return c});function l(){const c=i.value??b.VerticalAlignment.Top,d=r.indexOf(c),u=r[(d+1)%r.length];t(f=>{for(const h of e.entityIds){const p=b.VerticalAlign.write(f,h);p.value=u}})}return(c,d)=>a.unref(o).showTextMenuButtons?(a.openBlock(),a.createBlock(Bn,{key:0,title:"Vertical Align",onClick:l},{default:a.withCtx(()=>[i.value===a.unref(b.VerticalAlignment).Top||i.value===null?(a.openBlock(),a.createElementBlock("svg",aC,[...d[0]||(d[0]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===a.unref(b.VerticalAlignment).Center?(a.openBlock(),a.createElementBlock("svg",cC,[...d[1]||(d[1]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(a.openBlock(),a.createElementBlock("svg",dC,[...d[2]||(d[2]=[a.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),a.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),a.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):a.createCommentVNode("",!0)}}),uC={class:"wov-text-group-button"},fC={class:"wov-text-group-dropdown"},hC={class:"wov-text-group-row wov-text-group-row-full"},pC={class:"wov-text-group-row"},mC=a.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(n){const e=n,{state:t}=rt(()=>e.entityIds),o=a.inject("containerRef"),{width:r}=wh(o),s=a.computed(()=>r.value>0&&r.value<600),i=a.ref(new Map);return a.provide(sa,i),(l,c)=>a.unref(t).showTextMenuButtons?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[s.value?(a.openBlock(),a.createBlock(Ke,{key:0,title:"Text Formatting",placement:"top"},{button:a.withCtx(()=>[a.createElementVNode("div",uC,[c[0]||(c[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[a.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),a.createVNode(qe,{class:"wov-chevron-down"})])]),dropdown:a.withCtx(()=>[a.createElementVNode("div",fC,[a.createElementVNode("div",hC,[a.createVNode(Ul,{entityIds:n.entityIds},null,8,["entityIds"]),c[1]||(c[1]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(jl,{entityIds:n.entityIds},null,8,["entityIds"])]),a.createElementVNode("div",pC,[a.createVNode(Fl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Wl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Kl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(ql,{entityIds:n.entityIds},null,8,["entityIds"]),c[2]||(c[2]=a.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),a.createVNode(Gl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(zl,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Ch,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)])])]),_:1})):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createVNode(Ul,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(jl,{entityIds:n.entityIds},null,8,["entityIds"]),c[3]||(c[3]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Fl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Wl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(Kl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(ql,{entityIds:n.entityIds},null,8,["entityIds"]),c[4]||(c[4]=a.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),a.createVNode(Gl,{entityIds:n.entityIds},null,8,["entityIds"]),a.createVNode(zl,{entityIds:n.entityIds},null,8,["entityIds"]),n.showVerticalAlign?(a.openBlock(),a.createBlock(Ch,{key:0,entityIds:n.entityIds},null,8,["entityIds"])):a.createCommentVNode("",!0)],64))],64)):a.createCommentVNode("",!0)}}),xh=a.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(n){const e=n,t={kind:"none",color:"#f4f4f4",strokeColor:"#a1a1a1",subdivisionStep:5},o=a.computed(()=>({...t,...e.background})),r=Ne(b.Camera),s=Ne(b.Grid),i=a.inject("containerRef"),l=a.ref({width:0,height:0});let c=null;const d=a.ref(null);let u=null;typeof document<"u"&&(u=document.createElement("canvas"));function f(w,C,x,S){const M=S/2;w.beginPath(),w.arc(C,x,M,0,Math.PI*2),w.fill()}function h(w,C,x){if(!u)return null;const S=x.dotSize??2,M=w*x.subdivisionStep,E=C*x.subdivisionStep;if(M<=0||E<=0)return null;u.width=M,u.height=E;const v=u.getContext("2d");if(!v)return null;if(v.clearRect(0,0,M,E),v.fillStyle=x.strokeColor,x.subdivisionStep===1)f(v,M/2,E/2,S);else for(let T=0;T<x.subdivisionStep;T++)for(let D=0;D<x.subdivisionStep;D++){const P=(T+.5)*(M/x.subdivisionStep),R=(D+.5)*(E/x.subdivisionStep),z=T===0&&D===0?2*S:S;f(v,P,R,z)}return v.createPattern(u,"repeat")}function p(w,C,x,S,M,E){w.lineWidth=E,w.beginPath(),w.moveTo(C,x),w.lineTo(S,M),w.stroke()}function m(w,C,x){if(!u)return null;const S=x.gridSize??1,M=w*x.subdivisionStep,E=C*x.subdivisionStep;if(M<=0||E<=0)return null;u.width=M,u.height=E;const v=u.getContext("2d");if(!v)return null;if(v.clearRect(0,0,M,E),v.strokeStyle=x.strokeColor,x.subdivisionStep===1)p(v,0,0,M,0,S),p(v,0,0,0,E,S);else{const T=M/x.subdivisionStep,D=E/x.subdivisionStep;for(let P=0;P<=x.subdivisionStep;P++){const R=P*T,_=P%x.subdivisionStep===0;p(v,R,0,R,E,_?3*S:S)}for(let P=0;P<=x.subdivisionStep;P++){const R=P*D,_=P%x.subdivisionStep===0;p(v,0,R,M,R,_?3*S:S)}}return v.createPattern(u,"repeat")}function g(w){let C=s.value.colWidth,x=s.value.rowHeight;const S=o.value.subdivisionStep,M=l.value.width,E=l.value.height,v=r.value.left,T=r.value.top,D=v+M/r.value.zoom,P=T+E/r.value.zoom;let R=C*S,_=x*S,z=0,H=0,Z=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY;for(;;){R=S*C,_=S*x,z=Math.floor(v/R)*R,H=Math.floor(T/_)*_;const et=Math.ceil(D/R)*R,ge=Math.ceil(P/_)*_;if(K=Math.round((et-z)/C),Z=Math.round((ge-H)/x),Math.max(K,Z)>200)C*=2,x*=2;else break}const W=C*r.value.zoom,U=x*r.value.zoom,X=Math.max(1,Math.round(W)),te=Math.max(1,Math.round(U)),ne=h(X,te,o.value);if(!ne)return;ne.setTransform(new DOMMatrix().scale(W/X,U/te));const Ie=(z-v-C/2)*r.value.zoom,ce=(H-T-x/2)*r.value.zoom;w.save(),w.translate(Ie,ce),w.fillStyle=ne,w.fillRect(0,0,M+R*r.value.zoom,E+_*r.value.zoom),w.restore()}function y(w){let C=s.value.colWidth,x=s.value.rowHeight;const S=o.value.subdivisionStep,M=l.value.width,E=l.value.height,v=r.value.left,T=r.value.top,D=v+M/r.value.zoom,P=T+E/r.value.zoom;let R=C*S,_=x*S,z=0,H=0,Z=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY;for(;;){R=S*C,_=S*x,z=Math.floor(v/R)*R,H=Math.floor(T/_)*_;const et=Math.ceil(D/R)*R,ge=Math.ceil(P/_)*_;if(K=Math.round((et-z)/C),Z=Math.round((ge-H)/x),Math.max(K,Z)>200)C*=2,x*=2;else break}const W=C*r.value.zoom,U=x*r.value.zoom,X=Math.max(1,Math.round(W)),te=Math.max(1,Math.round(U)),ne=m(X,te,o.value);if(!ne)return;ne.setTransform(new DOMMatrix().scale(W/X,U/te));const Ie=(z-v)*r.value.zoom,ce=(H-T)*r.value.zoom;w.save(),w.translate(Ie,ce),w.fillStyle=ne,w.fillRect(0,0,M+R*r.value.zoom,E+_*r.value.zoom),w.restore()}function k(){const w=d.value;if(!w)return;const C=w.getContext("2d");if(!C)return;const{width:x,height:S}=l.value;x===0||S===0||(w.width=x,w.height=S,C.clearRect(0,0,x,S),C.fillStyle=o.value.color,C.fillRect(0,0,x,S),o.value.kind==="dots"?g(C):o.value.kind==="grid"&&y(C))}return a.watch(()=>[o.value,r.value,s.value,l.value],()=>{k()},{deep:!0}),a.onMounted(()=>{const w=i==null?void 0:i.value;if(w){const C=()=>{l.value={width:w.clientWidth,height:w.clientHeight}};C(),c=new ResizeObserver(C),c.observe(w)}k()}),a.onUnmounted(()=>{c==null||c.disconnect()}),(w,C)=>(a.openBlock(),a.createElementBlock("canvas",{ref_key:"canvasRef",ref:d,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function Sh(n,e){if(e.length===0)return new Set;const t=e[0].tag,o=n.blockDefs[t];if(!o)return new Set;const r=new Set(o.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,l=n.blockDefs[i];if(!l){r.clear();break}const c=new Set(l.components.map(d=>d.name));for(const d of r)c.has(d)||r.delete(d)}return r}const Eh=a.defineComponent({__name:"FloatingMenuBar",setup(n){const e=a.useSlots(),{reset:t}=Dt(),o=a.inject(la),{selectedIds:r,commonComponents:s}=o,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape","tape"]),l=a.computed(()=>{const d=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&d.push(u)}return d});function c(){t()}return a.onUnmounted(()=>{t()}),(d,u)=>(a.openBlock(),a.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:c},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(l.value,f=>a.renderSlot(d.$slots,`button:${f}`,{key:f,entityIds:a.unref(r)})),128)),a.unref(s).has("color")?a.renderSlot(d.$slots,"button:color",{key:0,entityIds:a.unref(r)},()=>[a.createVNode(hh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("shape")?a.renderSlot(d.$slots,"button:shape",{key:1,entityIds:a.unref(r)},()=>[a.createVNode(gh,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(mh,{entityIds:a.unref(r)},null,8,["entityIds"]),a.createVNode(yh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("penStroke")?a.renderSlot(d.$slots,"button:penStroke",{key:2,entityIds:a.unref(r)},()=>[a.createVNode(ph,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("elbowArrow")||a.unref(s).has("arcArrow")?(a.openBlock(),a.createElementBlock(a.Fragment,{key:3},[a.renderSlot(d.$slots,"button:arrowThickness",{entityIds:a.unref(r)},()=>[a.createVNode(dh,{entityIds:a.unref(r)},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadStart",{entityIds:a.unref(r)},()=>[a.createVNode(Vl,{entityIds:a.unref(r),side:"start"},null,8,["entityIds"])]),a.renderSlot(d.$slots,"button:arrowHeadEnd",{entityIds:a.unref(r)},()=>[a.createVNode(Vl,{entityIds:a.unref(r),side:"end"},null,8,["entityIds"])])],64)):a.createCommentVNode("",!0),a.unref(s).has("tape")?a.renderSlot(d.$slots,"button:tape",{key:4,entityIds:a.unref(r)},()=>[a.createVNode(kh,{entityIds:a.unref(r)},null,8,["entityIds"])]):a.createCommentVNode("",!0),a.unref(s).has("text")?a.renderSlot(d.$slots,"button:text",{key:5,entityIds:a.unref(r)},()=>[a.createVNode(mC,{entityIds:a.unref(r),showVerticalAlign:a.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])]):a.createCommentVNode("",!0),a.createVNode($l)],32))}}),gC={class:"wov-floating-menu-inner"},vh=a.defineComponent({__name:"FloatingMenu",setup(n){const e=a.inject(He),t=Bf([b.Block,le.Selected]),o=Ne(b.Camera),r=Ne(b.Screen),s=Ne(le.SelectionStateSingleton),i=Fo(),l=a.computed(()=>t.value.map(x=>x.entityId)),c=a.computed(()=>{const x=e==null?void 0:e.getEditor();if(!x||t.value.length===0)return new Set;const S=t.value.map(M=>({tag:M.block.value.tag}));return Sh(x,S)});a.provide(la,{selectedIds:l,commonComponents:c});const d=[0,0,0,0];function u(...x){let S=1/0,M=1/0,E=-1/0,v=-1/0,T=!1;for(const D of x){if(!D)continue;const P=D.getBoundingClientRect();P.width<=0||(T=!0,S=Math.min(S,P.left),M=Math.min(M,P.top),E=Math.max(E,P.right),v=Math.max(v,P.bottom))}return T?{x:S,y:M,left:S,top:M,right:E,bottom:v,width:E-S,height:v-M,toJSON:()=>({})}:null}const f=a.computed(()=>{if(t.value.length===0)return null;const x=o.value;if(!x)return null;let S=null;for(const M of t.value){const E=M.block.value;De.Rect.getAabb(E.position,E.size,E.rotateZ,d),De.Aabb.translate(d,[-x.left,-x.top]),De.Aabb.scale(d,x.zoom),S===null?S=De.Aabb.clone(d):De.Aabb.union(S,d)}return S}),h=a.inject("containerRef"),p=a.computed(()=>{const x=h==null?void 0:h.value;if(!x)return null;o.value,i.updateCounter.value;const S=i.blockElement.value,M=i.textElement.value,E=u(S,M);if(E)return{getBoundingClientRect:()=>E};const v=f.value;if(!v)return null;const T=x.getBoundingClientRect();return{getBoundingClientRect(){return{x:T.left+v[0],y:T.top+v[1],width:v[2]-v[0],height:v[3]-v[1],top:T.top+v[1],left:T.left+v[0],right:T.left+v[2],bottom:T.top+v[3]}}}}),m=a.ref(null),g={name:"clampToViewport",fn({y:x,rects:S}){const v=window.innerHeight-S.floating.height-8;return{y:Math.max(8,Math.min(x,v))}}},{floatingStyles:y}=eo(p,m,{placement:"top",middleware:[Xn(12),Zn({fallbackPlacements:["bottom"]}),Qn({padding:8}),g]}),k=a.computed(()=>{const x=f.value,S=r.value;return!x||!S?!0:x[2]<0||x[0]>S.width||x[3]<0||x[1]>S.height}),w=[le.SelectionState.Dragging,le.SelectionState.SelectionBoxDragging],C=a.computed(()=>t.value.length>0&&!k.value&&!w.includes(s.value.state));return(x,S)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-fade"},{default:a.withCtx(()=>[C.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:m,class:"wov-floating-menu",style:a.normalizeStyle(a.unref(y))},[a.createElementVNode("div",gC,[a.renderSlot(x.$slots,"default",{},()=>[a.createVNode(Eh)])])],4)):a.createCommentVNode("",!0)]),_:3}))}}),yC={key:0,class:"wov-loading-overlay"},kC={class:"wov-loading-spinner"},Mh=a.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(n){const e=a.ref("|"),t=["|","/","-","\\"];let o=null;return a.onMounted(()=>{o=setInterval(()=>{const r=t.indexOf(e.value);e.value=t[(r+1)%t.length]},100)}),a.onUnmounted(()=>{o!==null&&clearInterval(o)}),(r,s)=>(a.openBlock(),a.createBlock(a.Transition,{name:"wov-loading-fade"},{default:a.withCtx(()=>[n.isLoading?(a.openBlock(),a.createElementBlock("div",yC,[a.createElementVNode("div",kC,a.toDisplayString(e.value),1)])):a.createCommentVNode("",!0)]),_:1}))}}),to="editing",wC={class:"wov-action-bar"},bC=a.defineComponent({__name:"ActionBar",setup(n){const{getEditor:e}=de(),t=a.inject(He),o=a.ref(!1),r=a.ref(!1);if(t){const c=t.registerTickCallback(d=>{const{store:u}=b.getPluginResources(d,to);o.value=u.canUndo(),r.value=u.canRedo()});a.onUnmounted(c)}function s(){const c=e();c==null||c.command(b.Undo)}function i(){const c=e();c==null||c.command(b.Redo)}function l(){const c=e();c==null||c.command(le.RemoveSelected)}return(c,d)=>(a.openBlock(),a.createElementBlock("div",wC,[a.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...d[0]||(d[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-undo-icon lucide-undo"},[a.createElementVNode("path",{d:"M3 7v6h6"}),a.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...d[1]||(d[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-redo-icon lucide-redo"},[a.createElementVNode("path",{d:"M21 7v6h-6"}),a.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),a.createElementVNode("button",{class:"wov-action-button",onClick:l,"aria-label":"Delete"},[...d[2]||(d[2]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-trash-icon lucide-trash"},[a.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),a.createElementVNode("path",{d:"M3 6h18"}),a.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),at=a.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(n){const e=n,t=a.inject(_s);if(!t)throw new Error("ToolbarButton must be used within a Toolbar component");const o=t,r=a.ref(null),{show:s,hide:i}=Dt(),l=a.computed(()=>o.activeTool.value===e.name);function c(){o.setTool(e.name,e.placementSnapshot,e.cursor)}function d(){o.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){o.onToolPointerUp()}function f(){e.tooltip&&r.value&&s(e.tooltip,r.value)}function h(){i()}return(p,m)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:r,class:a.normalizeClass(["wov-toolbar-button",{selected:l.value}]),onClick:c,onPointerdown:d,onPointerup:u,onMouseenter:f,onMouseleave:h},[a.renderSlot(p.$slots,"default")],34))}}),CC='<?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>',xC='<?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>',SC='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 8v-2a2 2 0 0 1 2 -2h2" /><path d="M4 16v2a2 2 0 0 0 2 2h2" /><path d="M16 4h2a2 2 0 0 1 2 2v2" /><path d="M16 20h2a2 2 0 0 0 2 -2v-2" /><path d="M9 12l6 0" /><path d="M12 9l0 6" /></svg>',rn={Select:"select",Hand:"hand",Crosshair:"crosshair"},Th={[rn.Select]:{makeSvg:()=>CC,hotspot:[1,0],rotationOffset:0},[rn.Hand]:{makeSvg:()=>xC,hotspot:[12,12],rotationOffset:0},[rn.Crosshair]:{makeSvg:()=>SC,hotspot:[12,12],rotationOffset:0}},EC={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},Nh=a.defineComponent({__name:"SelectTool",setup(n){const{nextEditorTick:e}=de(),{activeTool:t}=hs();return a.watch(t,(o,r)=>{r==="select"&&e(s=>{le.DeselectAll.spawn(s)})}),(o,r)=>(a.openBlock(),a.createBlock(at,{name:"select",tooltip:"Select",cursor:a.unref(rn).Select},{default:a.withCtx(()=>[(a.openBlock(),a.createElementBlock("svg",EC,[...r[0]||(r[0]=[a.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-width":"0.5",d:"M2.39,2.88C2.38,2.885 2.34,2.9 2.33,2.91C2.32,2.91 2.298,2.939 2.28,2.97L1.51,4.41C1.44,4.54 1.41,4.6 1.37,4.61C1.34,4.62 1.3,4.61 1.27,4.6C1.24,4.58 1.22,4.51 1.18,4.37L0.16,0.41C0.13,0.28 0.11,0.22 0.13,0.18C0.15,0.15 0.17,0.13 0.21,0.12C0.25,0.12 0.31,0.14 0.42,0.2L4.01,2.14C4.14,2.21 4.2,2.24 4.21,2.28C4.22,2.31 4.21,2.35 4.2,2.38C4.18,2.41 4.11,2.43 3.97,2.47L2.39,2.88Z"})],-1)])]))]),_:1},8,["cursor"]))}}),Ah=a.defineComponent({__name:"HandTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"hand",tooltip:"Hand",cursor:a.unref(rn).Hand},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[a.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4.47,11.39v3.18M4.47,11.39V3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92M4.47,11.39c0-1.06-.86-1.87-1.92-1.87s-1.92.86-1.92,1.87v2.53c0,5.25,4.35,9.45,9.65,9.45s9.65-4.24,9.65-9.45v-6.32c0-1.06-.86-1.92-1.92-1.92s-1.92.86-1.92,1.92M8.36,3.81v6.97M8.36,3.81v-1.26c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v1.26M12.2,3.81v6.97M12.2,3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v3.79M16.09,7.6v3.18"})],-1)])]),_:1},8,["cursor"]))}}),Bh=a.defineComponent({__name:"StickyNoteTool",setup(n){const e=JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:b.TextAlignment.Center},verticalAlign:{value:b.VerticalAlignment.Center}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":a.unref(e),"placement-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M4 4h12v12H4z"}),a.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Ih=a.defineComponent({__name:"ShapeTool",setup(n){const e=JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:b.StrokeKind.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:b.TextAlignment.Center},verticalAlign:{value:b.VerticalAlignment.Center}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"shape",tooltip:"Shape","drag-out-snapshot":a.unref(e),"placement-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Oh=a.defineComponent({__name:"EraserTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"eraser",tooltip:"Eraser"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[a.createElementVNode("path",{d:"M210.5 480L333.5 480L398.8 414.7L225.3 241.2L98.6 367.9L210.6 479.9zM256 544L210.5 544C193.5 544 177.2 537.3 165.2 525.3L49 409C38.1 398.1 32 383.4 32 368C32 352.6 38.1 337.9 49 327L295 81C305.9 70.1 320.6 64 336 64C351.4 64 366.1 70.1 377 81L559 263C569.9 273.9 576 288.6 576 304C576 319.4 569.9 334.1 559 345L424 480L544 480C561.7 480 576 494.3 576 512C576 529.7 561.7 544 544 544L256 544z"})],-1)])]),_:1}))}}),Rh=a.defineComponent({__name:"PenTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"pen",tooltip:"Pen"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("path",{d:"M13.586 3.586a2 2 0 1 1 2.828 2.828l-8.793 8.793-3.536.707.707-3.536 8.794-8.792Z","stroke-linecap":"round","stroke-linejoin":"round"}),a.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),Ph=a.defineComponent({__name:"TextTool",setup(n){const e=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),t=JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24}});return(o,r)=>(a.openBlock(),a.createBlock(at,{name:"text",tooltip:"Text","drag-out-snapshot":a.unref(t),"placement-snapshot":a.unref(e)},{default:a.withCtx(()=>[...r[0]||(r[0]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-type-icon lucide-type"},[a.createElementVNode("path",{d:"M12 4v16"}),a.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),a.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),Dh=a.defineComponent({__name:"ElbowArrowTool",setup(n){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:ee.ArrowHeadKind.None,endArrowHead:ee.ArrowHeadKind.V},connector:{}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),_h=a.defineComponent({__name:"ImageTool",setup(n){const{nextEditorTick:e}=de(),{show:t,hide:o}=Dt(),{setTool:r}=hs(),{createImageBlock:s}=Af(),i=a.ref(null),l=a.ref(null);function c(){var h;(h=l.value)==null||h.click()}async function d(h){var x;const p=h.target,m=(x=p.files)==null?void 0:x[0];if(!m)return;if(p.value="",!m.type.startsWith("image/")){console.warn("Selected file is not an image");return}const g=await e(),y=b.Camera.read(g),k=b.Screen.read(g),w=y.left+k.width/y.zoom/2,C=y.top+k.height/y.zoom/2;await s(m,w,C),r("select",void 0,rn.Select)}function u(){i.value&&t("Image",i.value)}function f(){o()}return(h,p)=>(a.openBlock(),a.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:c,onMouseenter:u,onMouseleave:f},[p[0]||(p[0]=a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),a.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),a.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),a.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",accept:"image/*",style:{display:"none"},onChange:d},null,544)],544))}}),vC={class:"wov-embed-provider-grid"},MC=["onClick"],TC={class:"wov-embed-provider-icon"},NC={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},AC={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},BC={key:2,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},IC={key:3,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},OC={key:4,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},RC={key:5,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},PC={key:6,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},DC={key:7,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},_C={class:"wov-embed-provider-label"},LC={class:"wov-embed-panel-header"},VC={class:"wov-embed-url-form"},$C=["placeholder"],zC={key:0,class:"wov-embed-url-error"},Lh=a.defineComponent({__name:"EmbedTool",setup(n){const{nextEditorTick:e}=de(),{show:t,hide:o}=Dt(),{setTool:r}=hs(),s=a.ref(null),i=a.ref(null),l=a.ref(null),c=a.ref(!1),d=a.ref(null),u=a.ref(""),f=a.ref(""),h=a.inject("containerRef"),{floatingStyles:p}=eo(s,i,{placement:"top",middleware:[Xn(16),Zn(),Qn({padding:8})],whileElementsMounted:Ms}),m=[{value:b.EmbedProvider.Youtube,label:"YouTube",icon:"youtube"},{value:b.EmbedProvider.Spotify,label:"Spotify",icon:"spotify"},{value:b.EmbedProvider.GoogleMaps,label:"Google Maps",icon:"map"},{value:b.EmbedProvider.GoogleCalendar,label:"Google Calendar",icon:"calendar"},{value:b.EmbedProvider.GoogleSlides,label:"Google Slides",icon:"slides"},{value:b.EmbedProvider.Figma,label:"Figma",icon:"figma"},{value:b.EmbedProvider.GithubGist,label:"GitHub Gist",icon:"gist"},{value:b.EmbedProvider.Tldraw,label:"tldraw",icon:"tldraw"}],g=a.computed(()=>{if(!d.value)return"Paste a URL...";switch(d.value){case b.EmbedProvider.Youtube:return"https://www.youtube.com/watch?v=...";case b.EmbedProvider.Spotify:return"https://open.spotify.com/track/...";case b.EmbedProvider.GoogleMaps:return"https://www.google.com/maps/...";case b.EmbedProvider.GoogleCalendar:return"https://calendar.google.com/...";case b.EmbedProvider.GoogleSlides:return"https://docs.google.com/presentation/...";case b.EmbedProvider.Figma:return"https://www.figma.com/...";case b.EmbedProvider.GithubGist:return"https://gist.github.com/...";case b.EmbedProvider.Tldraw:return"https://www.tldraw.com/...";default:return"Paste a URL..."}});function y(){c.value=!c.value,d.value=null,u.value="",f.value=""}function k(v){d.value=v,u.value="",f.value="",a.nextTick(()=>{var T;(T=l.value)==null||T.focus()})}function w(){d.value=null,u.value="",f.value=""}async function C(){const v=u.value.trim();if(!v){f.value="Please enter a URL";return}try{new URL(v)}catch{f.value="Please enter a valid URL";return}const T=d.value??b.detectEmbedProvider(v),D=b.validateEmbedUrl(v,T);if(D){f.value=D;return}const P=b.resolveEmbedUrl(v,T);let R=480,_=320;switch(T){case b.EmbedProvider.Youtube:R=560,_=315;break;case b.EmbedProvider.Spotify:R=352,_=152;break;case b.EmbedProvider.GoogleMaps:R=600,_=450;break;case b.EmbedProvider.GoogleCalendar:R=600,_=500;break;case b.EmbedProvider.GoogleSlides:R=640,_=389;break;case b.EmbedProvider.Figma:R=600,_=400;break;case b.EmbedProvider.GithubGist:R=500,_=300;break;case b.EmbedProvider.Tldraw:R=600,_=400;break}const z=await e(),H=b.Camera.read(z),Z=b.Screen.read(z),K=H.left+Z.width/H.zoom/2,W=H.top+Z.height/H.zoom/2,U=b.Grid.read(z);U.enabled&&(R=Math.max(U.colWidth,Math.round(R/U.colWidth)*U.colWidth),_=Math.max(U.rowHeight,Math.round(_/U.rowHeight)*U.rowHeight));const X=b.createEntity(z);b.addComponent(z,X,b.Block);const te=b.Block.write(z,X);te.tag="embed",te.position[0]=K-R/2,te.position[1]=W-_/2,te.size[0]=R,te.size[1]=_,b.Grid.snapPosition(z,te.position),b.addComponent(z,X,b.Embed);const ne=b.Embed.write(z,X);ne.url=v,ne.embedUrl=P,ne.provider=T,b.addComponent(z,X,$e.Synced,{id:crypto.randomUUID()}),c.value=!1,d.value=null,u.value="",r("select",void 0,rn.Select)}function x(v){v.key==="Enter"?(v.preventDefault(),C()):v.key==="Escape"&&(v.preventDefault(),d.value?w():c.value=!1)}function S(v){const T=v.target;s.value&&!s.value.contains(T)&&i.value&&!i.value.contains(T)&&(c.value=!1)}a.watch(c,v=>{v?document.addEventListener("click",S,!0):document.removeEventListener("click",S,!0)});function M(){s.value&&t("Embed",s.value)}function E(){o()}return(v,T)=>{var D;return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("button",{ref_key:"buttonRef",ref:s,class:a.normalizeClass(["wov-toolbar-button",{"menu-open":c.value}]),onClick:y,onMouseenter:M,onMouseleave:E},[...T[1]||(T[1]=[a.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.createElementVNode("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)])],34),a.unref(h)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(h)},[c.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"wov-embed-panel",style:a.normalizeStyle(a.unref(p))},[d.value?(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createElementVNode("div",LC,[a.createElementVNode("button",{class:"wov-embed-back-button",onClick:w},[...T[11]||(T[11]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("polyline",{points:"15 18 9 12 15 6"})],-1)])]),a.createElementVNode("span",null,a.toDisplayString((D=m.find(P=>P.value===d.value))==null?void 0:D.label),1)]),a.createElementVNode("div",VC,[a.withDirectives(a.createElementVNode("input",{ref_key:"urlInputRef",ref:l,"onUpdate:modelValue":T[0]||(T[0]=P=>u.value=P),type:"text",placeholder:g.value,class:"wov-embed-url-input",onKeydown:x},null,40,$C),[[a.vModelText,u.value]]),f.value?(a.openBlock(),a.createElementBlock("div",zC,a.toDisplayString(f.value),1)):a.createCommentVNode("",!0),a.createElementVNode("button",{class:"wov-embed-submit-button",onClick:C}," Embed ")])],64)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[T[10]||(T[10]=a.createElementVNode("div",{class:"wov-embed-panel-header"},"Add embed",-1)),a.createElementVNode("div",vC,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(m,P=>a.createElementVNode("button",{key:P.value,class:"wov-embed-provider-button",onClick:R=>k(P.value)},[a.createElementVNode("span",TC,[P.icon==="youtube"?(a.openBlock(),a.createElementBlock("svg",NC,[...T[2]||(T[2]=[a.createElementVNode("path",{d:"M2.5 17V7a2 2 0 0 1 2-2h15a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2z"},null,-1),a.createElementVNode("path",{d:"m10 15 5-3-5-3z"},null,-1)])])):P.icon==="spotify"?(a.openBlock(),a.createElementBlock("svg",AC,[...T[3]||(T[3]=[a.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),a.createElementVNode("path",{d:"M8 11.973c2.5-1.473 5.5-.973 7.5.527"},null,-1),a.createElementVNode("path",{d:"M9 15c1.5-1 4-.5 5.5.5"},null,-1),a.createElementVNode("path",{d:"M7 9c3-2 7-1 10 1"},null,-1)])])):P.icon==="map"?(a.openBlock(),a.createElementBlock("svg",BC,[...T[4]||(T[4]=[a.createElementVNode("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"},null,-1),a.createElementVNode("circle",{cx:"12",cy:"9",r:"2.5"},null,-1)])])):P.icon==="calendar"?(a.openBlock(),a.createElementBlock("svg",IC,[...T[5]||(T[5]=[a.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"16",y1:"2",x2:"16",y2:"6"},null,-1),a.createElementVNode("line",{x1:"8",y1:"2",x2:"8",y2:"6"},null,-1),a.createElementVNode("line",{x1:"3",y1:"10",x2:"21",y2:"10"},null,-1)])])):P.icon==="slides"?(a.openBlock(),a.createElementBlock("svg",OC,[...T[6]||(T[6]=[a.createElementVNode("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"},null,-1),a.createElementVNode("line",{x1:"8",y1:"21",x2:"16",y2:"21"},null,-1),a.createElementVNode("line",{x1:"12",y1:"17",x2:"12",y2:"21"},null,-1)])])):P.icon==="figma"?(a.openBlock(),a.createElementBlock("svg",RC,[...T[7]||(T[7]=[a.createElementVNode("path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z"},null,-1),a.createElementVNode("path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z"},null,-1),a.createElementVNode("path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z"},null,-1),a.createElementVNode("path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z"},null,-1)])])):P.icon==="gist"?(a.openBlock(),a.createElementBlock("svg",PC,[...T[8]||(T[8]=[a.createElementVNode("polyline",{points:"16 18 22 12 16 6"},null,-1),a.createElementVNode("polyline",{points:"8 6 2 12 8 18"},null,-1)])])):P.icon==="tldraw"?(a.openBlock(),a.createElementBlock("svg",DC,[...T[9]||(T[9]=[a.createElementVNode("path",{fill:"currentColor",d:"M21.474 0H2.526C1.131 0 0 1.18 0 2.637v18.726C0 22.819 1.131 24 2.526 24h18.948C22.869 24 24 22.82 24 21.363V2.637C24 1.181 22.869 0 21.474 0m-11.01 5.388q.595-.607 1.474-.607q.854 0 1.448.607q.595.606.595 1.476c0 .87-.198 1.072-.595 1.476a1.95 1.95 0 0 1-1.448.607q-.879 0-1.474-.607q-.594-.606-.594-1.476c0-.87.198-1.072.594-1.476m3.13 11.49a4.9 4.9 0 0 1-2.018 2.136q-.724.422-1.19-.026q-.438-.422.26-1.002q.387-.29.646-.738q.258-.449.336-.923q.026-.21-.181-.21q-.517-.027-1.06-.581t-.543-1.37q0-.87.594-1.477a2.02 2.02 0 0 1 1.5-.633q.828 0 1.448.633q.62.605.724 1.37q.207 1.424-.517 2.822z"},null,-1)])])):a.createCommentVNode("",!0)]),a.createElementVNode("span",_C,a.toDisplayString(P.label),1)],8,MC)),64))])],64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)],64)}}}),FC="https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media",Vh=a.defineComponent({__name:"TapeTool",setup(n){const e=JSON.stringify({block:{tag:"tape",size:[200,30]},tape:{thickness:30},asset:{identifier:FC,uploadState:"complete"}});return(t,o)=>(a.openBlock(),a.createBlock(at,{name:"tape",tooltip:"Tape","drag-out-snapshot":a.unref(e)},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[a.createElementVNode("rect",{x:"1",y:"7",width:"18",height:"6",rx:"1",fill:"none",stroke:"currentColor"}),a.createElementVNode("line",{x1:"5",y1:"7",x2:"3",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"9",y1:"7",x2:"7",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"13",y1:"7",x2:"11",y2:"13",opacity:"0.4"}),a.createElementVNode("line",{x1:"17",y1:"7",x2:"15",y2:"13",opacity:"0.4"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),HC={class:"wov-toolbar-container"},$h=a.defineComponent({__name:"Toolbar",setup(n){const e=a.useSlots(),{reset:t}=Dt(),{nextEditorTick:o}=de(),r=a.ref(null),s=a.ref(null),i=Ne(b.Controls),l=a.computed(()=>i.value.leftMouseTool),c=[Nh,Ah,Ph,_h,Lh,Ih,Dh,Bh,Vh,Rh,Oh],d=a.inject("containerRef"),u=a.ref(null),f=a.ref(!1),h=a.ref(null),p=a.ref(null),m=a.ref(1/0),g=a.ref(0),y=a.ref([]),k=a.ref(8),w=a.ref(48),{width:C}=wh(d);function x(){return h.value?Array.from(h.value.children).filter(W=>!W.classList.contains("wov-overflow-button")&&!W.classList.contains("wov-menu-tooltip")):[]}function S(){var te;const W=x();if(W.length===0)return;g.value=W.length;const U=getComputedStyle(h.value);k.value=parseFloat(U.gap)||8;const X=((te=p.value)==null?void 0:te.offsetWidth)||40;w.value=X+k.value,y.value=W.map(ne=>ne.offsetWidth)}function M(){if(y.value.length===0)return;const X=C.value-40-20,te=k.value,ne=w.value;let Ie=0,ce=0;for(let et=0;et<y.value.length;et++){const ge=y.value[et],sn=Ie>0?ge+te:ge,bt=y.value.length-et-1>0?ne:0;if(Ie+sn+bt<=X)Ie+=sn,ce++;else break}m.value=Math.max(1,ce)}a.watch(C,()=>{y.value.length>0&&M()}),a.onMounted(()=>{a.nextTick(()=>{S(),M()})});const E=a.computed(()=>m.value<g.value);a.watchEffect(()=>{x().forEach((U,X)=>{U.style.display=X<m.value?"":"none"})}),a.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((U,X)=>{U.style.display=X>=m.value?"":"none"})});const{floatingStyles:v}=eo(p,u,{placement:"top",middleware:[Xn(16),Zn(),Qn({padding:8})],whileElementsMounted:Ms});function T(){f.value=!f.value}function D(){f.value=!1}function P(W){const U=W.target;p.value&&!p.value.contains(U)&&u.value&&!u.value.contains(U)&&D()}a.watch(f,W=>{W?document.addEventListener("click",P,!0):document.removeEventListener("click",P,!0)}),a.watch(E,W=>{W||D()});function R(W,U,X){s.value=U??null,o(te=>{const ne=b.Controls.write(te);ne.leftMouseTool=W,ne.heldSnapshot=U??"",X&&b.Cursor.setCursor(te,X)})}function _(W){o(U=>{const X=b.Controls.write(U);X.leftMouseTool="drag-out",X.heldSnapshot=W})}function z(W,U){r.value=W,s.value=U??null}function H(){r.value=null,s.value=null}function Z(){t(),r.value&&s.value&&_(s.value),r.value=null,s.value=null}const K={activeTool:l,heldTool:r,setTool:R,dragOutTool:_,onToolPointerDown:z,onToolPointerUp:H};return a.provide(_s,K),(W,U)=>(a.openBlock(),a.createElementBlock("div",HC,[a.createVNode(bC),a.createElementVNode("div",{ref_key:"toolsContainerRef",ref:h,class:"wov-toolbar",onMouseleave:Z},[a.unref(e).default?a.renderSlot(W.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(X,te)=>a.createVNode(a.resolveDynamicComponent(X),{key:te})),64)),E.value?(a.openBlock(),a.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:p,class:a.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:T},[...U[0]||(U[0]=[a.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[a.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):a.createCommentVNode("",!0),a.createVNode($l)],544),a.unref(d)?(a.openBlock(),a.createBlock(a.Teleport,{key:0,to:a.unref(d)},[f.value&&E.value?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:a.normalizeStyle(a.unref(v))},[a.unref(e).default?a.renderSlot(W.$slots,"default",{key:0}):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},a.renderList(c,(X,te)=>a.createVNode(a.resolveDynamicComponent(X),{key:te})),64))],4)):a.createCommentVNode("",!0)],8,["to"])):a.createCommentVNode("",!0)]))}}),UC=a.defineComponent({__name:"ArcArrowTool",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(at,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:a.withCtx(()=>[...t[0]||(t[0]=[a.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[a.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),a.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),jC={class:"wov-user-presence-avatars"},WC=["src","alt"],KC={class:"wov-user-presence-list"},qC=["src","alt"],GC={class:"wov-user-presence-name"},JC=4,zh=a.defineComponent({__name:"UserPresence",props:{users:{}},setup(n){const e=n,t=a.ref(!1),o=a.ref(null);U2(o,()=>{t.value=!1});function r(l){if(!l)return"?";const c=l.trim().split(/\s+/);return c.length>=2?(c[0][0]+c[1][0]).toUpperCase():l.slice(0,2).toUpperCase()}const s=a.computed(()=>e.users.map(l=>({sessionId:l.sessionId,name:l.name,color:l.color,avatar:l.avatar,initials:r(l.name)}))),i=a.computed(()=>s.value.slice(0,JC));return(l,c)=>n.users.length>1?(a.openBlock(),a.createElementBlock("div",{key:0,ref_key:"containerRef",ref:o,class:"wov-user-presence"},[a.createElementVNode("button",{class:a.normalizeClass(["wov-user-presence-trigger",{"is-open":t.value}]),onClick:c[0]||(c[0]=d=>t.value=!t.value)},[a.createElementVNode("div",jC,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-avatar",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,WC)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4))),128))])],2),t.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:c[1]||(c[1]=a.withModifiers(()=>{},["stop"]))},[a.createElementVNode("div",KC,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(s.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.sessionId,class:"wov-user-presence-item"},[a.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:a.normalizeStyle({backgroundColor:d.avatar?"transparent":d.color})},[d.avatar?(a.openBlock(),a.createElementBlock("img",{key:0,src:d.avatar,alt:d.name,class:"wov-user-avatar-img"},null,8,qC)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(d.initials),1)],64))],4),a.createElementVNode("span",GC,a.toDisplayString(d.name),1)]))),128))])],32)):a.createCommentVNode("",!0)],512)):a.createCommentVNode("",!0)}}),Jl=(n,e)=>e.some(t=>n instanceof t);let Fh,Hh;function YC(){return Fh||(Fh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function XC(){return Hh||(Hh=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Yl=new WeakMap,Xl=new WeakMap,Is=new WeakMap;function QC(n){const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("success",s),n.removeEventListener("error",i)},s=()=>{t(In(n.result)),r()},i=()=>{o(n.error),r()};n.addEventListener("success",s),n.addEventListener("error",i)});return Is.set(e,n),e}function ZC(n){if(Yl.has(n))return;const e=new Promise((t,o)=>{const r=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",i),n.removeEventListener("abort",i)},s=()=>{t(),r()},i=()=>{o(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",s),n.addEventListener("error",i),n.addEventListener("abort",i)});Yl.set(n,e)}let Ql={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Yl.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return In(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Uh(n){Ql=n(Ql)}function ex(n){return XC().includes(n)?function(...e){return n.apply(Zl(this),e),In(this.request)}:function(...e){return In(n.apply(Zl(this),e))}}function tx(n){return typeof n=="function"?ex(n):(n instanceof IDBTransaction&&ZC(n),Jl(n,YC())?new Proxy(n,Ql):n)}function In(n){if(n instanceof IDBRequest)return QC(n);if(Xl.has(n))return Xl.get(n);const e=tx(n);return e!==n&&(Xl.set(n,e),Is.set(e,n)),e}const Zl=n=>Is.get(n);function nx(n,e,{blocked:t,upgrade:o,blocking:r,terminated:s}={}){const i=indexedDB.open(n,e),l=In(i);return o&&i.addEventListener("upgradeneeded",c=>{o(In(i.result),c.oldVersion,c.newVersion,In(i.transaction),c)}),t&&i.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),l.then(c=>{s&&c.addEventListener("close",()=>s()),r&&c.addEventListener("versionchange",d=>r(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const ox=["get","getKey","getAll","getAllKeys","count"],rx=["put","add","delete","clear"],ea=new Map;function jh(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(ea.get(e))return ea.get(e);const t=e.replace(/FromIndex$/,""),o=e!==t,r=rx.includes(t);if(!(t in(o?IDBIndex:IDBObjectStore).prototype)||!(r||ox.includes(t)))return;const s=async function(i,...l){const c=this.transaction(i,r?"readwrite":"readonly");let d=c.store;return o&&(d=d.index(l.shift())),(await Promise.all([d[t](...l),r&&c.done]))[0]};return ea.set(e,s),s}Uh(n=>({...n,get:(e,t,o)=>jh(e,t)||n.get(e,t,o),has:(e,t)=>!!jh(e,t)||n.has(e,t)}));const sx=["continue","continuePrimaryKey","advance"],Wh={},ta=new WeakMap,Kh=new WeakMap,ix={get(n,e){if(!sx.includes(e))return n[e];let t=Wh[e];return t||(t=Wh[e]=function(...o){ta.set(this,Kh.get(this)[e](...o))}),t}};async function*lx(...n){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...n)),!e)return;e=e;const t=new Proxy(e,ix);for(Kh.set(t,e),Is.set(t,Zl(e));e;)yield t,e=await(ta.get(t)||e.continue()),ta.delete(t)}function qh(n,e){return e===Symbol.asyncIterator&&Jl(n,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Jl(n,[IDBIndex,IDBObjectStore])}Uh(n=>({...n,get(e,t,o){return qh(e,t)?lx:n.get(e,t,o)},has(e,t){return qh(e,t)||n.has(e,t)}}));async function na(n,e){const t=await nx(n,1,{upgrade(o){o.objectStoreNames.contains(e)||o.createObjectStore(e)}});return new ax(t,e)}var ax=class{constructor(n,e){this.db=n,this.storeName=e}async get(n){return this.db.get(this.storeName,n)}async put(n,e){await this.db.put(this.storeName,e,n)}async delete(n){await this.db.delete(this.storeName,n)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),t=await e.getAllKeys(),o=await e.getAll(),r=[];for(let s=0;s<t.length;s++)r.push([t[s],o[s]]);return r}async clear(){const n=this.db.transaction(this.storeName,"readwrite");n.objectStore(this.storeName).clear(),await n.done}close(){this.db.close()}},cx=class{constructor(n){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=n.provider,this.documentId=n.documentId,this.maxRetries=n.provider.maxRetries??3,this.retryDelay=n.provider.retryDelay??5e3}async init(){const n=`wovencanvas-assets-${this.documentId}`,[e,t]=await Promise.all([na(`${n}-jobs`,"jobs"),na(`${n}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=t}async upload(n,e,t){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(n,e);const o={identifier:n,metadata:t,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(n,o);const r=URL.createObjectURL(e);return this.blobUrls.set(n,r),new Promise((s,i)=>{this.uploadPromises.set(n,{resolve:s,reject:i}),this.startUpload(n)})}async getDisplayUrl(n){if(!n)return null;const e=this.blobUrls.get(n);if(e)return e;try{return await this.provider.resolveUrl(n)}catch(t){return console.error(`Failed to resolve URL for ${n}:`,t),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const n=await this.jobsStore.getAllEntries();for(const[e]of n){const t=await this.binariesStore.get(e);if(t){const o=URL.createObjectURL(t);this.blobUrls.set(e,o)}this.startUpload(e)}}hasPendingUpload(n){return this.blobUrls.has(n)}isUploading(n){return this.uploading.has(n)}async cancelUpload(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.reject(new Error("Upload cancelled")),this.uploadPromises.delete(n))}close(){var n,e;for(const t of this.blobUrls.values())URL.revokeObjectURL(t);this.blobUrls.clear(),(n=this.jobsStore)==null||n.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(n){if(!this.jobsStore||!this.binariesStore||this.uploading.has(n))return;this.uploading.add(n);const e=await this.jobsStore.get(n),t=await this.binariesStore.get(n);if(!e||!t){this.uploading.delete(n);return}try{await this.provider.upload(t,n,e.metadata),await this.onUploadSuccess(n)}catch(o){await this.onUploadError(n,e,o)}}async onUploadSuccess(n){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(n);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(n)),await this.jobsStore.delete(n),await this.binariesStore.delete(n),this.uploading.delete(n);const t=this.uploadPromises.get(n);t&&(t.resolve(),this.uploadPromises.delete(n))}async onUploadError(n,e,t){if(!this.jobsStore)return;const o=t instanceof Error?t.message:"Unknown error";if(console.error(`Upload failed for ${n}:`,o),this.uploading.delete(n),e.retryCount<this.maxRetries){const r={...e,retryCount:e.retryCount+1};await this.jobsStore.put(n,r),setTimeout(()=>{this.startUpload(n)},this.retryDelay*2**e.retryCount)}else{const r=this.uploadPromises.get(n);r&&(r.reject(new Error(o)),this.uploadPromises.delete(n))}}},dx="wovencanvas-assets",ux="blobs",fx=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(n,e,t){return await(await this.getStore()).put(e,{blob:n,metadata:t}),{}}async resolveUrl(n){if(n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/"))return n;const t=await(await this.getStore()).get(n);if(!t)throw new Error(`Asset not found: ${n}`);return URL.createObjectURL(t.blob)}async delete(n){await(await this.getStore()).delete(n)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=na(dx,ux).then(n=>(this.store=n,n))),this.initPromise)}};const hx={class:"wov-selection-box"},px=a.defineComponent({__name:"SelectionBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",hx))}}),mx={class:"wov-transform-box"},gx=a.defineComponent({__name:"TransformBox",setup(n){return(e,t)=>(a.openBlock(),a.createElementBlock("div",mx))}}),yx={},kx={class:"wov-transform-handle"};function wx(n,e){return a.openBlock(),a.createElementBlock("div",kx)}const bx=an(yx,[["render",wx]]),Cx=a.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(n){const e=n,t=pe(e.entityId,b.Color),o=pe(e.entityId,b.VerticalAlign),r=a.ref(null),s={[b.VerticalAlignment.Top]:"flex-start",[b.VerticalAlignment.Center]:"center",[b.VerticalAlignment.Bottom]:"flex-end"},i=a.computed(()=>{var c;return{backgroundColor:t.value?`rgb(${t.value.red}, ${t.value.green}, ${t.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((c=o.value)==null?void 0:c.value)??b.VerticalAlignment.Top]}}),{handleEditEnd:l}=Bl({blockData:e,containerRef:r,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(c,d)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"wov-sticky-note",style:a.normalizeStyle(i.value)},[a.createVNode(ps,a.mergeProps(e,{"block-element":r.value,onEditEnd:a.unref(l)}),null,16,["block-element","onEditEnd"])],4))}}),Os=$e.defineCanvasSingleton({name:"blockPlacementState"},{editedCheckpoint:b.field.string().default("").max(36)}),Gh=b.defineQuery(n=>n.with(b.Edited));function xx(n){var e;if(!n)return null;try{const t=JSON.parse(n);return(e=t.block)!=null&&e.tag?t:(console.warn("Block snapshot missing required tag:",t),null)}catch{return console.warn("Invalid block snapshot JSON:",n),null}}function Sx(n,e,t){const o=b.getBlockDef(n,e.block.tag);if(!o)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const r=e.block.size??[100,100],s=[t[0]-r[0]/2,t[1]-r[1]/2];b.Grid.snapPosition(n,s);const[i,l]=s,c=e.block.rank??b.RankBounds.genNext(n),d=b.createEntity(n);"synced"in e||b.addComponent(n,d,b.Synced,{id:crypto.randomUUID()});const u=Object.assign({},e.block,{position:[i,l],size:r,rank:c});b.addComponent(n,d,b.Block,u);for(const h of o.components)if(!(h.name in e))b.addComponent(n,d,h);else{const p=e[h.name];b.addComponent(n,d,h,p)}const{sessionId:f}=b.getResources(n);return b.addComponent(n,d,b.Held,{sessionId:f}),d}function Jh(n,e,t,o,r){const s=Sx(n,e,t),i=b.Block.read(n,s);if(b.canBlockEdit(n,e.block.tag)&&(b.addComponent(n,s,le.EditAfterPlacing,{}),r==="placement")){const{store:u}=b.getPluginResources(n,to),f=u.createCheckpoint();if(f){const h=Os.write(n);h.editedCheckpoint=f}}const l=le.SelectionStateSingleton.write(n);l.state=r==="dragOut"?le.SelectionState.Dragging:le.SelectionState.Pointing,l.dragStart=t,l.draggedEntity=s,l.draggedEntityStart=i.position,l.pointingStartClient=o,l.pointingStartWorld=t,l.isCloning=!1;const c=b.Controls.write(n);c.leftMouseTool="select",c.heldSnapshot="";const d=b.Cursor.write(n);d.cursorKind="select",d.rotation=0}function Ex(n){const e=Os.read(n);if(e.editedCheckpoint){const t=e.editedCheckpoint;Os.write(n).editedCheckpoint="";const{store:o}=b.getPluginResources(n,to);o.onSettled(()=>o.squashToCheckpoint(t),{frames:5})}}const vx=b.defineEditorSystem({phase:"capture"},n=>{Gh.removed(n).length>0&&Gh.current(n).length===0&&Ex(n);const e=b.Controls.read(n);if(!e.heldSnapshot)return;const t=b.getPointerInput(n,[b.PointerButton.Left]);if(t.length===0)return;const o=xx(e.heldSnapshot);if(!o)return;if(e.leftMouseTool==="drag-out"){const s=t.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;Jh(n,o,s.worldPosition,s.screenPosition,"dragOut")}else{const s=t.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;Jh(n,o,s.worldPosition,s.screenPosition,"placement")}}),Mx=b.defineEditorSystem({phase:"update"},n=>{const{store:e}=b.getPluginResources(n,to);b.on(n,b.Undo,()=>{e.canUndo()&&(le.deselectAll(n),e.undo())}),b.on(n,b.Redo,()=>{e.canRedo()&&(le.deselectAll(n),e.redo())})}),Tx=[{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 Yh(n){return{name:to,resources:{store:n.store},singletons:[Os],systems:[vx,Mx],cursors:Th,fonts:Tx,keybinds:[{command:b.Undo.name,key:b.Key.Z,mod:!0},{command:b.Redo.name,key:b.Key.Y,mod:!0},{command:b.Redo.name,key:b.Key.Z,mod:!0,shift:!0}]}}const Nx=a.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(n){const e=n,{nextEditorTick:t}=de(),{createImageBlock:o}=Af(),r=a.ref(!1);let s=0;const i=a.inject("containerRef");function l(w){var C;(C=w.dataTransfer)!=null&&C.types.some(x=>x==="Files"||x==="text/uri-list"||x==="text/html")&&(s++,s===1&&(r.value=!0))}function c(){s--,s===0&&(r.value=!1)}function d(){s=0,r.value=!1}a.onMounted(()=>{const w=i==null?void 0:i.value;w&&(w.addEventListener("dragenter",l),w.addEventListener("dragleave",c),w.addEventListener("drop",d))}),a.onUnmounted(()=>{const w=i==null?void 0:i.value;w&&(w.removeEventListener("dragenter",l),w.removeEventListener("dragleave",c),w.removeEventListener("drop",d))});function u(w){w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="copy")}function f(w){w.preventDefault()}function h(w){w.preventDefault()}async function p(w){if(w.preventDefault(),!w.dataTransfer)return;const C=w.clientX,x=w.clientY,S=Array.from(w.dataTransfer.files).filter(E=>E.type.startsWith("image/"));if(S.length>0){for(const E of S)await y(E,C,x);return}const M=m(w.dataTransfer);M&&await k(M,C,x)}function m(w){const C=w.getData("text/uri-list");if(C){const E=C.split(`
107
107
  `).filter(v=>!v.startsWith("#")).find(v=>g(v));if(E)return E}const x=w.getData("text/html");if(x){const M=x.match(/<img[^>]+src=["']([^"']+)["']/i);if(M!=null&&M[1])return M[1]}const S=w.getData("text/plain");return S&&g(S)?S:null}function g(w){try{const x=new URL(w).pathname.toLowerCase();return/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i.test(x)||w.startsWith("data:image/"),!0}catch{return!1}}async function y(w,C,x){const S=await t(),M=b.Camera.read(S),E=b.Screen.read(S),v=M.left+(C-E.left)/M.zoom,T=M.top+(x-E.top)/M.zoom;await o(w,v,T,{maxSize:e.maxSize})}async function k(w,C,x){try{const S=await fetch(w);if(!S.ok){console.warn("Failed to fetch image from URL:",w);return}const M=await S.blob();if(!M.type.startsWith("image/")){console.warn("URL did not return an image:",w);return}const v=new URL(w).pathname.split("/").pop()||"image",T=new File([M],v,{type:M.type});await y(T,C,x)}catch(S){console.warn("Failed to load image from URL:",w,S)}}return(w,C)=>(a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["wov-image-drop-zone",{"wov-drag-over":r.value}]),onDragover:u,onDragenter:f,onDragleave:h,onDrop:p},null,34))}}),Ax={class:"wov-user-cursors"},Bx={class:"wov-cursor-svg",viewBox:"0 0 4.35 4.75",width:"20",height:"20"},Ix=["fill"],Ox="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",Rx=a.defineComponent({__name:"UserCursors",props:{users:{},currentSessionId:{},camera:{}},setup(n){const e=n,t=a.computed(()=>e.users.filter(o=>o.sessionId!==e.currentSessionId).map(o=>({...o,screenX:(o.position[0]-e.camera.left)*e.camera.zoom,screenY:(o.position[1]-e.camera.top)*e.camera.zoom})));return(o,r)=>(a.openBlock(),a.createElementBlock("div",Ax,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.value,s=>(a.openBlock(),a.createElementBlock("div",{key:s.sessionId,class:"wov-user-cursor",style:a.normalizeStyle({transform:`translate(${s.screenX}px, ${s.screenY}px)`})},[(a.openBlock(),a.createElementBlock("svg",Bx,[a.createElementVNode("path",{fill:s.color,stroke:"#fff","stroke-miterlimit":"10","stroke-width":".25",d:Ox},null,8,Ix)])),a.createElementVNode("span",{class:"wov-cursor-label",style:a.normalizeStyle({backgroundColor:s.color})},a.toDisplayString(s.name),5)],4))),128))]))}}),Px={key:0,class:"wov-offline-indicator"},Dx=a.defineComponent({__name:"OfflineIndicator",props:{isOnline:{type:Boolean}},setup(n){return(e,t)=>n.isOnline?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",Px,"Working Offline"))}}),_x={key:0,class:"wov-version-mismatch-overlay"},Lx=a.defineComponent({__name:"VersionMismatch",props:{versionMismatch:{type:Boolean}},setup(n){function e(){window.location.reload()}return(t,o)=>n.versionMismatch?(a.openBlock(),a.createElementBlock("div",_x,[a.createElementVNode("div",{class:"wov-version-mismatch-dialog"},[o[0]||(o[0]=a.createElementVNode("p",null,"A new version is available.",-1)),o[1]||(o[1]=a.createElementVNode("p",null,"Please refresh the page to continue.",-1)),a.createElementVNode("button",{onClick:e},"Refresh")])])):a.createCommentVNode("",!0)}}),Vx=a.defineComponent({__name:"BackToContentButton",setup(n){const{nextEditorTick:e}=de(),t=Ne(b.Camera),o=b.defineQuery(d=>d.with(b.Synced,b.Block,b.Aabb)),r=a.ref(0),s=a.inject(He);if(s){const d=s.registerTickCallback(u=>{o.addedOrRemoved(u).length>0&&(r.value=o.current(u).length)});a.onUnmounted(d)}const i=a.ref(!1);a.watchEffect(()=>{i.value=!t.value.canSeeBlocks&&r.value>0});function l(d,u,f,h,p){const m=u+h,g=f+p;return d[0]<m&&d[2]>u&&d[1]<g&&d[3]>f}function c(){e(d=>{const u=o.current(d);if(u.length===0)return;let f=Number.POSITIVE_INFINITY,h=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const P of u){const R=b.Aabb.read(d,P);f=Math.min(f,R.value[0]),h=Math.min(h,R.value[1]),p=Math.max(p,R.value[2]),m=Math.max(m,R.value[3])}const g=b.Screen.read(d),y=b.Camera.read(d),k=b.getPluginResources(d,Ps.CONTROLS_PLUGIN_NAME)??Ps.DEFAULT_CONTROLS_OPTIONS;let w=Math.min(g.width/(p-f),g.height/(m-h));w/=1.1,w=Math.min(w,y.zoom),w=Math.max(k.minZoom,Math.min(k.maxZoom,w));const C=(f+p)/2,x=(h+m)/2;let S=C-g.width/w/2,M=x-g.height/w/2;const E=g.width/w,v=g.height/w;let T=!1;for(const P of u){const R=b.Aabb.read(d,P);if(l(R.value,S,M,E,v)){T=!0;break}}if(!T){const P=Math.floor(Math.random()*u.length),R=u[P],_=b.Aabb.read(d,R),z=(_.value[0]+_.value[2])/2,H=(_.value[1]+_.value[3])/2;S=z-E/2,M=H-v/2}const D=b.Camera.write(d);D.left=S,D.top=M,D.zoom=w})}return(d,u)=>i.value?(a.openBlock(),a.createElementBlock("button",{key:0,class:"wov-back-to-content",onClick:c},[...u[0]||(u[0]=[a.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a.createElementVNode("path",{d:"M10 12L6 8L10 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),a.createTextVNode(" Back to content ",-1)])])):a.createCommentVNode("",!0)}}),$x=["data-entity-id","data-selected","data-held-by-other","data-hovered"],zx=a.defineComponent({__name:"WovenCanvasCore",props:{store:{},editor:{},background:{},assetProvider:{},pluginOptions:{},controls:{},initialState:{}},emits:["ready"],async setup(n,{emit:e}){var ep,tp;let t,o;const r=b.defineQuery(N=>N.tracking(b.Block)),s=b.defineQuery(N=>N.with(b.Block).tracking(b.Connector)),i=b.defineQuery(N=>N.with(b.Block).tracking(le.Selected)),l=b.defineQuery(N=>N.with(b.Block).tracking(b.Held)),c=b.defineQuery(N=>N.with(b.Block).tracking(b.Hovered)),d=b.defineQuery(N=>N.with(b.Block).tracking(b.Edited)),u=b.defineQuery(N=>N.with(b.Block).tracking(b.Opacity)),f=b.defineQuery(N=>N.tracking(b.User)),h=n,p=e,m=a.ref(null),g=a.shallowRef(null),y=b.UserData.parse(((ep=h.editor)==null?void 0:ep.user)??{}),k=new Set,w=new Map,C=a.shallowRef([]),x=new Map,S=new Map,M=new Set,E=new Map,v=a.shallowRef([]),T=a.ref(!0),D=a.ref(!1),P=a.ref(!h.initialState),R=a.shallowRef(b.Camera.default());function _(N,F,A){let Q=x.get(N);Q||(Q=new Map,x.set(N,Q));let L=Q.get(F);return L||(L=new Set,Q.set(F,L)),L.add(A),()=>{L.delete(A),L.size===0&&(Q.delete(F),Q.size===0&&x.delete(N))}}function z(N,F,A,Q=!1){const L=x.get(F);if(!L)return;const V=L.get(A.name);if(!V||V.size===0)return;let xe=null;Q||(xe=A.snapshot(N,F));for(const ln of V)ln(xe)}function H(N,F){let A=S.get(N);return A||(A=new Set,S.set(N,A)),A.add(F),()=>{A.delete(F),A.size===0&&S.delete(N)}}function Z(N,F){const A=S.get(F.name);if(!A||A.size===0)return;const Q=F.snapshot(N);for(const L of A)L(Q)}function K(N){return M.add(N),()=>{M.delete(N)}}function W(){return y.sessionId}function U(N){return w.get(N)??null}const X={hasEntity:N=>k.has(N),getEditor:()=>g.value,getAssetManager:()=>ge,getSessionId:W,getUserBySessionId:U,subscribeComponent:_,subscribeSingleton:H,registerTickCallback:K};a.provide(He,X),a.provide("containerRef",m);const te=Vf();a.provide(aa,te);let ne=0,Ie=null,ce=null;const et=((tp=(h.store??{}).persistence)==null?void 0:tp.documentId)??"default";let ge=new cx({provider:h.assetProvider??new fx,documentId:et});function sn(N){var Q;const F=[],A=h.pluginOptions;return(A==null?void 0:A.controls)!==!1&&F.push(Ps.CanvasControlsPlugin((A==null?void 0:A.controls)??{})),(A==null?void 0:A.selection)!==!1&&F.push(le.createSelectionPlugin((A==null?void 0:A.selection)||void 0)),(A==null?void 0:A.eraser)!==!1&&F.push(Ko.createEraserPlugin((A==null?void 0:A.eraser)||void 0)),(A==null?void 0:A.pen)!==!1&&F.push(qo.createPenPlugin()),(A==null?void 0:A.arrows)!==!1&&F.push(ee.createArrowsPlugin((A==null?void 0:A.arrows)||void 0)),(A==null?void 0:A.tapes)!==!1&&F.push(lp.createTapesPlugin()),F.push(Yh({store:N})),(Q=h.editor)!=null&&Q.plugins&&F.push(...h.editor.plugins),F}function Rs(){const N=h.store??{},F={history:!0,...N};return N.websocket&&(F.websocket={...N.websocket,onVersionMismatch:A=>{var Q,L;D.value=!0,(L=(Q=N.websocket)==null?void 0:Q.onVersionMismatch)==null||L.call(Q,A)},onConnectivityChange:A=>{var Q,L;T.value=A,(L=(Q=N.websocket)==null?void 0:Q.onConnectivityChange)==null||L.call(Q,A)}}),F}async function no(N,F){const A=Rs();N||(delete A.persistence,delete A.websocket),F&&(A.initialState=F),ce=new $e.CanvasStore(A);const Q={...h.editor,user:y,plugins:sn(ce),controls:h.controls},L=new b.Editor(N,Q);return await L.initialize(),await ce.initialize({components:L.components,singletons:L.singletons}),L}async function bt(N){N.nextTick(F=>{ce&&ce.sync(F),Hx(F),Ux(F);for(const A of M)A(F)}),await N.tick()}async function Xh(){!g.value||!ce||(await bt(g.value),Ie=requestAnimationFrame(Xh))}if(H(b.Camera.name,N=>{N&&(R.value=N)}),h.initialState){const N=([t,o]=a.withAsyncContext(()=>no(null,h.initialState)),t=await t,o(),t);[t,o]=a.withAsyncContext(()=>bt(N)),await t,o(),[t,o]=a.withAsyncContext(()=>bt(N)),await t,o(),g.value=N}let Qh=null;a.onMounted(async()=>{if(!m.value)return;Qh=()=>{var F;(F=m.value)==null||F.scrollTo(0,0)},m.value.addEventListener("scroll",Qh),g.value&&(g.value.dispose(),ce==null||ce.close(),ce=null,ne=0);const N=await no(m.value,h.initialState);g.value=N,P.value=!1,await(ge==null?void 0:ge.init()),await(ge==null?void 0:ge.resumePendingUploads()),Ie=requestAnimationFrame(Xh),p("ready",g.value,ce)}),a.onUnmounted(()=>{var N;Ie!==null&&cancelAnimationFrame(Ie),ge==null||ge.close(),ce==null||ce.close(),(N=g.value)==null||N.dispose()});function Hx(N){const{events:F,newIndex:A}=N.eventBuffer.readEvents(ne);if(ne=A,F.length===0)return;const{componentsById:Q,singletonsById:L}=b.getResources(N);for(const{entityId:V,eventType:xe,componentId:ln}of F){if(V===b.SINGLETON_ENTITY_ID){if(xe===b.EventType.CHANGED){const ct=L.get(ln);ct&&Z(N,ct)}continue}if(xe===b.EventType.ADDED)k.add(V);else if(xe===b.EventType.REMOVED)k.delete(V),x.delete(V);else if(xe===b.EventType.COMPONENT_ADDED){k.add(V);const ct=Q.get(ln);ct&&z(N,V,ct)}else if(xe===b.EventType.COMPONENT_REMOVED){const ct=Q.get(ln);ct&&z(N,V,ct,!0)}else if(xe===b.EventType.CHANGED){const ct=Q.get(ln);ct&&z(N,V,ct)}}}function Ux(N){var Q;let F=!1;for(const L of r.added(N)){const V=b.Block.snapshot(N,L),xe=(Q=g.value)==null?void 0:Q.blockDefs[V.tag],ln=(xe==null?void 0:xe.stratum)??"content";E.set(L,a.ref({entityId:L,block:V,stratum:ln,selected:!1,held:null,hovered:!1,edited:!1,opacity:null,connector:null})),F=!0}for(const L of r.removed(N))E.delete(L),F=!0;for(const L of r.changed(N)){const V=E.get(L);if(V){const xe=b.Block.snapshot(N,L);V.value.block.rank!==xe.rank&&(F=!0),V.value.block=xe}}let A=!1;for(const L of f.addedOrChanged(N)){const V=b.User.snapshot(N,L);w.set(V.sessionId,V),A=!0}for(const L of f.removed(N)){const V=b.User.read(N,L);w.delete(V.sessionId),A=!0}A&&(C.value=Array.from(w.values()));for(const L of i.added(N)){const V=E.get(L);V&&!V.value.selected&&(V.value.selected=!0)}for(const L of i.removed(N)){const V=E.get(L);V&&V.value.selected&&(V.value.selected=!1)}for(const L of l.addedOrChanged(N)){const V=E.get(L);V&&(V.value.held=b.Held.snapshot(N,L))}for(const L of l.removed(N)){const V=E.get(L);V&&V.value.held!==null&&(V.value.held=null)}for(const L of c.added(N)){const V=E.get(L);V&&!V.value.hovered&&(V.value.hovered=!0)}for(const L of c.removed(N)){const V=E.get(L);V&&V.value.hovered&&(V.value.hovered=!1)}for(const L of d.added(N)){const V=E.get(L);V&&!V.value.edited&&(V.value.edited=!0)}for(const L of d.removed(N)){const V=E.get(L);V&&V.value.edited&&(V.value.edited=!1)}for(const L of u.addedOrChanged(N)){const V=E.get(L);V&&(V.value.opacity=b.Opacity.snapshot(N,L))}for(const L of u.removed(N)){const V=E.get(L);V&&V.value.opacity!==null&&(V.value.opacity=null)}for(const L of s.addedOrChanged(N)){const V=E.get(L);V&&(V.value.connector=b.Connector.snapshot(N,L))}for(const L of s.removed(N)){const V=E.get(L);V&&V.value.connector!==null&&(V.value.connector=null)}if(F){const L=Array.from(E.values());L.sort((V,xe)=>V.value.block.rank>xe.value.block.rank?1:-1),v.value=L}}function jx(N){const F=N.rotateZ!==0,A=N.flip[0],Q=N.flip[1];if(!F&&!A&&!Q)return;const L=[];return F&&L.push(`rotate(${N.rotateZ}rad)`),A&&L.push("scaleX(-1)"),Q&&L.push("scaleY(-1)"),L.join(" ")}function Zh(N){const{held:F}=N;if(!F||!F.sessionId||F.sessionId===y.sessionId)return null;const A=U(F.sessionId);return(A==null?void 0:A.color)??null}function Wx(N){const{block:F,stratum:A,opacity:Q}=N,L=Zh(N),V=Q!==null?Q.value/255:1;return{position:"absolute",left:`${F.position[0]}px`,top:`${F.position[1]}px`,width:`${F.size[0]}px`,height:`${F.size[1]}px`,zIndex:b.STRATUM_ORDER[A]*1e3,transform:jx(F),opacity:V,pointerEvents:"none",userSelect:"none","--wov-held-by-color":L??void 0,transition:V===1?"opacity 0ms 32ms":void 0}}return(N,F)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"containerRef",ref:m,class:"wov-root",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},[n.background?a.renderSlot(N.$slots,"background",{key:0,background:n.background},()=>[a.createVNode(xh,{background:n.background},null,8,["background"])]):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"wov-canvas",style:a.normalizeStyle({position:"absolute",transformOrigin:"0 0",transform:`scale(${R.value.zoom}) translate(${-R.value.left}px, ${-R.value.top}px)`,"--wov-zoom":R.value.zoom})},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(v.value,A=>(a.openBlock(),a.createElementBlock("div",{key:A.value.entityId,"data-entity-id":A.value.entityId,style:a.normalizeStyle(Wx(A.value)),"data-selected":A.value.selected||void 0,"data-held-by-other":Zh(A.value)!==null||void 0,"data-hovered":A.value.hovered||void 0,class:"wov-block"},[a.renderSlot(N.$slots,`block:${A.value.block.tag}`,a.mergeProps({ref_for:!0},A.value),()=>[A.value.block.tag==="selection-box"?(a.openBlock(),a.createBlock(px,a.mergeProps({key:0,ref_for:!0},A.value),null,16)):A.value.block.tag==="transform-box"?(a.openBlock(),a.createBlock(gx,a.mergeProps({key:1,ref_for:!0},A.value),null,16)):A.value.block.tag==="transform-handle"?(a.openBlock(),a.createBlock(bx,a.mergeProps({key:2,ref_for:!0},A.value),null,16)):A.value.block.tag==="arrow-handle"?(a.openBlock(),a.createBlock(da,a.mergeProps({key:3,ref_for:!0},A.value),null,16)):A.value.block.tag==="arrow-terminal"?(a.openBlock(),a.createBlock(ua,a.mergeProps({key:4,ref_for:!0},A.value),null,16)):A.value.block.tag==="sticky-note"?(a.openBlock(),a.createBlock(Cx,a.mergeProps({key:5,ref_for:!0},A.value),null,16)):A.value.block.tag==="eraser"?(a.openBlock(),a.createBlock(Aa,a.mergeProps({key:6,ref_for:!0},A.value),null,16)):A.value.block.tag==="pen-stroke"?(a.openBlock(),a.createBlock(Ia,a.mergeProps({key:7,ref_for:!0},A.value),null,16)):A.value.block.tag==="arc-arrow"?(a.openBlock(),a.createBlock(ca,a.mergeProps({key:8,ref_for:!0},A.value),null,16)):A.value.block.tag==="elbow-arrow"?(a.openBlock(),a.createBlock(fa,a.mergeProps({key:9,ref_for:!0},A.value),null,16)):A.value.block.tag==="text"?(a.openBlock(),a.createBlock(Hf,a.mergeProps({key:10,ref_for:!0},A.value),null,16)):A.value.block.tag==="image"?(a.openBlock(),a.createBlock(Ba,a.mergeProps({key:11,ref_for:!0},A.value),null,16)):A.value.block.tag==="shape"?(a.openBlock(),a.createBlock(zf,a.mergeProps({key:12,ref_for:!0},A.value),null,16)):A.value.block.tag==="embed"?(a.openBlock(),a.createBlock(ha,a.mergeProps({key:13,ref_for:!0},A.value),null,16)):A.value.block.tag==="tape"?(a.openBlock(),a.createBlock(Ff,a.mergeProps({key:14,ref_for:!0},A.value),null,16)):a.createCommentVNode("",!0)])],12,$x))),128))],4),g.value?a.renderSlot(N.$slots,"user-cursors",{key:1,users:C.value,currentSessionId:a.unref(y).sessionId,camera:R.value},()=>[a.createVNode(Rx,{users:C.value,"current-session-id":a.unref(y).sessionId,camera:R.value},null,8,["users","current-session-id","camera"])]):a.createCommentVNode("",!0),g.value?(a.openBlock(),a.createBlock(vh,{key:2},{default:a.withCtx(A=>[a.renderSlot(N.$slots,"floating-menu",a.normalizeProps(a.guardReactiveProps(A)))]),_:3})):a.createCommentVNode("",!0),g.value?a.renderSlot(N.$slots,"user-presence",{key:3,users:C.value},()=>[a.createVNode(zh,{users:C.value},null,8,["users"])]):a.createCommentVNode("",!0),g.value?a.renderSlot(N.$slots,"toolbar",{key:4},()=>[a.createVNode($h)]):a.createCommentVNode("",!0),g.value?a.renderSlot(N.$slots,"default",{key:5}):a.createCommentVNode("",!0),a.renderSlot(N.$slots,"offline-indicator",{isOnline:T.value},()=>[a.createVNode(Dx,{"is-online":T.value},null,8,["is-online"])]),a.renderSlot(N.$slots,"version-mismatch",{versionMismatch:D.value},()=>[a.createVNode(Lx,{"version-mismatch":D.value},null,8,["version-mismatch"])]),a.renderSlot(N.$slots,"back-to-content",{},()=>[a.createVNode(Vx)]),a.renderSlot(N.$slots,"loading",{isLoading:P.value},()=>[a.createVNode(Mh,{"is-loading":P.value},null,8,["is-loading"])]),g.value?a.renderSlot(N.$slots,"file-drop-zone",{key:6},()=>[a.createVNode(Nx)]):a.createCommentVNode("",!0)],512))}}),Fx=a.defineComponent({inheritAttrs:!1,__name:"WovenCanvas",setup(n){return(e,t)=>(a.openBlock(),a.createBlock(a.Suspense,null,{default:a.withCtx(()=>[a.createVNode(zx,a.normalizeProps(a.guardReactiveProps(e.$attrs)),a.createSlots({_:2},[a.renderList(e.$slots,(o,r)=>({name:r,fn:a.withCtx(s=>[a.renderSlot(e.$slots,r,a.normalizeProps(a.guardReactiveProps(s??{})))])}))]),1040)]),_:3}))}});Object.defineProperty(I,"CanvasComponentDef",{enumerable:!0,get:()=>$e.CanvasComponentDef}),Object.defineProperty(I,"CanvasSingletonDef",{enumerable:!0,get:()=>$e.CanvasSingletonDef}),Object.defineProperty(I,"CanvasStore",{enumerable:!0,get:()=>$e.CanvasStore}),Object.defineProperty(I,"Synced",{enumerable:!0,get:()=>$e.Synced}),Object.defineProperty(I,"defineCanvasComponent",{enumerable:!0,get:()=>$e.defineCanvasComponent}),Object.defineProperty(I,"defineCanvasSingleton",{enumerable:!0,get:()=>$e.defineCanvasSingleton}),I.ARROW_HEADS=Ds,I.ArcArrow=ca,I.ArcArrowTool=UC,I.ArrowHandle=da,I.ArrowHead=Ct,I.ArrowHeadButton=Vl,I.ArrowTerminal=ua,I.ArrowThicknessButton=dh,I.CURSORS=Th,I.CanvasBackground=xh,I.ColorButton=hh,I.ColorPicker=fh,I.CursorKind=rn,I.EDITING_PLUGIN_NAME=to,I.EditableText=ps,I.EditingPlugin=Yh,I.ElbowArrow=fa,I.ElbowArrowTool=Dh,I.EmbedBlock=ha,I.EmbedTool=Lh,I.Eraser=Aa,I.EraserTool=Oh,I.FloatingMenu=vh,I.FloatingMenuBar=Eh,I.HandTool=Ah,I.IconChevronDown=qe,I.ImageBlock=Ba,I.ImageTool=_h,I.LoadingOverlay=Mh,I.MenuButton=Bn,I.MenuDropdown=Ke,I.MenuTooltip=$l,I.PenStroke=Ia,I.PenStrokeThicknessButton=ph,I.PenTool=Rh,I.SHAPES=ro,I.SelectTool=Nh,I.ShapeBlock=zf,I.ShapeFillColorButton=mh,I.ShapeKindButton=gh,I.ShapeStrokeColorButton=yh,I.ShapeTool=Ih,I.StickyNoteTool=Bh,I.TapeBlock=Ff,I.TapeImageButton=kh,I.TapeTool=Vh,I.TextAlignmentButton=zl,I.TextBlock=Hf,I.TextBoldButton=Fl,I.TextColorButton=Gl,I.TextFontFamilyButton=Ul,I.TextFontSizeButton=jl,I.TextItalicButton=Wl,I.TextLinkButton=ql,I.TextTool=Ph,I.TextUnderlineButton=Kl,I.Toolbar=$h,I.ToolbarButton=at,I.UserPresence=zh,I.WovenCanvas=Fx,I.computeCommonComponents=Sh,I.createTooltipContext=Vf,I.getArrowHead=On,I.useComponent=pe,I.useComponents=Rt,I.useEditorContext=de,I.useFonts=bh,I.useQuery=Bf,I.useSingleton=Ne,I.useTextBatchController=Lf,I.useTextEditorController=Fo,I.useTextFormatting=rt,I.useTextStretchBehavior=Bl,I.useToolbar=hs,I.useTooltipSingleton=Dt,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woven-canvas/vue",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Vue 3 components for woven-canvas infinite canvas",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,7 +53,7 @@
53
53
  "@tiptap/vue-3": "^3.15.3",
54
54
  "@vueuse/core": "^14.0.0",
55
55
  "perfect-freehand": "^1.2.2",
56
- "@woven-canvas/asset-sync": "^1.0.2"
56
+ "@woven-canvas/asset-sync": "^1.0.4"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@vitejs/plugin-vue": "^5.2.4",
@@ -67,14 +67,14 @@
67
67
  "@woven-ecs/core": "^1.0.4",
68
68
  "typescript": "^5.9.3",
69
69
  "vue": "^3",
70
- "@woven-canvas/core": "^1.0.2",
71
- "@woven-canvas/math": "^1.0.1",
72
- "@woven-canvas/plugin-arrows": "^1.0.2",
73
- "@woven-canvas/plugin-canvas-controls": "^1.0.2",
74
- "@woven-canvas/plugin-eraser": "^1.0.1",
75
- "@woven-canvas/plugin-pen": "^1.0.1",
76
- "@woven-canvas/plugin-selection": "^1.0.2",
77
- "@woven-canvas/plugin-tapes": "^1.0.1"
70
+ "@woven-canvas/math": "^1.0.3",
71
+ "@woven-canvas/plugin-arrows": "^1.0.4",
72
+ "@woven-canvas/plugin-canvas-controls": "^1.0.5",
73
+ "@woven-canvas/core": "^1.0.4",
74
+ "@woven-canvas/plugin-eraser": "^1.0.3",
75
+ "@woven-canvas/plugin-pen": "^1.0.3",
76
+ "@woven-canvas/plugin-tapes": "^1.0.3",
77
+ "@woven-canvas/plugin-selection": "^1.0.4"
78
78
  },
79
79
  "scripts": {
80
80
  "dev": "vite",