@snowcone-app/canvas 0.1.10 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CanvasStateV1-BmE5V6me.cjs → CanvasStateV1-C4hC1MCe.cjs} +5 -5
- package/dist/{CanvasStateV1-BmE5V6me.cjs.map → CanvasStateV1-C4hC1MCe.cjs.map} +1 -1
- package/dist/{CanvasStateV1-CD3Q94F4.js → CanvasStateV1-CJU_xYW5.js} +3 -3
- package/dist/{CanvasStateV1-CD3Q94F4.js.map → CanvasStateV1-CJU_xYW5.js.map} +1 -1
- package/dist/{HybridHistoryManager-BV6XV0nD.js → HybridHistoryManager-jBBnVim8.js} +54 -54
- package/dist/{HybridHistoryManager-BV6XV0nD.js.map → HybridHistoryManager-jBBnVim8.js.map} +1 -1
- package/dist/{ElementFactory-Ckv6sSev.js → ImportManager-Oqu2yB54.js} +595 -378
- package/dist/ImportManager-Oqu2yB54.js.map +1 -0
- package/dist/{ElementFactory-DEjwp-Wg.cjs → ImportManager-W1eWhfyM.cjs} +5 -5
- package/dist/ImportManager-W1eWhfyM.cjs.map +1 -0
- package/dist/ThemeContext-BMNQKl1c.cjs +2 -0
- package/dist/{ThemeContext-4mJ_y0Me.cjs.map → ThemeContext-BMNQKl1c.cjs.map} +1 -1
- package/dist/ThemeContext-wj-wSO7J.js +1158 -0
- package/dist/{ThemeContext-H0Z-MqqR.js.map → ThemeContext-wj-wSO7J.js.map} +1 -1
- package/dist/advanced.js +5 -32
- package/dist/advanced.js.map +1 -1
- package/dist/advanced.mjs +588 -15069
- package/dist/advanced.mjs.map +1 -1
- package/dist/components/embed/KitLayout.d.ts +22 -0
- package/dist/components/embed/UndoRedoControls.d.ts +3 -0
- package/dist/compose-Dqh2f8tS.js +22222 -0
- package/dist/compose-Dqh2f8tS.js.map +1 -0
- package/dist/compose-HDJp4Z_d.cjs +60 -0
- package/dist/compose-HDJp4Z_d.cjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +600 -516
- package/dist/index.mjs.map +1 -1
- package/dist/internals.js +1 -1
- package/dist/internals.js.map +1 -1
- package/dist/internals.mjs +101 -102
- package/dist/internals.mjs.map +1 -1
- package/dist/style.css.d.ts +4 -0
- package/dist/testing.js +1 -1
- package/dist/testing.mjs +11 -11
- package/package.json +8 -4
- package/dist/ElementFactory-Ckv6sSev.js.map +0 -1
- package/dist/ElementFactory-DEjwp-Wg.cjs.map +0 -1
- package/dist/ImportManager-64OYjELO.js +0 -222
- package/dist/ImportManager-64OYjELO.js.map +0 -1
- package/dist/ImportManager-wSzrR-5a.cjs +0 -2
- package/dist/ImportManager-wSzrR-5a.cjs.map +0 -1
- package/dist/ThemeContext-4mJ_y0Me.cjs +0 -2
- package/dist/ThemeContext-H0Z-MqqR.js +0 -1077
- package/dist/compose-DHBRwi_A.cjs +0 -33
- package/dist/compose-DHBRwi_A.cjs.map +0 -1
- package/dist/compose-DIPiisIw.js +0 -7690
- package/dist/compose-DIPiisIw.js.map +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";const $t=require("react/jsx-runtime"),u=require("react"),Ge=require("./ThemeContext-4mJ_y0Me.cjs"),y=require("./HybridHistoryManager-BXD93pp8.cjs"),kr=require("react-dom"),re=require("./ElementFactory-DEjwp-Wg.cjs"),Sr=require("react-dom/server"),mo=require("lodash-es");function Mr(t,e){const n=t.icons,o=t.aliases||Object.create(null),r=Object.create(null);function i(s){if(n[s])return r[s]=[];if(!(s in r)){r[s]=null;const l=o[s]&&o[s].parent,a=l&&i(l);a&&(r[s]=[l].concat(a))}return r[s]}return Object.keys(n).concat(Object.keys(o)).forEach(i),r}const Xo=Object.freeze({left:0,top:0,width:16,height:16}),Yn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),eo=Object.freeze({...Xo,...Yn}),qn=Object.freeze({...eo,body:"",hidden:!1});function Rr(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const o=((t.rotate||0)+(e.rotate||0))%4;return o&&(n.rotate=o),n}function yo(t,e){const n=Rr(t,e);for(const o in qn)o in Yn?o in t&&!(o in n)&&(n[o]=Yn[o]):o in e?n[o]=e[o]:o in t&&(n[o]=t[o]);return n}function Tr(t,e,n){const o=t.icons,r=t.aliases||Object.create(null);let i={};function s(l){i=yo(o[l]||r[l],i)}return s(e),n.forEach(s),yo(t,i)}function Yo(t,e){const n=[];if(typeof t!="object"||typeof t.icons!="object")return n;t.not_found instanceof Array&&t.not_found.forEach(r=>{e(r,null),n.push(r)});const o=Mr(t);for(const r in o){const i=o[r];i&&(e(r,Tr(t,r,i)),n.push(r))}return n}const Ir={provider:"",aliases:{},not_found:{},...Xo};function $n(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function _o(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!$n(t,Ir))return null;const n=e.icons;for(const r in n){const i=n[r];if(!r||typeof i.body!="string"||!$n(i,qn))return null}const o=e.aliases||Object.create(null);for(const r in o){const i=o[r],s=i.parent;if(!r||typeof s!="string"||!n[s]&&!o[s]||!$n(i,qn))return null}return e}const xo=Object.create(null);function Ar(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function mn(t,e){const n=xo[t]||(xo[t]=Object.create(null));return n[e]||(n[e]=Ar(t,e))}function Fo(t,e){return _o(e)?Yo(e,(n,o)=>{o?t.icons[n]=o:t.missing.add(n)}):[]}function Pr(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const zo=/^[a-z0-9]+(-[a-z0-9]+)*$/,Fn=(t,e,n,o="")=>{const r=t.split(":");if(t.slice(0,1)==="@"){if(r.length<2||r.length>3)return null;o=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){const l=r.pop(),a=r.pop(),c={provider:r.length>0?r[0]:o,prefix:a,name:l};return e&&!On(c)?null:c}const i=r[0],s=i.split("-");if(s.length>1){const l={provider:o,prefix:s.shift(),name:s.join("-")};return e&&!On(l)?null:l}if(n&&o===""){const l={provider:o,prefix:"",name:i};return e&&!On(l,n)?null:l}return null},On=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Tn=!1;function jo(t){return typeof t=="boolean"&&(Tn=t),Tn}function bo(t){const e=typeof t=="string"?Fn(t,!0,Tn):t;if(e){const n=mn(e.provider,e.prefix),o=e.name;return n.icons[o]||(n.missing.has(o)?null:void 0)}}function Vo(t,e){const n=Fn(t,!0,Tn);if(!n)return!1;const o=mn(n.provider,n.prefix);return e?Pr(o,n.name,e):(o.missing.add(n.name),!0)}function Dr(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Tn&&!e&&!t.prefix){let r=!1;return _o(t)&&(t.prefix="",Yo(t,(i,s)=>{Vo(i,s)&&(r=!0)})),r}const n=t.prefix;if(!On({prefix:n,name:"a"}))return!1;const o=mn(e,n);return!!Fo(o,t)}const Wo=Object.freeze({width:null,height:null}),$o=Object.freeze({...Wo,...Yn}),Lr=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Br=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function vo(t,e,n){if(e===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*e*n)/n;if(typeof t!="string")return t;const o=t.split(Lr);if(o===null||!o.length)return t;const r=[];let i=o.shift(),s=Br.test(i);for(;;){if(s){const l=parseFloat(i);isNaN(l)?r.push(i):r.push(Math.ceil(l*e*n)/n)}else r.push(i);if(i=o.shift(),i===void 0)return r.join("");s=!s}}function Hr(t,e="defs"){let n="";const o=t.indexOf("<"+e);for(;o>=0;){const r=t.indexOf(">",o),i=t.indexOf("</"+e);if(r===-1||i===-1)break;const s=t.indexOf(">",i);if(s===-1)break;n+=t.slice(r+1,i).trim(),t=t.slice(0,o).trim()+t.slice(s+1)}return{defs:n,content:t}}function Or(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Xr(t,e,n){const o=Hr(t);return Or(o.defs,e+o.content+n)}const Yr=t=>t==="unset"||t==="undefined"||t==="none";function _r(t,e){const n={...eo,...t},o={...$o,...e},r={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach(M=>{const p=[],x=M.hFlip,w=M.vFlip;let E=M.rotate;x?w?E+=2:(p.push("translate("+(r.width+r.left).toString()+" "+(0-r.top).toString()+")"),p.push("scale(-1 1)"),r.top=r.left=0):w&&(p.push("translate("+(0-r.left).toString()+" "+(r.height+r.top).toString()+")"),p.push("scale(1 -1)"),r.top=r.left=0);let C;switch(E<0&&(E-=Math.floor(E/4)*4),E=E%4,E){case 1:C=r.height/2+r.top,p.unshift("rotate(90 "+C.toString()+" "+C.toString()+")");break;case 2:p.unshift("rotate(180 "+(r.width/2+r.left).toString()+" "+(r.height/2+r.top).toString()+")");break;case 3:C=r.width/2+r.left,p.unshift("rotate(-90 "+C.toString()+" "+C.toString()+")");break}E%2===1&&(r.left!==r.top&&(C=r.left,r.left=r.top,r.top=C),r.width!==r.height&&(C=r.width,r.width=r.height,r.height=C)),p.length&&(i=Xr(i,'<g transform="'+p.join(" ")+'">',"</g>"))});const s=o.width,l=o.height,a=r.width,c=r.height;let f,h;s===null?(h=l===null?"1em":l==="auto"?c:l,f=vo(h,a/c)):(f=s==="auto"?a:s,h=l===null?vo(f,c/a):l==="auto"?c:l);const m={},v=(M,p)=>{Yr(p)||(m[M]=p.toString())};v("width",f),v("height",h);const b=[r.left,r.top,a,c];return m.viewBox=b.join(" "),{attributes:m,viewBox:b,body:i}}const Fr=/\sid="(\S+)"/g,zr="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let jr=0;function Vr(t,e=zr){const n=[];let o;for(;o=Fr.exec(t);)n.push(o[1]);if(!n.length)return t;const r="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const s=typeof e=="function"?e(i):e+(jr++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+s+r+"$3")}),t=t.replace(new RegExp(r,"g"),""),t}const Zn=Object.create(null);function Wr(t,e){Zn[t]=e}function Qn(t){return Zn[t]||Zn[""]}function no(t){let e;if(typeof t.resources=="string")e=[t.resources];else if(e=t.resources,!(e instanceof Array)||!e.length)return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:t.random===!0,index:t.index||0,dataAfterTimeout:t.dataAfterTimeout!==!1}}const oo=Object.create(null),En=["https://api.simplesvg.com","https://api.unisvg.com"],Xn=[];for(;En.length>0;)En.length===1||Math.random()>.5?Xn.push(En.shift()):Xn.push(En.pop());oo[""]=no({resources:["https://api.iconify.design"].concat(Xn)});function $r(t,e){const n=no(e);return n===null?!1:(oo[t]=n,!0)}function ro(t){return oo[t]}const Gr=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let wo=Gr();function Ur(t,e){const n=ro(t);if(!n)return 0;let o;if(!n.maxURL)o=0;else{let r=0;n.resources.forEach(s=>{r=Math.max(r,s.length)});const i=e+".json?icons=";o=n.maxURL-r-n.path.length-i.length}return o}function Nr(t){return t===404}const Kr=(t,e,n)=>{const o=[],r=Ur(t,e),i="icons";let s={type:i,provider:t,prefix:e,icons:[]},l=0;return n.forEach((a,c)=>{l+=a.length+1,l>=r&&c>0&&(o.push(s),s={type:i,provider:t,prefix:e,icons:[]},l=a.length),s.icons.push(a)}),o.push(s),o};function qr(t){if(typeof t=="string"){const e=ro(t);if(e)return e.path}return"/"}const Zr=(t,e,n)=>{if(!wo){n("abort",424);return}let o=qr(e.provider);switch(e.type){case"icons":{const i=e.prefix,l=e.icons.join(","),a=new URLSearchParams({icons:l});o+=i+".json?"+a.toString();break}case"custom":{const i=e.uri;o+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let r=503;wo(t+o).then(i=>{const s=i.status;if(s!==200){setTimeout(()=>{n(Nr(s)?"abort":"next",s)});return}return r=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",r)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",r)})},Qr={prepare:Kr,send:Zr};function Go(t,e){t.forEach(n=>{const o=n.loaderCallbacks;o&&(n.loaderCallbacks=o.filter(r=>r.id!==e))})}function Jr(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const o=t.provider,r=t.prefix;e.forEach(i=>{const s=i.icons,l=s.pending.length;s.pending=s.pending.filter(a=>{if(a.prefix!==r)return!0;const c=a.name;if(t.icons[c])s.loaded.push({provider:o,prefix:r,name:c});else if(t.missing.has(c))s.missing.push({provider:o,prefix:r,name:c});else return n=!0,!0;return!1}),s.pending.length!==l&&(n||Go([t],i.id),i.callback(s.loaded.slice(0),s.missing.slice(0),s.pending.slice(0),i.abort))})}))}let ti=0;function ei(t,e,n){const o=ti++,r=Go.bind(null,n,o);if(!e.pending.length)return r;const i={id:o,icons:e,callback:t,abort:r};return n.forEach(s=>{(s.loaderCallbacks||(s.loaderCallbacks=[])).push(i)}),r}function ni(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort((r,i)=>r.provider!==i.provider?r.provider.localeCompare(i.provider):r.prefix!==i.prefix?r.prefix.localeCompare(i.prefix):r.name.localeCompare(i.name));let o={provider:"",prefix:"",name:""};return t.forEach(r=>{if(o.name===r.name&&o.prefix===r.prefix&&o.provider===r.provider)return;o=r;const i=r.provider,s=r.prefix,l=r.name,a=n[i]||(n[i]=Object.create(null)),c=a[s]||(a[s]=mn(i,s));let f;l in c.icons?f=e.loaded:s===""||c.missing.has(l)?f=e.missing:f=e.pending;const h={provider:i,prefix:s,name:l};f.push(h)}),e}function oi(t,e=!0,n=!1){const o=[];return t.forEach(r=>{const i=typeof r=="string"?Fn(r,e,n):r;i&&o.push(i)}),o}const ri={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function ii(t,e,n,o){const r=t.resources.length,i=t.random?Math.floor(Math.random()*r):t.index;let s;if(t.random){let $=t.resources.slice(0);for(s=[];$.length>1;){const T=Math.floor(Math.random()*$.length);s.push($[T]),$=$.slice(0,T).concat($.slice(T+1))}s=s.concat($)}else s=t.resources.slice(i).concat(t.resources.slice(0,i));const l=Date.now();let a="pending",c=0,f,h=null,m=[],v=[];typeof o=="function"&&v.push(o);function b(){h&&(clearTimeout(h),h=null)}function M(){a==="pending"&&(a="aborted"),b(),m.forEach($=>{$.status==="pending"&&($.status="aborted")}),m=[]}function p($,T){T&&(v=[]),typeof $=="function"&&v.push($)}function x(){return{startTime:l,payload:e,status:a,queriesSent:c,queriesPending:m.length,subscribe:p,abort:M}}function w(){a="failed",v.forEach($=>{$(void 0,f)})}function E(){m.forEach($=>{$.status==="pending"&&($.status="aborted")}),m=[]}function C($,T,L){const R=T!=="success";switch(m=m.filter(I=>I!==$),a){case"pending":break;case"failed":if(R||!t.dataAfterTimeout)return;break;default:return}if(T==="abort"){f=L,w();return}if(R){f=L,m.length||(s.length?N():w());return}if(b(),E(),!t.random){const I=t.resources.indexOf($.resource);I!==-1&&I!==t.index&&(t.index=I)}a="completed",v.forEach(I=>{I(L)})}function N(){if(a!=="pending")return;b();const $=s.shift();if($===void 0){if(m.length){h=setTimeout(()=>{b(),a==="pending"&&(E(),w())},t.timeout);return}w();return}const T={status:"pending",resource:$,callback:(L,R)=>{C(T,L,R)}};m.push(T),c++,h=setTimeout(N,t.rotate),n($,e,T.callback)}return setTimeout(N),x}function Uo(t){const e={...ri,...t};let n=[];function o(){n=n.filter(l=>l().status==="pending")}function r(l,a,c){const f=ii(e,l,a,(h,m)=>{o(),c&&c(h,m)});return n.push(f),f}function i(l){return n.find(a=>l(a))||null}return{query:r,find:i,setIndex:l=>{e.index=l},getIndex:()=>e.index,cleanup:o}}function Co(){}const Gn=Object.create(null);function si(t){if(!Gn[t]){const e=ro(t);if(!e)return;const n=Uo(e),o={config:e,redundancy:n};Gn[t]=o}return Gn[t]}function ai(t,e,n){let o,r;if(typeof t=="string"){const i=Qn(t);if(!i)return n(void 0,424),Co;r=i.send;const s=si(t);s&&(o=s.redundancy)}else{const i=no(t);if(i){o=Uo(i);const s=t.resources?t.resources[0]:"",l=Qn(s);l&&(r=l.send)}}return!o||!r?(n(void 0,424),Co):o.query(e,r,n)().abort}function Eo(){}function li(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,Jr(t)}))}function ci(t){const e=[],n=[];return t.forEach(o=>{(o.match(zo)?e:n).push(o)}),{valid:e,invalid:n}}function kn(t,e,n){function o(){const r=t.pendingIcons;e.forEach(i=>{r&&r.delete(i),t.icons[i]||t.missing.add(i)})}if(n&&typeof n=="object")try{if(!Fo(t,n).length){o();return}}catch(r){console.error(r)}o(),li(t)}function ko(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function di(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout(()=>{t.iconsQueueFlag=!1;const{provider:n,prefix:o}=t,r=t.iconsToLoad;if(delete t.iconsToLoad,!r||!r.length)return;const i=t.loadIcon;if(t.loadIcons&&(r.length>1||!i)){ko(t.loadIcons(r,o,n),f=>{kn(t,r,f)});return}if(i){r.forEach(f=>{const h=i(f,o,n);ko(h,m=>{const v=m?{prefix:o,icons:{[f]:m}}:null;kn(t,[f],v)})});return}const{valid:s,invalid:l}=ci(r);if(l.length&&kn(t,l,null),!s.length)return;const a=o.match(zo)?Qn(n):null;if(!a){kn(t,s,null);return}a.prepare(n,o,s).forEach(f=>{ai(n,f,h=>{kn(t,f.icons,h)})})}))}const ui=(t,e)=>{const n=oi(t,!0,jo()),o=ni(n);if(!o.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(o.loaded,o.missing,o.pending,Eo)}),()=>{a=!1}}const r=Object.create(null),i=[];let s,l;return o.pending.forEach(a=>{const{provider:c,prefix:f}=a;if(f===l&&c===s)return;s=c,l=f,i.push(mn(c,f));const h=r[c]||(r[c]=Object.create(null));h[f]||(h[f]=[])}),o.pending.forEach(a=>{const{provider:c,prefix:f,name:h}=a,m=mn(c,f),v=m.pendingIcons||(m.pendingIcons=new Set);v.has(h)||(v.add(h),r[c][f].push(h))}),i.forEach(a=>{const c=r[a.provider][a.prefix];c.length&&di(a,c)}),e?ei(e,o,i):Eo};function fi(t,e){const n={...t};for(const o in e){const r=e[o],i=typeof r;o in Wo?(r===null||r&&(i==="string"||i==="number"))&&(n[o]=r):i===typeof n[o]&&(n[o]=o==="rotate"?r%4:r)}return n}const hi=/[\s,]+/;function pi(t,e){e.split(hi).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function gi(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function o(r){for(;r<0;)r+=4;return r%4}if(n===""){const r=parseInt(t);return isNaN(r)?0:o(r)}else if(n!==t){let r=0;switch(n){case"%":r=25;break;case"deg":r=90}if(r){let i=parseFloat(t.slice(0,t.length-n.length));return isNaN(i)?0:(i=i/r,i%1===0?o(i):0)}}return e}function mi(t,e){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in e)n+=" "+o+'="'+e[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}function yi(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function xi(t){return"data:image/svg+xml,"+yi(t)}function bi(t){return'url("'+xi(t)+'")'}let Mn;function vi(){try{Mn=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Mn=null}}function wi(t){return Mn===void 0&&vi(),Mn?Mn.createHTML(t):t}const No={...$o,inline:!1},Ci={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ei={display:"inline-block"},Jn={backgroundColor:"currentColor"},Ko={backgroundColor:"transparent"},So={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Mo={WebkitMask:Jn,mask:Jn,background:Ko};for(const t in Mo){const e=Mo[t];for(const n in So)e[t+n]=So[n]}const ki={...No,inline:!0};function Ro(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Si=(t,e,n)=>{const o=e.inline?ki:No,r=fi(o,e),i=e.mode||"svg",s={},l=e.style||{},a={...i==="svg"?Ci:{}};if(n){const p=Fn(n,!1,!0);if(p){const x=["iconify"],w=["provider","prefix"];for(const E of w)p[E]&&x.push("iconify--"+p[E]);a.className=x.join(" ")}}for(let p in e){const x=e[p];if(x!==void 0)switch(p){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=x;break;case"className":a[p]=(a[p]?a[p]+" ":"")+x;break;case"inline":case"hFlip":case"vFlip":r[p]=x===!0||x==="true"||x===1;break;case"flip":typeof x=="string"&&pi(r,x);break;case"color":s.color=x;break;case"rotate":typeof x=="string"?r[p]=gi(x):typeof x=="number"&&(r[p]=x);break;case"ariaHidden":case"aria-hidden":x!==!0&&x!=="true"&&delete a["aria-hidden"];break;default:o[p]===void 0&&(a[p]=x)}}const c=_r(t,r),f=c.attributes;if(r.inline&&(s.verticalAlign="-0.125em"),i==="svg"){a.style={...s,...l},Object.assign(a,f);let p=0,x=e.id;return typeof x=="string"&&(x=x.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:wi(Vr(c.body,x?()=>x+"ID"+p++:"iconifyReact"))},u.createElement("svg",a)}const{body:h,width:m,height:v}=t,b=i==="mask"||(i==="bg"?!1:h.indexOf("currentColor")!==-1),M=mi(h,{...f,width:m+"",height:v+""});return a.style={...s,"--svg":bi(M),width:Ro(f.width),height:Ro(f.height),...Ei,...b?Jn:Ko,...l},u.createElement("span",a)};jo(!0);Wr("",Qr);if(typeof document<"u"&&typeof window<"u"){const t=window;if(t.IconifyPreload!==void 0){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof e=="object"&&e!==null&&(e instanceof Array?e:[e]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!Dr(o))&&console.error(n)}catch{console.error(n)}})}if(t.IconifyProviders!==void 0){const e=t.IconifyProviders;if(typeof e=="object"&&e!==null)for(let n in e){const o="IconifyProviders["+n+"] is invalid.";try{const r=e[n];if(typeof r!="object"||!r||r.resources===void 0)continue;$r(n,r)||console.error(o)}catch{console.error(o)}}}}function qo(t){const[e,n]=u.useState(!!t.ssr),[o,r]=u.useState({});function i(v){if(v){const b=t.icon;if(typeof b=="object")return{name:"",data:b};const M=bo(b);if(M)return{name:b,data:M}}return{name:""}}const[s,l]=u.useState(i(!!t.ssr));function a(){const v=o.callback;v&&(v(),r({}))}function c(v){if(JSON.stringify(s)!==JSON.stringify(v))return a(),l(v),!0}function f(){var v;const b=t.icon;if(typeof b=="object"){c({name:"",data:b});return}const M=bo(b);if(c({name:b,data:M}))if(M===void 0){const p=ui([b],f);r({callback:p})}else M&&((v=t.onLoad)===null||v===void 0||v.call(t,b))}u.useEffect(()=>(n(!0),a),[]),u.useEffect(()=>{e&&f()},[t.icon,e]);const{name:h,data:m}=s;return m?Si({...eo,...m},t,h):t.children?t.children:t.fallback?t.fallback:u.createElement("span",{})}const Zo=u.forwardRef((t,e)=>qo({...t,_ref:e}));u.forwardRef((t,e)=>qo({inline:!0,...t,_ref:e}));const Mi={"eos-icons:loading":{body:'<path fill="currentColor" d="M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z" opacity=".5"/><path fill="currentColor" d="M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z"><animateTransform attributeName="transform" dur="1s" from="0 12 12" repeatCount="indefinite" to="360 12 12" type="rotate"/></path>',width:24,height:24},"fa6-solid:icons":{body:'<path fill="currentColor" d="M500.3 7.3c7.4 6 11.7 15.1 11.7 24.7v144c0 26.5-28.7 48-64 48s-64-21.5-64-48s28.7-48 64-48V71l-96 19.2V208c0 26.5-28.7 48-64 48s-64-21.5-64-48s28.7-48 64-48V64c0-15.3 10.8-28.4 25.7-31.4l160-32c9.4-1.9 19.1.6 26.6 6.6zM74.7 304l11.8-17.8c5.9-8.9 15.9-14.2 26.6-14.2h61.7c10.7 0 20.7 5.3 26.6 14.2l11.9 17.8H240c26.5 0 48 21.5 48 48v112c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V352c0-26.5 21.5-48 48-48zM192 408a48 48 0 1 0-96 0a48 48 0 1 0 96 0m286.7-129.7L440.3 368H496c6.7 0 12.6 4.1 15 10.4s.6 13.3-4.4 17.7l-128 112c-5.6 4.9-13.9 5.3-19.9.9s-8.2-12.4-5.3-19.2l38.3-89.8H336c-6.7 0-12.6-4.1-15-10.4s-.6-13.3 4.4-17.7l128-112c5.6-4.9 13.9-5.3 19.9-.9s8.2 12.4 5.3 19.2zm-339-59.2c-6.5 6.5-17 6.5-23 0l-96.8-99.9c-28-29-26.5-76.9 5-103.9c27-23.5 68.4-19 93.4 6.5l10 10.5l9.5-10.5c25-25.5 65.9-30 93.9-6.5c31 27 32.5 74.9 4.5 103.9l-96.4 99.9z"/>',width:512,height:512},"gravity-ui:arrow-down-to-square":{body:'<path fill="currentColor" fill-rule="evenodd" d="M8.53 11.78a.75.75 0 0 1-1.06 0l-2.5-2.5a.75.75 0 0 1 1.06-1.06l1.22 1.22V1.75a.75.75 0 0 1 1.5 0v7.69l1.22-1.22a.75.75 0 1 1 1.06 1.06zM4.25 4a.75.75 0 1 1 0 1.5H4A1.5 1.5 0 0 0 2.5 7v5A1.5 1.5 0 0 0 4 13.5h8a1.5 1.5 0 0 0 1.5-1.5V7A1.5 1.5 0 0 0 12 5.5h-.25a.75.75 0 0 1 0-1.5H12a3 3 0 0 1 3 3v5a3 3 0 0 1-3 3H4a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:arrow-left":{body:'<path fill="currentColor" fill-rule="evenodd" d="M14.75 8a.75.75 0 0 1-.75.75H3.81l2.72 2.72a.75.75 0 1 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 1.06L3.81 7.25H14a.75.75 0 0 1 .75.75" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:arrow-rotate-left":{body:'<path fill="currentColor" fill-rule="evenodd" d="M8 1.5a6.5 6.5 0 1 1-6.445 7.348a.75.75 0 1 1 1.487-.194A5.001 5.001 0 1 0 4.43 4.5h1.32a.75.75 0 0 1 0 1.5h-3A.75.75 0 0 1 2 5.25v-3a.75.75 0 0 1 1.5 0v1.06A6.48 6.48 0 0 1 8 1.5" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:bars":{body:'<path fill="currentColor" fill-rule="evenodd" d="M1.25 3.25A.75.75 0 0 1 2 2.5h12A.75.75 0 0 1 14 4H2a.75.75 0 0 1-.75-.75m0 4.75A.75.75 0 0 1 2 7.25h12a.75.75 0 0 1 0 1.5H2A.75.75 0 0 1 1.25 8M2 12a.75.75 0 0 0 0 1.5h12a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:bold":{body:'<path fill="currentColor" fill-rule="evenodd" d="M4.25 2.25A.75.75 0 0 0 3.5 3v10c0 .414.336.75.75.75H9.5a3.25 3.25 0 0 0 1.477-6.146A3.25 3.25 0 0 0 8.5 2.25zm3.5 5a1.75 1.75 0 1 0 0-3.5h-2v3.5zm-2 1.5v3.5h3a1.75 1.75 0 1 0 0-3.5z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:copy":{body:'<path fill="currentColor" fill-rule="evenodd" d="M12 2.5H8A1.5 1.5 0 0 0 6.5 4v1H8a3 3 0 0 1 3 3v1.5h1A1.5 1.5 0 0 0 13.5 8V4A1.5 1.5 0 0 0 12 2.5M11 11h1a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H4a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3zM4 6.5h4A1.5 1.5 0 0 1 9.5 8v4A1.5 1.5 0 0 1 8 13.5H4A1.5 1.5 0 0 1 2.5 12V8A1.5 1.5 0 0 1 4 6.5" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:italic":{body:'<path fill="currentColor" fill-rule="evenodd" d="M7.25 2a.75.75 0 0 0 0 1.5h1.317l-2.7 9H4.25a.75.75 0 1 0 0 1.5h4.5a.75.75 0 0 0 0-1.5H7.433l2.7-9h1.617a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:layers":{body:'<path fill="currentColor" fill-rule="evenodd" d="m2.789 5.283l4.037-2.02A2.5 2.5 0 0 1 7.944 3h.112c.388 0 .77.09 1.118.264l4.037 2.019a.522.522 0 0 1 0 .934l-4.037 2.02a2.5 2.5 0 0 1-1.118.263h-.112a2.5 2.5 0 0 1-1.118-.264L2.79 6.217a.523.523 0 0 1 0-.934M1 5.75c0-.766.433-1.466 1.118-1.809l4.037-2.019a4 4 0 0 1 1.79-.422h.11a4 4 0 0 1 1.79.422l4.037 2.019a2.023 2.023 0 0 1 0 3.618l-.882.44l.882.442a2.023 2.023 0 0 1 0 3.618l-4.037 2.019a4 4 0 0 1-1.79.422h-.11a4 4 0 0 1-1.79-.422l-4.037-2.02a2.023 2.023 0 0 1 0-3.617L3 8l-.882-.441A2.02 2.02 0 0 1 1 5.75m3.677 3.088l-1.888.945a.523.523 0 0 0 0 .934l4.037 2.019A2.5 2.5 0 0 0 7.944 13h.112a2.5 2.5 0 0 0 1.118-.264l4.037-2.019a.523.523 0 0 0 0-.934l-1.888-.945l-1.478.74a4 4 0 0 1-1.79.422h-.11a4 4 0 0 1-1.79-.422z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:magnifier":{body:'<path fill="currentColor" fill-rule="evenodd" d="M11.5 7a4.5 4.5 0 1 1-9 0a4.5 4.5 0 0 1 9 0m-.82 4.74a6 6 0 1 1 1.06-1.06l2.79 2.79a.75.75 0 1 1-1.06 1.06z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:pencil":{body:'<path fill="currentColor" fill-rule="evenodd" d="M11.423 1A3.577 3.577 0 0 1 15 4.577c0 .27-.108.53-.3.722l-.528.529l-1.971 1.971l-5.059 5.059a3 3 0 0 1-1.533.82l-2.638.528a1 1 0 0 1-1.177-1.177l.528-2.638a3 3 0 0 1 .82-1.533l5.059-5.059l2.5-2.5c.191-.191.451-.299.722-.299m-2.31 4.009l-4.91 4.91a1.5 1.5 0 0 0-.41.766l-.38 1.903l1.902-.38a1.5 1.5 0 0 0 .767-.41l4.91-4.91a2.08 2.08 0 0 0-1.88-1.88m3.098.658a3.6 3.6 0 0 0-1.878-1.879l1.28-1.28c.995.09 1.788.884 1.878 1.88z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:picture":{body:'<path fill="currentColor" fill-rule="evenodd" d="M11.5 3h-7A1.5 1.5 0 0 0 3 4.5v5.027l.962-.7a1.75 1.75 0 0 1 2.079.016l.928.696l2.368-2.03a1.75 1.75 0 0 1 2.325.043L13 8.787V4.5A1.5 1.5 0 0 0 11.5 3m3 7.498V4.5a3 3 0 0 0-3-3h-7a3 3 0 0 0-3 3v7a3 3 0 0 0 3 3h7a3 3 0 0 0 3-3zm-1.5.33l-2.355-2.174a.25.25 0 0 0-.332-.006L7.488 11.07l-.457.392l-.481-.361l-1.41-1.057a.25.25 0 0 0-.296-.002L3 11.381v.119A1.5 1.5 0 0 0 4.5 13h7a1.5 1.5 0 0 0 1.5-1.5zM7.5 6a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:scissors":{body:'<path fill="currentColor" fill-rule="evenodd" d="M4.5 6a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m-3-1.5a3 3 0 0 0 4.524 2.585L6.939 8l-.915.915a3 3 0 1 0 1.06 1.06L8.122 8.94l5.501 3.209a.75.75 0 1 0 .756-1.296L9.488 8l4.89-2.852a.75.75 0 0 0-.756-1.296l-5.5 3.209l-1.037-1.037A3 3 0 1 0 1.5 4.5m3 5.5a1.5 1.5 0 1 1 0 3a1.5 1.5 0 0 1 0-3" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:sparkles":{body:'<path fill="currentColor" d="M13 10a.75.75 0 0 1 .725.556a2.37 2.37 0 0 0 1.72 1.72a.75.75 0 0 1 0 1.449a2.37 2.37 0 0 0-1.72 1.72a.75.75 0 0 1-1.45 0a2.37 2.37 0 0 0-1.72-1.72a.75.75 0 0 1 0-1.45a2.37 2.37 0 0 0 1.72-1.72l.043-.117A.75.75 0 0 1 13 10M7 0a1.5 1.5 0 0 1 1.48 1.253c.242 1.455.696 2.364 1.3 2.968c.603.603 1.512 1.057 2.967 1.3a1.5 1.5 0 0 1 0 2.958c-1.455.243-2.364.697-2.968 1.3c-.603.604-1.057 1.513-1.3 2.968a1.5 1.5 0 0 1-2.958 0c-.243-1.455-.697-2.364-1.3-2.968c-.604-.603-1.513-1.057-2.968-1.3a1.5 1.5 0 0 1 0-2.958c1.455-.243 2.364-.697 2.968-1.3c.603-.604 1.057-1.513 1.3-2.968l.028-.133A1.5 1.5 0 0 1 7 0m0 1.5C6.45 4.8 4.8 6.45 1.5 7c3.3.55 4.95 2.2 5.5 5.5c.55-3.3 2.2-4.95 5.5-5.5C9.2 6.45 7.55 4.8 7 1.5"/>',width:24,height:24},"gravity-ui:text":{body:'<path fill="currentColor" fill-rule="evenodd" d="M3.279 2.544A.75.75 0 0 1 4 2h8a.75.75 0 0 1 .721.544l.5 1.75a.75.75 0 1 1-1.442.412L11.434 3.5H8.75l-.004 9H9.5a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1 0-1.5h.746l.004-9H4.566L4.22 4.706a.75.75 0 1 1-1.442-.412z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:text-align-center":{body:'<path fill="currentColor" fill-rule="evenodd" d="M2.75 2a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zm0 7a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zm2 3.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5zM4 6.25a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 6.25" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:text-align-justify":{body:'<path fill="currentColor" fill-rule="evenodd" d="M2.75 2a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zM2 6.25a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 6.25M2.75 9a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zm0 3.5a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:text-align-left":{body:'<path fill="currentColor" fill-rule="evenodd" d="M2.75 2a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zm0 7a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zm0 3.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5zM2 6.25a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 2 6.25" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:text-align-right":{body:'<path fill="currentColor" fill-rule="evenodd" d="M2.75 2a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zM6 6.25a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 6 6.25M2.75 9a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5zm4 3.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>',width:24,height:24},"gravity-ui:underline":{body:'<path fill="currentColor" fill-rule="evenodd" d="M5 2.75a.75.75 0 0 0-1.5 0V7a4.5 4.5 0 0 0 9 0V2.75a.75.75 0 0 0-1.5 0V7a3 3 0 0 1-6 0zm-.75 9.75a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>',width:24,height:24},"healthicons:polygon":{body:'<path fill="currentColor" fill-rule="evenodd" d="M28 10c0 .507-.094.992-.266 1.438l7.696 5.497a4 4 0 1 1 2.706 7.063l-2.32 10.437A4 4 0 1 1 30.126 39H17.874A4.002 4.002 0 0 1 10 38a4 4 0 0 1 2.184-3.565l-2.32-10.437a4 4 0 1 1 2.706-7.063l7.696-5.497A4 4 0 1 1 28 10m-6.57 3.065l-7.696 5.497a4 4 0 0 1-1.917 5.003l2.319 10.437A4 4 0 0 1 17.874 37h12.252a4 4 0 0 1 3.738-2.998l2.32-10.437a4 4 0 0 1-1.918-5.003l-7.695-5.497A3.98 3.98 0 0 1 24 14a3.98 3.98 0 0 1-2.57-.935" clip-rule="evenodd"/>',width:48,height:48},"heroicons:swatch":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4.098 19.902a3.75 3.75 0 0 0 5.304 0l6.401-6.402M6.75 21A3.75 3.75 0 0 1 3 17.25V4.125C3 3.504 3.504 3 4.125 3h5.25c.621 0 1.125.504 1.125 1.125v4.072M6.75 21a3.75 3.75 0 0 0 3.75-3.75V8.197M6.75 21h13.125c.621 0 1.125-.504 1.125-1.125v-5.25c0-.621-.504-1.125-1.125-1.125h-4.072M10.5 8.197l2.88-2.88a1.124 1.124 0 0 1 1.59 0l3.712 3.713c.44.44.44 1.152 0 1.59l-2.879 2.88M6.75 17.25h.008v.008H6.75z"/>',width:24,height:24},"hugeicons:layer-bring-forward":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m15.89 11.5l3.397 1.56C21.096 13.892 22 14.308 22 15s-.904 1.109-2.713 1.94l-4.893 2.247c-1.18.542-1.77.813-2.394.813s-1.214-.271-2.394-.813l-4.893-2.248C2.904 16.11 2 15.693 2 15s.904-1.109 2.713-1.94L8.11 11.5m3.89-7V15m3-8c-.59-.607-2.16-3-3-3S9.59 6.393 9 7"/>',width:24,height:24},"hugeicons:layer-send-backward":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m15.89 12.5l3.397-1.56C21.096 10.108 22 9.692 22 9s-.904-1.109-2.713-1.94l-4.893-2.247C13.214 4.271 12.624 4 12 4s-1.214.271-2.394.813L4.713 7.061C2.904 7.89 2 8.307 2 9s.904 1.109 2.713 1.94L8.11 12.5m3.89 7V9m3 8c-.59.607-2.16 3-3 3s-2.41-2.393-3-3"/>',width:24,height:24},"lucide:a-large-small":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 16l2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16m-6.303-2h5.606M2 16l4.039-9.69a.5.5 0 0 1 .923 0L11 16m-7.696-3h6.392"/>',width:24,height:24},"lucide:aperture":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="m14.31 8l5.74 9.94M9.69 8h11.48M7.38 12l5.74-9.94M9.69 16L3.95 6.06M14.31 16H2.83m13.79-4l-5.74 9.94"/></g>',width:24,height:24},"lucide:arrow-left":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m12 19l-7-7l7-7m7 7H5"/>',width:24,height:24},"lucide:arrow-up-from-dot":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="m5 9l7-7l7 7m-7 7V2"/><circle cx="12" cy="21" r="1"/></g>',width:24,height:24},"lucide:blend":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="9" cy="9" r="7"/><circle cx="15" cy="15" r="7"/></g>',width:24,height:24},"lucide:case-upper":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5M2 16l4.039-9.69a.5.5 0 0 1 .923 0L11 16m-7.696-3h6.392"/>',width:24,height:24},"lucide:circle":{body:'<circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>',width:24,height:24},"lucide:circle-dashed":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.1 2.182a10 10 0 0 1 3.8 0m0 19.636a10 10 0 0 1-3.8 0m7.509-18.097a10 10 0 0 1 2.69 2.7M2.182 13.9a10 10 0 0 1 0-3.8m18.097 7.509a10 10 0 0 1-2.7 2.69M21.818 10.1a10 10 0 0 1 0 3.8M3.721 6.391a10 10 0 0 1 2.7-2.69m-.03 16.578a10 10 0 0 1-2.69-2.7"/>',width:24,height:24},"lucide:cloud":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9"/>',width:24,height:24},"lucide:copy":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></g>',width:24,height:24},"lucide:credit-card":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="20" height="14" x="2" y="5" rx="2"/><path d="M2 10h20"/></g>',width:24,height:24},"lucide:crop":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M6 2v14a2 2 0 0 0 2 2h14"/><path d="M18 22V8a2 2 0 0 0-2-2H2"/></g>',width:24,height:24},"lucide:ellipsis-vertical":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></g>',width:24,height:24},"lucide:flag":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528"/>',width:24,height:24},"lucide:flip-horizontal-2":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m3 7l5 5l-5 5zm18 0l-5 5l5 5zm-9 13v2m0-8v2m0-8v2m0-8v2"/>',width:24,height:24},"lucide:flip-vertical-2":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m17 3l-5 5l-5-5zm0 18l-5-5l-5 5zM4 12H2m8 0H8m8 0h-2m8 0h-2"/>',width:24,height:24},"lucide:folder-open":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>',width:24,height:24},"lucide:folder-plus":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m-3-3h6m5 7a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',width:24,height:24},"lucide:grid-2x2":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M12 3v18m-9-9h18"/><rect width="18" height="18" x="3" y="3" rx="2"/></g>',width:24,height:24},"lucide:grid-3x3":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18M3 15h18M9 3v18m6-18v18"/></g>',width:24,height:24},"lucide:grip-vertical":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></g>',width:24,height:24},"lucide:hexagon":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16"/>',width:24,height:24},"lucide:image":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></g>',width:24,height:24},"lucide:italic":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 4h-9m4 16H5M15 4L9 20"/>',width:24,height:24},"lucide:layout-grid":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></g>',width:24,height:24},"lucide:lightbulb":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 14c.2-1 .7-1.7 1.5-2.5c1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5c.7.7 1.3 1.5 1.5 2.5m0 4h6m-5 4h4"/>',width:24,height:24},"lucide:loader-circle":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 1 1-6.219-8.56"/>',width:24,height:24},"lucide:minus":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14"/>',width:24,height:24},"lucide:moon":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/>',width:24,height:24},"lucide:move-vertical":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 2v20m-4-4l4 4l4-4M8 6l4-4l4 4"/>',width:24,height:24},"lucide:paint-bucket":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 7L6 2m12.992 10H2.041m19.104 6.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595M8.5 4.5l2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33"/>',width:24,height:24},"lucide:palette":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M12 22a1 1 0 0 1 0-20a10 9 0 0 1 10 9a5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"/><circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/></g>',width:24,height:24},"lucide:pen-line":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 21h8m.174-14.188a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>',width:24,height:24},"lucide:pen-tool":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"/><path d="m18 13l-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18M2.3 2.3l7.286 7.286"/><circle cx="11" cy="11" r="2"/></g>',width:24,height:24},"lucide:redo-2":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="m15 14l5-5l-5-5"/><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"/></g>',width:24,height:24},"lucide:rotate-ccw":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></g>',width:24,height:24},"lucide:rotate-cw":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></g>',width:24,height:24},"lucide:scissors":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12L12 12m8-8L8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8L20 20"/></g>',width:24,height:24},"lucide:settings":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/></g>',width:24,height:24},"lucide:shapes":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z"/><rect width="7" height="7" x="3" y="14" rx="1"/><circle cx="17.5" cy="17.5" r="3.5"/></g>',width:24,height:24},"lucide:sparkles":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594zM20 2v4m2-2h-4"/><circle cx="4" cy="20" r="2"/></g>',width:24,height:24},"lucide:square":{body:'<rect width="18" height="18" x="3" y="3" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" rx="2"/>',width:24,height:24},"lucide:square-round-corner":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 11a8 8 0 0 0-8-8m8 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>',width:24,height:24},"lucide:stamp":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-6 0c0 2 1 2 1 3.5V13m10 2.5a2.5 2.5 0 0 0-2.5-2.5h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1zM5 22h14"/>',width:24,height:24},"lucide:star":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.12 2.12 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16z"/>',width:24,height:24},"lucide:sun":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"/></g>',width:24,height:24},"lucide:text-cursor":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1M7 22h1a4 4 0 0 0 4-4M7 2h1a4 4 0 0 1 4 4"/>',width:24,height:24},"lucide:trash":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',width:24,height:24},"lucide:trending-up":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M16 7h6v6"/><path d="m22 7l-8.5 8.5l-5-5L2 17"/></g>',width:24,height:24},"lucide:triangle":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/>',width:24,height:24},"lucide:type":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"/>',width:24,height:24},"lucide:undo-2":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M9 14L4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/></g>',width:24,height:24},"lucide:venetian-mask":{body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M18 11c-1.5 0-2.5.5-3 2"/><path d="M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5a8 8 0 0 1 5 2a8 8 0 0 1 5-2a5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2a8 8 0 0 0-5-2z"/><path d="M6 11c1.5 0 2.5.5 3 2"/></g>',width:24,height:24},"lucide:waves":{body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2c2.5 0 2.5-2 5-2c1.3 0 1.9.5 2.5 1M2 12c.6.5 1.2 1 2.5 1c2.5 0 2.5-2 5-2c2.6 0 2.4 2 5 2c2.5 0 2.5-2 5-2c1.3 0 1.9.5 2.5 1M2 18c.6.5 1.2 1 2.5 1c2.5 0 2.5-2 5-2c2.6 0 2.4 2 5 2c2.5 0 2.5-2 5-2c1.3 0 1.9.5 2.5 1"/>',width:24,height:24},"material-symbols:award-star-outline":{body:'<path fill="currentColor" d="M9.075 16.25L12 14.475l2.925 1.775l-.775-3.325l2.6-2.25l-3.425-.275L12 7.25l-1.325 3.15l-3.425.275l2.6 2.25zM12 23.3L8.65 20H4v-4.65L.7 12L4 8.65V4h4.65L12 .7L15.35 4H20v4.65L23.3 12L20 15.35V20h-4.65zm0-2.8l2.5-2.5H18v-3.5l2.5-2.5L18 9.5V6h-3.5L12 3.5L9.5 6H6v3.5L3.5 12L6 14.5V18h3.5zm0-8.5"/>',width:24,height:24},"mdi:cube-outline":{body:'<path fill="currentColor" d="M21 16.5c0 .38-.21.71-.53.88l-7.9 4.44c-.16.12-.36.18-.57.18s-.41-.06-.57-.18l-7.9-4.44A.99.99 0 0 1 3 16.5v-9c0-.38.21-.71.53-.88l7.9-4.44c.16-.12.36-.18.57-.18s.41.06.57.18l7.9 4.44c.32.17.53.5.53.88zM12 4.15L6.04 7.5L12 10.85l5.96-3.35zM5 15.91l6 3.38v-6.71L5 9.21zm14 0v-6.7l-6 3.37v6.71z"/>',width:24,height:24},"mdi:format-color-fill":{body:'<path fill="currentColor" d="M19 11.5s-2 2.17-2 3.5a2 2 0 0 0 2 2a2 2 0 0 0 2-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21L14.79 10m1.77-1.06L7.62 0L6.21 1.41l2.38 2.38l-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12"/>',width:24,height:24},"mdi:image-remove":{body:'<path fill="currentColor" d="M13.3 21H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2v8.3c-.6-.2-1.3-.3-2-.3c-1.1 0-2.2.3-3.1.9L14.5 12L11 16.5l-2.5-3L5 18h8.1c-.1.3-.1.7-.1 1c0 .7.1 1.4.3 2m7.1-2l2.1 2.1l-1.4 1.4l-2.1-2.1l-2.1 2.1l-1.4-1.4l2.1-2.1l-2.1-2.1l1.4-1.4l2.1 2.1l2.1-2.1l1.4 1.4z"/>',width:24,height:24},"ph:monitor-fill":{body:'<path fill="currentColor" d="M232 64v112a24 24 0 0 1-24 24H48a24 24 0 0 1-24-24V64a24 24 0 0 1 24-24h160a24 24 0 0 1 24 24m-72 152H96a8 8 0 0 0 0 16h64a8 8 0 0 0 0-16"/>',width:256,height:256},"radix-icons:font-size":{body:'<path fill="currentColor" d="M2.5 2.1a.4.4 0 0 1 .283.117l2 2l.05.064a.4.4 0 0 1-.05.503a.4.4 0 0 1-.503.05l-.063-.05L2.9 3.467v8.067l1.317-1.317a.4.4 0 0 1 .566.566l-2 2a.4.4 0 0 1-.566 0l-2-2l-.051-.063a.4.4 0 0 1 .554-.554l.063.051l1.316 1.316V3.467L.783 4.784a.401.401 0 0 1-.566-.567l2-2l.061-.05A.4.4 0 0 1 2.5 2.1m5.47 9.64a.501.501 0 0 1-.94-.34zm2.53-8.99a.5.5 0 0 1 .47.33l3 8.32a.5.5 0 0 1-.94.34l-.983-2.724H8.953l-.982 2.724l-.471-.17l-.47-.17l3-8.32l.031-.07a.5.5 0 0 1 .439-.26M9.259 8.166h2.482L10.5 4.725z"/>',width:15,height:15}};function Ri(){for(const[t,e]of Object.entries(Mi))Vo(t,e)}let To=!1;function Ti(){To||(Ri(),To=!0)}const Qo={elements:["text","image","shape","path","group"],transforms:["custom","circle","lean","arch","ascend","wave","flag","image","group","shape","path"],effects:["stroke","mask","distress","knockout"],panels:["layers","effects","export","images","artboards"],tools:["select","pen","crop","zoom"],features:{export:!0,multiArtboard:!0,richText:!0,undo:!0,keyboardShortcuts:!0}},io={elements:["text","image"],transforms:["custom","circle","arch","wave","image"],effects:["stroke"],panels:[],tools:["select","zoom"],features:{export:!0,multiArtboard:!1,richText:!1,undo:!0,keyboardShortcuts:!0}},Jo={name:"compact-customizer",layout:{slots:{topbar:["contextual-toolbar"],canvas:["canvas"]}},capabilities:{...io,effects:["stroke"],panels:[],tools:["select","zoom"]},behavior:{toolbar:"contextual",selection:"single",panelMode:"drawer",onEmptyClick:"deselect",autoExport:!1},style:{density:"compact",toolbarVariant:"pill",panelVariant:"floating"},content:{sampleText:"Your Text",defaultFontFamily:"Poppins"}},tr={name:"pro-studio",layout:{slots:{topbar:["add-element-menu","undo-redo-controls","contextual-toolbar"],left:["layers-panel"],canvas:["canvas"],right:["effects-panel"]}},capabilities:Qo,behavior:{toolbar:"contextual",selection:"multi",panelMode:"sidebar",onEmptyClick:"deselect",autoExport:!1},style:{density:"comfortable",toolbarVariant:"flat",panelVariant:"card"},content:{sampleText:"New Text",defaultFontFamily:"Poppins"}},er={name:"embed-only",layout:{slots:{canvas:["canvas"]}},capabilities:{...io,panels:[],tools:["select"],features:{export:!0,multiArtboard:!1,richText:!1,undo:!0,keyboardShortcuts:!1}},behavior:{toolbar:"none",selection:"single",panelMode:"inline",onEmptyClick:"noop",autoExport:!0},style:{density:"compact",toolbarVariant:"minimal",panelVariant:"flush"}},to=new Map([["compact-customizer",Jo],["pro-studio",tr],["embed-only",er]]);function nr(t){if(typeof t=="string"){const e=to.get(t);if(!e){const n=Array.from(to.keys()).join(", ");throw new Error(`[resolveKit] Unknown kit preset "${t}". Valid presets: ${n}`)}return e}return t}const or=u.createContext(null);function Ii({kit:t,children:e}){const[n,o]=u.useState(t);u.useEffect(()=>{o(t)},[t]);const r=u.useCallback(s=>{const l=typeof s=="string"?nr(s):s;o(l)},[]),i=u.useMemo(()=>({kit:n,setKit:r}),[n,r]);return $t.jsx(or.Provider,{value:i,children:e})}function rr(){const t=u.useContext(or);if(!t)throw new Error("useKit must be used within a KitProvider");return t}function Ai(){const{kit:t}=rr();return t.capabilities}const Pi=y.createLogger("ElementPreviewRenderer"),Di={width:40,height:40,padding:4,backgroundColor:"transparent"};function ir(t,e={}){const n={...Di,...e},o=document.createElement("canvas");o.width=n.width,o.height=n.height;const r=o.getContext("2d");if(!r)return"";n.backgroundColor!=="transparent"&&(r.fillStyle=n.backgroundColor,r.fillRect(0,0,n.width,n.height)),r.save();try{t instanceof y.GroupElement?Bi(r,t,n):Li(r,t,n)}catch(i){Pi.warn("Failed to generate preview:",i)}return r.restore(),o.toDataURL("image/png")}function Li(t,e,n){var v;const o=((v=e.getBoundingBox)==null?void 0:v.call(e))||{x:0,y:0,width:100,height:100},r=o.width,i=o.height;if(r===0||i===0){Io(t,e,n);return}const s=n.width-n.padding*2,l=n.height-n.padding*2,a=Math.min(s/r,l/i,1),c=r*a,f=i*a,h=n.padding+(s-c)/2,m=n.padding+(l-f)/2;t.save(),t.translate(h-o.x*a,m-o.y*a),t.scale(a,a),typeof e.render=="function"?e.render(t,!1,!1):Io(t,e,n),t.restore()}function Io(t,e,n){t.fillStyle="#888888",t.font="10px Arial",t.textAlign="center",t.textBaseline="middle";const o=e.transformType||"Element";t.fillText(o,n.width/2,n.height/2)}function Bi(t,e,n){const o=n.width-n.padding*2,r=n.height-n.padding*2,i=n.padding,s=n.padding;t.fillStyle="#888888",t.strokeStyle="#666666",t.lineWidth=1;const l=r*.7,a=s+r*.3,c=o*.4,f=r*.2;t.fillRect(i,a,o,l),t.fillRect(i,a-f,c,f),e.children&&e.children.length>0&&(t.fillStyle="#FFFFFF",t.font="bold 10px Arial",t.textAlign="center",t.textBaseline="middle",t.fillText(e.children.length.toString(),i+o/2,a+l/2))}const fe=y.createLogger("Layers");async function Ao(t,e=64,n="transparent"){try{return ir(t,{width:e,height:e,padding:8,backgroundColor:n})||null}catch(o){return fe.error("Failed to generate preview:",o),null}}function sr(t,e,n,o,r,i=0,s=null){return(i>0?t:t.filter(a=>{const c=a.parentId??null;return a instanceof y.GroupElement,c===null})).map(a=>{const c=a instanceof y.GroupElement,f=e===a.id||n.includes(a.id),h={id:a.id,name:a.name||`Layer ${a.id.slice(0,8)}`,type:a.transformType,visible:a.visible??!0,locked:a.locked??!1,isSelected:f,isGroup:c,depth:i,parentId:s,previewUrl:o.get(a.id)||null,refreshPreview:async()=>{await r(a.id)}};return c&&a instanceof y.GroupElement&&(h.children=sr(a.children,e,n,o,r,i+1,a.id)),h})}function ar(t){const e=[];for(const n of t)e.push(n),n.children&&e.push(...ar(n.children));return e}function lr(t={}){const{artboardId:e,includeHidden:n=!0,previewSize:o=64,previewBackgroundColor:r="transparent"}=t,{elements:i,selectedId:s,multiSelection:l,artboardManager:a,handleSelectionChange:c,handleElementUpdate:f,setMultiSelection:h,executeAddElement:m,executeRemoveElement:v,executeReorderElement:b}=Ge.useEditor(),M=u.useRef(new Map),[p,x]=u.useState(0),w=a.getActiveArtboardId(),E=e!==void 0?e:w,C=u.useCallback(async H=>{const Y=i.find(ot=>ot.id===H);if(!Y)return;const nt=await Ao(Y,o,r);M.current.set(H,nt),x(ot=>ot+1)},[i,o,r]),N=u.useMemo(()=>{let H=i;if(E){const Y=a.getElementsOnArtboard(E);H=H.filter(nt=>Y.includes(nt.id))}return n||(H=H.filter(Y=>Y.visible!==!1)),H},[i,E,n,a]),$=u.useMemo(()=>sr(N,s,l,M.current,C),[N,s,l,C,p]),T=u.useMemo(()=>ar($),[$]),L=u.useMemo(()=>T.filter(H=>H.isSelected),[T]),R=u.useCallback((H,Y=!1)=>{Y?l.includes(H)?h(l.filter(nt=>nt!==H)):h([...l,H]):c(H)},[l,h,c]),I=u.useCallback(H=>{h(H)},[h]),st=u.useCallback(()=>{c(null),h([])},[c,h]),A=u.useCallback(H=>{const Y=i.find(ot=>ot.id===H);if(!Y)return;const nt=Y.clone();nt.visible=!(Y.visible??!0),f(nt)},[i,f]),U=u.useCallback(H=>{const Y=i.find(ot=>ot.id===H);if(!Y)return;const nt=Y.clone();nt.locked=!(Y.locked??!1),f(nt)},[i,f]),g=u.useCallback((H,Y)=>{const nt=i.find(it=>it.id===H);if(!nt)return;const ot=nt.clone();ot.name=Y,f(ot)},[i,f]),tt=u.useCallback(H=>{const Y=i.find(nt=>nt.id===H);if(!Y){fe.warn(`Element ${H} not found for deletion`);return}v(Y),(s===H||l.includes(H))&&(c(null),h(l.filter(nt=>nt!==H)))},[i,v,s,l,c,h]),Et=u.useCallback(H=>{const Y=i.find(d=>d.id===H);if(!Y){fe.warn(`Element ${H} not found for duplication`);return}const ot=Y.clone().toJSON();delete ot.id;const it=Y.constructor,yt=new it(ot);yt.x=Y.x+20,yt.y=Y.y+20;const G=a.getArtboardIdForElement(H);if(!G){fe.warn(`Element ${H} not associated with any artboard`);return}m(yt,G,H),c(yt.id)},[i,a,m,c]),vt=u.useCallback((H,Y)=>{if(H===Y)return;if(H<0||H>=N.length){fe.warn(`Invalid fromIndex: ${H}`);return}if(Y<0||Y>=N.length){fe.warn(`Invalid toIndex: ${Y}`);return}const nt=N[H],ot=N[Y],it=H<Y?"after":"before";b(nt.id,ot.id,it)},[N,b]),kt=u.useCallback(H=>{const Y=T.findIndex(nt=>nt.id===H);if(Y<0){fe.warn(`Layer ${H} not found`);return}Y>=T.length-1||vt(Y,Y+1)},[T,vt]),X=u.useCallback(H=>{const Y=T.findIndex(nt=>nt.id===H);if(Y<0){fe.warn(`Layer ${H} not found`);return}Y<=0||vt(Y,Y-1)},[T,vt]),xt=u.useCallback(H=>{if(H.length<2){fe.warn("Need at least 2 elements to create a group");return}const Y=i.filter(z=>H.includes(z.id)&&z.transformType!=="shape");if(Y.length<2){fe.warn("Need at least 2 groupable elements (shapes cannot be grouped)");return}const nt=Y.map(z=>a.getArtboardIdForElement(z.id)),ot=[...new Set(nt)];if(ot.length!==1||!ot[0]){fe.warn("All elements must be on the same artboard to group");return}const it=ot[0],yt=Y.map(z=>z.getBoundingBox()).filter(Boolean);if(yt.length===0){fe.warn("Could not calculate bounding boxes for group");return}const G=Math.min(...yt.map(z=>z.x)),d=Math.min(...yt.map(z=>z.y)),O=new y.GroupElement({x:G,y:d});O.children=Y.map(z=>{const ut=z.clone();return ut.x=z.x-G,ut.y=z.y-d,ut}),Y.forEach(z=>v(z)),m(O,it),c(O.id),h([])},[i,a,v,m,c,h]),Mt=u.useCallback(H=>{const Y=i.find(yt=>yt.id===H);if(!Y){fe.warn(`Element ${H} not found for ungrouping`);return}if(!(Y instanceof y.GroupElement)){fe.warn(`Element ${H} is not a group`);return}const nt=Y;if(!nt.children||nt.children.length===0){fe.warn(`Group ${H} has no children`);return}const ot=a.getArtboardIdForElement(H);if(!ot){fe.warn(`Group ${H} not associated with any artboard`);return}const it=nt.children.map(yt=>{const G=yt.clone();return G.x=yt.x+nt.x,G.y=yt.y+nt.y,G});v(nt),it.forEach(yt=>m(yt,ot)),it.length>0&&c(it[0].id),h([])},[i,a,v,m,c,h]),mt=u.useCallback(async(H=o)=>{const Y=async nt=>{for(const ot of nt){const it=await Ao(ot,H,r);M.current.set(ot.id,it),ot instanceof y.GroupElement&&ot.children.length>0&&await Y(ot.children)}};await Y(N),x(nt=>nt+1)},[o,r,N]),bt=u.useCallback(()=>{M.current.clear()},[]),Ot=u.useCallback((H,Y,nt)=>{b(H,Y,nt)},[b]),Pt=u.useCallback((H,Y,nt,ot)=>{const it=i.find(K=>K.id===ot);if(!it||!(it instanceof y.GroupElement)){fe.warn(`Group ${ot} not found for reorder`);return}const yt=it.clone(),G=yt.children.findIndex(K=>K.id===H),d=yt.children.findIndex(K=>K.id===Y);if(G===-1||d===-1){fe.warn(`Children not found in group for reorder: ${H}, ${Y}`);return}const[O]=yt.children.splice(G,1),z=yt.children.findIndex(K=>K.id===Y),ut=nt==="before"?z:z+1;yt.children.splice(ut,0,O),f(yt)},[i,f]),Lt=u.useCallback(H=>{for(const Y of i){if(Y.id===H)return Y;if(Y instanceof y.GroupElement){const nt=Y.children.find(ot=>ot.id===H);if(nt)return nt}}return null},[i]),Wt=u.useCallback(H=>{for(const Y of i)if(Y instanceof y.GroupElement&&Y.children.some(nt=>nt.id===H))return Y;return null},[i]),he=u.useCallback((H,Y)=>{const nt=i.find(d=>d.id===H),ot=i.find(d=>d.id===Y);if(!nt||!ot||!(ot instanceof y.GroupElement)){fe.warn(`Cannot add ${H} to group ${Y}`);return}if(!a.getArtboardIdForElement(H))return;const yt=ot.clone(),G=nt.clone();G.x=nt.x,G.y=nt.y,yt.addChild(G),v(nt),f(yt)},[i,a,v,f]),Gt=u.useCallback((H,Y,nt)=>{const ot=Wt(H);if(!ot){fe.warn(`Element ${H} is not inside a group`);return}const it=ot.children.find(O=>O.id===H);if(!it)return;const yt=a.getArtboardIdForElement(ot.id);if(!yt)return;const G=it.clone(),d=ot.clone();d.removeChild(H),f(d),Y&&nt?m(G,yt,nt==="after"?Y:void 0,nt==="before"?Y:void 0):m(G,yt,void 0,ot.id),c(G.id)},[Wt,a,v,f,m,c]),me=u.useCallback(()=>{const H=a.getActiveArtboardId();if(!H){fe.warn("No active artboard for creating a group");return}const Y=new y.GroupElement({x:0,y:0,name:"New Group"});m(Y,H),c(Y.id)},[a,m,c]);return{layers:$,flatLayers:T,selectedLayers:L,selectLayer:R,selectMultipleLayers:I,clearSelection:st,toggleVisibility:A,toggleLock:U,renameLayer:g,deleteLayer:tt,duplicateLayer:Et,reorderLayers:vt,reorderById:Ot,reorderWithinGroup:Pt,moveLayerForward:kt,moveLayerBackward:X,groupLayers:xt,ungroupLayer:Mt,addToGroup:he,removeFromGroup:Gt,createEmptyGroup:me,findElementById:Lt,findParentGroup:Wt,generateAllPreviews:mt,clearPreviewCache:bt,artboardId:E,artboardManager:a,layerCount:T.length}}function Hi(t,e){if(e instanceof y.ImageElement&&e.isCropping||t instanceof y.ImageElement&&t.isCropping)return!0;if(t instanceof y.GroupElement){for(const n of t.children)if(n instanceof y.ImageElement&&n.isCropping)return!0}return!1}function Oi(t){const e=(t==null?void 0:t.enabled)??!0,{selectedElement:n,activeChildElement:o,multiSelection:r,elements:i,handleElementUpdate:s,handleCopyElements:l,handlePasteElements:a,executeRemoveElement:c,handleSelectionChange:f,setMultiSelection:h,undoActiveArtboard:m,redoActiveArtboard:v,setHideHandles:b,handleAddElement:M,isToolbarMenuOpen:p}=Ge.useEditor(),{duplicateLayer:x}=lr();u.useEffect(()=>{if(!e)return;const w=C=>{var $;const N=C.target;if(!(N.tagName==="INPUT"||N.tagName==="TEXTAREA")&&!(($=N.closest)!=null&&$.call(N,'[role="listbox"], [role="menu"], [role="tablist"]'))){if((C.metaKey||C.ctrlKey)&&C.key==="z"&&!C.shiftKey){C.preventDefault(),m();return}if((C.metaKey||C.ctrlKey)&&C.shiftKey&&C.key==="z"||C.ctrlKey&&C.key==="y"){C.preventDefault(),v();return}if((C.metaKey||C.ctrlKey)&&C.key==="c"){C.preventDefault(),l();return}if((C.metaKey||C.ctrlKey)&&C.key==="v"){C.preventDefault(),a();return}if((C.metaKey||C.ctrlKey)&&C.key==="d"){C.preventDefault(),n?x(n.id):r.length>0&&r.forEach(T=>{x(T)});return}if(C.key==="Escape"){C.preventDefault(),(n||r.length>0)&&(f(null),h([]));return}if(C.key==="t"&&!C.metaKey&&!C.ctrlKey&&!C.shiftKey&&!C.altKey){C.preventDefault(),M("text");return}if(C.key==="Delete"||C.key==="Backspace"){if(p||Hi(n,o))return;if(C.preventDefault(),r.length>0){i.filter(L=>r.includes(L.id)).forEach(L=>{c(L)}),h([]),f(null);return}n&&(c(n),f(null));return}if(C.key==="ArrowUp"||C.key==="ArrowDown"||C.key==="ArrowLeft"||C.key==="ArrowRight"){if(r.length>0){C.preventDefault(),b(!0);const T=C.shiftKey?10:1;let L=0,R=0;C.key==="ArrowLeft"&&(L=-T),C.key==="ArrowRight"&&(L=T),C.key==="ArrowUp"&&(R=-T),C.key==="ArrowDown"&&(R=T),i.filter(st=>r.includes(st.id)).forEach(st=>{const A=st.clone();A.x+=L,A.y+=R,s(A)});return}if(n){C.preventDefault(),b(!0);const T=C.shiftKey?10:1;let L=0,R=0;C.key==="ArrowLeft"&&(L=-T),C.key==="ArrowRight"&&(L=T),C.key==="ArrowUp"&&(R=-T),C.key==="ArrowDown"&&(R=T);const I=n.clone();I.x+=L,I.y+=R,s(I);return}}}},E=C=>{(C.key==="ArrowUp"||C.key==="ArrowDown"||C.key==="ArrowLeft"||C.key==="ArrowRight")&&b(!1)};return window.addEventListener("keydown",w),window.addEventListener("keyup",E),()=>{window.removeEventListener("keydown",w),window.removeEventListener("keyup",E)}},[e,n,o,r,i,s,l,a,c,f,h,m,v,b,x,p])}const Xi=280,Yi=t=>1-Math.pow(1-t,3);function _i(t,e=Xi){const[n,o]=u.useState(t),r=u.useRef(n);r.current=n;const i=u.useRef(null),s=t?`${t.x},${t.y},${t.width},${t.height}`:"none";return u.useEffect(()=>{if(i.current!==null&&(cancelAnimationFrame(i.current),i.current=null),!t){o(null);return}const l=r.current;if(!l){o(t);return}if(l.x===t.x&&l.y===t.y&&l.width===t.width&&l.height===t.height)return;const a=performance.now(),c=f=>{const h=Math.min(1,(f-a)/e),m=Yi(h);o({x:l.x+(t.x-l.x)*m,y:l.y+(t.y-l.y)*m,width:l.width+(t.width-l.width)*m,height:l.height+(t.height-l.height)*m}),h<1?i.current=requestAnimationFrame(c):i.current=null};return i.current=requestAnimationFrame(c),()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)}},[s,e]),n}function cr(t,e){if(t.length===0)return{start:0,end:0};const n=Math.max(0,Math.min(e,t.length-1)),o=/[^\s]/;if(!o.test(t[n])){let s=n;for(;s<t.length&&!o.test(t[s]);)s++;if(s<t.length){let a=s;for(;a<t.length&&o.test(t[a]);)a++;return{start:s,end:a}}let l=n;for(;l>0&&!o.test(t[l-1]);)l--;if(l>0){let a=l;for(;a>0&&o.test(t[a-1]);)a--;return{start:a,end:l}}return{start:n,end:n}}let r=n;for(;r>0&&o.test(t[r-1]);)r--;let i=n;for(;i<t.length&&o.test(t[i]);)i++;return{start:r,end:i}}function Fi(t,e){const{fontSize:n,fontFamily:o,bold:r,italic:i,textAlign:s}=t,l=t.getRichText(),c=t.getVisualBoundingBox().width;let f=c,h=0;t.transformType==="custom"&&(h=y.HORIZONTAL_PADDING,f=c-h*2);const m=y.wrapText(t.getText(),f,n,o,r,i,void 0,!0);let v=0,b=0;for(let R=0;R<m.length;R++){const I=v+m[R].length;if(e<=I){b=R;break}v+=m[R].length+1,R===m.length-1&&(b=R)}const M=m[b],p=e-v;let x=M,w=0;const E=b===0,C=b===m.length-1;if(!E){const R=M.match(/^ +/);w=R?R[0].length:0,w>0&&(x=x.substring(w))}if(!C){const R=x.match(/ +$/),I=R?R[0].length:0;I>0&&(x=x.substring(0,x.length-I))}const N=y.measureTextWidth(x,n,o,r,i);let $=h;s==="center"?$=(c-N)/2:s==="right"&&($=c-h-N);let T=$;const L=Math.min(p,M.length);for(let R=0;R<L;R++){if(!E&&R<w)continue;const I=M[R],st=v+R,A=l.getStyleAt(st),U=A.fontSize||n,g=A.fontFamily||o,tt=A.bold!==void 0?A.bold:r,Et=A.italic!==void 0?A.italic:i;T+=y.measureTextWidth(I,U,g,tt,Et)}return{lineIndex:b,lineCount:m.length,xPositionInLine:T,lineStartIndex:v}}function zi(t,e,n){const{fontSize:o}=t,i=o*1.2,s=Fi(t,e),l=n==="up"?Math.max(0,s.lineIndex-1):Math.min(s.lineCount-1,s.lineIndex+1);if(l===s.lineIndex)return e;const a=l*i+i/2;return en(t,{x:s.xPositionInLine,y:a})}function en(t,e){const{fontSize:n,fontFamily:o,bold:r,italic:i,textAlign:s}=t,l=t.getRichText(),c=t.getVisualBoundingBox().width;let f=c,h=0;t.transformType==="custom"&&(h=y.HORIZONTAL_PADDING,f=c-h*2);const m=y.wrapText(t.getText(),f,n,o,r,i,void 0,!0),b=n*1.2;let M=0,p=0;if(e.y<0)return 0;for(let A=0;A<m.length;A++){if(e.y>=p&&e.y<p+b){M=A;break}p+=b,A===m.length-1&&(M=A)}let x=0;for(let A=0;A<M;A++)x+=m[A].length+1;const w=m[M];let E=w,C=0,N=0;const $=M===0,T=M===m.length-1;if(!$){const A=w.match(/^ +/);C=A?A[0].length:0,C>0&&(E=E.substring(C))}if(!T){const A=E.match(/ +$/);N=A?A[0].length:0,N>0&&(E=E.substring(0,E.length-N))}const L=y.measureTextWidth(E,n,o,r,i);let R=h;s==="center"?R=(c-L)/2:s==="right"&&(R=c-h-L);const I=e.x-R;if(I<=0)return x+C;if(I>=L)return x+w.length-N;let st=0;for(let A=0;A<w.length;A++){if(!$&&A<C||!T&&A>=w.length-N)continue;const U=w[A],g=x+A,tt=l.getStyleAt(g),Et=tt.fontSize||n,vt=tt.fontFamily||o,kt=tt.bold!==void 0?tt.bold:r,X=tt.italic!==void 0?tt.italic:i,xt=y.measureTextWidth(U,Et,vt,kt,X);if(I<st+xt/2)return g;st+=xt}return x+w.length}function ji(){const[t,e]=u.useState(!1),[n,o]=u.useState({x:0,y:0}),[r,i]=u.useState({x:0,y:0}),[s,l]=u.useState([]);return u.useEffect(()=>{},[t]),{isMarqueeSelecting:t,marqueeStart:n,marqueeEnd:r,marqueePreviewSelection:s,startMarqueeSelection:(h,m)=>{e(!0),o({x:h,y:m}),i({x:h,y:m}),l([])},updateMarqueeSelection:(h,m,v)=>{i({x:h,y:m});const b=Math.min(n.x,h),M=Math.max(n.x,h),p=Math.min(n.y,m),x=Math.max(n.y,m),w=[];v.forEach(E=>{if(E.visible===!1)return;const C=E.getVisualBoundingBox(),N=C.x,$=C.x+C.width,T=C.y,L=C.y+C.height;!($<b||N>M||L<p||T>x)&&w.push(E.id)}),l(w)},finishMarqueeSelection:h=>{const m=[...s];e(!1),m.length>0&&h(m),l([])}}}class Vi{constructor(){this.state={active:!1,pathElement:null,points:[],currentPoint:null,isDraggingHandle:!1,previewPoint:null,isClosing:!1,closingClickPos:null}}startPath(e){this.state.active=!0,this.state.pathElement=e,this.state.points=[],this.state.currentPoint=null,this.state.isDraggingHandle=!1,this.state.previewPoint=null,this.state.isClosing=!1,this.state.closingClickPos=null}editPath(e){this.state.active=!0,this.state.pathElement=e,this.state.points=e.transformData.points.map(n=>({...n})),this.state.currentPoint=null,this.state.isDraggingHandle=!1,this.state.previewPoint=null,this.state.isClosing=!1,this.state.closingClickPos=null}isActive(){return this.state.active}getState(){return{...this.state}}setPreviewPoint(e,n){this.state.previewPoint={x:e,y:n}}clearPreviewPoint(){this.state.previewPoint=null}addPoint(e,n){const o={id:`point-${Date.now()}-${Math.random()}`,x:e,y:n,type:"corner"};return this.state.points.push(o),this.state.currentPoint=o,this.state.isDraggingHandle=!1,o}startDraggingHandle(){this.state.currentPoint&&(this.state.isDraggingHandle=!0,this.state.currentPoint.type==="corner"&&(this.state.currentPoint.type="bezier"))}updateHandle(e,n){if(!(!this.state.currentPoint||!this.state.isDraggingHandle))if(this.state.isClosing&&this.state.closingClickPos){const o=e-this.state.closingClickPos.x,r=n-this.state.closingClickPos.y,i=this.state.points[0];i.handleIn={x:o,y:r},i.handleOut={x:-o,y:-r},i.type==="corner"&&(i.type="bezier")}else{const o=e-this.state.currentPoint.x,r=n-this.state.currentPoint.y;this.state.currentPoint.handleOut={x:o,y:r},this.state.currentPoint.type==="smooth"?this.state.currentPoint.handleIn={x:-o,y:-r}:this.state.currentPoint.type==="bezier"&&(this.state.currentPoint.handleIn={x:-o,y:-r})}}finishDraggingHandle(){this.state.isDraggingHandle=!1,this.state.isClosing?this.closePath():this.state.currentPoint=null}canClosePath(e,n,o=10){if(this.state.points.length<3)return!1;const r=this.state.points[0],i=e-r.x,s=n-r.y;return Math.sqrt(i*i+s*s)<=o}startClosing(e,n){this.state.points.length<3||(this.state.isClosing=!0,this.state.closingClickPos={x:e,y:n},this.state.currentPoint=this.state.points[0])}isClosingPath(){return this.state.isClosing}recenterPath(){if(!this.state.pathElement||this.state.points.length===0)return;let e=1/0,n=1/0,o=-1/0,r=-1/0;for(const l of this.state.points)e=Math.min(e,l.x),n=Math.min(n,l.y),o=Math.max(o,l.x),r=Math.max(r,l.y);const i=(e+o)/2,s=(n+r)/2;this.state.pathElement.x+=i,this.state.pathElement.y+=s;for(const l of this.state.points)l.x-=i,l.y-=s}closePath(){this.state.pathElement&&(this.recenterPath(),this.state.pathElement.transformData.points=[...this.state.points],this.state.pathElement.transformData.closed=!0,this.state.pathElement.transformData.fillEnabled=!0,this.state.pathElement.transformData.fillColor=y.getThemeShapeFillColor(),this.state.pathElement.updateBounds(),this.endPath())}finishPath(){this.state.pathElement&&(this.recenterPath(),this.state.pathElement.transformData.points=[...this.state.points],this.state.pathElement.transformData.closed=!1,this.state.pathElement.updateBounds(),this.endPath())}deleteLastPoint(){this.state.points.length!==0&&(this.state.points.pop(),this.state.currentPoint=null)}cancelPath(){const e=this.state.pathElement;return this.state.active=!1,this.state.pathElement=null,this.state.points=[],this.state.currentPoint=null,this.state.isDraggingHandle=!1,this.state.previewPoint=null,this.state.isClosing=!1,this.state.closingClickPos=null,e}endPath(){this.state.active=!1,this.state.pathElement=null,this.state.points=[],this.state.currentPoint=null,this.state.isDraggingHandle=!1,this.state.previewPoint=null,this.state.isClosing=!1,this.state.closingClickPos=null}getPoints(){return this.state.points}getCurrentPoint(){return this.state.currentPoint}isDraggingHandle(){return this.state.isDraggingHandle}renderPreview(e,n){var s,l,a,c,f,h,m,v;if(!this.state.active||this.state.points.length===0)return;const{points:o,previewPoint:r,currentPoint:i}=this.state;if(e.save(),e.translate(n.x,n.y),e.strokeStyle=y.getThemePenPathColor(),e.lineWidth=2,e.setLineDash([]),e.beginPath(),o.length>0){const b=o[0];e.moveTo(b.x,b.y);for(let p=1;p<o.length;p++){const x=o[p-1],w=o[p];if(x.handleOut||w.handleIn){const C=x.x+(((s=x.handleOut)==null?void 0:s.x)||0),N=x.y+(((l=x.handleOut)==null?void 0:l.y)||0),$=w.x+(((a=w.handleIn)==null?void 0:a.x)||0),T=w.y+(((c=w.handleIn)==null?void 0:c.y)||0);e.bezierCurveTo(C,N,$,T,w.x,w.y)}else e.lineTo(w.x,w.y)}const M=this.state.isClosing||n.transformData.closed;if(M&&o.length>2){const p=o[o.length-1],x=o[0];if(p.handleOut||x.handleIn){const E=p.x+(((f=p.handleOut)==null?void 0:f.x)||0),C=p.y+(((h=p.handleOut)==null?void 0:h.y)||0),N=x.x+(((m=x.handleIn)==null?void 0:m.x)||0),$=x.y+(((v=x.handleIn)==null?void 0:v.y)||0);e.bezierCurveTo(E,C,N,$,x.x,x.y)}else e.lineTo(x.x,x.y)}else r&&!this.state.isDraggingHandle&&e.lineTo(r.x,r.y);e.stroke(),M&&n.transformData.fillEnabled&&(e.fillStyle=n.transformData.fillColor||y.getThemeShapeFillColor(),e.globalAlpha=n.transformData.fillOpacity??1,e.fill(),e.globalAlpha=1)}e.setLineDash([]);for(let b=0;b<o.length;b++){const M=o[b];if(b===0&&o.length>1&&(e.strokeStyle=y.getThemeAccentColor(),e.lineWidth=2,e.beginPath(),e.arc(M.x,M.y,8,0,Math.PI*2),e.stroke()),e.fillStyle=y.getThemePenAnchorFillColor(),e.strokeStyle=y.getThemeAccentColor(),e.lineWidth=2,e.beginPath(),e.arc(M.x,M.y,4,0,Math.PI*2),e.fill(),e.stroke(),M.handleIn){const x=M.x+M.handleIn.x,w=M.y+M.handleIn.y;e.strokeStyle=y.getThemePenHandleColor(),e.lineWidth=1,e.beginPath(),e.moveTo(M.x,M.y),e.lineTo(x,w),e.stroke(),e.fillStyle=y.getThemePenHandleColor(),e.beginPath(),e.arc(x,w,3,0,Math.PI*2),e.fill()}if(M.handleOut){const x=M.x+M.handleOut.x,w=M.y+M.handleOut.y;e.strokeStyle=y.getThemePenHandleColor(),e.lineWidth=1,e.beginPath(),e.moveTo(M.x,M.y),e.lineTo(x,w),e.stroke(),e.fillStyle=y.getThemePenHandleColor(),e.beginPath(),e.arc(x,w,3,0,Math.PI*2),e.fill()}}if(r&&this.canClosePath(r.x,r.y)){const b=o[0];e.strokeStyle=y.getThemeAccentColor(),e.lineWidth=3,e.beginPath(),e.arc(b.x,b.y,6,0,Math.PI*2),e.stroke()}if(r&&!this.state.isDraggingHandle){const b=y.getThemeAccentColor(),M=b.replace("#",""),p=parseInt(M.substring(0,2),16),x=parseInt(M.substring(2,4),16),w=parseInt(M.substring(4,6),16);e.fillStyle=`rgba(${p}, ${x}, ${w}, 0.3)`,e.strokeStyle=b,e.lineWidth=2,e.beginPath(),e.arc(r.x,r.y,4,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}}const Wi=y.createLogger("usePenTool");function $i({selectedElement:t}){const[e]=u.useState(()=>new Vi),[n,o]=u.useState("crosshair");return u.useEffect(()=>{try{const r=Sr.renderToStaticMarkup($t.jsx(Zo,{icon:"lucide:pen-tool",width:24,height:24})).replace(/<svg[^>]*>|<\/svg>/g,""),i=`
|
|
2
|
-
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<!-- White background stroke (thicker) -->
|
|
4
|
-
<g stroke="white" stroke-width="4" fill="none" stroke-linejoin="round" stroke-linecap="round">
|
|
5
|
-
${r}
|
|
6
|
-
</g>
|
|
7
|
-
<!-- Black pen icon stroke on top (thinner) -->
|
|
8
|
-
<g stroke="#000000" stroke-width="2" fill="none" stroke-linejoin="round" stroke-linecap="round">
|
|
9
|
-
${r}
|
|
10
|
-
</g>
|
|
11
|
-
</svg>
|
|
12
|
-
`.trim(),l=`data:image/svg+xml,${encodeURIComponent(i)}`;o(`url('${l}') 0 0, crosshair`)}catch(r){Wi.error("Failed to create pen cursor:",r),o("crosshair")}},[]),u.useEffect(()=>{t instanceof y.PathElement&&t.transformData.points.length===0&&!e.isActive()&&e.startPath(t)},[t,e]),{penTool:e,penCursor:n}}function Gi({elements:t,selectedElement:e,transformHandles:n,onActiveChildChange:o}){const[r,i]=u.useState(null),s=u.useRef(null),l=u.useCallback(a=>{i(a),o==null||o(a)},[o]);return u.useEffect(()=>{if(r&&e instanceof y.GroupElement){const a=e.children.find(c=>c.id===r.id);a&&a!==r&&(a instanceof y.GroupElement||(i(a),o==null||o(a),n.update(a)))}},[t,r,e,n,o]),{activeChildElement:r,setActiveChildElement:i,updateActiveChild:l,editingChildIdRef:s}}function Ui({onHoverChange:t}){const[e,n]=u.useState({type:null,data:null,startTime:null}),o=u.useCallback(r=>{n(i=>{var l,a,c,f;const s=r.type!==i.type||r.type==="element"&&((l=r.data)==null?void 0:l.id)!==((a=i.data)==null?void 0:a.id)||r.type==="group-sibling"&&((c=r.data)==null?void 0:c.id)!==((f=i.data)==null?void 0:f.id);return{...r,startTime:s&&r.type!==null?performance.now():i.startTime}})},[]);return u.useEffect(()=>{if(!t)return;let r=null;if(e.type==="element"||e.type==="group-sibling"){const i=e.data;r=(i==null?void 0:i.id)??null}t(r)},[e,t]),{hoverState:e,setHoverState:o}}class so{constructor(e,n,o,r,i){this.x=e,this.y=n,this.rotation=o,this.flipH=r,this.flipV=i}worldToLocal(e,n){const o=e-this.x,r=n-this.y,i=y.RotationUtils.toRadiansInverse(this.rotation),s=Math.cos(i),l=Math.sin(i);let a=o*s+r*l,c=-o*l+r*s;return this.flipH&&(a=-a),this.flipV&&(c=-c),{x:a,y:c}}localToWorld(e,n){let o=this.flipH?-e:e,r=this.flipV?-n:n;const i=y.RotationUtils.toRadians(this.rotation),s=Math.cos(i),l=Math.sin(i),a=o*s-r*l,c=o*l+r*s;return{x:a+this.x,y:c+this.y}}transformVector(e,n,o=!1){let r=this.flipH?-e:e,i=this.flipV?-n:n;const s=o?y.RotationUtils.toRadiansInverse(this.rotation):y.RotationUtils.toRadians(this.rotation),l=Math.cos(s),a=Math.sin(s);return o?{dx:r*l+i*a,dy:-r*a+i*l}:{dx:r*l-i*a,dy:r*a+i*l}}static fromElement(e){return new so(e.x,e.y,e.rotation||0,e.flipH||!1,e.flipV||!1)}}class Ni{handleCropImageDrag(e,n,o,r){const i=o-n.startX,s=r-n.startY,l=n.startData.x,a=n.startData.y,c=n.startData.transformData,f=c.width,h=c.height,m=n.startData.cropX??0,v=n.startData.cropY??0,b=n.startData.cropWidth??1,M=n.startData.cropHeight??1,x=y.Transform.fromSnapshot(n.startData).worldDeltaToLocal(i,s);let w=x.dx,E=x.dy;const C=c.flipHorizontal?-1:1,N=c.flipVertical?-1:1;w*=C,E*=N;const $=-w/f,T=-E/h;let L=m+$,R=v+T;const I=1-b,st=1-M;return L=Math.max(0,Math.min(I,L)),R=Math.max(0,Math.min(st,R)),{cropX:L,cropY:R,cropWidth:b,cropHeight:M,x:l,y:a}}handleCropBoxResize(e,n,o,r,i,s){const l=o.startData.transformData,a=l.flipHorizontal,c=l.flipVertical,f=this._getCropResizeCursor(n,!!a,!!c),h=o.startData.rotation,m=o.startData.x,v=o.startData.y,b=y.Transform.fromSnapshot(o.startData),{cos:M,sin:p}=b.getInverseCosSin(),x=a?-1:1,w=c?-1:1,E=i-m,C=s-v;let N=E*M-C*p,$=E*p+C*M;N*=x,$*=w;const T=r.startX-m,L=r.startY-v;let R=T*M-L*p,I=T*p+L*M;R*=x,I*=w;const st=N-R,A=$-I,U=l.cropX,g=l.cropY,tt=l.cropWidth,Et=l.cropHeight,vt=l.width,kt=l.height,X=st/vt,xt=A/kt,Mt=this._calculateNewCropValues(n,U,g,tt,Et,X,xt),mt=this._calculateCropCenterOffset(U,g,tt,Et,Mt.cropX,Mt.cropY,Mt.cropWidth,Mt.cropHeight,vt,kt,h,x,w);return{...Mt,x:m+mt.worldOffsetX,y:v+mt.worldOffsetY,rotation:h,width:vt,height:kt,cursor:f}}_getCropResizeCursor(e,n,o){let r=e;return n&&(r.includes("left")?r=r.replace("left","right"):r.includes("right")&&(r=r.replace("right","left"))),o&&(r.includes("top")?r=r.replace("top","bottom"):r.includes("bottom")&&(r=r.replace("bottom","top"))),r==="top-left"||r==="bottom-right"?"nwse-resize":r==="top-right"||r==="bottom-left"?"nesw-resize":r==="top"||r==="bottom"?"ns-resize":r==="left"||r==="right"?"ew-resize":"default"}_calculateNewCropValues(e,n,o,r,i,s,l){const a=y.MIN_CROP_SIZE;let c=n,f=o,h=r,m=i;return e==="top-left"?(c=n+s,f=o+l,h=r-s,m=i-l):e==="top-right"?(f=o+l,h=r+s,m=i-l):e==="bottom-left"?(c=n+s,h=r-s,m=i+l):e==="bottom-right"?(h=r+s,m=i+l):e==="top"?(f=o+l,m=i-l):e==="bottom"?m=i+l:e==="left"?(c=n+s,h=r-s):e==="right"&&(h=r+s),this._constrainCropValues(e,c,f,h,m,n,o,r,i,a)}_constrainCropValues(e,n,o,r,i,s,l,a,c,f){let h=n,m=o,v=r,b=i;return v<f&&(v=f,e.includes("left")&&(h=s+a-f)),h+v>1&&(e.includes("left")?h=1-v:v=1-h),h<0&&(v=v+h,h=0),b<f&&(b=f,e.includes("top")&&(m=l+c-f)),m+b>1&&(e.includes("top")?m=1-b:b=1-m),m<0&&(b=b+m,m=0),{cropX:h,cropY:m,cropWidth:v,cropHeight:b}}_calculateCropCenterOffset(e,n,o,r,i,s,l,a,c,f,h,m,v){const b=e*c+o*c/2,M=n*f+r*f/2,p=i*c+l*c/2,x=s*f+a*f/2;let w=p-b,E=x-M;w*=m,E*=v;const N=new y.Transform({rotation:h,x:0,y:0}).localDeltaToWorld(w,E),$=N.dx,T=N.dy;return{worldOffsetX:$,worldOffsetY:T}}getCropBoxHandlePosition(e,n){const o=so.fromElement(e),r=e.transformData,i=r.width,s=r.height,l=r.cropX||0,a=r.cropY||0,c=r.cropWidth||1,f=r.cropHeight||1;let h=0,m=0;return n.includes("left")?h=(l-.5)*i:n.includes("right")?h=(l+c-.5)*i:h=(l+c/2-.5)*i,n.includes("top")?m=(a-.5)*s:n.includes("bottom")?m=(a+f-.5)*s:m=(a+f/2-.5)*s,o.localToWorld(h,m)}}function Ki(){const[t]=u.useState(()=>new Ni);return{cropController:t}}function qi(t){const e=u.useRef(null),n=u.useRef(null);return u.useEffect(()=>{n.current=null},[t]),{multiSelectionGroupBoundsRef:e,multiSelectionOBBRef:n}}function Po(t){return t!=null&&t instanceof y.TextElement}function Zi({selectedElement:t,ref:e}){const[n,o]=u.useState(!1),[r,i]=u.useState(""),[s,l]=u.useState({x:0,y:0,width:200,height:50}),[a,c]=u.useState(0),[f,h]=u.useState(0),[m,v]=u.useState(0),b=u.useRef(1),M=u.useRef(performance.now()),p=u.useRef(0),x=u.useRef(!1),[w,E]=u.useState(null),[C,N]=u.useState(null),$=u.useRef(null),T=u.useCallback(I=>{if(!n||!w)return;const st=Math.min(f,m),A=Math.max(f,m);if(st===A){const U=w.clone(),g=U.getText().length;U.applyStyle(0,g,I),$.current=U,E(U),i(U.getText()),N(tt=>({...tt,...I}))}else{const U=w.clone();U.applyStyle(st,A,I),$.current=U,E(U),i(U.getText()),N(g=>({...g,...I}))}},[n,w,f,m]),L=u.useCallback(()=>{if(!n||!w||!t)return null;const I=Math.min(f,m),st=Math.max(f,m);return I===st?I===0?Po(t)?t.getDefaultStyle():{}:w.getStyleAt(Math.max(0,I-1)):w.getStyleAt(I)},[n,w,f,m,t]),R=u.useCallback(I=>{if(!n||!w||!t)return;const st=L(),g=!{...Po(t)?t.getDefaultStyle():{},...st}[I];T({[I]:g})},[n,w,t,L,T]);return u.useImperativeHandle(e,()=>({applyTextFormatting:I=>{T(I)},toggleFormattingProperty:I=>{R(I)},isEditingText:()=>n,getSelectionStyle:()=>L()}),[T,R,n,L]),{isEditing:n,setIsEditing:o,editText:r,setEditText:i,editPosition:s,setEditPosition:l,cursorPosition:a,setCursorPosition:c,selectionStart:f,setSelectionStart:h,selectionEnd:m,setSelectionEnd:v,cursorOpacityRef:b,cursorStartTimeRef:M,selectionAnchorRef:p,didDragSelectRef:x,editRichText:w,setEditRichText:E,editRichTextRef:$,currentFormattingStyle:C,setCurrentFormattingStyle:N,applyFormattingToSelection:T,getSelectionStyle:L,toggleFormattingProperty:R}}function Qi({width:t,height:e,zoom:n,viewPadding:o,artboardBorderRadius:r,fixedMargin:i,fixedMarginX:s,fixedMarginY:l,artboards:a,artboardManager:c,focusedPieceRect:f}){const[h,m]=u.useState(!1);u.useEffect(()=>{const A="ontouchstart"in window||navigator.maxTouchPoints>0;m(A)},[]);const v=u.useRef(null);u.useEffect(()=>{const A=U=>{v.current=U.target,setTimeout(()=>{v.current=null},500)};return document.addEventListener("touchstart",A,{capture:!0,passive:!0}),document.addEventListener("pointerdown",A,{capture:!0,passive:!0}),()=>{document.removeEventListener("touchstart",A,{capture:!0}),document.removeEventListener("pointerdown",A,{capture:!0})}},[]);const[b,M]=u.useState({width:t??window.innerWidth,height:e??window.innerHeight});u.useEffect(()=>{if(f){M({width:f.width,height:f.height});return}if(t!==void 0&&e!==void 0){M({width:t,height:e});return}const A=c.getActiveArtboard();A&&M({width:A.width,height:A.height})},[t,e,a,c,f]),u.useEffect(()=>{const A=()=>{if(f){M({width:f.width,height:f.height});return}if(t===void 0&&e===void 0){const U=c.getActiveArtboard();M(U?{width:U.width,height:U.height}:{width:window.innerWidth,height:window.innerHeight})}};return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[t,e,c,f]);const p=Math.max(.1,Math.min(1,o)),x=s??i,w=l??i,E=x!==void 0&&n>0?x/n:0,C=w!==void 0&&n>0?w/n:0,N=x!==void 0?b.width+E*2:b.width/p,$=w!==void 0?b.height+C*2:b.height/p,T=x!==void 0?E:(N-b.width)/2,L=w!==void 0?C:($-b.height)/2,R=f?T-f.x:T,I=f?L-f.y:L,st=n>0?r/n:r;return{isTouchDevice:h,canvasSize:b,lastTouchTargetRef:v,effectiveViewPadding:p,paddedCanvasWidth:N,paddedCanvasHeight:$,paddingOffsetX:R,paddingOffsetY:I,zoomInvariantBorderRadius:st}}function Ji(){const[t,e]=u.useState([]),[n,o]=u.useState([]),[r,i]=u.useState(!1),[s,l]=u.useState(!1),[a,c]=u.useState(0),[f,h]=u.useState(0),[,m]=u.useState(0);return{snapGuides:t,setSnapGuides:e,spacingIndicators:n,setSpacingIndicators:o,isAltKeyPressed:r,setIsAltKeyPressed:i,isRotating:s,setIsRotating:l,setRotationStartAngle:c,currentRotation:f,setCurrentRotation:h,setRotatingElementVersion:m}}function ts({elements:t}){const[,e]=u.useState({}),[n,o]=u.useState(0),[r,i]=u.useState(0),[s,l]=u.useState(0),a=u.useCallback(()=>{i(c=>c+1)},[]);return u.useEffect(()=>y.subscribeToImageLoads(f=>{t.some(m=>m.id===f)&&i(m=>m+1)}),[t]),{renderVersion:r,forceRender:a,handlesVersion:n,setHandlesVersion:o,forceUpdate:e,cursorAnimationFrame:s,setCursorAnimationFrame:l}}const Sn={bleedMode:"gradient",bleedInnerEdge:"boundary",bleedFill:"#000000",bleedOpacity:1,dieCutMode:"blur-tint",dieCutTint:"#333",dieCutTintAlpha:.7,dieCutBlurPx:4,dieCutStroke:"",dieCutStrokeWidthPx:1,bleedBlurScale:.04,boundaryStroke:"",boundaryStrokeWidthPx:1,safeAreaStroke:"",safeAreaStrokeWidthPx:1.5,safeAreaDashPx:[6,4],zoneFill:{wrap:"rgba(148, 163, 184, 0.25)",binding:"rgba(234, 88, 12, 0.20)",dieCut:"rgba(0, 0, 0, 0.7)",warning:"rgba(245, 158, 11, 0.25)",custom:"rgba(100, 100, 100, 0.15)"},zoneStroke:{wrap:"#64748b",binding:"#ea580c",dieCut:"#ffffff",warning:"#f59e0b",custom:"#6b7280"},labelColor:"#111827",labelFontSizePx:14,labelFontFamily:"ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",labelHaloColor:"#ffffff"};let ln=null;function es(t){const e=t.width,n=t.height;if(e<=0||n<=0)return null;ln||(ln=document.createElement("canvas")),ln.width!==e&&(ln.width=e),ln.height!==n&&(ln.height=n);const o=ln.getContext("2d");return o?(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,e,n),o.drawImage(t,0,0),ln):null}function Un(t,e){const n=t.trim();if(!n.startsWith("var("))return n;const o=n.slice(4,-1),[r,...i]=o.split(","),s=r.trim(),l=i.length>0?i.join(",").trim():"",a=e??document.documentElement;return getComputedStyle(a).getPropertyValue(s).trim()||l||"#333"}function ns(t){if(typeof document>"u")return!1;const e=document.documentElement;return!!(e.classList.contains("dark")||e.getAttribute("data-theme")==="dark")}function Do(t){const e=dr(t);return e!==null&&e<.5}function Lo(t){const e=dr(t);return e!==null&&e>=.5}function dr(t){const e=t.trim();if(e.startsWith("#")){const o=e.slice(1);let r,i,s;if(o.length===3)r=parseInt(o[0]+o[0],16),i=parseInt(o[1]+o[1],16),s=parseInt(o[2]+o[2],16);else if(o.length===6)r=parseInt(o.slice(0,2),16),i=parseInt(o.slice(2,4),16),s=parseInt(o.slice(4,6),16);else return null;return Number.isNaN(r)||Number.isNaN(i)||Number.isNaN(s)?null:Bo(r,i,s)}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return n?Bo(Number(n[1]),Number(n[2]),Number(n[3])):null}function Bo(t,e,n){const o=r=>{const i=r/255;return i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)};return .2126*o(t)+.7152*o(e)+.0722*o(n)}function An(t,e){if(e.kind==="rect"){t.rect(e.x,e.y,e.width,e.height);return}if(e.kind==="roundedRect"){const o=e.rx??e.ry??0,r=e.ry??e.rx??0;if(o<=0&&r<=0){t.rect(e.x,e.y,e.width,e.height);return}o===r?t.roundRect(e.x,e.y,e.width,e.height,o):t.roundRect(e.x,e.y,e.width,e.height,[{x:o,y:r}]);return}const n=new Path2D(e.d);t.__pieceGuidePath2D=n}function In(t,e,n){if(e.kind==="path"){const o=new Path2D(e.d);t.fill(o);return}t.beginPath(),An(t,e),t.fill()}function Rn(t,e){if(e.kind==="path"){const n=new Path2D(e.d);t.stroke(n);return}t.beginPath(),An(t,e),t.stroke()}function os(t,e){e.kind!=="path"&&An(t,e)}function _n(t,e){if(e.kind==="rect"){t.rect(e.x,e.y,e.width,e.height);return}if(e.kind==="roundedRect"){const n=e.rx??e.ry??0,o=e.ry??e.rx??0;if(n<=0&&o<=0){t.rect(e.x,e.y,e.width,e.height);return}n===o?t.roundRect(e.x,e.y,e.width,e.height,n):t.roundRect(e.x,e.y,e.width,e.height,[{x:n,y:o}]);return}t.addPath(new Path2D(e.d))}function rs(t,e,n){return(t==null?void 0:t.boundary)??{kind:"rect",x:0,y:0,width:e,height:n}}function is(t,e,n,o){if(t!=null&&t.safeArea)return t.safeArea;if(e.safeAreaInsetPx&&e.safeAreaInsetPx>0){const r=e.safeAreaInsetPx;return{kind:"rect",x:r,y:r,width:Math.max(0,n-r*2),height:Math.max(0,o-r*2)}}return null}function ur(t){var x,w,E,C,N,$,T;const{ctx:e,pieces:n,pieceGuides:o,artboardOrigin:r,zoom:i}=t;if(!n.length)return;const s={bleed:((x=t.show)==null?void 0:x.bleed)??!0,zones:((w=t.show)==null?void 0:w.zones)??!0,boundary:((E=t.show)==null?void 0:E.boundary)??!0,safeArea:((C=t.show)==null?void 0:C.safeArea)??!0,labels:((N=t.show)==null?void 0:N.labels)??!0},l=e.canvas,a=l instanceof HTMLCanvasElement?l:null,c=ns(),h={...{...Sn,bleedFill:c?"#ffffff":"#000000"},...t.style};h.zoneFill={...Sn.zoneFill,...(($=t.style)==null?void 0:$.zoneFill)??{}},h.zoneStroke={...Sn.zoneStroke,...((T=t.style)==null?void 0:T.zoneStroke)??{}};let m=Un(h.bleedFill,a);const v=Un(h.dieCutTint,a);let b=Un(h.boundaryStroke,a);c&&Do(m)?m="#ffffff":!c&&Lo(m)&&(m="#000000"),c&&Do(b)?b="#ffffff":!c&&Lo(b)&&(b="#000000");const p=n.some(L=>{var R;return(((R=o==null?void 0:o[L.id])==null?void 0:R.zones)??[]).some(I=>I.kind==="dieCut")})&&a?es(a):null;e.save(),e.translate(r.x,r.y);for(const L of n){if(t.focusedPieceId!=null&&L.id!==t.focusedPieceId)continue;const R=o==null?void 0:o[L.id],I=(R==null?void 0:R.zones)??[],st=(R==null?void 0:R.labels)??[];e.save(),e.translate(L.x,L.y);const A=L.rotation??0;A===90?(e.translate(L.width,0),e.rotate(Math.PI/2)):A===180?(e.translate(L.width,L.height),e.rotate(Math.PI)):A===270&&(e.translate(0,L.height),e.rotate(3*Math.PI/2));const U=A===90||A===270,g=U?L.height:L.width,tt=U?L.width:L.height,Et=rs(R,g,tt),vt=is(R,L,g,tt),kt=!0,X=Math.max(0,(R==null?void 0:R.outerRadius)??0),xt=X>0?{kind:"roundedRect",x:0,y:0,width:g,height:tt,rx:X,ry:X}:{kind:"rect",x:0,y:0,width:g,height:tt};if(X>0&&(e.save(),e.beginPath(),os(e,xt),e.clip()),s.bleed&&h.bleedOpacity>0){const Mt=h.bleedInnerEdge==="safeArea"&&vt?vt:Et;if(Mt){const mt=c?"screen":"multiply",bt=h.bleedOpacity;h.bleedMode==="solid"?as(e,xt,Mt,m,bt,mt):ss(e,g,tt,xt,Mt,m,bt,h.bleedBlurScale,i,mt)}}if(s.zones)for(const Mt of I)Mt.kind!=="dieCut"&&(e.save(),e.fillStyle=h.zoneFill[Mt.kind]??Sn.zoneFill[Mt.kind],In(e,Mt.path),e.strokeStyle=h.zoneStroke[Mt.kind]??Sn.zoneStroke[Mt.kind],y.setZoomInvariantStroke(e,1.5,Mt.kind==="wrap"?[4,3]:[]),Rn(e,Mt.path),e.setLineDash([]),e.restore());if(s.zones)for(const Mt of I)Mt.kind==="dieCut"&&(h.dieCutMode==="knockout"?us(e,Mt,h.dieCutStroke,h.dieCutStrokeWidthPx,t.interacting===!0,kt,p,h.dieCutBlurPx):cs(e,Mt,p,v,h.dieCutTintAlpha,h.dieCutBlurPx,h.dieCutStroke,h.dieCutStrokeWidthPx));s.boundary&&b&&h.boundaryStrokeWidthPx>0&&(e.save(),e.strokeStyle=b,y.setZoomInvariantStroke(e,h.boundaryStrokeWidthPx),Rn(e,Et),e.restore()),s.safeArea&&vt&&h.safeAreaStroke&&(e.save(),e.strokeStyle=h.safeAreaStroke,y.setZoomInvariantStroke(e,h.safeAreaStrokeWidthPx,h.safeAreaDashPx),Rn(e,vt),e.setLineDash([]),e.restore()),s.labels&&st.length>0&&fs(e,st,h,i),X>0&&e.restore(),e.restore()}e.restore()}function ss(t,e,n,o,r,i,s,l,a,c="source-over"){const f=Math.max(6,Math.round(Math.min(e,n)*l)),h=a>0?f*a:f,m=typeof window<"u"&&window.devicePixelRatio||1,v=f,b=e+2*v,M=n+2*v,p=Math.max(1,Math.ceil(b*a*m)),x=Math.max(1,Math.ceil(M*a*m)),w=ls(p,x);if(!w)return;const E=w.getContext("2d");if(!E)return;E.setTransform(1,0,0,1,0,0),E.clearRect(0,0,p,x),E.scale(a*m,a*m),E.translate(v,v),E.fillStyle=i,E.globalAlpha=s;const C=new Path2D;_n(C,o),E.fill(C),E.globalAlpha=1,E.filter=`blur(${h*m}px)`,E.globalCompositeOperation="destination-out",E.fillStyle="#000";const N=new Path2D;_n(N,r),E.fill(N),E.filter="none",E.globalCompositeOperation="source-over";const $=t.globalCompositeOperation;t.globalCompositeOperation=c,t.drawImage(w,-v,-v,b,M),t.globalCompositeOperation=$}function as(t,e,n,o,r,i="source-over"){t.save(),t.globalAlpha=t.globalAlpha*r,t.globalCompositeOperation=i,t.fillStyle=o;const s=new Path2D;_n(s,e),_n(s,n),t.fill(s,"evenodd"),t.restore()}let un=null;function ls(t,e){return typeof document>"u"?null:(un||(un=document.createElement("canvas")),un.width!==t&&(un.width=t),un.height!==e&&(un.height=e),un)}function cs(t,e,n,o,r,i,s,l){const a=e.path;if(t.save(),t.beginPath(),An(t,a),t.clip(),n&&(t.save(),t.globalCompositeOperation="destination-out",t.fillStyle="#000",a.kind==="path"?In(t,a):t.fillRect(a.x,a.y,a.width,a.height),t.restore(),i>0)){const c=t.globalAlpha,f=t.getTransform();t.save(),t.setTransform(1,0,0,1,0,0),t.filter=`blur(${i}px)`,t.globalAlpha=c*.4,t.drawImage(n,0,0),t.filter="none",t.globalAlpha=c,t.setTransform(f),t.restore()}if(r>0){const c=t.globalAlpha;t.fillStyle=o,t.globalAlpha=c*r,a.kind==="path"?In(t,a):t.fillRect(a.x,a.y,a.width,a.height),t.globalAlpha=c}t.restore(),s&&(t.save(),t.strokeStyle=s,y.setZoomInvariantStroke(t,l),Rn(t,a),t.restore())}const ds=.3;function us(t,e,n,o,r,i=!0,s,l=0){const a=e.path;if(i)if(r&&s&&l>0){t.save(),t.beginPath(),An(t,a),t.clip(),t.save(),t.globalCompositeOperation="destination-out",t.fillStyle="#000",a.kind==="path"||a.kind==="roundedRect"?In(t,a):t.fillRect(a.x,a.y,a.width,a.height),t.restore();const c=t.globalAlpha,f=t.getTransform();t.save(),t.setTransform(1,0,0,1,0,0),t.filter=`blur(${l}px)`,t.globalAlpha=c*.4,t.drawImage(s,0,0),t.filter="none",t.globalAlpha=c,t.setTransform(f),t.restore(),t.restore()}else t.save(),t.globalCompositeOperation="destination-out",t.globalAlpha=r?1-ds:1,t.fillStyle="#000",a.kind==="path"||a.kind==="roundedRect"?In(t,a):t.fillRect(a.x,a.y,a.width,a.height),t.restore();n&&(t.save(),t.strokeStyle=n,y.setZoomInvariantStroke(t,o),Rn(t,a),t.restore())}function fs(t,e,n,o){const r=o>0?n.labelFontSizePx/o:n.labelFontSizePx,i=Math.max(2,n.labelFontSizePx*.25),s=o>0?i/o:i;t.save(),t.font=`${r}px ${n.labelFontFamily}`;for(const l of e){const a=l.anchor??"c";t.textAlign=hs(a),t.textBaseline=ps(a),t.lineJoin="round",t.strokeStyle=n.labelHaloColor,t.lineWidth=s,t.strokeText(l.text,l.x,l.y),t.fillStyle=n.labelColor,t.fillText(l.text,l.x,l.y)}t.restore()}function hs(t){return t.endsWith("l")?"start":t.endsWith("r")?"end":"center"}function ps(t){return t.startsWith("t")?"hanging":t.startsWith("b")?"alphabetic":"middle"}function gs(t){const{ctx:e,displaySelection:n,elements:o,activeArtboardElementIds:r,stateMachine:i,multiSelectionOBB:s,isRotating:l,currentRotation:a,isMarqueeSelecting:c,zoom:f=1}=t,h=n.filter(mt=>r.has(mt));if(h.length===0)return{updatedOBB:null,groupBounds:null};const m=i._multiSelectionDragContext,v=i.getMode()==="drag"&&m;h.forEach(mt=>{let bt=o.find(Ot=>Ot.id===mt);if(v&&m.currentElements){const Ot=m.currentElements.get(mt);Ot&&(bt=Ot)}if(bt){const Ot=bt.getVisualBoundingBox(),Pt=bt.getRotationAnchor();e.save(),bt.rotation!==0&&(e.translate(Pt.x,Pt.y),e.rotate(-bt.rotation*Math.PI/180),e.translate(-Pt.x,-Pt.y)),e.strokeStyle=y.getThemeAccentColor(),e.lineWidth=re.getLineWidth(f),e.strokeRect(Ot.x,Ot.y,Ot.width,Ot.height),e.restore()}});let b=h.map(mt=>o.find(bt=>bt.id===mt)).filter(mt=>mt!==void 0);if(v&&m.currentElements&&(b=b.map(mt=>m.currentElements.get(mt.id)||mt)),b.length===0)return{updatedOBB:null,groupBounds:null};let M=1/0,p=1/0,x=-1/0,w=-1/0;b.forEach(mt=>{const bt=mt.getVisualBoundingBox(),Ot=[{x:bt.x,y:bt.y},{x:bt.x+bt.width,y:bt.y},{x:bt.x,y:bt.y+bt.height},{x:bt.x+bt.width,y:bt.y+bt.height}];if(mt.rotation!==0){const Pt=mt.getRotationAnchor(),Lt=-mt.rotation*Math.PI/180,Wt=Math.cos(Lt),he=Math.sin(Lt);Ot.forEach(Gt=>{const me=Gt.x-Pt.x,H=Gt.y-Pt.y;Gt.x=Pt.x+(me*Wt-H*he),Gt.y=Pt.y+(me*he+H*Wt)})}Ot.forEach(Pt=>{M=Math.min(M,Pt.x),p=Math.min(p,Pt.y),x=Math.max(x,Pt.x),w=Math.max(w,Pt.y)})});const E=x-M,C=w-p,N=(M+x)/2,$=(p+w)/2;let T=s;if((!T||T.width===0||T.height===0)&&(T={centerX:N,centerY:$,width:E,height:C,rotation:0}),i.getMode()==="drag"&&i._multiSelectionDragContext){const mt=i._multiSelectionDragContext;if(mt!=null&&mt.startOBB&&(mt!=null&&mt.currentDelta)){const{dx:bt,dy:Ot}=mt.currentDelta;T={...T,centerX:mt.startOBB.centerX+bt,centerY:mt.startOBB.centerY+Ot}}else T={...T,centerX:N,centerY:$}}const I=l&&i.getMode()==="rotate"?T.rotation+a:T.rotation,st=T.width,A=T.height,U=T.centerX,g=T.centerY,tt=U-st/2,Et=g-A/2,vt=U+st/2,kt=g+A/2;let X=U,xt=kt+y.ROTATION_HANDLE_DISTANCE;if(I!==0){const mt=-I*Math.PI/180,bt=Math.cos(mt),Ot=Math.sin(mt),Pt=X-U,Lt=xt-g;X=U+(Pt*bt-Lt*Ot),xt=g+(Pt*Ot+Lt*bt)}const Mt={minX:tt,minY:Et,maxX:vt,maxY:kt,centerX:U,centerY:g,rotationHandleX:X,rotationHandleY:xt,rotation:I};return e.save(),e.translate(U,g),e.rotate(-I*Math.PI/180),e.translate(-U,-g),e.strokeStyle=y.getThemeAccentColor(),e.lineWidth=re.getLineWidth(f),e.setLineDash(re.getDashPattern(f)),e.strokeRect(tt,Et,st,A),e.restore(),c||ms(e,{renderMinX:tt,renderMinY:Et,renderMaxX:vt,renderMaxY:kt,renderCenterX:U,renderCenterY:g,renderWidth:st,renderHeight:A,groupRotation:I,rotationHandleX:X,rotationHandleY:xt,stateMachine:i,zoom:f}),{updatedOBB:T,groupBounds:Mt}}function ms(t,e){var E;const{renderMinX:n,renderMinY:o,renderMaxX:r,renderMaxY:i,renderCenterX:s,renderCenterY:l,renderWidth:a,renderHeight:c,groupRotation:f,rotationHandleX:h,rotationHandleY:m,stateMachine:v,zoom:b}=e,M=re.getHandleRadius(b),p=[{x:n,y:o,anchor:"top-left"},{x:r,y:o,anchor:"top-right"},{x:n,y:i,anchor:"bottom-left"},{x:r,y:i,anchor:"bottom-right"}],x=v.getMode()==="resize",w=x?(E=v._multiSelectionResizeContext)==null?void 0:E.anchor:null;p.forEach(C=>{if(x&&w&&C.anchor!==w)return;let N=C.x,$=C.y;if(f!==0){const T=-f*Math.PI/180,L=Math.cos(T),R=Math.sin(T),I=C.x-s,st=C.y-l;N=s+(I*L-st*R),$=l+(I*R+st*L)}t.save(),t.beginPath(),t.arc(N,$,M,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle=y.getThemeAccentColor(),t.lineWidth=x&&w&&C.anchor===w?re.getLineWidth(b)*1.25:re.getLineWidth(b),t.stroke(),t.restore()}),x||re.renderRotationHandle(t,h,m,b,y.getThemeAccentColor()),v.getMode()==="resize"&&ys(t,s,i,a,c)}function ys(t,e,n,o,r){const i=`${Math.round(o)} × ${Math.round(r)}`,s=e,l=n+30;t.save(),t.font="10px system-ui, -apple-system, sans-serif";const c=t.measureText(i).width+12,f=18;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4,t.shadowOffsetY=1,t.fillStyle="#333",t.beginPath(),t.roundRect(s-c/2,l-f/2,c,f,3),t.fill(),t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetY=0,t.fillStyle="#fff",t.textAlign="center",t.textBaseline="middle",t.fillText(i,s,l+.5),t.restore()}function xs(t){const{ctx:e,marqueeStart:n,marqueeEnd:o,zoom:r=1}=t,i=Math.min(n.x,o.x),s=Math.max(n.x,o.x),l=Math.min(n.y,o.y),a=Math.max(n.y,o.y);e.save(),e.strokeStyle=y.getThemeAccentColor(),e.lineWidth=re.getLineWidth(r),e.strokeRect(i,l,s-i,a-l),e.fillStyle=y.getThemeAccentColorWithAlpha(.1),e.fillRect(i,l,s-i,a-l),e.restore()}function bs(t){const{ctx:e,hoveredChild:n,zoom:o=1}=t,r=n.getVisualBoundingBox();e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(-n.rotation*Math.PI/180),e.translate(-(r.x+r.width/2),-(r.y+r.height/2)),e.strokeStyle=y.getThemeHoverBorderColor(),e.lineWidth=re.getLineWidth(o),e.setLineDash([]),e.strokeRect(r.x,r.y,r.width,r.height),e.restore()}const vs=60;class gn{constructor(){this.frameTimes=[],this.metrics={frameTime:0,frameCount:0,elementCount:0,cacheHitRate:0,lastExportDuration:0}}static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}recordFrameTime(e){this.frameTimes.push(e),this.frameTimes.length>vs&&this.frameTimes.shift(),this.metrics.frameCount++,this.metrics.frameTime=this._average(this.frameTimes)}recordExportDuration(e){this.metrics.lastExportDuration=e}setElementCount(e){this.metrics.elementCount=e}setCacheHitRate(e){this.metrics.cacheHitRate=e}getMetrics(){return{...this.metrics}}reset(){this.frameTimes=[],this.metrics={frameTime:0,frameCount:0,elementCount:0,cacheHitRate:0,lastExportDuration:0}}_average(e){if(e.length===0)return 0;let n=0;for(let o=0;o<e.length;o++)n+=e[o];return n/e.length}}function ws(t,e,n){if(t.length===0||!t.every(s=>{var a;const l=(a=e==null?void 0:e[s.id])==null?void 0:a.boundary;return l&&typeof l=="object"&&l.kind==="path"&&typeof l.d=="string"}))return;const r=n?t.filter(s=>s.id===n):t;return{type:"composite-path",pieces:(r.length>0?r:t).map(s=>{var f;const l=(f=e==null?void 0:e[s.id])==null?void 0:f.boundary,a=(s.rotation??0)%360,c=a===90||a===270;return{d:l.d,x:s.x,y:s.y,rotation:a,baseWidth:c?s.height:s.width,baseHeight:c?s.width:s.height}})}}function Cs(t){const e=u.useRef(t);e.current=t;const n=u.useRef(!0),o=u.useRef(null),r=u.useRef("#0a0a0a");u.useEffect(()=>{const i=e.current.canvasRef.current??document.documentElement,s=getComputedStyle(i).getPropertyValue("--color-canvas-bg").trim();r.current=s||"#0a0a0a"},[t.resolvedTheme]),u.useEffect(()=>{n.current=!0},[t.elementsByArtboard,t.artboards,t.selectedId,t.selectedElement,t.activeChildElement,t.canvasSize,t.zoom,t.renderVersion,t.resolvedTheme,t.pieceGuides]),u.useEffect(()=>{n.current=!0},[t.transformHandles,t.currentRotation,t.isRotating,t.hoverState,t.isEditing,t.editText,t.editRichText,t.cursorPosition,t.selectionStart,t.selectionEnd,t.stateMachine,t.snapGuides,t.spacingIndicators,t.handlesVersion,t.multiSelection,t.isMarqueeSelecting,t.marqueeStart,t.marqueeEnd,t.marqueePreviewSelection,t.isAltKeyPressed,t.penTool,t.cursorAnimationFrame]),u.useEffect(()=>{let i;const l=()=>{const{hoverState:a}=e.current;if(a.startTime!==null&&a.type!==null&&performance.now()-a.startTime<150&&(n.current=!0),n.current){n.current=!1;const c=performance.now();Es(e.current,r,o),gn.getInstance().recordFrameTime(performance.now()-c)}i=requestAnimationFrame(l)};return i=requestAnimationFrame(l),()=>cancelAnimationFrame(i)},[])}function Es(t,e,n){var Ue,Fe,lt;const{canvasRef:o,elements:r,elementsByArtboard:i,artboards:s,artboardManager:l,artboardRenderer:a,selectedId:c,selectedElement:f,activeChildElement:h,editingChildIdRef:m,transformHandles:v,stateMachine:b,paddedCanvasWidth:M,paddedCanvasHeight:p,paddingOffsetX:x,paddingOffsetY:w,zoom:E,zoomInvariantBorderRadius:C,effectiveViewPadding:N,showRotationHandle:$,isRotating:T,currentRotation:L,hoverState:R,isEditing:I,editText:st,editRichText:A,cursorPosition:U,selectionStart:g,selectionEnd:tt,cursorOpacityRef:Et,cursorStartTimeRef:vt,isTouchDevice:kt,selectionHandlePositionsRef:X,multiClickSelectionRef:xt,lastMultiClickTimeRef:Mt,MULTI_CLICK_DEBOUNCE:mt,snapGuides:bt,spacingIndicators:Ot,isAltKeyPressed:Pt,multiSelection:Lt,multiSelectionOBBRef:Wt,multiSelectionGroupBoundsRef:he,isMarqueeSelecting:Gt,marqueeStart:me,marqueeEnd:H,marqueePreviewSelection:Y,penTool:nt,hideHandles:ot,pieceGuides:it}=t,yt=o.current;if(!yt)return;const G=yt.getContext("2d");if(!G)return;if(I){const ct=Bt=>Bt<.5?4*Bt*Bt*Bt:1-Math.pow(-2*Bt+2,3)/2,Ft=(performance.now()-vt.current)%1060/1060,Ct=Ft<.5?1-ct(Ft*2):ct((Ft-.5)*2);Et.current=Ct}else Et.current=1;const d=window.devicePixelRatio||1,O=M*E,z=p*E;if(O<=0||z<=0)return;const ut=4096,K=O*d,Tt=z*d,wt=Math.max(K,Tt),jt=wt>ut?ut/wt:1,zt=d*jt;yt.width=O*zt,yt.height=z*zt,G.setTransform(1,0,0,1,0,0),G.clearRect(0,0,yt.width,yt.height);const _=e.current;G.scale(zt,zt),E!==1&&G.scale(E,E),(x!==0||w!==0)&&G.translate(x,w);const W=s.find(ht=>ht.id===l.getActiveArtboardId()),ie=(W==null?void 0:W.id)??null,Ut=it&&W?ws(it.pieces,it.guides,t.focusedPieceId??null):void 0;let te=it?0:C;if(it&&it.pieces.length===1&&W){const ht=it.pieces[0].id,Ht=(Ue=it.guides)==null?void 0:Ue[ht],Ft=Ht==null?void 0:Ht.outerRadius,Ct=Ht==null?void 0:Ht.boundary,Bt=Ct&&typeof Ct=="object"&&Ct.kind==="roundedRect"?Ct.rx??Ct.ry:void 0,Yt=typeof Ft=="number"&&Ft>0?Ft:typeof Bt=="number"&&Bt>0?Bt:0;Yt>0&&(te=Yt)}if(W&&!it)if(G.fillStyle=_,Ut&&typeof Ut=="object"&&Ut.type==="path")try{const ht=new Path2D(Ut.d);G.save(),G.translate(W.x,W.y),G.fill(ht),G.restore()}catch{G.fillRect(W.x,W.y,W.width,W.height)}else te>0?(G.beginPath(),G.roundRect(W.x,W.y,W.width,W.height,te),G.fill()):G.fillRect(W.x,W.y,W.width,W.height);W&&!it&&a.render(G,W,!0);let Me=h||f,pe=i.get(ie)||[];if(b.getMode()==="drag"&&f){const ct=b.getContext()._cachedElement;ct&&ct[f.id]&&(pe=pe.map(Ht=>Ht.id===f.id?ct[f.id]:Ht),h||(Me=ct[f.id]))}if(I&&f){const ht=m.current??null,ct=n.current;if(!(ct!==null&&ct.elementId===f.id&&ct.childId===ht&&ct.editRichText===A)){let Ft=null;if(ht&&f instanceof y.GroupElement){const Ct=pe.find(Bt=>Bt.id===f.id&&Bt instanceof y.GroupElement);if(Ct){const Bt=Ct.clone();Bt.children=Bt.children.map(Yt=>{if(Yt.id===ht&&A&&Yt instanceof y.TextElement){const Nt=Yt.clone();return Nt.setRichText(A),Nt}return Yt}),Ft=Bt}}else if(A&&f instanceof y.TextElement){const Ct=f.clone();Ct.setRichText(A),Ft=Ct}Ft?n.current={elementId:f.id,childId:ht,editRichText:A,clonedElement:Ft}:n.current=null}if(n.current){const{clonedElement:Ft}=n.current;pe=pe.map(Ct=>Ct.id===f.id?Ft:Ct)}}else n.current=null;const ve=ot||nt.isActive()&&f instanceof y.PathElement||I;if(re.CanvasRenderer.render({ctx:G,elements:pe,selectedId:c,selectedElement:Me||null,transformHandles:v,currentRotation:L,isRotating:T,hoverState:R,isEditing:I,stateMachine:b,snapGuides:bt,spacingIndicators:Ot,hideHandles:ve,isAltKeyPressed:Pt,artboardBackgroundColor:W==null?void 0:W.backgroundColor,distressTexture:W==null?void 0:W.distressTexture,imageMask:W==null?void 0:W.imageMask,artboard:W?{x:W.x,y:W.y,width:W.width,height:W.height,borderRadius:te,clipShape:Ut??W.clipShape}:void 0,zoom:E,paddingOffset:{x,y:w},showOverflowDimmed:N<1,suppressOverflowDim:!1,showRotationHandle:$,editModeData:I?(()=>{const ht=xt.current,ct=Date.now()-Mt.current<mt,Ht=ht&&ct;return{cursorPosition:Ht?ht.cursor:U,selectionStart:Ht?ht.start:g,selectionEnd:Ht?ht.end:tt,editText:st,editRichText:A,cursorOpacity:Et.current,isTouchDevice:kt,selectionHandlePositionsRef:X}})():void 0}),it&&it.pieces.length>0&&W){let ht=!1;const ct=Me??null;if(ct&&it){const Ct=ct.getVisualBoundingBox();t:for(const Bt of it.pieces){const Yt=((lt=(Fe=it.guides)==null?void 0:Fe[Bt.id])==null?void 0:lt.zones)??[];for(const Nt of Yt){if(Nt.kind!=="dieCut")continue;const _t=Nt.path;if(_t.kind!=="rect"&&_t.kind!=="roundedRect"){ht=!0;break t}const le=Bt.x+(_t.x??0),se=Bt.y+(_t.y??0),He=_t.width??0,Ae=_t.height??0;if(Ct.x<le+He&&Ct.x+Ct.width>le&&Ct.y<se+Ae&&Ct.y+Ct.height>se){ht=!0;break t}}}}const Ht=ht,Ft=te>0&&W!==void 0;if(Ft&&(G.save(),G.beginPath(),G.roundRect(W.x,W.y,W.width,W.height,te),G.clip()),ur({ctx:G,artboardOrigin:{x:W.x,y:W.y},artboardWidth:W.width,artboardHeight:W.height,pieces:it.pieces,pieceGuides:it.guides,show:it.show,style:it.style,zoom:E,interacting:Ht,focusedPieceId:t.focusedPieceId??null}),Ft&&G.restore(),t.focusedPieceId&&it.pieces.length>1){const Ct=t.focusedPieceRect??it.pieces.find(Bt=>Bt.id===t.focusedPieceId)??null;if(Ct){G.save(),G.translate(W.x,W.y),G.globalCompositeOperation="destination-out";const Bt=!!f;G.globalAlpha=Bt?1-.3:1,G.fillStyle="#000",G.beginPath();const Yt=1e7;G.rect(-Yt,-Yt,2*Yt,2*Yt),G.rect(Ct.x,Ct.y,Ct.width,Ct.height),G.fill("evenodd"),G.restore()}}}W&&re.CanvasRenderer.renderInteractionChromeLayer({ctx:G,selectedElement:Me||null,transformHandles:v,stateMachine:b,currentRotation:L,isRotating:T,hoverState:R,selectedId:c,hideHandles:ve,isEditing:I,isAltKeyPressed:Pt,artboardBackgroundColor:W.backgroundColor,hoverClipArtboard:{x:W.x,y:W.y,width:W.width,height:W.height,borderRadius:te,clipShape:W.clipShape},showRotationHandle:$,zoom:E,paddingOffset:{x,y:w}});const Re=Gt?Y:Lt,ke=new Set(pe.map(ht=>ht.id)),{updatedOBB:ge,groupBounds:_e}=gs({ctx:G,displaySelection:Re,elements:r,activeArtboardElementIds:ke,stateMachine:b,multiSelectionOBB:Wt.current,isRotating:T,currentRotation:L,isMarqueeSelecting:Gt,zoom:E});ge&&Wt.current!==ge&&(Wt.current=ge),he.current=_e,Gt&&xs({ctx:G,marqueeStart:me,marqueeEnd:H,zoom:E}),R.type==="group-sibling"&&R.data&&bs({ctx:G,hoveredChild:R.data,zoom:E}),nt.isActive()&&f instanceof y.PathElement&&nt.renderPreview(G,f)}class ks{static calculatePinch({element:e,startData:n,scale:o,rotationDelta:r,startCentroid:i,currentCentroid:s,snapRotation:l}){const a=n.width??0,c=n.height??0,f=Math.max(1,a*o),h=Math.max(1,c*o);e.resize("bottom-right",f,h,n);const m=n.x-i.x,v=n.y-i.y,b=Math.cos(r),M=Math.sin(r),p=o*m,x=o*v;e.x=s.x+p*b-x*M,e.y=s.y+p*M+x*b;let w=n.rotation-r*180/Math.PI;return w=(w%360+360)%360,w>180&&(w-=360),l&&(w=l(w,e)),e.setRotation(w),e}}class Ss{constructor(){this.isProtectedFlag=!1,this.timeout=null,this.timeoutDuration=5e3}protectNextClick(){this.isProtectedFlag=!0,this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.isProtectedFlag=!1,this.timeout=null},this.timeoutDuration)}shouldProtectClick(){const e=this.isProtectedFlag;return this.isProtectedFlag&&(this.isProtectedFlag=!1,this.timeout&&(clearTimeout(this.timeout),this.timeout=null)),e}clearProtection(){this.isProtectedFlag=!1,this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}isProtected(){return this.isProtectedFlag}}const fr=new Ss;function Ms(t){const{x:e,y:n,bounds:o,zoom:r=1}=t,i=y.CORNER_HANDLE_HIT_RADIUS/r,s=o.rotation||0,a=[{x:o.minX,y:o.minY,anchor:"top-left"},{x:o.maxX,y:o.minY,anchor:"top-right"},{x:o.minX,y:o.maxY,anchor:"bottom-left"},{x:o.maxX,y:o.maxY,anchor:"bottom-right"}].map(v=>{if(s!==0){const b=-s*Math.PI/180,M=Math.cos(b),p=Math.sin(b),x=v.x-o.centerX,w=v.y-o.centerY;return{x:o.centerX+(x*M-w*p),y:o.centerY+(x*p+w*M),anchor:v.anchor}}return v});for(const v of a){const b=e-v.x,M=n-v.y;if(Math.sqrt(b*b+M*M)<=i)return{type:"corner-handle",anchor:v.anchor,corner:v}}const c=18/r;if(Math.sqrt(Math.pow(e-o.rotationHandleX,2)+Math.pow(n-o.rotationHandleY,2))<=c)return{type:"rotation-handle"};let h=e,m=n;if(s!==0){const v=s*Math.PI/180,b=Math.cos(v),M=Math.sin(v),p=e-o.centerX,x=n-o.centerY;h=o.centerX+(p*b-x*M),m=o.centerY+(p*M+x*b)}return h>=o.minX&&h<=o.maxX&&m>=o.minY&&m<=o.maxY?{type:"bounds-drag"}:{type:"none"}}function Rs(t){const{multiSelection:e,elements:n,bounds:o,anchor:r,corner:i,x:s,y:l,stateMachine:a}=t,c=e.map(f=>n.find(h=>h.id===f)).filter(f=>f!==void 0&&!f.locked);return c.length===0?!1:(a._multiSelectionResizeContext={anchor:r,startBounds:{...o},elementsStartData:c.map(f=>({element:f,startData:f.getTransformStartData()}))},a.startResize(c[0],{anchor:r,x:i.x,y:i.y,cursor:"nwse-resize",type:"corner"},s,l,{x:o.minX,y:o.minY,width:o.maxX-o.minX,height:o.maxY-o.minY},{x:o.minX,y:o.minY,width:o.maxX-o.minX,height:o.maxY-o.minY}),!0)}function Ts(t){const{multiSelection:e,elements:n,bounds:o,x:r,y:i,stateMachine:s,setIsRotating:l,setRotationStartAngle:a,setCurrentRotation:c}=t,f=e.map(m=>n.find(v=>v.id===m)).filter(m=>m!==void 0&&!m.locked);if(f.length===0)return!1;const h=y.calculateAngle(o.centerX,o.centerY,r,i);return s._multiSelectionRotationContext={startBounds:{...o},elementsStartData:f.map(m=>({element:m,startData:m.getTransformStartData()}))},l(!0),a(h),c(0),s.startRotate(f[0],r,i,h,0),!0}function Is(t){const{multiSelection:e,elements:n,x:o,y:r,stateMachine:i,dragOriginalElementsRef:s,setHoverState:l}=t,a=e.map(c=>n.find(f=>f.id===c)).filter(c=>c!==void 0&&!c.locked);return a.length===0?!1:(i._multiSelectionDragContext={startX:o,startY:r,elementsStartData:a.map(c=>({element:c,startData:c.getTransformStartData()})),currentElements:new Map},s.current=new Map,a.forEach(c=>{s.current.set(c.id,c.clone())}),i.startDrag(a[0],o,r),l({type:null,data:null}),!0)}function As(t){const{selectedElement:e,activeChildElement:n}=t;let o=null,r=-1;if(n instanceof y.ImageElement&&n.isCropping)o=n,e instanceof y.GroupElement&&(r=e.children.findIndex(s=>s.id===n.id));else if(e instanceof y.GroupElement)for(let s=0;s<e.children.length;s++){const l=e.children[s];if(l.visible!==!1&&l instanceof y.ImageElement&&l.isCropping){o=l,r=s;break}}const i=o||(e instanceof y.ImageElement&&e.isCropping?e:null);return i?{croppingImage:i,croppingChild:o,croppingChildIndex:r,isChildInGroup:o!==null}:null}function Ps(t){const{x:e,y:n,cropContext:o,transformHandles:r,zoom:i=1}=t,{croppingImage:s}=o,l=s.hitTestCropHandle(e,n,i);if(l)return{type:"crop-handle",handle:l};const a=r.hitTestResize(e,n,i);return a?{type:"image-handle",handle:a}:s.hitTest(e,n)?{type:"image-drag"}:{type:"exit-crop"}}function Ds(t){const{cropContext:e,cropHandle:n,x:o,y:r,selectedElement:i,activeChildElement:s,stateMachine:l}=t,{croppingImage:a,croppingChild:c,croppingChildIndex:f}=e,h=a.getCropBoxBounds();h&&(l.startResize(a,{anchor:"crop-"+n.anchor,x:0,y:0,cursor:"grab",type:n.type},o,r,h,h),c&&(s&&s.id===c.id?l._activeChildContext={group:i,childId:c.id}:l._cropGroupContext={group:i,childIndex:f}))}function Ls(t){const{cropContext:e,imageHandle:n,x:o,y:r,selectedElement:i,activeChildElement:s,stateMachine:l}=t,{croppingImage:a,croppingChild:c,croppingChildIndex:f}=e,h=a.getBoundingBox(),m=a.getVisualBoundingBox();l.startResize(a,n,o,r,h,m),c&&(s&&s.id===c.id?l._activeChildContext={group:i,childId:c.id}:l._cropGroupContext={group:i,childIndex:f})}function Bs(t){const{cropContext:e,x:n,y:o,selectedElement:r,activeChildElement:i,stateMachine:s,dragOriginalElementsRef:l,setHoverState:a}=t,{croppingImage:c,croppingChild:f,croppingChildIndex:h}=e;l.current=new Map,f&&r?l.current.set(r.id,r.clone()):l.current.set(c.id,c.clone()),s.startDrag(c,n,o,"crop-image-drag"),a({type:null,data:null}),f&&(i&&i.id===f.id?s._activeChildContext={group:r,childId:f.id}:s._cropGroupContext={group:r,childIndex:h})}function Hs(t){const{cropContext:e,selectedElement:n,onElementUpdate:o,transformHandles:r,updateActiveChild:i,zoom:s}=t,{croppingImage:l,croppingChild:a,croppingChildIndex:c}=e;if(a&&n instanceof y.GroupElement){const f=a.clone();f.exitCropMode();const h=n.clone();h.children[c]=f,o(h),r.update(h,s),i(null)}else{const f=l.clone();f.exitCropMode(),o(f),r.update(f,s)}}function Os(t){const{x:e,y:n,activeChildElement:o,selectedElement:r,updateActiveChild:i,transformHandles:s,setHandlesVersion:l,stateMachine:a,dragOriginalElementsRef:c,setHoverState:f,forceUpdate:h,zoom:m}=t;for(let v=r.children.length-1;v>=0;v--){const b=r.children[v];if(!(b.visible===!1||b.id===o.id)&&b.hitTest(e,n))return i(b),s.update(b,m),l(M=>M+1),a.startDrag(b,e,n),c.current=new Map,c.current.set(b.id,b.clone()),f({type:null,data:null}),a._activeChildContext={group:r,childId:b.id},h({}),!0}return!1}function Ho(t){const{updateActiveChild:e,selectedElement:n,transformHandles:o,setHandlesVersion:r,zoom:i}=t;e(null),n&&(o.update(n,i),r(s=>s+1))}function Xs(t){const{x:e,y:n,shiftKey:o,activeArtboardElements:r,selectedElement:i,multiSelection:s,onSelectionChange:l,onMultiSelectionChange:a,stateMachine:c,dragOriginalElementsRef:f,setHoverState:h,forceUpdate:m}=t;for(let v=r.length-1;v>=0;v--)if(r[v].visible!==!1&&r[v].hitTest(e,n)){const b=r[v].id;if(o){if(i&&s.length===0)a([i.id,b]),l(null);else if(s.includes(b)){const M=s.filter(p=>p!==b);a(M)}else a([...s,b]);return!0}if(s.length>0&&s.includes(b)){const M=s.map(p=>r.find(x=>x.id===p)).filter(p=>p!==void 0&&!p.locked);if(M.length>0)return c._multiSelectionDragContext={startX:e,startY:n,elementsStartData:M.map(p=>({element:p,startData:p.getTransformStartData()})),currentElements:new Map},f.current=new Map,M.forEach(p=>{f.current.set(p.id,p.clone())}),c.startDrag(M[0],e,n),h({type:null,data:null}),m({}),!0}return l(b),a([]),f.current=new Map,f.current.set(b,r[v].clone()),c.startDrag(r[v],e,n),h({type:null,data:null}),r[v]instanceof y.GroupElement&&(c._groupDragOriginalElement=r[v].clone()),m({}),!0}return!1}const Ys=900;function Nn(t,e,n,o){if(!o)return!0;const r=t.getVisualBoundingBox(),i=Math.max(r.x,o.x),s=Math.max(r.y,o.y),l=Math.min(r.x+r.width,o.x+o.width),a=Math.min(r.y+r.height,o.y+o.height);return Math.max(0,l-i)*Math.max(0,a-s)<Ys?!0:e>=o.x&&e<=o.x+o.width&&n>=o.y&&n<=o.y+o.height}function _s(t){const{canvasRef:e,inputRef:n,repositioningCursorRef:o,lastClickTimeRef:r,clickCountRef:i,lastProcessedClickTimeRef:s,lastMultiClickTimeRef:l,multiClickSelectionRef:a,skipDragSelectionRef:c,draggingSelectionHandleRef:f,selectionHandlePositionsRef:h,lastMousePosRef:m,dragOriginalElementsRef:v,rotatingElementRef:b,editingChildIdRef:M,editRichTextRef:p,editModeEnteredAtRef:x,multiSelectionGroupBoundsRef:w,MULTI_CLICK_THRESHOLD:E,MULTI_CLICK_DEBOUNCE:C,CLICK_DEDUP_THRESHOLD:N,isEditing:$,editText:T,isTouchDevice:L,selectionStart:R,selectionEnd:I,isRotating:st,isMarqueeSelecting:A,isAltKeyPressed:U,selectedElement:g,activeChildElement:tt,elements:Et,multiSelection:vt,multiSelectionOBBRef:kt,zoom:X,paddingOffsetX:xt,paddingOffsetY:Mt,spacingIndicators:mt,focusedPieceRect:bt,setCursorPosition:Ot,setSelectionStart:Pt,setSelectionEnd:Lt,setIsRotating:Wt,setRotationStartAngle:he,setCurrentRotation:Gt,setRotatingElementVersion:me,setIsAltKeyPressed:H,setSnapGuides:Y,setSpacingIndicators:nt,setHandlesVersion:ot,setHoverState:it,setElements:yt,forceUpdate:G,stateMachine:d,transformHandles:O,snapSystem:z,spacingSystem:ut,penTool:K,cropController:Tt,onElementUpdate:wt,executeElementUpdate:jt,onSelectionChange:zt,onMultiSelectionChange:_,onRotationStateChange:W,onCropModeEnter:ie,updateActiveChild:Ut,getActiveArtboardElements:te,startMarqueeSelection:Me,updateMarqueeSelection:pe,finishMarqueeSelection:ve,enterTextEditMode:Re,setEditPosition:ke,setEditText:ge,setEditRichText:_e,setIsEditing:Ue,setCurrentFormattingStyle:Fe,getWrappedTextForEditing:lt}=t,ht=u.useRef(null),ct=u.useRef(new Map),Ht=u.useRef(null),Ft=u.useRef(null),Ct=u.useRef(null),Bt=u.useRef(null),Yt=u.useRef(null),Nt=u.useRef(null),_t=u.useRef(null),{userZoom:le,setUserZoom:se,panOffset:He,setPanOffset:Ae}=Ge.useViewportContext(),Qe=u.useRef(le);Qe.current=le;const It=u.useRef(He);It.current=He,u.useEffect(()=>{const F=e.current;if(!F)return;const Rt=()=>{ht.current=F.getBoundingClientRect()};return Rt(),window.addEventListener("scroll",Rt,{passive:!0,capture:!0}),window.addEventListener("resize",Rt,{passive:!0}),()=>{window.removeEventListener("scroll",Rt,{capture:!0}),window.removeEventListener("resize",Rt)}},[e]),u.useEffect(()=>{const F=e.current;F&&(ht.current=F.getBoundingClientRect())},[X,e]);const zn=u.useCallback(F=>{var et,ft,q,pt,rt;const Rt=e.current;if(!Rt)return;const Zt=Rt.getBoundingClientRect();ht.current=Zt;const J=(F.clientX-Zt.left)/X-xt,Z=(F.clientY-Zt.top)/X-Mt;ct.current.size===0&&(Ct.current=(g==null?void 0:g.id)??null),ct.current.set(F.pointerId,{x:J,y:Z,clientX:F.clientX,clientY:F.clientY});const ee=$||g instanceof y.ImageElement&&g.isCropping||K.isActive();if(ct.current.size===2&&!ee){const k=Array.from(ct.current.keys()),j=ct.current.get(k[0]),P=ct.current.get(k[1]),B=Ct.current!==null;if(!(B&&g&&!g.locked&&(g.hitTest(j.x,j.y)||g.hitTest(P.x,P.y)))){if(v.current&&v.current.size>0){const xe=v.current;yt(ce=>ce.map(de=>{const Oe=xe.get(de.id);return Oe?Oe.clone():de})),v.current=null}!B&&g&&zt(null),d.isInteracting()&&d.end(),_t.current=null,Bt.current=null,Yt.current=null,delete d._pendingTextEditMode,delete d._pendingChildSelection;const at=P.clientX-j.clientX,Dt=P.clientY-j.clientY,Vt=Math.hypot(at,Dt),ye=(((et=Rt.parentElement)==null?void 0:et.parentElement)??Rt).getBoundingClientRect();Nt.current={pointerA:k[0],pointerB:k[1],startUserZoom:Qe.current,startPanOffset:{...It.current},startCentroidClient:{x:(j.clientX+P.clientX)/2,y:(j.clientY+P.clientY)/2},startDistance:Math.max(Vt,1),containerRect:{left:ye.left,top:ye.top}};try{Rt.setPointerCapture(F.pointerId)}catch{}F.preventDefault();return}}if(ct.current.size===2&&g&&!g.locked&&!ee){if(d.isInteracting()){const B=d.getContext();if(B.element){const dt=te().find(at=>at.id===B.element.id);jt(dt,B.element)}d.end()}const k=Array.from(ct.current.keys());Ht.current={a:k[0],b:k[1]};const j=ct.current.get(k[0]),P=ct.current.get(k[1]);Bt.current=null,Yt.current=null,_t.current=null,Ft.current=g.clone(),d.startPinch(g,j,P);try{Rt.setPointerCapture(F.pointerId)}catch{}F.preventDefault();return}if($&&g instanceof y.TextElement){if(L&&R!==I){const k=h.current;if(k.start||k.end){const j=y.RotationUtils.toRadiansInverse(g.rotation),P=g.getRotationAnchor(),B=J-P.x,dt=Z-P.y,at=Math.cos(j),Dt=Math.sin(j),Vt=B*at-dt*Dt,ae=B*Dt+dt*at,ye=Vt,xe=ae,ce=44/X;if(k.start&&Math.sqrt(Math.pow(ye-k.start.center.x,2)+Math.pow(xe-k.start.center.y,2))<=ce){F.preventDefault(),f.current="start",(ft=n.current)==null||ft.focus();return}if(k.end&&Math.sqrt(Math.pow(ye-k.end.center.x,2)+Math.pow(xe-k.end.center.y,2))<=ce){F.preventDefault(),f.current="end",(q=n.current)==null||q.focus();return}}}if(g.hitTest(J,Z)){F.preventDefault(),o.current=!0;const k=g.getVisualBoundingBox(),j=y.RotationUtils.toRadiansInverse(g.rotation),P=g.getRotationAnchor(),B=J-P.x,dt=Z-P.y,at=Math.cos(j),Dt=Math.sin(j),Vt=B*at-dt*Dt,ae=B*Dt+dt*at,ye=Vt+k.width/2,xe=ae+k.height/2,ce=en(g,{x:ye,y:xe}),de=Date.now();if(de-s.current<N){(pt=n.current)==null||pt.focus();return}s.current=de,de-l.current>=C&&(a.current=null),de-r.current<E?i.current+=1:i.current=1,r.current=de;const ne=T;if(i.current>=3)F.preventDefault(),l.current=de,a.current={start:0,end:ne.length,cursor:ne.length},c.current=!0,i.current=0,Ot(ne.length),Pt(0),Lt(ne.length),n.current&&(n.current.focus(),n.current.setSelectionRange(0,ne.length));else if(i.current===2){F.preventDefault(),l.current=de,c.current=!0;const we=cr(ne,ce);a.current={start:we.start,end:we.end,cursor:we.end},Ot(we.end),Pt(we.start),Lt(we.end),n.current&&(n.current.focus(),n.current.setSelectionRange(we.start,we.end))}else a.current=null,Ot(ce),Pt(ce),Lt(ce),n.current&&(n.current.focus(),n.current.setSelectionRange(ce,ce)),c.current=!1;return}a.current=null,(rt=n.current)==null||rt.blur();return}if($)return;if(F.target.setPointerCapture(F.pointerId),K.isActive()&&g instanceof y.PathElement){const k=J-g.x,j=Z-g.y;if(K.canClosePath(k,j,15)){K.startClosing(k,j),K.startDraggingHandle(),ot(P=>P+1);return}K.addPoint(k,j),K.startDraggingHandle(),ot(P=>P+1);return}if(vt.length>0&&w.current){const k=w.current,j=Ms({x:J,y:Z,bounds:k,zoom:X});if(j.type==="corner-handle"){if(Rs({multiSelection:vt,elements:Et,bounds:k,anchor:j.anchor,corner:j.corner,x:J,y:Z,stateMachine:d})){G({});return}}else if(j.type==="rotation-handle"){if(Ts({multiSelection:vt,elements:Et,bounds:k,x:J,y:Z,stateMachine:d,setIsRotating:Wt,setRotationStartAngle:he,setCurrentRotation:Gt})){G({});return}}else if(j.type==="bounds-drag"&&Is({multiSelection:vt,elements:Et,x:J,y:Z,stateMachine:d,dragOriginalElementsRef:v,setHoverState:it})){G({});return}}const D=tt||g;if(D&&D.visible!==!1&&!D.locked&&(vt.length===0||tt)){const k=As({selectedElement:g||null,activeChildElement:tt});if(k){const P=Ps({x:J,y:Z,cropContext:k,transformHandles:O,zoom:X});if(P.type==="crop-handle"){Ds({cropContext:k,cropHandle:P.handle,x:J,y:Z,selectedElement:g||null,activeChildElement:tt,stateMachine:d}),G({});return}else if(P.type==="image-handle"){Ls({cropContext:k,imageHandle:P.handle,x:J,y:Z,selectedElement:g||null,activeChildElement:tt,stateMachine:d}),G({});return}else if(P.type==="image-drag"){Bs({cropContext:k,x:J,y:Z,selectedElement:g||null,activeChildElement:tt,stateMachine:d,dragOriginalElementsRef:v,setHoverState:it}),G({});return}else if(P.type==="exit-crop"){Hs({cropContext:k,selectedElement:g||null,onElementUpdate:wt,transformHandles:O,updateActiveChild:Ut,zoom:X}),ot(B=>B+1);return}}if(O.hitTestRotation(J,Z,X)){if(D.locked)return;const P=D.getBoundingBox(),B=y.getBoundingBoxCenter(P),dt=y.calculateAngle(B.x,B.y,J,Z);Wt(!0),he(dt),Gt(D.rotation),d.startRotate(D,J,Z,dt,D.rotation),tt&&g instanceof y.GroupElement&&(d._activeChildContext={group:g,childId:tt.id}),Bt.current=D.id,Yt.current={x:J,y:Z},G({});return}const j=O.hitTestResize(J,Z,X);if(j){if(D.locked)return;const P=D.getBoundingBox(),B=D.getVisualBoundingBox();d.startResize(D,j,J,Z,P,B),Bt.current=D.id,Yt.current={x:J,y:Z},tt&&g instanceof y.GroupElement&&(d._activeChildContext={group:g,childId:tt.id}),G({});return}if(D.hitTest(J,Z)){if(D.locked)return;if(g instanceof y.GroupElement&&!tt){const P=g.hitTestChild(J,Z);P&&(d._pendingChildSelection=P)}g&&D.id===g.id&&!(D instanceof y.TextElement)&&(Bt.current=D.id,Yt.current={x:J,y:Z}),D instanceof y.TextElement&&!(D instanceof y.GroupElement)&&g&&D.id===g.id&&!$&&(d._pendingTextEditMode={elementId:D.id,originalX:D.x,originalY:D.y,clickX:J,clickY:Z}),d.startDrag(D,J,Z),v.current=new Map,v.current.set(D.id,D.clone()),it({type:null,data:null}),D instanceof y.GroupElement&&(d._groupDragOriginalElement=D.clone()),tt&&g instanceof y.GroupElement&&(d._activeChildContext={group:g,childId:tt.id}),G({});return}}if(tt&&g instanceof y.GroupElement){if(Os({x:J,y:Z,activeChildElement:tt,selectedElement:g,updateActiveChild:Ut,transformHandles:O,setHandlesVersion:ot,stateMachine:d,dragOriginalElementsRef:v,setHoverState:it,forceUpdate:G,zoom:X}))return;Ho({updateActiveChild:Ut,selectedElement:g||null,transformHandles:O,setHandlesVersion:ot,zoom:X});return}if(tt){Ho({updateActiveChild:Ut,selectedElement:g||null,transformHandles:O,setHandlesVersion:ot,zoom:X});return}if(!F.shiftKey){const k=te(),j=[];for(let B=k.length-1;B>=0;B--){const dt=k[B];dt.visible!==!1&&dt.hitTest(J,Z)&&Nn(dt,J,Z,bt)&&j.push(dt)}let P=null;if(j.length===0)g&&(P={kind:"deselect"});else{const B=g?j.findIndex(dt=>dt.id===g.id):-1;B===-1?P={kind:"select-element",elementId:j[0].id,x:J,y:Z,shiftKey:F.shiftKey}:B+1<j.length?P={kind:"select-element",elementId:j[B+1].id,x:J,y:Z,shiftKey:F.shiftKey}:P={kind:"deselect"}}_t.current={pointerId:F.pointerId,startClientX:F.clientX,startClientY:F.clientY,startPanOffset:{...It.current},movedPastThreshold:!1,pendingTap:P};try{Rt.setPointerCapture(F.pointerId)}catch{}F.preventDefault();return}const At=te();if(Xs({x:J,y:Z,shiftKey:F.shiftKey,activeArtboardElements:At,selectedElement:g||null,multiSelection:vt,onSelectionChange:zt,onMultiSelectionChange:_,stateMachine:d,dragOriginalElementsRef:v,setHoverState:it,forceUpdate:G}))return;const V=fr.shouldProtectClick(),Q=Ge.shouldPreserveSelection(F.target);if(!V&&!Q)if(Qe.current>1.001){_t.current={pointerId:F.pointerId,startClientX:F.clientX,startClientY:F.clientY,startPanOffset:{...It.current},movedPastThreshold:!1,pendingTap:null};try{Rt.setPointerCapture(F.pointerId)}catch{}F.preventDefault()}else zt(null),_([]),Me(J,Z)},[$,g,te,zt,_,O,tt,vt,d,K,jt,ot,X,Ot,Pt,Lt,e,yt,bt]),yn=u.useCallback(F=>{var ee;const Rt=e.current;if(!Rt)return;const Zt=ht.current??Rt.getBoundingClientRect(),J=(F.clientX-Zt.left)/X-xt,Z=(F.clientY-Zt.top)/X-Mt;if(m.current={x:J,y:Z},ct.current.has(F.pointerId)&&ct.current.set(F.pointerId,{x:J,y:Z,clientX:F.clientX,clientY:F.clientY}),Nt.current){const D=Nt.current,At=ct.current.get(D.pointerA),S=ct.current.get(D.pointerB);if(At&&S){const V=S.clientX-At.clientX,Q=S.clientY-At.clientY,ft=Math.hypot(V,Q)/D.startDistance,q=Math.min(Math.max(D.startUserZoom*ft,.25),8),pt=D.startCentroidClient.x-D.containerRect.left,rt=D.startCentroidClient.y-D.containerRect.top,k=(At.clientX+S.clientX)/2-D.containerRect.left,j=(At.clientY+S.clientY)/2-D.containerRect.top,P=q/D.startUserZoom,B=k-(pt-D.startPanOffset.x)*P,dt=j-(rt-D.startPanOffset.y)*P,at=e.current;if(at){const Dt=at.getBoundingClientRect(),Vt=(ee=at.parentElement)==null?void 0:ee.parentElement,ae=(Vt==null?void 0:Vt.clientWidth)??Dt.width,ye=(Vt==null?void 0:Vt.clientHeight)??Dt.height,xe=80,ce=q/Math.max(Qe.current,1e-4),de=Dt.width*ce,Oe=Dt.height*ce,ne=It.current.x,we=It.current.y,ze=Dt.left-D.containerRect.left,je=Dt.top-D.containerRect.top,Ce=ze+(B-ne),Pe=je+(dt-we),De=Math.min(Math.max(Ce,-de+xe),ae-xe),Se=Math.min(Math.max(Pe,-Oe+xe),ye-xe);se(q),Ae({x:B+(De-Ce),y:dt+(Se-Pe)})}else se(q),Ae({x:B,y:dt})}return}if(_t.current&&_t.current.pointerId===F.pointerId){const D=_t.current,At=F.clientX-D.startClientX,S=F.clientY-D.startClientY;if(!D.movedPastThreshold)if(Math.hypot(At,S)>5)D.movedPastThreshold=!0,D.pendingTap=null;else return;if(Qe.current<=1.001)return;Ae({x:D.startPanOffset.x+At,y:D.startPanOffset.y+S});return}if(d.getMode()==="pinch"&&Ht.current){const{a:D,b:At}=Ht.current,S=ct.current.get(D),V=ct.current.get(At);if(S&&V){const Q=d.updatePinch(S,V),{element:et,startData:ft}=d.getPinchContext();ks.calculatePinch({element:et,startData:ft,scale:Q.scale,rotationDelta:Q.rotationDelta,startCentroid:Q.startCentroid,currentCentroid:Q.currentCentroid,snapRotation:z?(q,pt)=>z.snapRotation(q,pt):void 0}),yt(q=>q.map(pt=>pt.id===et.id?et:pt))}F.preventDefault();return}if(f.current&&g instanceof y.TextElement){const D=g.getVisualBoundingBox(),At=g.getRotationAnchor(),S=y.RotationUtils.toRadiansInverse(g.rotation),V=J-At.x,Q=Z-At.y,et=Math.cos(S),ft=Math.sin(S),q=V*et-Q*ft,pt=V*ft+Q*et,rt=h.current;let k=0;f.current==="start"&&(rt!=null&&rt.start)?k=rt.start.textEdge.y-rt.start.center.y:f.current==="end"&&(rt!=null&&rt.end)&&(k=rt.end.textEdge.y-rt.end.center.y);const j=q+D.width/2,P=pt+k+D.height/2,B=en(g,{x:j,y:P});if(f.current==="start"?B<=I?(Pt(B),Ot(B)):(Pt(I),Lt(B),Ot(B),f.current="end"):B>=R?(Lt(B),Ot(B)):(Lt(R),Pt(B),Ot(B),f.current="start"),n.current){const dt=Math.min(R,I),at=Math.max(R,I);n.current.setSelectionRange(dt,at)}return}if(K.isActive()&&g instanceof y.PathElement){K.isDraggingHandle()?(K.updateHandle(J-g.x,Z-g.y),ot(D=>D+1)):(K.setPreviewPoint(J-g.x,Z-g.y),ot(D=>D+1));return}if(F.altKey!==U&&H(F.altKey),A){pe(J,Z,Et);return}if(d.getMode()==="drag"){const D=d._multiSelectionDragContext;if(D&&vt.length>0){const At=J-D.startX,S=Z-D.startY;D.currentElements||(D.currentElements=new Map);const V=[];D.elementsStartData.forEach(Q=>{const et=Q.element,ft=Q.startData,q=et.clone();q.x=ft.x+At,q.y=ft.y+S,D.currentElements.set(q.id,q),V.push(q)}),yt(Q=>Q.map(et=>V.find(ft=>ft.id===et.id)||et)),D.currentDelta={dx:At,dy:S},!D.startOBB&&kt.current&&(D.startOBB={...kt.current}),ot(Q=>Q+1),G({});return}}if(d.getMode()==="drag"&&g){if(d.getDragMode()==="crop-image-drag"){const q=d.getContext(),pt=q.element;if(pt instanceof y.ImageElement&&pt.isCropping){const rt=Tt.handleCropImageDrag(pt,q,J,Z),k=d._cropGroupContext,j=d._activeChildContext,P=k||j;if(P&&g instanceof y.GroupElement){const B=pt.clone();B.x=rt.x,B.y=rt.y,B.updateCrop(rt.cropX,rt.cropY,rt.cropWidth,rt.cropHeight,!1);const dt=g.clone(),at=k?k.childIndex:dt.children.findIndex(Vt=>Vt.id===P.childId);at>=0&&(dt.children[at]=B,dt.updateBoundsFromChildren(!0)),yt(Vt=>Vt.map(ae=>ae.id===dt.id?dt:ae));const Dt=d.getContext();Dt._cachedElement||(Dt._cachedElement={}),Dt._cachedElement[dt.id]=dt,j&&at>=0&&(Ut(dt.children[at]),O.update(B,X)),ot(Vt=>Vt+1)}else{const B=pt.clone();B.x=rt.x,B.y=rt.y,B.updateCrop(rt.cropX,rt.cropY,rt.cropWidth,rt.cropHeight,!1),yt(at=>at.map(Dt=>Dt.id===B.id?B:Dt));const dt=d.getContext();dt._cachedElement||(dt._cachedElement={}),dt._cachedElement[B.id]=B,O.update(B,X),ot(at=>at+1)}return}}const At=d._activeChildContext,S=te(),V=[];S.forEach(q=>{q instanceof y.GroupElement?V.push(...q.children):V.push(q)});let Q=d.updateDrag(J,Z,V);const et=At&&g instanceof y.GroupElement?g.children.find(q=>q.id===At.childId):g;if(et&&(Q=ut.snapToSpacing(Q,et,V)),At&&g instanceof y.GroupElement){const q=g.clone(),pt=q.children.findIndex(k=>k.id===At.childId);if(pt>=0){const k=q.children[pt].clone();k.x=Q.x,k.y=Q.y,q.children[pt]=k,q.updateBoundsFromChildren(!0)}yt(k=>k.map(j=>j.id===q.id?q:j));const rt=d.getContext();if(rt._cachedElement||(rt._cachedElement={}),rt._cachedElement[q.id]=q,pt>=0){const k=q.children[pt];Ut(k),O.update(k,X)}ot(k=>k+1),G({})}else{const q=d._groupDragOriginalElement,pt=g instanceof y.GroupElement&&q?q.clone():g.clone();if(pt instanceof y.GroupElement){const j=d.getContext().startData,P=Q.x-j.x,B=Q.y-j.y;pt.move(P,B)}else pt.x=Q.x,pt.y=Q.y;yt(k=>k.map(j=>j.id===pt.id?pt:j)),O.update(pt,X);const rt=d.getContext();rt._cachedElement||(rt._cachedElement={}),rt._cachedElement[pt.id]=pt}ot(q=>q+1),Y(z.getGuides());let ft;if(At&&g instanceof y.GroupElement)ft=g.children.find(q=>q.id===At.childId);else{const q=d.getContext();q._cachedElement&&g?ft=q._cachedElement[g.id]:ft=g||void 0}if(ft){const q=ut.detectSpacing(ft,V,U);nt(q)}}else if(d.getMode()==="resize"){const{dx:D,dy:At}=d.updateResize(J,Z),S=d.getResizeContext(),V=d._multiSelectionResizeContext;if(V&&vt.length>0){const k=V.startBounds,j=V.anchor;let P,B,dt,at;switch(j){case"top-left":P=k.maxX,B=k.maxY,dt=k.minX,at=k.minY;break;case"top-right":P=k.minX,B=k.maxY,dt=k.maxX,at=k.minY;break;case"bottom-left":P=k.maxX,B=k.minY,dt=k.minX,at=k.maxY;break;case"bottom-right":P=k.minX,B=k.minY,dt=k.maxX,at=k.maxY;break;default:P=k.minX,B=k.minY,dt=k.maxX,at=k.maxY}const Dt=dt+D,Vt=at+At,ae=Math.abs(dt-P),ye=Math.abs(at-B),xe=Math.abs(Dt-P),ce=Math.abs(Vt-B),de=ae>0?xe/ae:1,Oe=ye>0?ce/ye:1,ne=(de+Oe)/2,we=k.maxX-k.minX,ze=k.maxY-k.minY,je=we*ne,Ce=ze*ne;let Pe=P,De=B,Se=P,Xe=B;switch(j){case"top-left":Se=P,Xe=B,Pe=P-je,De=B-Ce;break;case"top-right":Pe=P,Xe=B,Se=P+je,De=B-Ce;break;case"bottom-left":Se=P,De=B,Pe=P-je,Xe=B+Ce;break;case"bottom-right":Pe=P,De=B,Se=P+je,Xe=B+Ce;break}if(V.elementsStartData.forEach(cn=>{const bn=cn.element,Ve=cn.startData,Dn=Ve.x-P,Ln=Ve.y-B,hn=P+Dn*ne,vn=B+Ln*ne,Te=bn.clone();if(Te instanceof y.ImageElement){Te.x=hn,Te.y=vn;const on=Te.transformData,rn=Ve.transformData;on.width=rn.width*ne,on.height=rn.height*ne}else if(Te instanceof y.GroupElement){Te.x=hn,Te.y=vn;const on=Ve.width*ne,rn=Ve.height*ne;Te.resize(j,on,rn,Ve)}else{const on=Ve.width*ne,rn=Ve.height*ne;Te.resize(j,on,rn,Ve),Te.x=hn,Te.y=vn}wt(Te)}),kt.current){const cn=(Pe+Se)/2,bn=(De+Xe)/2;kt.current={centerX:cn,centerY:bn,width:Se-Pe,height:Xe-De,rotation:kt.current.rotation}}return}const Q=S.element;if(Q instanceof y.ImageElement&&Q.isCropping&&S.handle.anchor&&S.handle.anchor.startsWith("crop-")){const k=S.handle.anchor.replace("crop-",""),j=d.getContext(),P=Tt.handleCropBoxResize(Q,k,S,j,J,Z);Rt.style.cursor=P.cursor;const B=d._cropGroupContext,dt=d._activeChildContext,at=B||dt;if(at&&g instanceof y.GroupElement){const Dt=Q.clone();Dt.x=P.x,Dt.y=P.y,Dt.rotation=P.rotation,Dt.transformData.width=P.width,Dt.transformData.height=P.height,Dt.updateCrop(P.cropX,P.cropY,P.cropWidth,P.cropHeight,!1);const Vt=g.clone(),ae=B?B.childIndex:Vt.children.findIndex(ye=>ye.id===at.childId);ae>=0&&(Vt.children[ae]=Dt,Vt.updateBoundsFromChildren(!0)),wt(Vt),dt&&ae>=0&&Ut(Vt.children[ae])}else{const Dt=Q.clone();Dt.x=P.x,Dt.y=P.y,Dt.rotation=P.rotation,Dt.transformData.width=P.width,Dt.transformData.height=P.height,Dt.updateCrop(P.cropX,P.cropY,P.cropWidth,P.cropHeight,!1),wt(Dt)}return}if(!g)return;const et=d._activeChildContext,ft=et&&g instanceof y.GroupElement,q=[];Et.forEach(k=>{k instanceof y.GroupElement?q.push(...k.children):q.push(k)});let rt=re.globalResizePipeline.executeResize({element:S.element,handle:S.handle,dx:D,dy:At,startData:S.startData,allElements:q,snapSystem:z}).element;if(d.updateResizeElement(rt),ft){const k=g.clone(),j=k.children.findIndex(P=>P.id===et.childId);j>=0&&(k.children[j]=rt,k.updateBoundsFromChildren(!0)),wt(k),j>=0&&(Ut(k.children[j]),O.update(k.children[j],X))}else wt(rt),O.update(rt,X);ot(k=>k+1),Y(z.getGuides())}else if(d.getMode()==="rotate"){Rt.style.cursor="grabbing",st||(Wt(!0),W==null||W(!0));const D=d._multiSelectionRotationContext;if(D&&vt.length>0){const rt=D.startBounds,k=d.updateRotate(J,Z,rt.centerX,rt.centerY);Gt(k),D.elementsStartData.forEach(j=>{const P=j.element,B=j.startData,dt=y.Transform.rotatePointAroundAnchor(B.x,B.y,rt.centerX,rt.centerY,k),at=P.clone();at.x=dt.x,at.y=dt.y,at.setRotation(B.rotation+k),wt(at)});return}const At=d._activeChildContext,S=At?tt:g;if(!S)return;const V=S.getBoundingBox(),Q=y.getBoundingBoxCenter(V),et=Q.x,ft=Q.y,q=d.updateRotate(J,Z,Q.x,Q.y),pt=S.clone();if(pt.setRotation(q),!(pt instanceof y.GroupElement)){const rt=pt.getBoundingBox(),k=y.getBoundingBoxCenter(rt),j=et-k.x,P=ft-k.y;pt.x+=j,pt.y+=P}if(b.current=pt,Gt(pt.rotation),me(rt=>rt+1),At&&g instanceof y.GroupElement){const rt=g.clone(),k=rt.children.findIndex(j=>j.id===At.childId);k>=0&&(rt.children[k]=pt,rt.updateBoundsFromChildren(!0)),wt(rt),k>=0&&(Ut(rt.children[k]),O.update(rt.children[k],X))}else wt(pt),O.update(pt,X);ot(rt=>rt+1)}else{if(vt.length>0&&w.current){const S=w.current,V=16/X,Q=[{x:S.minX,y:S.minY,anchor:"top-left",cursor:"nwse-resize"},{x:S.maxX,y:S.minY,anchor:"top-right",cursor:"nesw-resize"},{x:S.minX,y:S.maxY,anchor:"bottom-left",cursor:"nesw-resize"},{x:S.maxX,y:S.maxY,anchor:"bottom-right",cursor:"nwse-resize"}],et=S.rotation||0,ft=Q.map(j=>{if(et!==0){const P=-et*Math.PI/180,B=Math.cos(P),dt=Math.sin(P),at=j.x-S.centerX,Dt=j.y-S.centerY;return{x:S.centerX+(at*B-Dt*dt),y:S.centerY+(at*dt+Dt*B),anchor:j.anchor,cursor:j.cursor}}return j});for(const j of ft){const P=J-j.x,B=Z-j.y;if(Math.sqrt(P*P+B*B)<=V){Rt.style.cursor=j.cursor,it({type:"multi-selection-handle",data:j});return}}const q=18/X;if(Math.sqrt(Math.pow(J-S.rotationHandleX,2)+Math.pow(Z-S.rotationHandleY,2))<=q){Rt.style.cursor="grab",it({type:"multi-selection-rotation-handle",data:null});return}let rt=J,k=Z;if(et!==0){const j=et*Math.PI/180,P=Math.cos(j),B=Math.sin(j),dt=J-S.centerX,at=Z-S.centerY;rt=S.centerX+(dt*P-at*B),k=S.centerY+(dt*B+at*P)}if(rt>=S.minX&&rt<=S.maxX&&k>=S.minY&&k<=S.maxY){Rt.style.cursor="move",it({type:"multi-selection-bounds",data:S});return}}if(F.altKey){let S=null;const V=te();for(let Q=V.length-1;Q>=0;Q--){const et=V[Q];if(et.visible!==!1){if(et instanceof y.GroupElement)for(let ft=et.children.length-1;ft>=0;ft--){const q=et.children[ft];if(q.visible===!1)continue;const pt=q.getVisualBoundingBox();if(J>=pt.x&&J<=pt.x+pt.width&&Z>=pt.y&&Z<=pt.y+pt.height){S=q;break}}else{const ft=et.getVisualBoundingBox();if(J>=ft.x&&J<=ft.x+ft.width&&Z>=ft.y&&Z<=ft.y+ft.height){S=et;break}}if(S)break}}if(S){const Q=[];V.forEach(ft=>{ft instanceof y.GroupElement?Q.push(...ft.children):Q.push(ft)});const et=ut.detectSpacing(S,Q,!0);nt(et)}else nt([])}else mt.length>0&&nt([]);const D=tt||g;if(D&&D.visible!==!1)if(D instanceof y.ImageElement&&D.isCropping){const S=D.hitTestCropHandle(J,Z,X);if(S){const Q=y.getCursorForWorldPosition(S.worldX,S.worldY,D.x,D.y,S.type,D.rotation,S.anchor);Rt.style.cursor=Q,it({type:"crop-handle",data:S});return}const V=O.hitTestResize(J,Z,X);if(V){Rt.style.cursor=V.cursor,it({type:"resize-handle",data:V});return}if(D.hitTest(J,Z)){Rt.style.cursor="move",it({type:"element",data:D});return}}else{if(O.hitTestRotation(J,Z,X)){Rt.style.cursor="grab",it({type:"rotation-handle",data:null});return}const S=O.hitTestResize(J,Z,X);if(S){Rt.style.cursor=S.cursor,it({type:"resize-handle",data:S});return}if(D.hitTest(J,Z)){Rt.style.cursor="move",it({type:"element",data:D});return}}if(tt&&g instanceof y.GroupElement)for(let S=g.children.length-1;S>=0;S--){const V=g.children[S];if(!(V.visible===!1||V.id===tt.id)&&V.hitTest(J,Z)){Rt.style.cursor="pointer",it({type:"group-sibling",data:V});return}}const At=te();for(let S=At.length-1;S>=0;S--)if(At[S].visible!==!1&&!At[S].locked&&At[S].hitTest(J,Z)){if(!Nn(At[S],J,Z,bt))continue;Rt.style.cursor="pointer",it({type:"element",data:At[S]});return}Rt.style.cursor="default",it({type:null,data:null})}},[d,g,te,wt,O,A,z,vt,kt,tt,K,ot,X,xt,Mt,it,ut,nt,mt,Tt,se,Ae]),nn=u.useCallback(F=>{var J,Z,ee,D,At;if(F.target.releasePointerCapture(F.pointerId),ct.current.delete(F.pointerId),Nt.current&&(F.pointerId===Nt.current.pointerA||F.pointerId===Nt.current.pointerB)){Nt.current=null,ct.current.clear();return}if(_t.current&&_t.current.pointerId===F.pointerId){const S=_t.current;_t.current=null,S.movedPastThreshold||(((J=S.pendingTap)==null?void 0:J.kind)==="select-element"?(zt(S.pendingTap.elementId),_([])):((Z=S.pendingTap)==null?void 0:Z.kind)==="deselect"&&(zt(null),_([])));return}if(d.getMode()==="pinch"&&Ht.current){const{a:S,b:V}=Ht.current;if(F.pointerId===S||F.pointerId===V){const et=d.getContext().element,ft=Ft.current??void 0;et&&jt(ft,et),d.end(),Ht.current=null,Ft.current=null,ct.current.clear();return}}if(f.current&&(f.current=null),K.isActive()&&K.isDraggingHandle()){const S=K.isClosingPath();if(K.finishDraggingHandle(),S&&g instanceof y.PathElement){const V=g.clone();jt(g,V)}ot(V=>V+1);return}if(A){ve(_);return}v.current&&d.getMode()==="drag"&&(v.current.forEach((V,Q)=>{const et=Et.find(ft=>ft.id===Q);et&&(V.x!==et.x||V.y!==et.y||V instanceof y.GroupElement&&et instanceof y.GroupElement&&JSON.stringify(V.children.map(q=>({x:q.x,y:q.y})))!==JSON.stringify(et.children.map(q=>({x:q.x,y:q.y}))))&&jt(V,et)}),v.current=null);const Rt=e.current;if(Rt&&(Rt.style.cursor="default"),z.clearGuides(),z.clearSnapState(),Y([]),ut.clearIndicators(),nt([]),d._cropGroupContext&&delete d._cropGroupContext,d._activeChildContext){if(tt&&g instanceof y.GroupElement){const S=d.getContext(),et=(S._cachedElement&&S._cachedElement[g.id]||g).children.find(ft=>ft.id===tt.id);et&&(Ut(et),O.update(et,X))}delete d._activeChildContext}if(d._multiSelectionResizeContext&&delete d._multiSelectionResizeContext,Et.forEach(S=>{if(S instanceof y.CustomTransform&&S._lockedLineCount!==void 0){const V=S.clone();V._lockedLineCount=void 0,wt(V)}}),d._multiSelectionDragContext){const S=d._multiSelectionDragContext;if(S.startOBB&&S.currentDelta){const{dx:V,dy:Q}=S.currentDelta,et=S.startOBB;kt.current={...et,centerX:et.centerX+V,centerY:et.centerY+Q}}delete d._multiSelectionDragContext}if(d._multiSelectionRotationContext){if(d.getMode()==="rotate"&&vt.length>0&&kt.current){const S=kt.current;kt.current={...S,rotation:S.rotation+d._multiSelectionRotationContext.currentRotation||S.rotation}}delete d._multiSelectionRotationContext}const Zt=d.getContext();if(Zt._cachedElement&&delete Zt._cachedElement,d._pendingChildSelection){const S=d._pendingChildSelection;let V=!0;if(g instanceof y.GroupElement){const Q=d._groupDragOriginalElement;Q&&(V=!(Math.abs(g.x-Q.x)>.1||Math.abs(g.y-Q.y)>.1))}V&&(Ut(S),O.update(S,X),ot(Q=>Q+1)),delete d._pendingChildSelection}if(d._pendingTextEditMode){const S=d._pendingTextEditMode,V=Et.find(et=>et.id===S.elementId);!(V&&(Math.abs(V.x-S.originalX)>.1||Math.abs(V.y-S.originalY)>.1))&&V instanceof y.TextElement&&!(V instanceof y.ImageElement)&&!(V instanceof y.ShapeElement)&&Re(V,S.clickX,S.clickY),delete d._pendingTextEditMode}if(Bt.current){const S=Bt.current,V=Yt.current,Q=Et.find(pt=>pt.id===S),et=(ee=v.current)==null?void 0:ee.get(S),ft=!!(Q&&et&&(Math.abs(Q.x-et.x)>.1||Math.abs(Q.y-et.y)>.1)),q=V?Math.hypot((F.clientX-(((D=ht.current)==null?void 0:D.left)??0))/X-xt-V.x,(F.clientY-(((At=ht.current)==null?void 0:At.top)??0))/X-Mt-V.y)>4/Math.max(X,1e-4):!1;if(!ft&&!q&&S===(g==null?void 0:g.id)&&V){const pt=te(),rt=[];for(let j=pt.length-1;j>=0;j--){const P=pt[j];P.visible!==!1&&P.hitTest(V.x,V.y)&&Nn(P,V.x,V.y,bt)&&rt.push(P)}const k=rt.findIndex(j=>j.id===S);k!==-1&&k+1<rt.length?zt(rt[k+1].id):zt(null)}Bt.current=null,Yt.current=null}d._groupDragOriginalElement&&delete d._groupDragOriginalElement,d.end(),Wt(!1),W==null||W(!1),b.current=null,me(0),G({})},[d,z,A,_,vt,kt,tt,g,Ut,O,e,K,ot,X,xt,Mt,W,Re,Et,zt,jt,bt]),Pn=u.useCallback(F=>{if(!g)return;const Rt=e.current;if(!Rt)return;const Zt=ht.current??Rt.getBoundingClientRect(),J=(F.clientX-Zt.left)/X-xt,Z=(F.clientY-Zt.top)/X-Mt;if(g.hitTest(J,Z)){if(g instanceof y.GroupElement){const at=g.hitTestChild(J,Z);if(at){if(!(tt&&tt.id===at.id))return;if(at instanceof y.TextElement&&!(at instanceof y.GroupElement)&&!(at instanceof y.ShapeElement)){const Vt=at.getVisualBoundingBox(),ae=y.RotationUtils.toRadiansInverse(at.rotation),ye=at.getRotationAnchor(),xe=J-ye.x,ce=Z-ye.y,de=Math.cos(ae),Oe=Math.sin(ae),ne=xe*de-ce*Oe,we=xe*Oe+ce*de,ze=ne+Vt.width/2,je=we+Vt.height/2,Ce=en(at,{x:ze,y:je}),Pe=Vt.height+16,De=6;ke({x:Zt.left+(Vt.x+xt)*X-De,y:Zt.top+(Vt.y+Mt)*X-De,width:Math.max(20,Vt.width*X),height:Math.max(Pe*X,50)}),ge(lt(at));const Se=at.getRichText().clone();p.current=Se,_e(Se);const Xe=at.getRichText().getStyleAt(Math.max(0,at.text.length-1));Fe({...at.getDefaultStyle(),...Xe}),Ot(Ce),Pt(Ce),Lt(Ce),Ue(!0),x.current=Date.now(),M.current=at.id;return}}return}if(g instanceof y.PathElement){K.editPath(g),ot(at=>at+1);return}if(g instanceof y.ShapeElement||!(g instanceof y.TextElement))return;const ee=g.getVisualBoundingBox(),D=y.RotationUtils.toRadiansInverse(g.rotation),At=g.getRotationAnchor(),S=J-At.x,V=Z-At.y,Q=Math.cos(D),et=Math.sin(D),ft=S*Q-V*et,q=S*et+V*Q,pt=ft+ee.width/2,rt=q+ee.height/2,k=en(g,{x:pt,y:rt}),j=ee.height+16,P=6;ke({x:Zt.left+(ee.x+xt)*X-P,y:Zt.top+(ee.y+Mt)*X-P,width:Math.max(20,ee.width*X),height:Math.max(j*X,50)}),ge(lt(g));const B=g.getRichText().clone();p.current=B,_e(B);const dt=g.getRichText().getStyleAt(Math.max(0,g.text.length-1));Fe({...g.getDefaultStyle(),...dt}),Ot(k),Pt(k),Lt(k),Ue(!0),x.current=Date.now()}},[g,wt,tt,O,K,ot,X,xt,Mt,ke,ge,_e,Fe,Ot,Pt,Lt,Ue,Ut,ie,lt]),fn=u.useCallback(F=>{const Rt=e.current;if(!Rt||d.getMode()==="idle")return;const J=ht.current??Rt.getBoundingClientRect();if(F.clientX>=J.left&&F.clientX<=J.right&&F.clientY>=J.top&&F.clientY<=J.bottom)return;const ee={clientX:F.clientX,clientY:F.clientY,altKey:F.altKey,shiftKey:F.shiftKey,ctrlKey:F.ctrlKey,metaKey:F.metaKey,bubbles:!0,cancelable:!0,currentTarget:Rt,target:Rt,nativeEvent:F,type:"pointermove",pointerId:F.pointerId||0,pointerType:F.pointerType||"mouse",preventDefault:()=>F.preventDefault(),stopPropagation:()=>F.stopPropagation(),isPropagationStopped:()=>!1,isDefaultPrevented:()=>F.defaultPrevented};yn(ee)},[yn,e,d]),xn=u.useCallback(F=>{const Rt=e.current;if(!Rt)return;const Zt=F.target,J=Zt?Rt.contains(Zt):!1,Z=ct.current.has(F.pointerId)||Nt.current!==null||_t.current!==null||Ht.current!==null||d.isInteracting();if(!J&&!Z)return;const ee={clientX:F.clientX,clientY:F.clientY,currentTarget:Rt,target:Rt,pointerId:F.pointerId||0,pointerType:F.pointerType||"mouse"};nn(ee)},[nn,e,d]);return u.useEffect(()=>(document.addEventListener("pointermove",fn),document.addEventListener("pointerup",xn),()=>{document.removeEventListener("pointermove",fn),document.removeEventListener("pointerup",xn)}),[fn,xn]),{handlePointerDown:zn,handlePointerMove:yn,handlePointerUp:nn,handleDoubleClick:Pn}}function Bn(t){if(t.transformType!=="custom")return t.text;const n=t.getVisualBoundingBox().width,o=t.getText();return y.wrapText(o,n,t.fontSize,t.fontFamily,t.bold,t.italic).join(`
|
|
13
|
-
`)}function Fs(t){const{canvasRef:e,inputRef:n,editingChildIdRef:o,editRichTextRef:r,selectionAnchorRef:i,cursorStartTimeRef:s,lastMultiClickTimeRef:l,multiClickSelectionRef:a,editPositionUpdateTimerRef:c,draggingSelectionHandleRef:f,repositioningCursorRef:h,editModeEnteredAtRef:m,lastTouchTargetRef:v,MULTI_CLICK_DEBOUNCE:b,EDIT_MODE_BLUR_DEBOUNCE:M,isEditing:p,editText:x,editRichText:w,cursorPosition:E,selectionStart:C,selectionEnd:N,selectedId:$,selectedElement:T,activeChildElement:L,elements:R,zoom:I,paddingOffsetX:st,paddingOffsetY:A,setIsEditing:U,setEditText:g,setEditRichText:tt,setCursorPosition:Et,setSelectionStart:vt,setSelectionEnd:kt,setEditPosition:X,setCurrentFormattingStyle:xt,setCursorAnimationFrame:Mt,setHandlesVersion:mt,setElements:bt,onElementUpdate:Ot,onTextSelectionChange:Pt,transformHandles:Lt,updateActiveChild:Wt}=t,he=u.useCallback((d,O,z)=>{const ut=e.current;if(!ut)return;const K=ut.getBoundingClientRect(),Tt=d.getVisualBoundingBox(),wt=y.RotationUtils.toRadiansInverse(d.rotation),jt=d.getRotationAnchor(),zt=O-jt.x,_=z-jt.y,W=Math.cos(wt),ie=Math.sin(wt),Ut=zt*W-_*ie,te=zt*ie+_*W,Me=Ut+Tt.width/2,pe=te+Tt.height/2,ve=en(d,{x:Me,y:pe}),Re=Tt.height+16,ke=6;X({x:K.left+(Tt.x+st)*I-ke,y:K.top+(Tt.y+A)*I-ke,width:Math.max(20,Tt.width*I),height:Math.max(Re*I,50)}),g(Bn(d));const ge=d.getRichText().clone();r.current=ge,tt(ge);const _e=d.getRichText().getStyleAt(Math.max(0,d.text.length-1));xt({...d.getDefaultStyle(),..._e}),Et(ve),vt(ve),kt(ve),U(!0),m.current=Date.now()},[I,X,g,tt,xt,Et,vt,kt,U]),Gt=u.useCallback(d=>{if(!p||!w)return;const O=Math.min(C,N),z=Math.max(C,N);if(O===z){const ut=w.clone(),K=ut.getText().length;ut.applyStyle(0,K,d),r.current=ut,tt(ut),g(ut.getText()),xt(Tt=>({...Tt,...d}))}else{const ut=w.clone();ut.applyStyle(O,z,d),r.current=ut,tt(ut),g(ut.getText()),xt(K=>({...K,...d}))}},[p,w,C,N]),me=u.useCallback(()=>{if(!p||!w||!T)return null;const d=Math.min(C,N),O=Math.max(C,N);return d===O?d===0?T instanceof y.TextElement?T.getDefaultStyle():{}:w.getStyleAt(Math.max(0,d-1)):w.getStyleAt(d)},[p,w,C,N,T]),H=u.useCallback(d=>{if(!p||!w||!T)return;const O=me(),K=!{...T instanceof y.TextElement?T.getDefaultStyle():{},...O}[d];Gt({[d]:K})},[p,w,T,me,Gt]),Y=u.useCallback(()=>{if(!p)return;const d=r.current||w;if(T&&d){const O=o.current;if(O&&T instanceof y.GroupElement){const z=T.clone(),ut=z.children.findIndex(Tt=>Tt.id===O);if(ut>=0){const Tt=z.children[ut];Tt instanceof y.TextElement&&Tt.setRichText(d),z.updateBoundsFromChildren(!0)}Ot(z);const K=z.children[ut];K&&(Wt(K),Lt.update(K,I),mt(Tt=>Tt+1))}else if(T instanceof y.TextElement){const z=T.clone();z.setRichText(d),Ot(z),Lt.update(z,I),mt(ut=>ut+1)}}a.current=null,U(!1),g(""),tt(null),r.current=null,xt(null),o.current=null},[p,x,w,r,T,Ot,Lt,Wt,I]),nt=u.useCallback(()=>{if(Date.now()-l.current<b){if(n.current){n.current.focus();const z=a.current;z&&n.current.setSelectionRange(z.start,z.end)}return}setTimeout(()=>{var wt,jt,zt;if(Date.now()-m.current<M){(wt=n.current)==null||wt.focus();return}if(h.current){h.current=!1,(jt=n.current)==null||jt.focus(),n.current&&n.current.setSelectionRange(C,N);return}let K=document.activeElement,Tt=!1;for(;K;){const _=K.classList,W=K.getAttribute("data-slot");if(W&&(W.includes("popover")||W.includes("dialog"))){Tt=!0;break}if(K.hasAttribute("data-preserve-selection")){Tt=!0;break}if(_&&(_.contains("toolbar")||_.contains("toolbar-items")||_.contains("toolbar-btn")||_.contains("toolbar-btn-sm")||_.contains("toolbar-btn-icon")||_.contains("toolbar-color")||_.contains("toolbar-label")||_.contains("toolbar-select")||_.contains("toolbar-select-sm")||_.contains("toolbar-group")||_.contains("toolbar-scroll")||_.contains("toolbar-color-label")||_.contains("toolbar-color-square")||_.contains("color-picker-dropdown")||_.contains("text-color-panel")||_.contains("tooltip-wrapper")||_.contains("font-dropdown-with-label")||_.contains("font-family-select-button")||_.contains("more-menu-btn")||_.contains("more-menu-toolbar")||_.contains("font-drawer-overlay")||_.contains("font-drawer-content")||_.contains("font-drawer-handle")||_.contains("font-drawer-handle-bar")||_.contains("font-dropdown-list-container")||_.contains("font-dropdown-search")||_.contains("font-search-input")||_.contains("font-category-filters")||_.contains("font-category-btn")||_.contains("font-grid-option")||_.contains("font-section")||_.contains("font-section-header")||_.contains("font-section-used")||_.contains("font-section-header-used")||_.contains("font-dropdown-list-grid")||_.contains("font-dropdown-list-grid-used")||_.contains("font-preview")||_.contains("font-name-label")||_.contains("font-size-slider-container")||_.contains("font-size-slider")||_.contains("font-size-icon-small")||_.contains("font-size-icon-large")||_.contains("font-icon-toggle")||_.contains("font-dropdown-empty")||_.contains("vaul-drawer-wrapper")||_.contains("vaul-overlay"))){Tt=!0;break}K=K.parentElement}if(!Tt&&v.current)for(K=v.current;K;){const _=K.classList,W=K.getAttribute("data-slot");if(W&&(W.includes("popover")||W.includes("dialog"))){Tt=!0;break}if(K.hasAttribute("data-preserve-selection")){Tt=!0;break}if(_&&(_.contains("toolbar")||_.contains("toolbar-items")||_.contains("toolbar-btn")||_.contains("toolbar-btn-sm")||_.contains("toolbar-btn-icon")||_.contains("toolbar-color")||_.contains("toolbar-label")||_.contains("toolbar-select")||_.contains("toolbar-select-sm")||_.contains("toolbar-group")||_.contains("toolbar-scroll")||_.contains("toolbar-color-label")||_.contains("toolbar-color-square")||_.contains("color-picker-dropdown")||_.contains("text-color-panel")||_.contains("tooltip-wrapper")||_.contains("font-dropdown-with-label")||_.contains("font-family-select-button")||_.contains("more-menu-btn")||_.contains("more-menu-toolbar")||_.contains("vaul-drawer-wrapper")||_.contains("vaul-overlay"))){Tt=!0;break}K=K.parentElement}if(!Tt)Y();else{const _=C,W=N;(zt=n.current)==null||zt.focus(),n.current&&n.current.setSelectionRange(_,W)}},0)},[Y,C,N]),ot=u.useCallback(d=>{const O=d.currentTarget;if(d.key==="Enter"&&(d.metaKey||d.ctrlKey))d.preventDefault(),Y();else if(d.key==="Escape")d.preventDefault(),d.stopPropagation(),U(!1),g(""),tt(null),r.current=null,xt(null),o.current=null;else if((d.metaKey||d.ctrlKey)&&d.key.toLowerCase()==="b")d.preventDefault(),H("bold");else if((d.metaKey||d.ctrlKey)&&d.key.toLowerCase()==="i")d.preventDefault(),H("italic");else if((d.metaKey||d.ctrlKey)&&d.key.toLowerCase()==="u")d.preventDefault(),H("underline");else if(d.key==="ArrowLeft"||d.key==="ArrowRight")setTimeout(()=>{const z=O.selectionStart;Et(z),vt(z),kt(O.selectionEnd),i.current=z},0);else if(d.key==="ArrowUp"||d.key==="ArrowDown"){if(T&&T instanceof y.TextElement){d.preventDefault();const z=d.key==="ArrowUp"?"up":"down",ut=zi(T,E,z);Et(ut),vt(ut),kt(ut),i.current=ut,O.setSelectionRange(ut,ut)}}else(d.key==="Home"||d.key==="End")&&setTimeout(()=>{const z=O.selectionStart;Et(z),vt(z),kt(O.selectionEnd),i.current=z},0)},[Y,H,Et,vt,kt,i,E,T]);u.useEffect(()=>{p&&(s.current=performance.now())},[p,E,s]),u.useEffect(()=>{if(!p)return;let d,O=0;const z=33,ut=K=>{K-O>=z&&(Mt(Tt=>(Tt+1)%1e3),O=K),d=requestAnimationFrame(ut)};return d=requestAnimationFrame(ut),()=>cancelAnimationFrame(d)},[p]);const it=u.useRef(!1);u.useEffect(()=>{if(p&&!it.current&&n.current){n.current.focus();const d=x.length;Et(d),vt(d),kt(d),n.current.setSelectionRange(d,d)}it.current=p},[p,x]);const yt=u.useRef(null),G=(d,O)=>d===O?!0:!d||!O?!1:d.color===O.color&&d.fontFamily===O.fontFamily&&d.fontSize===O.fontSize&&d.bold===O.bold&&d.italic===O.italic&&d.underline===O.underline&&d.strikethrough===O.strikethrough;return u.useEffect(()=>{if(!p||!w)return;const d=Math.min(C,N),O=Math.max(C,N);if(d===O){let z=null;if(d>0)z=w.getStyleAt(d-1);else{const ut=R.find(K=>K.id===$);ut instanceof y.TextElement&&(z=ut.getDefaultStyle())}z&&!G(z,yt.current)&&(yt.current=z,xt(z))}},[p,w,C,N,$]),u.useEffect(()=>{if(!p||!n.current)return;const d=n.current;(d.selectionStart!==C||d.selectionEnd!==N)&&(C!==N?d.setSelectionRange(C,N):d.setSelectionRange(E,E))},[x,p,E,C,N]),u.useEffect(()=>{const d=R.find(O=>O.id===$);if(!(!p||!d||!e.current||!n.current))return c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{let O=d;if(o.current&&d instanceof y.GroupElement){const jt=d.children.find(zt=>zt.id===o.current);jt&&(O=jt)}if(!(O instanceof y.TextElement))return;const z=O.clone();w&&z.setRichText(w);const ut=z.getVisualBoundingBox(),K=e.current.getBoundingClientRect(),Tt=ut.height+16,wt=6;if(X({x:K.left+(ut.x+st)*I-wt,y:K.top+(ut.y+A)*I-wt,width:Math.max(20,ut.width*I),height:Math.max(Tt*I,50)}),o.current&&d instanceof y.GroupElement){const jt=d.clone(),zt=jt.children.findIndex(_=>_.id===o.current);zt>=0&&(jt.children[zt]=z,jt.updateBoundsFromChildren(!0)),bt(_=>_.map(W=>W.id===jt.id?jt:W)),Lt.update(z,I)}else bt(jt=>jt.map(zt=>zt.id===z.id?z:zt)),Lt.update(z,I);mt(jt=>jt+1)},50),()=>{c.current&&clearTimeout(c.current)}},[x,w,p,$,I]),u.useEffect(()=>{if(!p||!n.current)return;const d=n.current,O=()=>{if(f.current||Date.now()-l.current<b)return;const K=d.selectionStart||0,Tt=d.selectionEnd||0;Et(wt=>wt===Tt?wt:Tt),vt(wt=>wt===K?wt:K),kt(wt=>wt===Tt?wt:Tt),Pt==null||Pt()};d.addEventListener("click",O),d.addEventListener("keyup",O),d.addEventListener("select",O),d.addEventListener("mouseup",O);const z=()=>{document.activeElement===d&&O()};return document.addEventListener("selectionchange",z),O(),()=>{d.removeEventListener("click",O),d.removeEventListener("keyup",O),d.removeEventListener("select",O),d.removeEventListener("mouseup",O),document.removeEventListener("selectionchange",z)}},[p]),u.useEffect(()=>{const d=O=>{const z=O.target;if(z.tagName==="INPUT"||z.tagName==="TEXTAREA"||O.key!=="Enter"||p||!e.current)return;const ut=e.current.getBoundingClientRect();if(L&&L instanceof y.TextElement&&!(L instanceof y.GroupElement)&&!(L instanceof y.ImageElement)&&!(L instanceof y.ShapeElement)){O.preventDefault();const K=L.getVisualBoundingBox(),Tt=K.height+16,wt=6;X({x:ut.left+(K.x+st)*I-wt,y:ut.top+(K.y+A)*I-wt,width:Math.max(200,K.width*I),height:Math.max(Tt*I,50)}),g(Bn(L)),U(!0),m.current=Date.now(),o.current=L.id;return}if(T&&T instanceof y.TextElement&&!(T instanceof y.GroupElement)&&!(T instanceof y.ImageElement)&&!(T instanceof y.ShapeElement)){O.preventDefault();const K=T.getVisualBoundingBox(),Tt=K.height+16,wt=6;X({x:ut.left+(K.x+st)*I-wt,y:ut.top+(K.y+A)*I-wt,width:Math.max(200,K.width*I),height:Math.max(Tt*I,50)}),g(Bn(T)),U(!0),m.current=Date.now()}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[T,L,p]),{handleTextEditComplete:Y,handleTextEditBlur:nt,handleTextKeyDown:ot,applyFormattingToSelection:Gt,getSelectionStyle:me,toggleFormattingProperty:H,enterTextEditMode:he,getWrappedTextForEditing:Bn}}const hr=u.forwardRef(({elements:t,artboards:e,artboardManager:n,selectedId:o,multiSelection:r,onElementUpdate:i,setElements:s,executeElementUpdate:l,onSelectionChange:a,onMultiSelectionChange:c,onActiveChildChange:f,onTextSelectionChange:h,onHoverChange:m,onRotationStateChange:v,onCropModeEnter:b,hideHandles:M=!1,canvasRef:p,width:x,height:w,zoom:E=1,offsetX:C=0,offsetY:N=0,viewPadding:$=1,artboardBorderRadius:T=0,fixedMargin:L,fixedMarginX:R,fixedMarginY:I,showRotationHandle:st=!0,canvasCutouts:A,pieceGuides:U,pieceFocus:g,focusedPieceRect:tt},Et)=>{const{resolvedTheme:vt}=Ge.useTheme(),kt=u.useRef(null),X=p||kt,xt=u.useRef(null),Mt=u.useRef(!1),mt=u.useRef(0),bt=u.useRef(0),Ot=u.useRef(0),Pt=u.useRef(!1),Lt=u.useRef(0),Wt=u.useRef(null),he=u.useRef(0),Gt=u.useRef(null),me=u.useRef({start:null,end:null}),H=u.useRef(null),Y=u.useRef(null),nt=u.useRef(null),ot=u.useRef(null),it=400,yt=300,G=50,d=200,O=u.useMemo(()=>{if(!g||g==="spread")return null;const St=(U==null?void 0:U.pieces)??[];if(St.length<=1)return null;const gt=St.find(Kt=>Kt.id===g.pieceId);return gt?{x:gt.x,y:gt.y,width:gt.width,height:gt.height}:null},[g,U]),z=tt!==void 0?tt:O,ut=u.useMemo(()=>{if(z)return z;const St=(U==null?void 0:U.pieces)??[];if(St.length===1){const gt=St[0];return{x:gt.x,y:gt.y,width:gt.width,height:gt.height}}return null},[z,U]),{isTouchDevice:K,canvasSize:Tt,lastTouchTargetRef:wt,effectiveViewPadding:jt,paddedCanvasWidth:zt,paddedCanvasHeight:_,paddingOffsetX:W,paddingOffsetY:ie,zoomInvariantBorderRadius:Ut}=Qi({width:x,height:w,zoom:E,viewPadding:$,artboardBorderRadius:T,fixedMargin:L,fixedMarginX:R,fixedMarginY:I,artboards:e,artboardManager:n,focusedPieceRect:z}),{snapGuides:te,setSnapGuides:Me,spacingIndicators:pe,setSpacingIndicators:ve,isAltKeyPressed:Re,setIsAltKeyPressed:ke,isRotating:ge,setIsRotating:_e,setRotationStartAngle:Ue,currentRotation:Fe,setCurrentRotation:lt,setRotatingElementVersion:ht}=Ji(),{renderVersion:ct,forceRender:Ht,handlesVersion:Ft,setHandlesVersion:Ct,forceUpdate:Bt,cursorAnimationFrame:Yt,setCursorAnimationFrame:Nt}=ts({elements:t}),[_t]=u.useState(()=>new re.TransformHandles),[le]=u.useState(()=>new re.ArtboardRenderer({showBorder:!1,showLabel:!1})),[se]=u.useState(()=>new re.AlignmentSnapSystem({enabled:!0,showGuides:!0})),[He]=u.useState(()=>new re.SpacingSystem({enabled:!0,showLabels:!0})),[Ae]=u.useState(()=>{const St=new re.InteractionStateMachine;return St.setResizePipeline(re.globalResizePipeline),St.setSnapHandler(se),St});u.useEffect(()=>{le.setOptions({borderRadius:Ut})},[Ut,le]),u.useEffect(()=>{const St=tt!==void 0?tt:O;se.setExtraSnapRects(St?[{id:"focused-piece",...St}]:[])},[se,tt,O]);const Qe=u.useRef(t);Qe.current=t;const It=t.find(St=>St.id===o),zn=u.useRef(It);zn.current=It;const[yn,nn]=u.useState("");u.useEffect(()=>{var gt;if(!o)return;const St=t.find(Kt=>Kt.id===o);if(St)if(St instanceof y.TextElement){const Kt=((gt=St.text)==null?void 0:gt.slice(0,40))||"empty";nn(`Selected text element: ${Kt}`)}else St instanceof y.ImageElement?nn("Selected image element"):St instanceof y.GroupElement?nn("Selected group"):nn("Selected element")},[o,t]);const Pn=u.useRef(n);Pn.current=n;const fn=u.useRef(new Map);u.useEffect(()=>{const St=gt=>{const Kt=gt,Qt=Pn.current.getActiveArtboardId(),Jt=fn.current.get(Qt)||[],be=[];return Jt.forEach(Ee=>{Ee instanceof y.GroupElement?be.push(...Ee.children):be.push(Ee)}),se.snapDimensions(Kt,be,Kt.startData)};return re.globalResizePipeline.addHook("afterResize",St),()=>{re.globalResizePipeline.removeHook("afterResize",St)}},[se]);const{cropController:xn}=Ki(),{penTool:F,penCursor:Rt}=$i({selectedElement:It}),{isEditing:Zt,setIsEditing:J,editText:Z,setEditText:ee,editPosition:D,setEditPosition:At,cursorPosition:S,setCursorPosition:V,selectionStart:Q,setSelectionStart:et,selectionEnd:ft,setSelectionEnd:q,cursorOpacityRef:pt,cursorStartTimeRef:rt,selectionAnchorRef:k,didDragSelectRef:j,editRichText:P,setEditRichText:B,editRichTextRef:dt,currentFormattingStyle:at,setCurrentFormattingStyle:Dt}=Zi({selectedElement:It,ref:Et});u.useEffect(()=>{const St=Date.now()-Lt.current,gt=Wt.current;gt&&St<yt?(Q!==gt.start||ft!==gt.end)&&(V(gt.cursor),et(gt.start),q(gt.end),xt.current&&xt.current.setSelectionRange(gt.start,gt.end)):gt&&St>=yt&&(Wt.current=null)},[Q,ft,S]);const{isMarqueeSelecting:Vt,marqueeStart:ae,marqueeEnd:ye,marqueePreviewSelection:xe,startMarqueeSelection:ce,updateMarqueeSelection:de,finishMarqueeSelection:Oe}=ji(),{multiSelectionGroupBoundsRef:ne,multiSelectionOBBRef:we}=qi(r),{activeChildElement:ze,updateActiveChild:je,editingChildIdRef:Ce}=Gi({elements:t,selectedElement:It,transformHandles:_t,onActiveChildChange:f}),{hoverState:Pe,setHoverState:De}=Ui({onHoverChange:m}),Se=u.useMemo(()=>{const St=new Map;return t.forEach(gt=>{const Kt=n.getArtboardIdForElement(gt.id);St.has(Kt)||St.set(Kt,[]),St.get(Kt).push(gt)}),St},[t,n]);fn.current=Se;const Xe=u.useCallback(()=>{const St=n.getActiveArtboardId();return Se.get(St)||[]},[Se,n]);u.useEffect(()=>{const St=Qt=>{if(!Zt){if(F.isActive()&&It instanceof y.PathElement){if(Qt.key==="Escape"){Qt.preventDefault(),F.finishPath();const Jt=It.clone();l(It,Jt),Ct(be=>be+1);return}else if(Qt.key==="Backspace"||Qt.key==="Delete"){Qt.preventDefault(),F.deleteLastPoint(),Ct(Jt=>Jt+1);return}}Qt.altKey&&ke(!0)}},gt=Qt=>{Qt.altKey||ke(!1)},Kt=Qt=>{(!Qt.relatedTarget||!Qt.relatedTarget.ownerDocument)&&ke(!1)};return window.addEventListener("keydown",St),window.addEventListener("keyup",gt),window.addEventListener("blur",Kt),()=>{window.removeEventListener("keydown",St),window.removeEventListener("keyup",gt),window.removeEventListener("blur",Kt)}},[F,It,l,Ct,Zt]),u.useEffect(()=>{if(!X.current||!H.current||Ae.getMode()==="drag"||Ae.getMode()==="resize")return;const{x:gt,y:Kt}=H.current;if(Re){let Qt=null;const Jt=Xe();for(let be=Jt.length-1;be>=0;be--){const Ee=Jt[be];if(Ee.visible!==!1){if(Ee instanceof y.GroupElement)for(let ue=Ee.children.length-1;ue>=0;ue--){const qt=Ee.children[ue];if(qt.visible===!1)continue;const Xt=qt.getVisualBoundingBox();if(gt>=Xt.x&><=Xt.x+Xt.width&&Kt>=Xt.y&&Kt<=Xt.y+Xt.height){Qt=qt;break}}else{const ue=Ee.getVisualBoundingBox();if(gt>=ue.x&><=ue.x+ue.width&&Kt>=ue.y&&Kt<=ue.y+ue.height){Qt=Ee;break}}if(Qt)break}}if(Qt){const be=[];Jt.forEach(ue=>{ue instanceof y.GroupElement?be.push(...ue.children):be.push(ue)});const Ee=He.detectSpacing(Qt,be,!0);ve(Ee)}}else ve([])},[Re,Xe,He,Ae]);const cn=u.useRef(null);u.useEffect(()=>{const St=t.find(Kt=>Kt.id===o),gt=ze||St;if(gt){const Kt=gt.getBoundingBox(),Qt=`${gt.id}-${Kt.x}-${Kt.y}-${Kt.width}-${Kt.height}-${gt.rotation}`;cn.current!==Qt&&(cn.current=Qt,_t.update(gt,E),Ct(Jt=>Jt+1))}},[o,ze,_t,E,t]);const{handleTextEditBlur:bn,handleTextKeyDown:Ve,applyFormattingToSelection:Dn,getSelectionStyle:Ln,toggleFormattingProperty:hn,enterTextEditMode:vn,getWrappedTextForEditing:Te}=Fs({canvasRef:X,inputRef:xt,editingChildIdRef:Ce,editRichTextRef:dt,selectionAnchorRef:k,cursorStartTimeRef:rt,lastMultiClickTimeRef:Lt,multiClickSelectionRef:Wt,editPositionUpdateTimerRef:ot,draggingSelectionHandleRef:Gt,repositioningCursorRef:Mt,editModeEnteredAtRef:Ot,lastTouchTargetRef:wt,MULTI_CLICK_DEBOUNCE:yt,EDIT_MODE_BLUR_DEBOUNCE:d,isEditing:Zt,editText:Z,editRichText:P,cursorPosition:S,selectionStart:Q,selectionEnd:ft,selectedId:o,selectedElement:It,activeChildElement:ze,elements:t,zoom:E,paddingOffsetX:W,paddingOffsetY:ie,setIsEditing:J,setEditText:ee,setEditRichText:B,setCursorPosition:V,setSelectionStart:et,setSelectionEnd:q,setEditPosition:At,setCurrentFormattingStyle:Dt,setCursorAnimationFrame:Nt,setHandlesVersion:Ct,setElements:s,onElementUpdate:i,onTextSelectionChange:h,transformHandles:_t,updateActiveChild:je}),{handlePointerDown:on,handlePointerMove:rn,handlePointerUp:ao,handleDoubleClick:mr}=_s({canvasRef:X,inputRef:xt,repositioningCursorRef:Mt,lastClickTimeRef:mt,clickCountRef:bt,lastProcessedClickTimeRef:he,lastMultiClickTimeRef:Lt,multiClickSelectionRef:Wt,skipDragSelectionRef:Pt,draggingSelectionHandleRef:Gt,selectionHandlePositionsRef:me,lastMousePosRef:H,dragOriginalElementsRef:Y,rotatingElementRef:nt,editingChildIdRef:Ce,editRichTextRef:dt,editModeEnteredAtRef:Ot,multiSelectionGroupBoundsRef:ne,MULTI_CLICK_THRESHOLD:it,MULTI_CLICK_DEBOUNCE:yt,CLICK_DEDUP_THRESHOLD:G,isEditing:Zt,editText:Z,isTouchDevice:K,selectionStart:Q,selectionEnd:ft,isRotating:ge,isMarqueeSelecting:Vt,isAltKeyPressed:Re,selectedElement:It,activeChildElement:ze,elements:t,multiSelection:r,multiSelectionOBBRef:we,zoom:E,paddingOffsetX:W,paddingOffsetY:ie,spacingIndicators:pe,focusedPieceRect:ut,setCursorPosition:V,setSelectionStart:et,setSelectionEnd:q,setIsRotating:_e,setRotationStartAngle:Ue,setCurrentRotation:lt,setRotatingElementVersion:ht,setIsAltKeyPressed:ke,setSnapGuides:Me,setSpacingIndicators:ve,setHandlesVersion:Ct,setHoverState:De,setElements:s,forceUpdate:Bt,stateMachine:Ae,transformHandles:_t,snapSystem:se,spacingSystem:He,penTool:F,cropController:xn,onElementUpdate:i,executeElementUpdate:l,onSelectionChange:a,onMultiSelectionChange:c,onRotationStateChange:v,onCropModeEnter:b,updateActiveChild:je,getActiveArtboardElements:Xe,startMarqueeSelection:ce,updateMarqueeSelection:de,finishMarqueeSelection:Oe,enterTextEditMode:vn,setEditPosition:At,setEditText:ee,setEditRichText:B,setIsEditing:J,setCurrentFormattingStyle:Dt,getWrappedTextForEditing:Te});Cs({canvasRef:X,elements:t,elementsByArtboard:Se,artboards:e,artboardManager:n,artboardRenderer:le,selectedId:o,selectedElement:It,activeChildElement:ze,editingChildIdRef:Ce,transformHandles:_t,stateMachine:Ae,canvasSize:Tt,paddedCanvasWidth:zt,paddedCanvasHeight:_,paddingOffsetX:W,paddingOffsetY:ie,zoom:E,zoomInvariantBorderRadius:Ut,effectiveViewPadding:jt,showRotationHandle:st,isRotating:ge,currentRotation:Fe,hoverState:Pe,isEditing:Zt,editText:Z,editRichText:P,cursorPosition:S,selectionStart:Q,selectionEnd:ft,cursorOpacityRef:pt,cursorStartTimeRef:rt,isTouchDevice:K,selectionHandlePositionsRef:me,multiClickSelectionRef:Wt,lastMultiClickTimeRef:Lt,MULTI_CLICK_DEBOUNCE:yt,snapGuides:te,spacingIndicators:pe,isAltKeyPressed:Re,multiSelection:r,multiSelectionOBBRef:we,multiSelectionGroupBoundsRef:ne,isMarqueeSelecting:Vt,marqueeStart:ae,marqueeEnd:ye,marqueePreviewSelection:xe,penTool:F,handlesVersion:Ft,hideHandles:M,resolvedTheme:vt,cursorAnimationFrame:Yt,renderVersion:ct,pieceGuides:U,focusedPieceId:g&&g!=="spread"?g.pieceId:null,focusedPieceRect:z}),u.useImperativeHandle(Et,()=>({applyTextFormatting:St=>{Dn(St)},toggleFormattingProperty:St=>{hn(St)},isEditingText:()=>Zt,isRotating:()=>ge,getSelectionStyle:()=>Ln(),getZoom:()=>E,forceRender:Ht,getEditingState:()=>({isEditing:Zt,editText:Z,cursorPosition:S,selectionStart:Q,selectionEnd:ft}),getCropState:()=>({isCropping:It instanceof y.ImageElement&&It.isCropping,elementId:(It==null?void 0:It.id)||null}),getPaddingOffset:()=>({x:W,y:ie})}),[Dn,hn,Zt,ge,Ln,E,Ht,Z,S,Q,ft,It,W,ie]);const yr=u.useMemo(()=>{if(!A||A.length===0)return;const St=zt*E,gt=_*E,Kt=`M 0 0 h ${St} v ${gt} h ${-St} Z`,Qt=A.map(Jt=>{if(Jt.kind==="rect"||Jt.kind==="roundedRect"){const be=(W+Jt.x)*E,Ee=(ie+Jt.y)*E,ue=Jt.width*E,qt=Jt.height*E;if(Jt.kind==="roundedRect"){const Xt=(Jt.rx??Jt.ry??0)*E,oe=(Jt.ry??Jt.rx??0)*E;if(Xt>0||oe>0)return[`M ${be+Xt} ${Ee}`,`h ${ue-2*Xt}`,`a ${Xt} ${oe} 0 0 1 ${Xt} ${oe}`,`v ${qt-2*oe}`,`a ${Xt} ${oe} 0 0 1 ${-Xt} ${oe}`,`h ${-(ue-2*Xt)}`,`a ${Xt} ${oe} 0 0 1 ${-Xt} ${-oe}`,`v ${-(qt-2*oe)}`,`a ${Xt} ${oe} 0 0 1 ${Xt} ${-oe}`,"Z"].join(" ")}return`M ${be} ${Ee} h ${ue} v ${qt} h ${-ue} Z`}return""}).filter(Boolean);if(Qt.length!==0)return`path(evenodd, "${Kt} ${Qt.join(" ")}")`},[A,zt,_,W,ie,E]);return $t.jsxs($t.Fragment,{children:[$t.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",borderWidth:0},children:yn}),$t.jsx("canvas",{role:"application","aria-label":"Design editor canvas. Use mouse or touch to select, move, and resize elements.",ref:X,onPointerDown:on,onPointerMove:rn,onPointerUp:ao,onPointerCancel:ao,onDoubleClick:mr,style:{display:"block",background:U?"transparent":"var(--color-canvas-bg)",width:`${zt*E}px`,height:`${_*E}px`,cursor:F.isActive()&&It instanceof y.PathElement?Rt:void 0,position:"absolute",left:`${C}px`,top:`${N}px`,touchAction:"none",clipPath:yr}}),Zt&&(()=>{let St=It;if(Ce.current&&It instanceof y.GroupElement){const qt=It.children.find(Xt=>Xt.id===Ce.current);qt&&(St=qt)}const gt=St instanceof y.TextElement?St:null,Kt=(gt==null?void 0:gt.fontSize)||24,Qt=(gt==null?void 0:gt.fontFamily)||"Arial",Jt=(gt==null?void 0:gt.bold)||!1,be=(gt==null?void 0:gt.italic)||!1,Ee=(gt==null?void 0:gt.textAlign)||"center",ue=$t.jsx("textarea",{ref:xt,"data-preserve-selection":"",value:Z,onChange:qt=>{const Xt=qt.target.value;if(!P){const Be=y.RichText.fromPlainText(Xt,{});dt.current=Be,B(Be),ee(Xt);const wn=qt.target.selectionEnd;V(wn),et(qt.target.selectionStart),q(qt.target.selectionEnd);return}const oe=Z,Je=P.clone();let Ie=0;for(;Ie<oe.length&&Ie<Xt.length&&oe[Ie]===Xt[Ie];)Ie++;let Le=0;for(;Le<oe.length-Ie&&Le<Xt.length-Ie&&oe[oe.length-1-Le]===Xt[Xt.length-1-Le];)Le++;const We=Ie,sn=oe.length-Le,an=Xt.substring(Ie,Xt.length-Le);if(sn>We&&Je.delete(We,sn),an.length>0){let Be;at?Be=at:We>0?Be=Je.getStyleAt(We-1):It instanceof y.TextElement?Be=It.getDefaultStyle():Be={},Je.insert(We,an,Be)}dt.current=Je,B(Je),ee(Xt);const Ne=qt.target.selectionEnd;V(Ne),et(qt.target.selectionStart),q(qt.target.selectionEnd),k.current=Ne;const tn=qt.target;setTimeout(()=>{tn&&document.activeElement===tn&&tn.setSelectionRange(Ne,Ne)},0)},onBlur:bn,onKeyDown:Ve,onPointerDown:qt=>{if(qt.preventDefault(),!It||!(It instanceof y.TextElement)||!X.current)return;const Xt=Date.now();if(Xt-he.current<G)return;he.current=Xt,Xt-Lt.current>=yt&&(Wt.current=null);const oe=X.current.getBoundingClientRect(),Je=(qt.clientX-oe.left)/E-W,Ie=(qt.clientY-oe.top)/E-ie,Le=It.getVisualBoundingBox(),We=It.getRotationAnchor(),sn=y.RotationUtils.toRadiansInverse(It.rotation),an=Je-We.x,Ne=Ie-We.y,tn=Math.cos(sn),Be=Math.sin(sn),wn=an*tn-Ne*Be,jn=an*Be+Ne*tn,Vn=wn+Le.width/2,dn=jn+Le.height/2,Ye=en(It,{x:Vn,y:dn});Xt-mt.current<it?bt.current+=1:bt.current=1,mt.current=Xt;const Ke=Z;if(j.current=!1,bt.current>=3)qt.preventDefault(),Lt.current=Xt,Wt.current={start:0,end:Ke.length,cursor:Ke.length},Pt.current=!0,bt.current=0,k.current=0,V(Ke.length),et(0),q(Ke.length),xt.current&&(xt.current.focus(),xt.current.setSelectionRange(0,Ke.length));else if(bt.current===2){qt.preventDefault();const $e=cr(Ke,Ye);Lt.current=Xt,Wt.current={start:$e.start,end:$e.end,cursor:$e.end},Pt.current=!0,k.current=$e.start,V($e.end),et($e.start),q($e.end),xt.current&&(xt.current.focus(),xt.current.setSelectionRange($e.start,$e.end))}else Wt.current=null,k.current=Ye,et(Ye),V(Ye),q(Ye),xt.current&&(xt.current.focus(),xt.current.setSelectionRange(Ye,Ye)),Pt.current=!1},onPointerMove:qt=>{if(qt.buttons!==1)return;if(Gt.current&&It instanceof y.TextElement&&X.current){const Cn=X.current.getBoundingClientRect(),Ke=(qt.clientX-Cn.left)/E-W,$e=(qt.clientY-Cn.top)/E-ie,lo=It.getVisualBoundingBox(),co=It.getRotationAnchor(),uo=y.RotationUtils.toRadiansInverse(It.rotation),fo=Ke-co.x,ho=$e-co.y,po=Math.cos(uo),go=Math.sin(uo),xr=fo*po-ho*go,br=fo*go+ho*po,qe=me.current;let Wn=0;Gt.current==="start"&&(qe!=null&&qe.start)?Wn=qe.start.textEdge.y-qe.start.center.y:Gt.current==="end"&&(qe!=null&&qe.end)&&(Wn=qe.end.textEdge.y-qe.end.center.y);const vr=xr+lo.width/2,wr=br+Wn+lo.height/2,Ze=en(It,{x:vr,y:wr});if(Gt.current==="start"?Ze<=ft?(et(Ze),V(Ze)):(et(ft),q(Ze),V(Ze),Gt.current="end"):Ze>=Q?(q(Ze),V(Ze)):(q(Q),et(Ze),V(Ze),Gt.current="start"),xt.current){const Cr=Math.min(Q,ft),Er=Math.max(Q,ft);xt.current.setSelectionRange(Cr,Er)}return}if(Pt.current||!It||!(It instanceof y.TextElement)||!X.current)return;const Xt=X.current.getBoundingClientRect(),oe=(qt.clientX-Xt.left)/E-W,Je=(qt.clientY-Xt.top)/E-ie,Ie=It.getVisualBoundingBox(),Le=It.getRotationAnchor(),We=y.RotationUtils.toRadiansInverse(It.rotation),sn=oe-Le.x,an=Je-Le.y,Ne=Math.cos(We),tn=Math.sin(We),Be=sn*Ne-an*tn,wn=sn*tn+an*Ne,jn=Be+Ie.width/2,Vn=wn+Ie.height/2,dn=en(It,{x:jn,y:Vn}),Ye=k.current;if(Ye!==dn&&(j.current=!0),q(dn),V(dn),et(Ye),xt.current){const Cn=Math.min(Ye,dn),Ke=Math.max(Ye,dn);xt.current.setSelectionRange(Cn,Ke)}},onPointerUp:()=>{Gt.current&&(Gt.current=null)},onClick:()=>{j.current=!1,Pt.current=!1},onSelect:()=>{},autoFocus:!0,spellCheck:!1,style:{position:"fixed",left:`${D.x}px`,top:`${D.y}px`,width:`${D.width}px`,height:`${D.height||50}px`,fontSize:`${Kt*E}px`,fontFamily:`"${Qt}", Arial, sans-serif`,fontWeight:Jt?700:400,fontStyle:be?"italic":"normal",textAlign:Ee,lineHeight:1.2,opacity:0,zIndex:1001,resize:"none",border:"2px solid transparent",outline:"none",padding:"4px",margin:"0",overflow:"hidden",color:"transparent",background:"transparent",caretColor:"transparent",whiteSpace:"pre-wrap",wordBreak:"normal",overflowWrap:"normal"}});return kr.createPortal(ue,document.body)})()]})});hr.displayName="CanvasEditor";const zs=.25,js=8,Vs=.1,Ws=4,$s=.001,Gs=({className:t,style:e,width:n,height:o,zoom:r,fitPadding:i=.95,interactive:s=!1,artboardBorderRadius:l=0,fixedMargin:a,maxHeight:c,showRotationHandle:f=!0,enableShortcuts:h=!0,canvasCutouts:m,pieceGuides:v,pieceFocus:b})=>{var Fe;const{canvasEditorRef:M,canvasRef:p,elements:x,artboards:w,artboardManager:E,handleElementUpdate:C,setElements:N,executeElementUpdate:$}=Ge.useEditor(),{zoom:T,setZoom:L,panOffset:R,setPanOffset:I,isPanning:st,setIsPanning:A,userZoom:U,setUserZoom:g,resetUserView:tt}=Ge.useViewportContext(),{selectedId:Et,multiSelection:vt,handleSelectionChange:kt,setMultiSelection:X,handleActiveChildChange:xt,setHoveredElementId:Mt,hideHandles:mt}=Ge.useSelectionContext(),{setTextSelectionVersion:bt,setExpandedPanelType:Ot}=Ge.useToolStateContext(),Pt=u.useCallback(()=>{Ot("crop")},[Ot]),Lt=u.useRef(null),[Wt,he]=u.useState(0),[Gt,me]=u.useState(0),[H,Y]=u.useState(!1),nt=u.useRef(0),ot=u.useRef(!1),[it,yt]=u.useState(!1),G=u.useRef(null);Oi({enabled:h});const d=E.getActiveArtboard(),O=u.useCallback(lt=>{if(!(s||lt.ctrlKey||lt.metaKey))return;lt.preventDefault();const ct=Lt.current;if(!ct)return;const Ht=ct.getBoundingClientRect(),Ft=lt.clientX-Ht.left,Ct=lt.clientY-Ht.top,Bt=-lt.deltaY*$s;if(s){const Yt=Wt,Nt=Math.min(Math.max(Yt*(1+Bt),Vs),Ws);if(Nt===Yt)return;const _t=Nt/Yt,le=Ft-(Ft-R.x)*_t,se=Ct-(Ct-R.y)*_t;he(Nt),I({x:le,y:se})}else{const Yt=U,Nt=Math.min(Math.max(Yt*(1+Bt),zs),js);if(Nt===Yt)return;const _t=Nt/Yt,le=Ft-(Ft-R.x)*_t,se=Ct-(Ct-R.y)*_t;g(Nt),I({x:le,y:se})}},[s,Wt,R,I,U,g]);u.useEffect(()=>{const lt=Lt.current;if(lt)return lt.addEventListener("wheel",O,{passive:!1}),()=>lt.removeEventListener("wheel",O)},[O]),u.useEffect(()=>{if(!s)return;const lt=ct=>{ct.code==="Space"&&!ct.repeat&&yt(!0)},ht=ct=>{ct.code==="Space"&&(yt(!1),G.current=null)};return window.addEventListener("keydown",lt),window.addEventListener("keyup",ht),()=>{window.removeEventListener("keydown",lt),window.removeEventListener("keyup",ht)}},[s]);const z=u.useCallback(lt=>{if(!s)return;const ht=lt.button===1,ct=it&<.button===0;(ht||ct)&&(lt.preventDefault(),lt.target.setPointerCapture(lt.pointerId),A(!0),G.current={x:lt.clientX,y:lt.clientY,panX:R.x,panY:R.y})},[s,it,R,A]),ut=u.useCallback(lt=>{if(!st||!G.current)return;const ht=lt.clientX-G.current.x,ct=lt.clientY-G.current.y;I({x:G.current.panX+ht,y:G.current.panY+ct})},[st,I]),K=u.useCallback(lt=>{st&&(lt&<.target.releasePointerCapture(lt.pointerId),A(!1),G.current=null)},[st,A]);u.useEffect(()=>{if(!s||!st)return;const lt=()=>{A(!1),G.current=null};return window.addEventListener("pointerup",lt),()=>window.removeEventListener("pointerup",lt)},[s,st,A]);const Tt=u.useMemo(()=>{if(!b||!v)return null;const lt=v.pieces??[];if(lt.length<=1)return null;if(b==="spread")return d?{x:0,y:0,width:d.width,height:d.height}:null;const ht=lt.find(ct=>ct.id===b.pieceId);return ht?{x:ht.x,y:ht.y,width:ht.width,height:ht.height}:null},[b,v,d]),wt=_i(Tt);u.useEffect(()=>{if(r!==void 0){he(r);return}if(!Lt.current||!d)return;let lt=0;const ht=()=>{if(!Lt.current||!d)return;const Ft=Lt.current.clientWidth;if(Ft===0)return;let Ct=d.width,Bt=d.height;if(b&&b!=="spread"&&v){const _t=v.pieces??[];if(_t.length>1){const le=_t.find(se=>se.id===b.pieceId);le&&(Ct=le.width,Bt=le.height)}}let Yt,Nt=!1;if(a!==void 0){const _t=Ft-a*2,le=Math.min(_t/Ct,1);if(wt&&c!==void 0){const se=c-a*2,He=Math.min(se/Bt,1);Yt=Math.min(le,He),Nt=He<=le}else if(Yt=le,c!==void 0&&Bt*Yt+a*2>c){const Qe=(c-a*2)/Bt;Yt=Math.min(Yt,Qe,1),Nt=!0}}else Yt=Math.min(Ft*i/Ct,1);he(Yt),me(Ft),Y(Nt)};let ct=!1;ot.current?ht():lt=requestAnimationFrame(()=>{lt=requestAnimationFrame(()=>{ct||(ht(),ot.current=!0)})});const Ht=new ResizeObserver(()=>{ht()});return Ht.observe(Lt.current),()=>{ct=!0,cancelAnimationFrame(lt),Ht.disconnect()}},[r,d,i,a,c,b,v,wt]);const jt=Wt>0&&U>0?Wt*U:Wt;u.useEffect(()=>{nt.current=jt,L(jt)},[jt,L]);const zt=u.useRef(null);u.useEffect(()=>{const lt=wt&&"id"in wt?wt.id??null:null;lt!==zt.current&&(zt.current!==null&&tt(),zt.current=lt)},[wt,tt]),u.useEffect(()=>{s&&T!==nt.current&&T>0&&(he(T),nt.current=T)},[s,T]);const _=wt?wt.width:(d==null?void 0:d.width)??0,W=wt?wt.height:(d==null?void 0:d.height)??0,ie=_*jt,Ut=W*jt,te=_*Wt;let Me=d?a!==void 0?Ut+a*2:Ut/i:0;c!==void 0&&Me>c&&(Me=c);let pe=a,ve=a;const Re=((Fe=Lt.current)==null?void 0:Fe.clientWidth)||Gt;a!==void 0&&H&&Re>0&&te>0&&(pe=(Re-te)/2);const ke=Me,ge=u.useRef({w:0,h:0});u.useEffect(()=>{const lt=Lt.current;if(!lt)return;ge.current={w:lt.clientWidth,h:lt.clientHeight};const ht=new ResizeObserver(ct=>{const Ht=ct[0];Ht&&(ge.current={w:Ht.contentRect.width,h:Ht.contentRect.height})});return ht.observe(lt),()=>ht.disconnect()},[]),u.useEffect(()=>{if(s)return;if(U<=1.001){(R.x!==0||R.y!==0)&&I({x:0,y:0});return}const lt=ge.current.w,ht=ge.current.h;if(lt===0||ht===0||ie===0||Ut===0)return;const ct=.25*Math.min(ie,lt),Ht=.25*Math.min(Ut,ht),Ft=ct-(pe??0)-ie,Ct=lt-ct-(pe??0),Bt=Ht-(ve??0)-Ut,Yt=ht-Ht-(ve??0),Nt=Math.max(Ft,Math.min(Ct,R.x)),_t=Math.max(Bt,Math.min(Yt,R.y));(Nt!==R.x||_t!==R.y)&&I({x:Nt,y:_t})},[s,U,R,ie,Ut,pe,ve,I]);const _e=s?{position:"relative",width:n?`${n}px`:"100%",height:o?`${o}px`:"100%",overflow:"hidden",cursor:st?"grabbing":it?"grab":"default",touchAction:"none",overscrollBehaviorX:"none",...e}:{position:"relative",width:n?`${n}px`:"100%",height:o?`${o}px`:ke>0?`${ke}px`:"auto",overflow:"hidden",touchAction:"none",overscrollBehaviorX:"none",...e},Ue=s?{position:"absolute",left:0,top:0,transform:`translate(${R.x}px, ${R.y}px)`,transformOrigin:"0 0",pointerEvents:st?"none":"auto"}:{transform:R.x!==0||R.y!==0?`translate(${R.x}px, ${R.y}px)`:void 0,transformOrigin:"0 0",willChange:R.x!==0||R.y!==0?"transform":void 0};return $t.jsxs("div",{ref:Lt,className:t,style:_e,onPointerDown:s?z:void 0,onPointerMove:s?ut:void 0,onPointerUp:s?K:void 0,onPointerLeave:s?K:void 0,onPointerCancel:s?K:void 0,children:[$t.jsx("div",{style:Ue,children:$t.jsx(hr,{ref:M,elements:x,artboards:w,artboardManager:E,selectedId:Et,multiSelection:vt,onElementUpdate:C,setElements:N,executeElementUpdate:$,onSelectionChange:kt,onMultiSelectionChange:X,onActiveChildChange:xt,onTextSelectionChange:()=>bt(lt=>lt+1),onHoverChange:Mt,onCropModeEnter:Pt,hideHandles:mt,canvasRef:p,width:d==null?void 0:d.width,height:d==null?void 0:d.height,zoom:jt,viewPadding:i,artboardBorderRadius:l,fixedMargin:a,fixedMarginX:pe,fixedMarginY:ve,showRotationHandle:f,canvasCutouts:m,pieceGuides:v,pieceFocus:b,focusedPieceRect:wt})}),!s&&(U<.999||U>1.001)&&$t.jsx(Ns,{userZoom:U,onSetZoom:lt=>{if(lt<=1.001){tt();return}const ht=Lt.current;if(!ht){g(lt);return}const ct=ht.getBoundingClientRect(),Ht=ct.width/2,Ft=ct.height/2,Ct=lt/Math.max(U,1e-4);g(lt),I({x:Ht-(Ht-R.x)*Ct,y:Ft-(Ft-R.y)*Ct})}})]})},Us=[1,2,4,8];function Ns({userZoom:t,onSetZoom:e}){const n=Math.round(t*100),[o,r]=u.useState(!1);return $t.jsxs("div",{style:{position:"absolute",bottom:12,right:12,zIndex:30,pointerEvents:"auto"},"data-preserve-selection":!0,children:[o&&$t.jsxs($t.Fragment,{children:[$t.jsx("div",{onClick:()=>r(!1),style:{position:"fixed",inset:0,zIndex:29}}),$t.jsx("div",{role:"menu",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:31,minWidth:96,backdropFilter:"blur(6px)"},className:"flex flex-col rounded-2xl border border-border/40 bg-popover/95 p-1 shadow-lg",children:Us.map(i=>{const s=i*100,l=Math.abs(t-i)<.05;return $t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{r(!1),e(i)},className:l?"rounded-xl bg-foreground/10 px-4 py-2 text-base font-medium tabular-nums text-foreground text-right":"rounded-xl px-4 py-2 text-base font-medium tabular-nums text-foreground/80 hover:bg-foreground/5 hover:text-foreground text-right",children:[s,"%"]},i)})})]}),$t.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/40 bg-popover/85 p-1 shadow-sm",style:{backdropFilter:"blur(6px)"},children:$t.jsxs("button",{type:"button",onClick:()=>r(i=>!i),"aria-haspopup":"menu","aria-expanded":o,"aria-label":"Zoom level",className:"rounded-full px-4 py-1.5 text-base font-medium tabular-nums text-foreground/80 hover:text-foreground",style:{minWidth:72},children:[n,"%"]})})]})}const Kn=y.createLogger("useArtboards"),Ks=()=>{const{artboards:t,artboardManager:e,refreshArtboards:n,setSelectedId:o,setMultiSelection:r}=Ge.useEditor(),i=e.getActiveArtboardId(),s=e.getActiveArtboard(),l=u.useMemo(()=>t.map(p=>{const w=e.getElementsOnArtboard(p.id).length;return{id:p.id,name:p.name,x:p.x,y:p.y,width:p.width,height:p.height,backgroundColor:p.backgroundColor,clipShape:p.clipShape,isActive:p.id===i,elementCount:w}}),[t,e,i]),a=u.useMemo(()=>{if(!s)return null;const x=e.getElementsOnArtboard(s.id).length;return{id:s.id,name:s.name,x:s.x,y:s.y,width:s.width,height:s.height,backgroundColor:s.backgroundColor,clipShape:s.clipShape,isActive:!0,elementCount:x}},[s,e]),c=u.useCallback((p=1200,x=1200,w)=>{const E={width:p,height:x,...w};e.createArtboard(E),n()},[e,n]),f=u.useCallback(p=>{e.deleteArtboard(p),n()},[e,n]),h=u.useCallback(p=>{const x=t.find(w=>w.id===p);if(!x){Kn.warn(`[useArtboards] Artboard ${p} not found`);return}e.createArtboard({width:x.width,height:x.height,name:`${x.name} Copy`,backgroundColor:x.backgroundColor,clipShape:x.clipShape}),n()},[t,e,n]),m=u.useCallback((p,x)=>{const w=t.find(E=>E.id===p);if(!w){Kn.warn(`[useArtboards] Artboard ${p} not found`);return}w.name=x,n()},[t,n]),v=u.useCallback((p,x)=>{const w=t.find(E=>E.id===p);if(!w){Kn.warn(`[useArtboards] Artboard ${p} not found`);return}x.name!==void 0&&(w.name=x.name),x.width!==void 0&&(w.width=x.width),x.height!==void 0&&(w.height=x.height),x.backgroundColor!==void 0&&(w.backgroundColor=x.backgroundColor),x.clipShape!==void 0&&(w.clipShape=x.clipShape),"distressTexture"in x&&(w.distressTexture=x.distressTexture?{...x.distressTexture}:void 0),n()},[t,n]),b=u.useCallback(p=>{o(null),r([]),e.setActiveArtboard(p),n()},[e,n,o,r]),M=u.useCallback((p,x)=>{p!==x&&(p<0||p>=t.length||x<0||x>=t.length||([...t],e.reorderArtboards(p,x),n()))},[t,e,n]);return{artboards:t,artboardsInfo:l,activeArtboard:s,activeArtboardId:i,activeArtboardInfo:a,createArtboard:c,deleteArtboard:f,duplicateArtboard:h,renameArtboard:m,updateArtboard:v,selectArtboard:b,reorderArtboards:M,count:t.length}},qs=y.createLogger("useExport");function Zs(){const{artboards:t,artboardManager:e,elements:n,canvasRef:o}=Ge.useEditor(),[r,i]=u.useState(!1),[s,l]=u.useState(!1),[a,c]=u.useState([]),[f,h]=u.useState({}),[m,v]=u.useState({totalExports:0,avgExportTime:0,isWorkerActive:!1}),b=u.useRef(0),M=u.useRef(null),p=re.ExportManager.supportsWorkerExport(),x=u.useCallback(async(L,R={})=>{const I=t.find(A=>A.id===L);if(!I)throw new Error(`[useExport] Artboard ${L} not found`);if(!o.current)throw new Error("[useExport] Canvas ref not available");i(!0);const st={artboardId:L,artboardName:I.name,status:"rendering",progress:0,timestamp:Date.now()};c(A=>[...A,st]);try{const A=Date.now(),U=E.current,g=e.getElementsOnArtboard(L),tt=U.filter(kt=>g.includes(kt.id)),Et=await re.ExportManager.exportArtboardToDataURL(I,tt,o.current,{format:R.format||"png",scale:R.scale||3,transparentBackground:R.transparentBackground??!0,...R}),vt=Date.now()-A;return c(kt=>kt.map(X=>X.artboardId===L?{...X,status:"complete",progress:100,dataUrl:Et,timestamp:Date.now()}:X)),h(kt=>({...kt,[L]:Et})),v(kt=>({totalExports:kt.totalExports+1,avgExportTime:(kt.avgExportTime*kt.totalExports+vt)/(kt.totalExports+1),isWorkerActive:p})),Et}catch(A){throw c(U=>U.map(g=>g.artboardId===L?{...g,status:"error",error:A,timestamp:Date.now()}:g)),A}finally{i(!1)}},[t,e,n,o,p]),w=u.useCallback(async(L={})=>{i(!0);try{const R=t.map(async A=>{const U=await x(A.id,L);return{id:A.id,dataUrl:U}}),I=await Promise.all(R),st={};for(const{id:A,dataUrl:U}of I)st[A]=U;return st}finally{i(!1)}},[t,x]),E=u.useRef(n);E.current=n;const C=u.useCallback(async(L,R={})=>{const I=t.find(st=>st.id===L);if(!I)throw new Error(`[useExport] Artboard ${L} not found`);if(!o.current)throw new Error("[useExport] Canvas ref not available");i(!0);try{const st=E.current,A=e.getElementsOnArtboard(L),U=st.filter(tt=>A.includes(tt.id));return await re.ExportManager.exportArtboardToBlob(I,U,o.current,{format:R.format||"png",scale:R.scale||3,transparentBackground:R.transparentBackground??!0,...R})}finally{i(!1)}},[t,e,n,o]),N=u.useCallback(async(L={})=>{i(!0);try{const R=t.map(async A=>{const U=await C(A.id,L);return{id:A.id,blob:U}}),I=await Promise.all(R),st={};for(const{id:A,blob:U}of I)st[A]=U;return st}finally{i(!1)}},[t,C]),$=u.useCallback(()=>{b.current++,l(!1),M.current=null},[]),T=u.useCallback(L=>{b.current++;const R=b.current;M.current=L,l(!0);const{artboardIds:I,interval:st=500,scale:A=3,format:U="png",onChange:g}=L,tt=I?t.filter(X=>I.includes(X.id)):t,Et=()=>b.current===R,vt=async()=>{try{const X=tt.map(async mt=>{const bt=await x(mt.id,{scale:A,format:U,transparentBackground:!0});return{id:mt.id,dataUrl:bt}}),xt=await Promise.all(X),Mt={};for(const{id:mt,dataUrl:bt}of xt)Mt[mt]=bt;h(mt=>({...mt,...Mt})),g&&g(Mt)}catch(X){qs.error("[useExport] Continuous export error:",X)}};(async()=>{for(await vt();Et()&&(await new Promise(X=>setTimeout(X,st)),!!Et());)await vt()})()},[t,x]);return u.useEffect(()=>()=>{$()},[$]),{exportArtboard:x,exportArtboardAsBlob:C,exportAllArtboards:w,exportAllArtboardsAsBlobs:N,startContinuousExport:T,stopContinuousExport:$,isExporting:r,isContinuousExporting:s,progress:a,latestExports:f,supportsWorkerExport:p,workerStats:m}}const Oo=y.createLogger("AutoExportManager"),pr={enabled:!0,debounceMs:100,maxWaitMs:1e3};class Qs{constructor(e={}){this.onExportCallback=null,this.onExportScheduledCallback=null,this.revision=0,this.lastExportedRevision=-1,this.stats={totalExports:0,skippedExports:0,lastExportTime:null,avgExportInterval:0},this.exportTimestamps=[],this.config={...pr,...e},this.debouncedExport=mo.debounce(()=>this.performExport(),this.config.debounceMs,{maxWait:this.config.maxWaitMs,leading:!1,trailing:!0})}scheduleExport(){const e=Date.now();!this.config.enabled||(this.revision++,(this.stats.lastExportTime?e-this.stats.lastExportTime:1/0)<200)||(this.onExportScheduledCallback&&this.onExportScheduledCallback(),this.debouncedExport())}async forceExport(){this.debouncedExport.cancel(),this.revision++,await this.performExport()}async performExport(){if(!this.config.enabled)return;if(this.revision===this.lastExportedRevision){this.stats.skippedExports++;return}const e=this.revision,n=Date.now();if(this.exportTimestamps.push(n),this.exportTimestamps.length>10&&this.exportTimestamps.shift(),this.exportTimestamps.length>1){const o=[];for(let r=1;r<this.exportTimestamps.length;r++)o.push(this.exportTimestamps[r]-this.exportTimestamps[r-1]);this.stats.avgExportInterval=o.reduce((r,i)=>r+i,0)/o.length}this.stats.totalExports++,this.stats.lastExportTime=n,this.onExportCallback?setTimeout(async()=>{const o=this.onExportCallback;if(o){try{await o()}catch(r){Oo.error("Export failed:",r)}this.lastExportedRevision=e,this.revision>e&&this.config.enabled&&this.debouncedExport()}},0):Oo.warn("No export callback registered")}onExport(e){this.onExportCallback=e}onExportScheduled(e){this.onExportScheduledCallback=e}updateConfig(e){const n={...this.config};n.enabled&&e.enabled===!1&&this.debouncedExport.flush(),this.config={...this.config,...e},(n.debounceMs!==this.config.debounceMs||n.maxWaitMs!==this.config.maxWaitMs)&&(this.debouncedExport.cancel(),this.debouncedExport=mo.debounce(()=>this.performExport(),this.config.debounceMs,{maxWait:this.config.maxWaitMs,leading:!1,trailing:!0}))}getStats(){return{...this.stats}}resetStats(){this.stats={totalExports:0,skippedExports:0,lastExportTime:null,avgExportInterval:0},this.exportTimestamps=[]}resetChangeDetection(){this.lastExportedRevision=-1}destroy(){this.debouncedExport.cancel(),this.onExportCallback=null,this.onExportScheduledCallback=null,this.lastExportedRevision=-1}}function Js({width:t=800,height:e=600,style:n}){return $t.jsxs("div",{className:"canvas-skeleton",style:{width:t,height:e,backgroundColor:"var(--divider)",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden",...n},children:[$t.jsx("div",{style:{position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent)",animation:"shimmer 2s infinite"}}),$t.jsx("div",{style:{fontSize:"14px",color:"var(--muted)",fontFamily:"system-ui, sans-serif"},children:"Loading canvas..."}),$t.jsx("style",{children:`
|
|
14
|
-
@keyframes shimmer {
|
|
15
|
-
0% { transform: translateX(0); }
|
|
16
|
-
100% { transform: translateX(200%); }
|
|
17
|
-
}
|
|
18
|
-
`})]})}function ta({itemCount:t=5,style:e}){return $t.jsxs("div",{className:"layers-panel-skeleton",style:{width:"100%",padding:"16px",backgroundColor:"var(--surface)",borderRadius:"8px",...e},children:[Array.from({length:t}).map((n,o)=>$t.jsx("div",{className:"layer-item-skeleton",style:{height:"48px",backgroundColor:"var(--divider)",borderRadius:"6px",marginBottom:o<t-1?"8px":0,position:"relative",overflow:"hidden"},children:$t.jsx("div",{style:{position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent)",animation:"shimmer 2s infinite",animationDelay:`${o*.1}s`}})},o)),$t.jsx("style",{children:`
|
|
19
|
-
@keyframes shimmer {
|
|
20
|
-
0% { transform: translateX(0); }
|
|
21
|
-
100% { transform: translateX(200%); }
|
|
22
|
-
}
|
|
23
|
-
`})]})}function ea({style:t}){return $t.jsxs("div",{className:"toolbar-skeleton",style:{height:"56px",display:"flex",alignItems:"center",gap:"8px",padding:"0 16px",backgroundColor:"var(--surface)",borderBottom:"1px solid var(--divider)",...t},children:[[40,60,80,100,60,40].map((e,n)=>$t.jsx("div",{style:{width:`${e}px`,height:"32px",backgroundColor:"var(--divider)",borderRadius:"6px",position:"relative",overflow:"hidden"},children:$t.jsx("div",{style:{position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent)",animation:"shimmer 2s infinite",animationDelay:`${n*.15}s`}})},n)),$t.jsx("style",{children:`
|
|
24
|
-
@keyframes shimmer {
|
|
25
|
-
0% { transform: translateX(0); }
|
|
26
|
-
100% { transform: translateX(200%); }
|
|
27
|
-
}
|
|
28
|
-
`})]})}function na({size:t=32,color:e="var(--primary)"}){return $t.jsx("div",{className:"spinner",style:{width:`${t}px`,height:`${t}px`,border:"3px solid var(--divider)",borderTopColor:e,borderRadius:"50%",animation:"spin 0.8s linear infinite"},children:$t.jsx("style",{children:`
|
|
29
|
-
@keyframes spin {
|
|
30
|
-
to { transform: rotate(360deg); }
|
|
31
|
-
}
|
|
32
|
-
`})})}function oa(t){var i;const e=[],n=[];(!t.name||t.name.trim()==="")&&e.push("Kit name is required"),t.behavior.toolbar==="none"&&((i=t.layout.slots.topbar)!=null&&i.length)&&n.push('Toolbar mode is "none" but topbar has sections — topbar sections will be ignored'),t.behavior.selection==="multi"&&!t.capabilities.tools.includes("select")&&n.push('Multi-selection enabled but "select" tool not in capabilities'),t.capabilities.elements.length===0&&e.push("At least one element type must be enabled in capabilities.elements"),t.capabilities.transforms.length===0&&e.push("At least one transform type must be enabled in capabilities.transforms"),t.behavior.autoExport&&!t.capabilities.features.export&&n.push("autoExport is enabled but features.export is false — exports will not be produced");const o=[...t.layout.slots.left??[],...t.layout.slots.right??[]],r=["layers-panel","effects-panel","export-panel","images-panel","artboard-tabs"];for(const s of o)if(r.includes(s)){const a={"layers-panel":"layers","effects-panel":"effects","export-panel":"export","images-panel":"images","artboard-tabs":"artboards"}[s];a&&!t.capabilities.panels.includes(a)&&n.push(`Layout references "${s}" but "${a}" is not in capabilities.panels`)}return{valid:e.length===0,errors:e,warnings:n}}function pn(t,e){const n=new Set(t),o=[...t];for(const r of e)n.has(r)||(n.add(r),o.push(r));return o}function Hn(t,e){return{...t,...e}}const ra=["topbar","left","canvas","right","bottombar"];function gr(t,e){var v;const n=e.name??t.name,o=t.layout.slots,r=(v=e.layout)==null?void 0:v.slots,i={};for(const b of ra){const M=o[b],p=r==null?void 0:r[b];M&&p?i[b]=pn(M,p):p?i[b]=[...p]:M&&(i[b]=[...M])}const s=t.capabilities,l=e.capabilities,a={elements:s.elements,transforms:s.transforms,effects:s.effects,panels:s.panels,tools:s.tools,features:{...s.features}};l&&(l.elements&&(a.elements=pn(s.elements,l.elements)),l.transforms&&(a.transforms=pn(s.transforms,l.transforms)),l.effects&&(a.effects=pn(s.effects,l.effects)),l.panels&&(a.panels=pn(s.panels,l.panels)),l.tools&&(a.tools=pn(s.tools,l.tools)),l.features&&(a.features=Hn(s.features,l.features)));const c=e.behavior?Hn(t.behavior,e.behavior):{...t.behavior},f=e.style?Hn(t.style,e.style):{...t.style},h=t.content??{},m=e.content?Hn(h,e.content):{...h};return{name:n,layout:{slots:i},capabilities:a,behavior:c,style:f,content:m}}const ia={layout:{slots:{canvas:["canvas"]}},capabilities:{elements:["text","image"],transforms:["custom","image"],effects:[],panels:[],tools:["select"],features:{export:!0,multiArtboard:!1,richText:!1,undo:!0,keyboardShortcuts:!0}},behavior:{toolbar:"contextual",selection:"single",panelMode:"drawer",onEmptyClick:"deselect",autoExport:!1},style:{density:"compact",toolbarVariant:"pill",panelVariant:"floating"},content:{sampleText:"Your Text",defaultFontFamily:"Poppins"}};function sa(t){const{name:e,...n}=t,o={name:e,...ia};return gr(o,n)}exports.ALL_CAPABILITIES=Qo;exports.AutoExportManager=Qs;exports.COMPACT_CUSTOMIZER=Jo;exports.Canvas=Gs;exports.CanvasSkeleton=Js;exports.DEFAULT_AUTO_EXPORT_CONFIG=pr;exports.EMBED_ONLY=er;exports.Icon=Zo;exports.KIT_PRESETS=to;exports.KitProvider=Ii;exports.LayersPanelSkeleton=ta;exports.MINIMAL_CAPABILITIES=io;exports.PRO_STUDIO=tr;exports.Spinner=na;exports.ToolbarSkeleton=ea;exports.clickProtection=fr;exports.createKit=sa;exports.ensureIconsRegistered=Ti;exports.extendKit=gr;exports.generateElementPreview=ir;exports.renderPieceGuides=ur;exports.resolveKit=nr;exports.useArtboards=Ks;exports.useCapabilities=Ai;exports.useExport=Zs;exports.useKit=rr;exports.useLayers=lr;exports.validateKit=oa;
|
|
33
|
-
//# sourceMappingURL=compose-DHBRwi_A.cjs.map
|