@fraczled/sdk 1.30.55 → 1.30.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { g as V, b as q, a as B, t as I, c as Z, d as R, e as Q, f as K, h as m, i as J, j as x, k as nt, l as at, s as it, m as lt, E as H, n as ct, o as tt, p as ot, r as ft } from "./index-Dx68n4Os.js";
1
+ import { g as V, b as q, a as B, t as I, c as Z, d as R, e as Q, f as K, h as m, i as J, j as x, k as nt, l as at, s as it, m as lt, E as H, n as ct, o as tt, p as ot, r as ft } from "./index-DHugiMpj.js";
2
2
  const ht = {
3
3
  normal: "source-over",
4
4
  dissolve: "source-over",
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "react-dom/client";
3
- import { S as o, w as p, v as c, x as i } from "./index-Dx68n4Os.js";
3
+ import { S as o, w as p, v as c, x as i } from "./index-DHugiMpj.js";
4
4
  export {
5
5
  o as Store,
6
6
  p as createFraczledEditor,
@@ -811,7 +811,7 @@ end`};e.events.push(["putFont",function(s){(function(A){var l=A.font,c=A.out,f=A
811
811
  *
812
812
  * This source code is licensed under the ISC license.
813
813
  * See the LICENSE file in the root directory of this source tree.
814
- */const WQ=Ot("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function ZQ(t){const[e,r]=ne.useState(()=>typeof window<"u"?window.matchMedia(t).matches:!1);return ne.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia(t);r(n.matches);const a=s=>r(s.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[t]),e}const Xc=()=>ZQ("(max-width: 767px)"),JQ=({title:t="Untitled Design",onExport:e,onCustomExport:r,onUndo:n,onRedo:a,canUndo:s,canRedo:A,onTitleChange:l,onToggleSettings:c,zoom:f,setZoom:h,showToolbar:g=!0,children:v,exportAccess:m,canSaveLoadJson:x=!0,upgradeUrl:w,onRequestUpgrade:C,onSaveDesign:S,onNewDesign:F,isExporting:M=!1,customToolbarItems:L,toolbarContext:Z,customExportFormats:J,topbarMode:K="default",exportMenu:ee})=>{const[V,fe]=ne.useState(!1),[j,te]=ne.useState(!1),z=Xc(),D=ne.useRef(null),se=ne.useRef(null),q=g&&d.Children.count(v)>0,X=(m==null?void 0:m.web)!==!1,Y=(m==null?void 0:m.print)!==!1,W=new Map;((ee==null?void 0:ee.items)||[]).forEach(pe=>{pe!=null&&pe.id&&W.set(pe.id,pe)});const P=pe=>W.get(pe),O=(ee==null?void 0:ee.hideDefaultItems)===!0,k={label:"Export for Web",description:"Fast Download (PNG)",icon:Ed},Q={label:"Download PDF",description:"Best for Documents",icon:zu},N={label:"Download PNGs",description:"High Quality Images",icon:ng},I={label:"Save Design (JSON)",description:"Download project file",icon:qu},_=P("web"),R=P("print_pdf"),ie=P("print_png"),ae=P("json"),ge=!O&&!(_!=null&&_.hidden),ce=!O&&!(R!=null&&R.hidden),Ae=!O&&!(ie!=null&&ie.hidden),ue=!O&&!(ae!=null&&ae.hidden),Be=r?(J||[]).filter(pe=>(pe==null?void 0:pe.id)&&(pe==null?void 0:pe.label)):[],$={web:[],print:[],other:[]};Be.forEach(pe=>{const ke=P(pe.id);if(ke!=null&&ke.hidden)return;const Qe=(ke==null?void 0:ke.section)??pe.section??"other";Qe==="web"||Qe==="print"||Qe==="other"?$[Qe].push({...pe,...ke}):$.other.push({...pe,...ke})});const Ne=(ge||ce||Ae||ue||Be.length>0)&&(!!w||ge&&X||(ce||Ae)&&Y||ue&&x||Be.length>0),Ue=(L||[]).filter(pe=>(pe==null?void 0:pe.id)&&(pe==null?void 0:pe.label)).filter(pe=>pe.location==="topbar"||pe.location==="both").filter(pe=>!pe.showFor||pe.showFor.length===0?!0:Z!=null&&Z.element?pe.showFor.includes(Z.element.type):!1),We=K==="custom",Ze=pe=>{if(!Z)return null;if(pe.render){const Qe=pe.render;return d.createElement(d.Fragment,{key:pe.id},d.createElement(Qe,{...Z}))}const ke=pe.icon;return d.createElement("button",{key:pe.id,onClick:()=>{var Qe;return(Qe=pe.onClick)==null?void 0:Qe.call(pe,Z)},className:"flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-sm font-medium text-slate-600 hover:bg-gray-100 transition-colors"},ke&&d.createElement(ke,{size:16}),d.createElement("span",{className:"hidden lg:inline"},pe.label))};ne.useEffect(()=>{const pe=ke=>{D.current&&!D.current.contains(ke.target)&&fe(!1),se.current&&!se.current.contains(ke.target)&&te(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[]);const st=pe=>{pe==="web"&&!X||pe!=="web"&&!Y||(e(pe),fe(!1))},rt=pe=>pe==="web"?X:pe==="print"?Y:X||Y,Ie=pe=>{const ke=pe.section??"other";rt(ke)&&(r==null||r(pe),fe(!1))},De=pe=>{const ke=pe.icon||Fb,Qe=pe.section??"other",Ge=!rt(Qe);return d.createElement("button",{key:pe.id,onClick:()=>!Ge&&Ie(pe),disabled:Ge,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${Ge?"opacity-60 cursor-not-allowed":""}`},d.createElement("div",{className:"p-2 bg-slate-50 text-slate-700 rounded-md group-hover:bg-slate-100 transition-colors"},d.createElement(ke,{size:18})),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},pe.label),pe.description&&d.createElement("div",{className:"text-xs text-slate-500"},pe.description)),Ge&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro")))};return d.createElement("div",{className:"bg-white border-b border-gray-200 flex flex-col flex-shrink-0 z-[100] relative",style:{paddingTop:"env(safe-area-inset-top)"}},d.createElement("div",{className:`${z?"h-16":"h-14"} flex items-center gap-2 px-2 md:px-4 justify-between`},d.createElement("div",{className:"flex items-center gap-2 md:gap-4 shrink-0"},d.createElement("button",{onClick:c,className:"p-2 hover:bg-gray-100 rounded-md transition-colors text-slate-700 hidden md:block",title:"Document Settings"},d.createElement(OQ,{size:20})),d.createElement("button",{onClick:c,className:`md:hidden ${z?"p-3":"p-2"} hover:bg-gray-100 rounded-full text-slate-600`},d.createElement(RQ,{size:z?22:20})),d.createElement("div",{className:"flex items-center"},d.createElement("input",{type:"text",value:t,onChange:pe=>l(pe.target.value),className:"font-bold text-lg text-slate-800 hover:border-gray-300 border border-transparent rounded px-2 -ml-1 focus:border-slate-500 focus:outline-none bg-transparent transition-all w-40 sm:w-64 md:w-auto hidden sm:block"}))),d.createElement("div",{className:"hidden md:flex flex-1 min-w-0 items-center"},d.createElement("div",{className:"w-full overflow-x-auto overflow-y-visible"},d.createElement("div",{className:"flex items-center gap-3 px-2 min-w-max mx-auto"},v))),d.createElement("div",{className:"flex items-center gap-1 md:gap-3 shrink-0 flex-1 justify-end"},We?d.createElement("div",{className:"flex items-center gap-1 md:gap-3"},Ue.map(Ze)):d.createElement(d.Fragment,null,d.createElement("div",{className:"md:hidden relative order-last ml-1",ref:se},d.createElement("button",{onClick:()=>te(!j),className:`${z?"p-3":"p-2"} hover:bg-gray-100 rounded-full transition-colors ${j?"bg-indigo-50 text-indigo-600":"text-slate-600"}`},d.createElement(WQ,{size:z?22:20})),j&&d.createElement("div",{className:"absolute right-0 top-full mt-2 bg-white rounded-lg shadow-xl border border-gray-200 p-3 z-50 min-w-[200px]"},d.createElement("div",{className:"flex items-center gap-2 justify-center mb-3"},d.createElement("button",{onClick:()=>h(Math.max(10,f-10)),className:"p-2 hover:bg-gray-100 rounded text-slate-600"},d.createElement(tg,{size:18})),d.createElement("span",{className:"text-sm font-medium w-12 text-center tabular-nums"},f,"%"),d.createElement("button",{onClick:()=>h(Math.min(200,f+10)),className:"p-2 hover:bg-gray-100 rounded text-slate-600"},d.createElement(LA,{size:18}))),d.createElement("input",{type:"range",min:"10",max:"200",step:"5",value:f,onChange:pe=>h(parseInt(pe.target.value)),className:"w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),d.createElement("div",{className:"flex justify-between text-[10px] text-slate-400 mt-1"},d.createElement("span",null,"10%"),d.createElement("span",null,"200%")))),d.createElement("div",{className:"flex md:hidden gap-0.5 ml-auto"},d.createElement("button",{onClick:n,disabled:!s,className:`${z?"p-2.5":"p-2"} rounded-full ${s?"text-slate-700 hover:bg-gray-100":"text-slate-300"}`},d.createElement(XQ,{size:z?20:18})),d.createElement("button",{onClick:a,disabled:!A,className:`${z?"p-2.5":"p-2"} rounded-full ${A?"text-slate-700 hover:bg-gray-100":"text-slate-300"}`},d.createElement(MQ,{size:z?20:18})),F&&d.createElement("button",{onClick:()=>F(),className:`${z?"p-2.5":"p-2"} rounded-full text-emerald-600 hover:bg-emerald-50`,title:"New Design"},d.createElement(kb,{size:z?20:18}))),d.createElement("button",{className:"hidden md:flex items-center justify-center p-2 hover:opacity-80 transition-opacity group relative",style:{color:"#5046e5"},onClick:()=>S==null?void 0:S()},d.createElement(qu,{size:20}),d.createElement("div",{className:"absolute top-full mt-2 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg"},"Save Design")),d.createElement("button",{className:"hidden md:flex items-center justify-center p-2 hover:opacity-80 transition-opacity mr-2 group relative",style:{color:"#10b981"},onClick:()=>F==null?void 0:F()},d.createElement(kb,{size:20}),d.createElement("div",{className:"absolute top-full mt-2 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg"},"New Design")),Ue.length>0&&d.createElement("div",{className:"hidden md:flex items-center gap-1 mr-2"},Ue.map(Ze)),d.createElement("div",{className:"relative",ref:D},d.createElement("button",{onClick:()=>!M&&fe(!V),disabled:!Ne||M,className:`flex items-center gap-2 ${z?"px-3 py-2.5 text-sm":"px-2 py-1.5 md:px-4 md:py-2 text-sm"} bg-slate-900 hover:bg-slate-800 text-white rounded-lg font-medium transition-colors shadow-sm ${!Ne||M?"opacity-60 cursor-not-allowed":""}`},M?d.createElement($c,{size:16,className:"animate-spin"}):(()=>{const pe=(ee==null?void 0:ee.buttonIcon)||Fb;return d.createElement(pe,{size:z?18:16})})(),d.createElement("span",{className:"hidden md:inline"},M?ee!=null&&ee.buttonLabel?`${ee.buttonLabel}...`:"Exporting...":(ee==null?void 0:ee.buttonLabel)||"Export"),!M&&d.createElement(Gl,{size:14,className:"md:ml-1 opacity-70"})),V&&d.createElement("div",{className:"absolute right-0 top-full mt-2 w-64 bg-white rounded-xl shadow-xl border border-gray-100 p-1.5 animate-in fade-in zoom-in-95 duration-100 z-50"},ge&&d.createElement("button",{onClick:()=>st("web"),disabled:!X,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${X?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-md group-hover:bg-blue-100 transition-colors"},(()=>{const pe=(_==null?void 0:_.icon)||k.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(_==null?void 0:_.label)||k.label),d.createElement("div",{className:"text-xs text-slate-500"},(_==null?void 0:_.description)||k.description)),!X&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro"))),$.web.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Custom Web"),$.web.map(De)),(ce||Ae||$.print.length>0)&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Print Ready (300 DPI)")),ce&&d.createElement("button",{onClick:()=>st("print_pdf"),disabled:!Y,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${Y?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-red-50 text-red-600 rounded-md group-hover:bg-red-100 transition-colors"},(()=>{const pe=(R==null?void 0:R.icon)||Q.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(R==null?void 0:R.label)||Q.label),d.createElement("div",{className:"text-xs text-slate-500"},(R==null?void 0:R.description)||Q.description)),!Y&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro"))),Ae&&d.createElement("button",{onClick:()=>st("print_png"),disabled:!Y,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${Y?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-purple-50 text-purple-600 rounded-md group-hover:bg-purple-100 transition-colors"},(()=>{const pe=(ie==null?void 0:ie.icon)||N.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(ie==null?void 0:ie.label)||N.label),d.createElement("div",{className:"text-xs text-slate-500"},(ie==null?void 0:ie.description)||N.description)),!Y&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro"))),$.print.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Custom Print"),$.print.map(De)),$.other.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Custom Exports"),$.other.map(De)),ue&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Backup"),d.createElement("button",{onClick:()=>st("json"),disabled:!x,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${x?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-emerald-50 text-emerald-600 rounded-md group-hover:bg-emerald-100 transition-colors"},(()=>{const pe=(ae==null?void 0:ae.icon)||I.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(ae==null?void 0:ae.label)||I.label),d.createElement("div",{className:"text-xs text-slate-500"},(ae==null?void 0:ae.description)||I.description)),!x&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro")))),!Y&&d.createElement("div",{className:"mt-2 rounded-lg border border-amber-100 bg-amber-50 px-3 py-2 text-[11px] text-amber-700 flex items-center justify-between gap-2"},d.createElement("span",null,"Upgrade to unlock print exports."),C&&d.createElement("button",{onClick:()=>C("export-print"),className:"text-[11px] font-semibold text-amber-700 hover:text-amber-900"},"Upgrade")),!X&&d.createElement("div",{className:"mt-2 rounded-lg border border-amber-100 bg-amber-50 px-3 py-2 text-[11px] text-amber-700 flex items-center justify-between gap-2"},d.createElement("span",null,"Upgrade to unlock web exports."),C&&d.createElement("button",{onClick:()=>C("export-web"),className:"text-[11px] font-semibold text-amber-700 hover:text-amber-900"},"Upgrade"))))))),q&&d.createElement("div",{"data-mobile-toolbar":"true",className:"md:hidden fixed left-0 right-0 border-t border-gray-100 bg-white/95 backdrop-blur-sm shadow-lg z-[50]",style:{top:"calc(56px + env(safe-area-inset-top))"}},d.createElement("div",{className:"overflow-x-auto overflow-y-visible"},d.createElement("div",{className:"flex items-center gap-3 px-3 py-2 min-w-max"},v))))};var cr=(t=>(t.TEMPLATES="Templates",t.DESIGN="Design",t.ELEMENTS="Elements",t.TEXT="Text",t.BRAND="Brand",t.UPLOADS="Uploads",t.IMAGES="Images",t.ICONS="Icons",t.DRAW="Draw",t.PROJECTS="Projects",t.LAYERS="Layers",t.QR_CODE="QR Code",t.POSITION="Position",t.COLOR="Color",t.FONT="Font",t.EFFECTS="Effects",t))(cr||{});const eI=({activeTool:t,setActiveTool:e,featureAccess:r={},onRequestUpgrade:n,isLicenseValid:a=!0,customPanels:s,hideDefaultPanels:A=!1,hiddenPanels:l=[]})=>{const c=[{id:cr.TEMPLATES,icon:LA,label:"Create",feature:"templates"},{id:cr.DESIGN,icon:Vc,label:"Design",feature:"design"},{id:cr.ELEMENTS,icon:DQ,label:"Elements",feature:"elements"},{id:cr.DRAW,icon:Ob,label:"Draw",feature:"draw"},{id:cr.TEXT,icon:Sd,label:"Text",feature:"text"},{id:cr.IMAGES,icon:Ed,label:"Images",feature:"images"},{id:cr.ICONS,icon:SQ,label:"Icons",feature:"icons"},{id:cr.BRAND,icon:rg,label:"Brand",feature:"brand"},{id:cr.UPLOADS,icon:gQ,label:"Uploads",feature:"uploads"},{id:cr.QR_CODE,icon:i1,label:"QR Code",feature:"qrcode"},{id:cr.LAYERS,icon:Cd,label:"Layers",feature:"layers"}],f=new Set(l),h=A?[]:c.filter(m=>!f.has(m.id)),g=(s||[]).filter(m=>(m==null?void 0:m.id)&&(m==null?void 0:m.label)).filter(m=>!f.has(m.id)),v=[...h];return g.forEach(m=>{const x=v.findIndex(S=>S.id===m.id),w=x>=0?v[x]:null,C={id:m.id,icon:m.icon||(w==null?void 0:w.icon)||TQ,label:m.label||(w==null?void 0:w.label)||m.id,feature:m.feature??(w==null?void 0:w.feature)};x>=0?v[x]=C:v.push(C)}),d.createElement("div",{className:`
814
+ */const WQ=Ot("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function ZQ(t){const[e,r]=ne.useState(()=>typeof window<"u"?window.matchMedia(t).matches:!1);return ne.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia(t);r(n.matches);const a=s=>r(s.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[t]),e}const Xc=()=>ZQ("(max-width: 767px)"),JQ=({title:t="Untitled Design",onExport:e,onCustomExport:r,onUndo:n,onRedo:a,canUndo:s,canRedo:A,onTitleChange:l,onToggleSettings:c,zoom:f,setZoom:h,showToolbar:g=!0,children:v,exportAccess:m,canSaveLoadJson:x=!0,upgradeUrl:w,onRequestUpgrade:C,onSaveDesign:S,onNewDesign:F,isExporting:M=!1,customToolbarItems:L,toolbarContext:Z,customExportFormats:J,topbarMode:K="default",exportMenu:ee})=>{const[V,fe]=ne.useState(!1),[j,te]=ne.useState(!1),z=Xc(),D=ne.useRef(null),se=ne.useRef(null),q=g&&d.Children.count(v)>0,X=(m==null?void 0:m.web)!==!1,Y=(m==null?void 0:m.print)!==!1,W=new Map;((ee==null?void 0:ee.items)||[]).forEach(pe=>{pe!=null&&pe.id&&W.set(pe.id,pe)});const P=pe=>W.get(pe),O=(ee==null?void 0:ee.hideDefaultItems)===!0,k={label:"Export for Web",description:"Fast Download (PNG)",icon:Ed},Q={label:"Download PDF",description:"Best for Documents",icon:zu},N={label:"Download PNGs",description:"High Quality Images",icon:ng},I={label:"Save Design (JSON)",description:"Download project file",icon:qu},_=P("web"),R=P("print_pdf"),ie=P("print_png"),ae=P("json"),ge=!O&&!(_!=null&&_.hidden),ce=!O&&!(R!=null&&R.hidden),Ae=!O&&!(ie!=null&&ie.hidden),ue=!O&&!(ae!=null&&ae.hidden),Be=r?(J||[]).filter(pe=>(pe==null?void 0:pe.id)&&(pe==null?void 0:pe.label)):[],$={web:[],print:[],other:[]};Be.forEach(pe=>{const ke=P(pe.id);if(ke!=null&&ke.hidden)return;const Qe=(ke==null?void 0:ke.section)??pe.section??"other";Qe==="web"||Qe==="print"||Qe==="other"?$[Qe].push({...pe,...ke}):$.other.push({...pe,...ke})});const Ne=(ge||ce||Ae||ue||Be.length>0)&&(!!w||ge&&X||(ce||Ae)&&Y||ue&&x||Be.length>0),Ue=(L||[]).filter(pe=>(pe==null?void 0:pe.id)&&(pe==null?void 0:pe.label)).filter(pe=>pe.location==="topbar"||pe.location==="both").filter(pe=>!pe.showFor||pe.showFor.length===0?!0:Z!=null&&Z.element?pe.showFor.includes(Z.element.type):!1),We=K==="custom",Ze=pe=>{if(!Z)return null;if(pe.render){const Qe=pe.render;return d.createElement(d.Fragment,{key:pe.id},d.createElement(Qe,{...Z}))}const ke=pe.icon;return d.createElement("button",{key:pe.id,onClick:()=>{var Qe;return(Qe=pe.onClick)==null?void 0:Qe.call(pe,Z)},className:"flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-sm font-medium text-slate-600 hover:bg-gray-100 transition-colors"},ke&&d.createElement(ke,{size:16}),d.createElement("span",{className:"hidden lg:inline"},pe.label))};ne.useEffect(()=>{const pe=ke=>{D.current&&!D.current.contains(ke.target)&&fe(!1),se.current&&!se.current.contains(ke.target)&&te(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[]);const st=pe=>{pe==="web"&&!X||pe!=="web"&&!Y||(e(pe),fe(!1))},rt=pe=>pe==="web"?X:pe==="print"?Y:X||Y,Ie=pe=>{const ke=pe.section??"other";rt(ke)&&(r==null||r(pe),fe(!1))},De=pe=>{const ke=pe.icon||Fb,Qe=pe.section??"other",Ge=!rt(Qe);return d.createElement("button",{key:pe.id,onClick:()=>!Ge&&Ie(pe),disabled:Ge,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${Ge?"opacity-60 cursor-not-allowed":""}`},d.createElement("div",{className:"p-2 bg-slate-50 text-slate-700 rounded-md group-hover:bg-slate-100 transition-colors"},d.createElement(ke,{size:18})),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},pe.label),pe.description&&d.createElement("div",{className:"text-xs text-slate-500"},pe.description)),Ge&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro")))};return d.createElement("div",{className:"bg-white border-b border-gray-200 flex flex-col flex-shrink-0 z-[100] relative",style:{paddingTop:"env(safe-area-inset-top)"}},d.createElement("div",{className:`${z?"h-16":"h-14"} flex items-center gap-2 px-2 md:px-4 justify-between`},d.createElement("div",{className:"flex items-center gap-2 md:gap-4 shrink-0"},d.createElement("button",{onClick:c,className:"p-2 hover:bg-gray-100 rounded-md transition-colors text-slate-700 hidden md:block",title:"Document Settings"},d.createElement(OQ,{size:20})),d.createElement("button",{onClick:c,className:`md:hidden ${z?"p-3":"p-2"} hover:bg-gray-100 rounded-full text-slate-600`},d.createElement(RQ,{size:z?22:20}))),d.createElement("div",{className:"hidden md:flex flex-1 min-w-0 items-center"},d.createElement("div",{className:"w-full"},v)),d.createElement("div",{className:"flex items-center gap-1 md:gap-3 shrink-0 justify-end"},We?d.createElement("div",{className:"flex items-center gap-1 md:gap-3"},Ue.map(Ze)):d.createElement(d.Fragment,null,d.createElement("div",{className:"md:hidden relative order-last ml-1",ref:se},d.createElement("button",{onClick:()=>te(!j),className:`${z?"p-3":"p-2"} hover:bg-gray-100 rounded-full transition-colors ${j?"bg-indigo-50 text-indigo-600":"text-slate-600"}`},d.createElement(WQ,{size:z?22:20})),j&&d.createElement("div",{className:"absolute right-0 top-full mt-2 bg-white rounded-lg shadow-xl border border-gray-200 p-3 z-50 min-w-[200px]"},d.createElement("div",{className:"flex items-center gap-2 justify-center mb-3"},d.createElement("button",{onClick:()=>h(Math.max(10,f-10)),className:"p-2 hover:bg-gray-100 rounded text-slate-600"},d.createElement(tg,{size:18})),d.createElement("span",{className:"text-sm font-medium w-12 text-center tabular-nums"},f,"%"),d.createElement("button",{onClick:()=>h(Math.min(200,f+10)),className:"p-2 hover:bg-gray-100 rounded text-slate-600"},d.createElement(LA,{size:18}))),d.createElement("input",{type:"range",min:"10",max:"200",step:"5",value:f,onChange:pe=>h(parseInt(pe.target.value)),className:"w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),d.createElement("div",{className:"flex justify-between text-[10px] text-slate-400 mt-1"},d.createElement("span",null,"10%"),d.createElement("span",null,"200%")))),d.createElement("div",{className:"flex md:hidden gap-0.5 ml-auto"},d.createElement("button",{onClick:n,disabled:!s,className:`${z?"p-2.5":"p-2"} rounded-full ${s?"text-slate-700 hover:bg-gray-100":"text-slate-300"}`},d.createElement(XQ,{size:z?20:18})),d.createElement("button",{onClick:a,disabled:!A,className:`${z?"p-2.5":"p-2"} rounded-full ${A?"text-slate-700 hover:bg-gray-100":"text-slate-300"}`},d.createElement(MQ,{size:z?20:18})),F&&d.createElement("button",{onClick:()=>F(),className:`${z?"p-2.5":"p-2"} rounded-full text-emerald-600 hover:bg-emerald-50`,title:"New Design"},d.createElement(kb,{size:z?20:18}))),d.createElement("button",{className:"hidden md:flex items-center justify-center p-2 hover:opacity-80 transition-opacity group relative",style:{color:"#5046e5"},onClick:()=>S==null?void 0:S()},d.createElement(qu,{size:20}),d.createElement("div",{className:"absolute top-full mt-2 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg"},"Save Design")),d.createElement("button",{className:"hidden md:flex items-center justify-center p-2 hover:opacity-80 transition-opacity mr-2 group relative",style:{color:"#10b981"},onClick:()=>F==null?void 0:F()},d.createElement(kb,{size:20}),d.createElement("div",{className:"absolute top-full mt-2 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg"},"New Design")),Ue.length>0&&d.createElement("div",{className:"hidden md:flex items-center gap-1 mr-2"},Ue.map(Ze)),d.createElement("div",{className:"relative",ref:D},d.createElement("button",{onClick:()=>!M&&fe(!V),disabled:!Ne||M,className:`flex items-center gap-2 ${z?"px-3 py-2.5 text-sm":"px-2 py-1.5 md:px-4 md:py-2 text-sm"} bg-slate-900 hover:bg-slate-800 text-white rounded-lg font-medium transition-colors shadow-sm ${!Ne||M?"opacity-60 cursor-not-allowed":""}`},M?d.createElement($c,{size:16,className:"animate-spin"}):(()=>{const pe=(ee==null?void 0:ee.buttonIcon)||Fb;return d.createElement(pe,{size:z?18:16})})(),d.createElement("span",{className:"hidden md:inline"},M?ee!=null&&ee.buttonLabel?`${ee.buttonLabel}...`:"Exporting...":(ee==null?void 0:ee.buttonLabel)||"Export"),!M&&d.createElement(Gl,{size:14,className:"md:ml-1 opacity-70"})),V&&d.createElement("div",{className:"absolute right-0 top-full mt-2 w-64 bg-white rounded-xl shadow-xl border border-gray-100 p-1.5 animate-in fade-in zoom-in-95 duration-100 z-50"},ge&&d.createElement("button",{onClick:()=>st("web"),disabled:!X,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${X?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-md group-hover:bg-blue-100 transition-colors"},(()=>{const pe=(_==null?void 0:_.icon)||k.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(_==null?void 0:_.label)||k.label),d.createElement("div",{className:"text-xs text-slate-500"},(_==null?void 0:_.description)||k.description)),!X&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro"))),$.web.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Custom Web"),$.web.map(De)),(ce||Ae||$.print.length>0)&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Print Ready (300 DPI)")),ce&&d.createElement("button",{onClick:()=>st("print_pdf"),disabled:!Y,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${Y?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-red-50 text-red-600 rounded-md group-hover:bg-red-100 transition-colors"},(()=>{const pe=(R==null?void 0:R.icon)||Q.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(R==null?void 0:R.label)||Q.label),d.createElement("div",{className:"text-xs text-slate-500"},(R==null?void 0:R.description)||Q.description)),!Y&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro"))),Ae&&d.createElement("button",{onClick:()=>st("print_png"),disabled:!Y,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${Y?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-purple-50 text-purple-600 rounded-md group-hover:bg-purple-100 transition-colors"},(()=>{const pe=(ie==null?void 0:ie.icon)||N.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(ie==null?void 0:ie.label)||N.label),d.createElement("div",{className:"text-xs text-slate-500"},(ie==null?void 0:ie.description)||N.description)),!Y&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro"))),$.print.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Custom Print"),$.print.map(De)),$.other.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Custom Exports"),$.other.map(De)),ue&&d.createElement(d.Fragment,null,d.createElement("div",{className:"my-1 border-t border-gray-100"}),d.createElement("div",{className:"px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider"},"Backup"),d.createElement("button",{onClick:()=>st("json"),disabled:!x,className:`w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 flex items-center gap-3 transition-colors group ${x?"":"opacity-60 cursor-not-allowed"}`},d.createElement("div",{className:"p-2 bg-emerald-50 text-emerald-600 rounded-md group-hover:bg-emerald-100 transition-colors"},(()=>{const pe=(ae==null?void 0:ae.icon)||I.icon;return d.createElement(pe,{size:18})})()),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-800"},(ae==null?void 0:ae.label)||I.label),d.createElement("div",{className:"text-xs text-slate-500"},(ae==null?void 0:ae.description)||I.description)),!x&&d.createElement("div",{className:"ml-auto text-[10px] font-semibold text-amber-600 flex items-center gap-1"},d.createElement(IA,{size:12}),d.createElement("span",null,"Pro")))),!Y&&d.createElement("div",{className:"mt-2 rounded-lg border border-amber-100 bg-amber-50 px-3 py-2 text-[11px] text-amber-700 flex items-center justify-between gap-2"},d.createElement("span",null,"Upgrade to unlock print exports."),C&&d.createElement("button",{onClick:()=>C("export-print"),className:"text-[11px] font-semibold text-amber-700 hover:text-amber-900"},"Upgrade")),!X&&d.createElement("div",{className:"mt-2 rounded-lg border border-amber-100 bg-amber-50 px-3 py-2 text-[11px] text-amber-700 flex items-center justify-between gap-2"},d.createElement("span",null,"Upgrade to unlock web exports."),C&&d.createElement("button",{onClick:()=>C("export-web"),className:"text-[11px] font-semibold text-amber-700 hover:text-amber-900"},"Upgrade"))))))),q&&d.createElement("div",{"data-mobile-toolbar":"true",className:"md:hidden fixed left-0 right-0 border-t border-gray-100 bg-white/95 backdrop-blur-sm shadow-lg z-[50]",style:{top:"calc(56px + env(safe-area-inset-top))"}},d.createElement("div",{className:"px-3 py-2"},d.createElement("div",{className:"w-full"},v))))};var cr=(t=>(t.TEMPLATES="Templates",t.DESIGN="Design",t.ELEMENTS="Elements",t.TEXT="Text",t.BRAND="Brand",t.UPLOADS="Uploads",t.IMAGES="Images",t.ICONS="Icons",t.DRAW="Draw",t.PROJECTS="Projects",t.LAYERS="Layers",t.QR_CODE="QR Code",t.POSITION="Position",t.COLOR="Color",t.FONT="Font",t.EFFECTS="Effects",t))(cr||{});const eI=({activeTool:t,setActiveTool:e,featureAccess:r={},onRequestUpgrade:n,isLicenseValid:a=!0,customPanels:s,hideDefaultPanels:A=!1,hiddenPanels:l=[]})=>{const c=[{id:cr.TEMPLATES,icon:LA,label:"Create",feature:"templates"},{id:cr.DESIGN,icon:Vc,label:"Design",feature:"design"},{id:cr.ELEMENTS,icon:DQ,label:"Elements",feature:"elements"},{id:cr.DRAW,icon:Ob,label:"Draw",feature:"draw"},{id:cr.TEXT,icon:Sd,label:"Text",feature:"text"},{id:cr.IMAGES,icon:Ed,label:"Images",feature:"images"},{id:cr.ICONS,icon:SQ,label:"Icons",feature:"icons"},{id:cr.BRAND,icon:rg,label:"Brand",feature:"brand"},{id:cr.UPLOADS,icon:gQ,label:"Uploads",feature:"uploads"},{id:cr.QR_CODE,icon:i1,label:"QR Code",feature:"qrcode"},{id:cr.LAYERS,icon:Cd,label:"Layers",feature:"layers"}],f=new Set(l),h=A?[]:c.filter(m=>!f.has(m.id)),g=(s||[]).filter(m=>(m==null?void 0:m.id)&&(m==null?void 0:m.label)).filter(m=>!f.has(m.id)),v=[...h];return g.forEach(m=>{const x=v.findIndex(S=>S.id===m.id),w=x>=0?v[x]:null,C={id:m.id,icon:m.icon||(w==null?void 0:w.icon)||TQ,label:m.label||(w==null?void 0:w.label)||m.id,feature:m.feature??(w==null?void 0:w.feature)};x>=0?v[x]=C:v.push(C)}),d.createElement("div",{className:`
815
815
  w-full min-h-[72px] border-t
816
816
  md:w-[72px] md:h-full md:border-r md:border-t-0
817
817
  bg-white border-gray-200
@@ -936,7 +936,7 @@ end`};e.events.push(["putFont",function(s){(function(A){var l=A.font,c=A.out,f=A
936
936
  `,v.style.width=`${f}px`,v.style.height=`${h}px`,v.style.backgroundImage=`url(${c.toDataURL("image/png")})`,v.style.backgroundSize="100% 100%",document.body.appendChild(v);const m={elementId:e,canvas:c,originalElement:r,overlay:v,bounds:l,scale:a};return this._cache.set(e,m),m}catch(l){return console.warn("Failed to create raster cache:",l),null}}async _renderElementToCanvas(e,r,n,a){const s=e.cloneNode(!0),A=window.getComputedStyle(e);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.width=`${a.width}px`,s.style.height=`${a.height}px`,s.style.margin="0",s.style.transform="none",["fontFamily","fontSize","fontWeight","fontStyle","color","backgroundColor","backgroundImage","textShadow","boxShadow","filter","borderRadius","border","WebkitTextStroke","textStroke","opacity","letterSpacing","lineHeight"].forEach(w=>{s.style[w]=A.getPropertyValue(w.replace(/([A-Z])/g,"-$1").toLowerCase())});const c="http://www.w3.org/2000/svg",f=document.createElementNS(c,"svg");f.setAttribute("width",String(a.width+n*2)),f.setAttribute("height",String(a.height+n*2)),f.setAttribute("xmlns",c);const h=document.createElementNS(c,"foreignObject");h.setAttribute("width","100%"),h.setAttribute("height","100%"),h.setAttribute("x",String(n)),h.setAttribute("y",String(n));const g=document.createElement("div");g.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),g.style.width=`${a.width}px`,g.style.height=`${a.height}px`,g.appendChild(s),h.appendChild(g),f.appendChild(h);const v=new XMLSerializer().serializeToString(f),m=new Blob([v],{type:"image/svg+xml;charset=utf-8"}),x=URL.createObjectURL(m);return new Promise((w,C)=>{const S=new Image;S.onload=()=>{r.drawImage(S,0,0),URL.revokeObjectURL(x),w()},S.onerror=()=>{URL.revokeObjectURL(x),r.fillStyle="#ddd",r.fillRect(n,n,a.width,a.height),w()},S.src=x})}activateCache(e,r,n){const a=this._cache.get(e);if(!a)return!1;const s=20;return a.overlay.style.left=`${r-s}px`,a.overlay.style.top=`${n-s}px`,a.overlay.style.display="block",a.originalElement.style.visibility="hidden",this._activeOverlays.add(e),!0}moveCache(e,r,n){const a=this._cache.get(e);if(!a||!this._activeOverlays.has(e))return;const s=20;a.overlay.style.left=`${r-s}px`,a.overlay.style.top=`${n-s}px`}deactivateCache(e){const r=this._cache.get(e);r&&(r.overlay.style.display="none",r.originalElement.style.visibility="visible",this._activeOverlays.delete(e))}invalidateCache(e){const r=this._cache.get(e);r&&(r.overlay.remove(),this._cache.delete(e),this._activeOverlays.delete(e))}clearAll(){for(const[e]of this._cache)this.invalidateCache(e)}hasCache(e){return this._cache.has(e)}isCacheActive(e){return this._activeOverlays.has(e)}}const RA=new OO;function DO(t){var h;const e=window.getComputedStyle(t),r=e.getPropertyValue("-webkit-text-stroke-width")!=="0px"||e.getPropertyValue("text-stroke-width")!=="0px",n=e.textShadow!=="none",a=e.boxShadow!=="none",s=e.filter!=="none",A=e.getPropertyValue("backdrop-filter")!=="none"||e.getPropertyValue("-webkit-backdrop-filter")!=="none",l=(h=e.filter)==null?void 0:h.includes("url("),c=e.getPropertyValue("mask")!=="none"||e.getPropertyValue("-webkit-mask")!=="none",f=e.clipPath!=="none";return r||n||a||s||A||l||c||f}function RO(t={}){const{enabled:e=typeof window<"u"&&"ontouchstart"in window,threshold:r=5,padding:n=30}=t,a=ne.useRef({activeIds:new Set,isCaching:!1}),s=ne.useRef(null),A=ne.useRef(!1),l=ne.useRef(new Map),c=ne.useCallback(async(x,w)=>{if(!e)return;a.current.activeIds=new Set(x),a.current.isCaching=!1,s.current={x:w.clientX,y:w.clientY},A.current=!1,l.current.clear();const C=x.map(async S=>{const F=document.querySelector(`[data-element-id="${S}"]`);if(!F||!DO(F))return;await RA.createCache(S,F,{padding:n});const M=F.getBoundingClientRect();l.current.set(S,{offsetX:M.left,offsetY:M.top})});await Promise.all(C)},[e,n]),f=ne.useCallback((x,w,C,S)=>{if(!e||!s.current)return;const{activeIds:F}=a.current;if(F.size===0)return;if(!A.current){const Z=w-s.current.x,J=C-s.current.y;if(Math.sqrt(Z*Z+J*J)<r)return;A.current=!0}const M=w-s.current.x,L=C-s.current.y;for(const Z of F){const J=l.current.get(Z);J&&(!RA.isCacheActive(Z)&&RA.hasCache(Z)&&(RA.activateCache(Z,J.offsetX,J.offsetY),a.current.isCaching=!0),RA.isCacheActive(Z)&&RA.moveCache(Z,J.offsetX+M,J.offsetY+L))}},[e,r]),h=ne.useCallback(()=>{if(!e)return;const{activeIds:x}=a.current;for(const w of x)RA.deactivateCache(w);a.current.activeIds.clear(),a.current.isCaching=!1,s.current=null,A.current=!1,l.current.clear()},[e]),g=ne.useCallback(x=>{e&&RA.invalidateCache(x)},[e]),v=ne.useCallback(()=>{e&&RA.clearAll()},[e]),m=ne.useCallback(()=>a.current.isCaching,[]);return ne.useEffect(()=>()=>{RA.clearAll()},[]),{onDragStart:c,onDragMove:f,onDragEnd:h,invalidate:g,invalidateAll:v,isActive:m,enabled:e}}const Rd=10,HO=8,PO=10,Wl=(t,e,r)=>Math.min(r,Math.max(e,t)),Ju=(t,e)=>{if(e.length<=1)return null;const r=t.filter(l=>e.includes(l.id));if(r.length===0)return null;let n=1/0,a=1/0,s=-1/0,A=-1/0;return r.forEach(l=>{const c=l.rotation*Math.PI/180,f=Math.cos(c),h=Math.sin(c),g=l.clip||{top:0,right:0,bottom:0,left:0},v=l.x+g.left,m=l.y+g.top,x=l.width-g.left-g.right,w=l.height-g.top-g.bottom,C=v+x/2,S=m+w/2;[{x:v,y:m},{x:v+x,y:m},{x:v+x,y:m+w},{x:v,y:m+w}].forEach(M=>{const L=M.x-C,Z=M.y-S,J=L*f-Z*h+C,K=L*h+Z*f+S;J<n&&(n=J),J>s&&(s=J),K<a&&(a=K),K>A&&(A=K)})}),{x:n,y:a,width:s-n,height:A-a}},ew=t=>{const e=t==null?void 0:t.trim().toLowerCase();return e?e==="ellipse"?"circle":e:null},zO=(t,e,r,n,a,s,A,l,c,f)=>{if(A<=0||l<=0)return t;const h=t.x*A,g=t.y*l,v=t.width*A,m=t.height*l,x=h+v,w=g+m,C=h+v/2,S=g+m/2,F=Math.max(1,v),M=Math.max(1,m),L=a/F,Z=s/M,J=r/L,K=n/Z;let ee=0,V=0;e.includes("l")&&(ee=-J),e.includes("r")&&(ee=J),e.includes("t")&&(V=-K),e.includes("b")&&(V=K),c&&((e.includes("l")||e.includes("r"))&&(ee*=2),(e.includes("t")||e.includes("b"))&&(V*=2));let fe=v+ee,j=m+V;if(f){const Y=s>0?a/s:v/Math.max(1,m),W=e==="l"||e==="r",P=e==="t"||e==="b";W&&!P?j=fe/Y:P&&!W?fe=j*Y:Math.abs(ee)>=Math.abs(V)?j=fe/Y:fe=j*Y}const te=Math.min(A,Rd),z=Math.min(l,Rd);fe=Wl(fe,te,A),j=Wl(j,z,l);let D,se;c||!e.includes("l")&&!e.includes("r")?(D=C-fe/2,se=C+fe/2):e.includes("l")?(se=x,D=se-fe):(D=h,se=D+fe);let q,X;return c||!e.includes("t")&&!e.includes("b")?(q=S-j/2,X=S+j/2):e.includes("t")?(X=w,q=X-j):(q=g,X=q+j),D<0&&(se-=D,D=0),se>A&&(D-=se-A,se=A),q<0&&(X-=q,q=0),X>l&&(q-=X-l,X=l),D=Wl(D,0,Math.max(0,A-fe)),q=Wl(q,0,Math.max(0,l-j)),{x:D/A,y:q/l,width:fe/A,height:j/l}},jO=(t,e,r,n,a,s,A,l,c,f)=>{if(A<=0||l<=0)return t;const h=t.width*A,g=t.height*l,v=a/Math.max(1,h),m=s/Math.max(1,g),x=A*v,w=l*m,C=-(t.x*A)*v,S=-(t.y*l)*m,F=C+x,M=S+w,L=C+x/2,Z=S+w/2;let J=0,K=0;e.includes("l")&&(J=-r),e.includes("r")&&(J=r),e.includes("t")&&(K=-n),e.includes("b")&&(K=n),c&&((e.includes("l")||e.includes("r"))&&(J*=2),(e.includes("t")||e.includes("b"))&&(K*=2));let ee=x+J,V=w+K;if(f){const _=w>0?x/w:1,R=e==="l"||e==="r",ie=e==="t"||e==="b";R&&!ie?V=ee/_:ie&&!R?ee=V*_:Math.abs(J)>=Math.abs(K)?V=ee/_:ee=V*_}const fe=Math.min(A,Rd),j=Math.min(l,Rd),te=a,z=s,D=a*A/Math.max(1,fe),se=s*l/Math.max(1,j);ee=Wl(ee,te,D),V=Wl(V,z,se);let q,X;c||!e.includes("l")&&!e.includes("r")?(q=L-ee/2,X=L+ee/2):e.includes("l")?(X=F,q=X-ee):(q=C,X=q+ee);let Y,W;c||!e.includes("t")&&!e.includes("b")?(Y=Z-V/2,W=Z+V/2):e.includes("t")?(W=M,Y=W-V):(Y=S,W=Y+V);const P=ee/A,O=V/l,k=a/ee,Q=s/V,N=-q/(A*P),I=-Y/(l*O);return l1({x:N,y:I,width:k,height:Q})},KO=(t,e,r,n,a,s,A,l)=>{if(s<=0||A<=0)return t;const c=t.width*s,f=t.height*A,h=n/Math.max(1,c),g=a/Math.max(1,f),v=-e/h,m=-r/g,x=t.x+v/s,w=t.y+m/A,C=-.9,S=1-.1*t.width,F=-.9,M=1-.1*t.height;return{...t,x:Wl(x,C,S),y:Wl(w,F,M)}},qO=({pages:t,activePageId:e,zoom:r,setZoom:n,settings:a,selection:s,setSelection:A,activeGroupId:l,onSetActiveGroupId:c,updateElement:f,customContextMenuItems:h,onDuplicate:g,onDelete:v,onBringToFront:m,onSendToBack:x,onResetZoom:w,onSetActivePage:C,onAddPage:S,onDuplicatePage:F,onDeletePage:M,onRenamePage:L,interactionMode:Z,onAddText:J,showCredit:K,showWatermark:ee})=>{const V=ne.useRef(null),fe=t.find(re=>re.id===e),j=(fe==null?void 0:fe.width)??a.width,te=(fe==null?void 0:fe.height)??a.height,{hitTestTopmost:z,invalidate:D,updateElements:se,updateConfig:q}=MO({width:j,height:te,scale:r/100,offsetX:0,offsetY:0});LO({onUpdate:ne.useCallback(re=>{re.forEach((Te,at)=>{f(at,Te,!1)})},[f])});const{onDragStart:X,onDragMove:Y,onDragEnd:W}=RO({padding:30}),P=ne.useRef(t),O=ne.useRef(e),k=ne.useRef(a),Q=ne.useRef(null),N=ne.useRef(null),I=ne.useRef(()=>{});ne.useLayoutEffect(()=>{P.current=t,O.current=e,k.current=a}),ne.useEffect(()=>{fe&&se(fe.elements)},[fe==null?void 0:fe.elements,se]),ne.useEffect(()=>{q({width:j,height:te,scale:r/100,offsetX:0,offsetY:0})},[j,te,r,q]),ne.useEffect(()=>()=>{Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null),wn.current!==null&&(cancelAnimationFrame(wn.current),wn.current=null),Oa.current!==null&&(cancelAnimationFrame(Oa.current),Oa.current=null)},[]);const[_,R]=ne.useState(!1),[ie,ae]=ne.useState(!1),[ge,ce]=ne.useState(!1),[Ae,ue]=ne.useState(null),[Be,$]=ne.useState({x:0,y:0}),ve=ne.useRef(Be),be=ne.useRef(null),Ne=ne.useRef(!0),Ue=ne.useRef(null),We=ne.useRef(!1),Ze=ne.useRef(null),st=ne.useRef(null),rt=ne.useRef(0),Ie=ne.useRef({snapX:0,snapY:0,lines:[]}),De=ne.useRef(null),[pe,ke]=ne.useState(null),Qe=ne.useRef(0),Ge=ne.useRef(0),[pt,et]=ne.useState(null),[_t,Tt]=ne.useState({}),Mt=ne.useRef(_t),Nt=ne.useRef(null),Rt=ne.useRef(null),Ht=ne.useRef(null),Yt=ne.useRef(!1),[Wt,Zt]=ne.useState(null),[Ir,ur]=ne.useState(.15);ne.useEffect(()=>{ee&&fetch("/api/settings/public").then(re=>re.json()).then(re=>{re.watermarkUrl&&Zt(re.watermarkUrl),re.watermarkOpacity&&ur(parseFloat(re.watermarkOpacity))}).catch(()=>{})},[ee]);const gt=ne.useCallback(re=>{ve.current=re,$(re)},[]),Vt=ne.useCallback(re=>{Mt.current=re,Tt(re)},[]),mn=ne.useCallback((re,Te,at)=>{const qe=++Qe.current;ke({id:qe,x:re,y:Te,type:at}),setTimeout(()=>{ke(Xe=>(Xe==null?void 0:Xe.id)===qe?null:Xe)},260)},[]),Sr=ne.useCallback(()=>{Oa.current!==null&&(cancelAnimationFrame(Oa.current),Oa.current=null),Za.current={vx:0,vy:0},Re.current=null},[]),Mr=ne.useCallback(()=>{if(!V.current)return;let{vx:re,vy:Te}=Za.current;const at=.02;if(Math.abs(re)+Math.abs(Te)<at)return;Oa.current!==null&&cancelAnimationFrame(Oa.current);let qe=performance.now();const Xe=Qt=>{const vt=Math.max(1,Qt-qe);if(qe=Qt,!V.current){Oa.current=null;return}V.current.scrollLeft+=re*vt,V.current.scrollTop+=Te*vt;const Gt=Math.pow(.92,vt/16.7);if(re*=Gt,Te*=Gt,Math.abs(re)+Math.abs(Te)<at){Oa.current=null;return}Oa.current=requestAnimationFrame(Xe)};Oa.current=requestAnimationFrame(Xe)},[]),pr=ne.useCallback((re=!1)=>{Ze.current&&(clearTimeout(Ze.current),Ze.current=null),st.current=null,re&&(We.current=!1)},[]),dr=ne.useCallback(re=>{pr(!0),st.current={x:re.clientX,y:re.clientY},Ze.current=setTimeout(()=>{Ze.current=null,st.current&&(We.current=!0,mn(st.current.x,st.current.y,"precision"))},300)},[pr,mn]),Sn=ne.useCallback(re=>{const Te=document.querySelector(`[data-element-id="${re}"] img`);return{width:(Te==null?void 0:Te.naturalWidth)??0,height:(Te==null?void 0:Te.naturalHeight)??0}},[]),ta=ne.useCallback((re,Te,at)=>c1(re.crop,re.width,re.height,Te,at),[]),[Pr,cn]=ne.useState(null),[Jt,on]=ne.useState(null),[Bn,sn]=ne.useState(null),[$r,en]=ne.useState([]),[Zr,tn]=ne.useState([]),[rn,ma]=ne.useState(null),[Yn,Ln]=ne.useState(null),[or,_e]=ne.useState(null),[$e,Se]=ne.useState([]),[kt,yt]=ne.useState(!1),[Le,$t]=ne.useState(!1),[Ct,fr]=ne.useState({x:0,y:0,scrollLeft:0,scrollTop:0}),jr=ne.useRef(new Map),er=ne.useRef(null),Xr=ne.useRef(!1),pa=ne.useRef(null),Oa=ne.useRef(null),Za=ne.useRef({vx:0,vy:0}),Re=ne.useRef(null),ht=ne.useRef(null),tr=ne.useRef(null),_r=ne.useRef(null),[zt,Lr]=ne.useState(null),[sr,xr]=ne.useState(!1),[Tr,Br]=ne.useState(null),[Vr,kn]=ne.useState(null),[Ca,bn]=ne.useState(null),En=ne.useRef(null),wn=ne.useRef(null),qn=ne.useRef(null),On=ne.useRef(!1);ne.useEffect(()=>{if(!Vr)return;const re=s.length===1?s[0]:null;(Z!=="direct-select"||!re||re!==Vr.elementId)&&kn(null)},[Z,s,Vr]);const[Qo,lo]=ne.useState(!1);ne.useEffect(()=>{typeof window<"u"&&window.__FRACZLED_DISABLE_AUTO_FIT__||setTimeout(()=>co(),100)},[]),ne.useEffect(()=>{const re=document.getElementById(`page-wrapper-${e}`);if(re&&V.current&&!Le){const Te=re.getBoundingClientRect(),at=V.current.getBoundingClientRect();if(!(Te.top>=at.top&&Te.bottom<=at.bottom)){const Xe=re.offsetTop,Qt=re.clientHeight,vt=V.current.clientHeight,Gt=Math.max(0,Xe-(vt-Qt)/2);V.current.scrollTo({top:Gt,behavior:"smooth"})}}},[e]);const co=()=>{const re=P.current,Te=O.current,at=k.current;setTimeout(()=>{if(!V.current)return;const qe=re.find(Pt=>Pt.id===Te);if(!qe)return;const Xe=qe.width??at.width,Qt=qe.height??at.height,{clientWidth:vt,clientHeight:Gt}=V.current,nt=document.querySelector('[data-mobile-toolbar="true"]'),ft=nt?nt.getBoundingClientRect().height:0,je=64,Ye=80+ft,Ke=Math.max(100,vt-je),Dt=Math.max(100,Gt-Ye),rr=Xe+(at.showBleed?at.bleed*2:0),Er=Qt+(at.showBleed?at.bleed*2:0),Cr=Ke/rr,ar=Dt/Er,Dr=Math.min(Cr,ar),Xt=Math.floor(Dr*100),mr=Math.max(5,Math.min(200,Xt));n(mr),lo(!0)},0)};ne.useEffect(()=>{if(Qo&&V.current){const re=setTimeout(()=>{const Te=document.getElementById(`page-wrapper-${e}`);if(Te&&V.current){const at=Te.offsetTop,qe=Te.offsetHeight,Xe=V.current.clientHeight;let Qt=at-(Xe-qe)/2;Qt=Math.max(0,Qt),V.current.scrollTo({top:Qt,left:0,behavior:"auto"})}lo(!1)},50);return()=>clearTimeout(re)}},[Qo,r,e]),ne.useEffect(()=>{const re=()=>co(),Te=Qt=>{var Gt;const vt=(Gt=Qt.detail)==null?void 0:Gt.id;vt&&Ln(nt=>nt===vt?null:vt)},at=()=>{V.current&&V.current.scrollTo({top:0,left:0,behavior:"auto"})};window.addEventListener("canvas-fit-to-screen",re),window.addEventListener("toggle-crop-mode",Te),window.addEventListener("canvas-scroll-to-top",at);const qe=Qt=>{const vt=Qt.target,Gt=vt.tagName==="INPUT"||vt.tagName==="TEXTAREA"||vt.isContentEditable;Qt.code==="Space"&&!Gt&&(Qt.preventDefault(),yt(!0))},Xe=Qt=>{Qt.code==="Space"&&(yt(!1),$t(!1))};return window.addEventListener("keydown",qe),window.addEventListener("keyup",Xe),()=>{window.removeEventListener("canvas-fit-to-screen",re),window.removeEventListener("toggle-crop-mode",Te),window.removeEventListener("canvas-scroll-to-top",at),window.removeEventListener("keydown",qe),window.removeEventListener("keyup",Xe)}},[]),ne.useEffect(()=>{const re=Te=>{const at=Te.target;if(!(at&&(at.tagName==="INPUT"||at.tagName==="TEXTAREA"||at.isContentEditable))){if(Te.code==="Escape"){const Xe=Ht.current;Xe&&(f(Xe.id,{crop:Xe.crop},!1),Yt.current=!0,R(!1),cn(null),_e(null),on(null),Se([]),Rt.current=null,Nt.current=null,Ht.current=null),Yn&&Ln(null)}Te.code==="Enter"&&Yn&&Ln(null)}};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[Yn,f]);const Da=(re,Te,at)=>{const qe=document.getElementById(`page-canvas-${at??e}`);if(!qe)return{x:0,y:0};const Xe=qe.getBoundingClientRect(),Qt=r/100;return{x:(re-Xe.left)/Qt,y:(Te-Xe.top)/Qt}},fs=(re,Te)=>re?Te.filter(at=>{const qe=re.elements.find(Xe=>Xe.id===at);return!!qe&&!qe.locked}):Te,bo=(re,Te,at)=>{const qe=re.clip;if(!qe)return!0;const Xe=Math.max(0,qe.left??0),Qt=Math.max(0,qe.top??0),vt=Math.max(0,qe.right??0),Gt=Math.max(0,qe.bottom??0);if(!(Qt>0||vt>0||Gt>0||Xe>0))return!0;const ft=re.width-Xe-vt,je=re.height-Qt-Gt;if(ft<=0||je<=0)return!1;const Ye=Xe+ft/2,Ke=Qt+je/2,Dt=re.x+Ye,rr=re.y+Ke,Er=-(re.rotation||0)*Math.PI/180,Cr=Te-Dt,ar=at-rr,Dr=Cr*Math.cos(Er)-ar*Math.sin(Er)+Ye,Xt=Cr*Math.sin(Er)+ar*Math.cos(Er)+Ke;return Dr>=Xe&&Dr<=Xe+ft&&Xt>=Qt&&Xt<=Qt+je},Io=re=>{let Te=0,at=0,qe=0;return re.forEach(Xe=>{Te+=Xe.x,at+=Xe.y,qe+=1}),{x:Te/qe,y:at/qe}},gr=re=>{if(re.pointerType!=="touch"||!V.current)return!1;const Te=jr.current;if(Te.set(re.pointerId,{x:re.clientX,y:re.clientY}),Te.size<2)return!1;if(!Yt.current&&(Pr||Ae)){if(Pr){const Qt=t.flatMap(vt=>vt.elements).find(vt=>vt.id===Pr);Qt&&f(Qt.id,{},!0)}if(Ae){const Qt=Object.keys(Ae.elementSnapshots)[0];Qt&&f(Qt,{},!0)}}Yt.current=!1,R(!1),ae(!1),ce(!1),cn(null),_e(null),on(null),sn(null),en([]),tn([]),Se([]),ue(null),Rt.current=null,Nt.current=null,_r.current=null,Ht.current=null,Ue.current=null,De.current=null,xr(!1),Br(null),pr(!0),rt.current=0,Ie.current={snapX:0,snapY:0,lines:[]},Ge.current=0,ke(null);const at=Io(Te);er.current={x:at.x,y:at.y,scrollLeft:V.current.scrollLeft,scrollTop:V.current.scrollTop},Sr(),Za.current={vx:0,vy:0},Re.current={x:at.x,y:at.y,time:performance.now()};const qe=Array.from(Te.values()),Xe=Math.hypot(qe[1].x-qe[0].x,qe[1].y-qe[0].y);return pa.current={distance:Xe,zoom:r},Xr.current=!0,$t(!0),xr(!1),Br(null),!0},wo=re=>{Sr(),gr(re),re.pointerType==="touch"&&(be.current={x:re.clientX,y:re.clientY},Ne.current=!1,Ue.current=null,De.current=null,pr(!0))},Bs=(re,Te)=>{if(re.pointerType==="touch"&&Xr.current)return;if(re.stopPropagation(),re.preventDefault(),re.target.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"group-resize",handle:Te};return}const qe=t.find(Gt=>Gt.id===e);if(!qe)return;const Xe=fs(qe,s),Qt=Ju(qe.elements,Xe);if(!Qt)return;const vt={};Xe.forEach(Gt=>{const nt=qe.elements.find(ft=>ft.id===Gt);nt&&(vt[Gt]=JSON.parse(JSON.stringify(nt)))}),ue({type:"resize",handle:Te,startBounds:Qt,startMouse:{x:re.clientX,y:re.clientY},elementSnapshots:vt})},Or=re=>{if(re.pointerType==="touch"&&Xr.current)return;if(re.stopPropagation(),re.preventDefault(),re.target.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"group-rotate"};return}const at=t.find(vt=>vt.id===e);if(!at)return;const qe=fs(at,s),Xe=Ju(at.elements,qe);if(!Xe)return;const Qt={};qe.forEach(vt=>{const Gt=at.elements.find(nt=>nt.id===vt);Gt&&(Qt[vt]=JSON.parse(JSON.stringify(Gt)))}),ue({type:"rotate",startBounds:Xe,startMouse:{x:re.clientX,y:re.clientY},elementSnapshots:Qt,rotation:0})},Yi=re=>{if(re.pointerType==="touch"&&Xr.current)return;if(re.stopPropagation(),re.preventDefault(),re.target.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"group-move"};return}const at=t.find(vt=>vt.id===e);if(!at)return;const qe=fs(at,s),Xe=Ju(at.elements,qe);if(!Xe)return;const Qt={};qe.forEach(vt=>{const Gt=at.elements.find(nt=>nt.id===vt);Gt&&(Qt[vt]=JSON.parse(JSON.stringify(Gt)))}),ue({type:"move",startBounds:Xe,startMouse:{x:re.clientX,y:re.clientY},elementSnapshots:Qt})},va=(re,Te,at)=>{ds(),tr.current={x:re,y:Te,elementId:at},ht.current=setTimeout(()=>{if(tr.current){const{x:qe,y:Xe,elementId:Qt}=tr.current;Ue.current=null,Ne.current=!0,pr(!0),Qt?(s.includes(Qt)||A([Qt]),Lr({x:qe,y:Xe,type:"object",targetId:Qt})):Lr({x:qe,y:Xe,type:"canvas"}),R(!1),cn(null)}tr.current=null},500)},ds=()=>{ht.current&&(clearTimeout(ht.current),ht.current=null),tr.current=null},uo=re=>{if(re.preventDefault(),Le)return;const{x:Te,y:at}=Da(re.clientX,re.clientY),qe=z(Te,at);if(qe.elementId)s.includes(qe.elementId)||A([qe.elementId]),Lr({x:re.clientX,y:re.clientY,type:"object",targetId:qe.elementId});else{const Qt=re.target.closest("[data-element-id]");if(Qt){const vt=Qt.getAttribute("data-element-id");if(vt){s.includes(vt)||A([vt]),Lr({x:re.clientX,y:re.clientY,type:"object",targetId:vt});return}}Lr({x:re.clientX,y:re.clientY,type:"canvas"})}},Pa=re=>{var Xe;if(re.pointerType==="touch"&&Xr.current)return;if(kt||Z==="hand"){re.preventDefault(),$t(!0),V.current&&fr({x:re.clientX,y:re.clientY,scrollLeft:V.current.scrollLeft,scrollTop:V.current.scrollTop});return}if(Z==="pen")return;if(Z==="direct-select"){re.button===0&&!re.shiftKey&&(A([]),kn(null),c(null),Lr(null));return}if(Yn){re.target.closest(".crop-controls")||(Ln(null),_e(null),Rt.current=null);return}const Te=re.target;if(Te.closest("button")||Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.closest(".handle-control"))return;const at=Te.closest('[id^="page-wrapper-"]'),qe=((Xe=at==null?void 0:at.id)==null?void 0:Xe.replace("page-wrapper-",""))||e;if(re.pointerType==="touch"&&s.length>0&&qe===e){const Qt=t.find(Gt=>Gt.id===qe),vt=Qt?Ju(Qt.elements,s):null;if(vt){const{x:Gt,y:nt}=Da(re.clientX,re.clientY,qe),ft=(Rn?18:12)*(100/r);if(Gt>=vt.x-ft&&Gt<=vt.x+vt.width+ft&&nt>=vt.y-ft&&nt<=vt.y+vt.height+ft){const Ye=fs(Qt,s);if(Ye.length>0){De.current=null,xr(!1),Br(null),Ue.current={kind:"drag",dragSelectionIds:Ye,activeDragId:Ye[0],pageId:qe},re.currentTarget.setPointerCapture(re.pointerId),re.preventDefault();return}}}}if((re.target===V.current||re.target.closest(".group\\/page"))&&re.button===0){re.shiftKey||(A([]),c(null),Lr(null)),at&&qe&&qe!==e&&C(qe);const{x:Qt,y:vt}=Da(re.clientX,re.clientY,qe);re.pointerType==="touch"?(De.current={pageId:qe,startX:Qt,startY:vt},xr(!1),Br(null)):(xr(!0),Br({startX:Qt,startY:vt,currentX:Qt,currentY:vt})),re.currentTarget.setPointerCapture(re.pointerId),re.preventDefault()}},Wi=(re,Te)=>{if(re.stopPropagation(),re.pointerType==="touch"&&Xr.current||kt||Le||Z==="hand"||Z==="pen")return;if(Z==="direct-select"){re.button===0&&!re.shiftKey&&(A([]),kn(null),c(null));return}if(re.button!==0)return;if(e!==Te&&C(Te),Z==="text"){const Qt=re.currentTarget.getBoundingClientRect(),vt=r/100,Gt=(re.clientX-Qt.left)/vt,nt=(re.clientY-Qt.top)/vt;J("Type here","body",Gt,nt);return}re.shiftKey||(A([]),c(null)),xr(!0);const{x:at,y:qe}=Da(re.clientX,re.clientY,Te);re.pointerType==="touch"?(De.current={pageId:Te,startX:at,startY:qe},xr(!1),Br(null)):Br({startX:at,startY:qe,currentX:at,currentY:qe}),re.currentTarget.setPointerCapture(re.pointerId)},Qi=re=>{l&&(c(null),A([]))},Go=(re,Te)=>{if(re.stopPropagation(),!Te.locked){if(Te.groupId&&l!==Te.groupId){c(Te.groupId),A([Te.id],!1);return}Te.type==="text"?ma(Te.id):Te.type==="image"&&!Te.isIcon&&Ln(Te.id)}},ci=(re,Te,at)=>{if(re.pointerType==="touch"&&Xr.current||kt||Z==="hand"||Z==="pen")return;e!==at&&C(at);const qe=t.find(Xt=>Xt.id===at),Xe=qe==null?void 0:qe.elements.find(Xt=>Xt.id===Te);if(Xe!=null&&Xe.locked||rn===Te)return;const vt=!!re.target.closest(".handle-control"),{x:Gt,y:nt}=Da(re.clientX,re.clientY,at);if(Xe&&!vt&&!bo(Xe,Gt,nt))return;if(re.stopPropagation(),Yt.current=!1,zt&&Lr(null),re.pointerType==="touch"&&va(re.clientX,re.clientY,Te),Yn===Te){const Xt=re.target;if(re.target.closest(".crop-controls"))return;if(Xt.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"crop-pan",id:Te,pageId:at};return}if(R(!0),cn(Te),_e(Te),Rt.current="pan",Nt.current=null,gt({x:re.clientX,y:re.clientY}),Xe){const mr=Sn(Te),Pt=mr.width||Xe.width,Un=mr.height||Xe.height,fn=ta(Xe,Pt,Un);Vt({[Te]:{x:Xe.x,y:Xe.y,width:Xe.width,height:Xe.height,rotation:Xe.rotation,cropRect:fn,naturalWidth:Pt,naturalHeight:Un}}),Ht.current={id:Te,crop:fn}}return}Ln(null),_e(null),Rt.current=null,re.target.setPointerCapture(re.pointerId);let je=[...s];const Ye=l&&(Xe==null?void 0:Xe.groupId)===l;l&&(Xe==null?void 0:Xe.groupId)!==l&&!re.shiftKey&&c(null);const Ke=Xt=>{const mr=qe==null?void 0:qe.elements.find(Pt=>Pt.id===Xt);return mr!=null&&mr.groupId?(qe==null?void 0:qe.elements.filter(Pt=>Pt.groupId===mr.groupId&&!Pt.locked).map(Pt=>Pt.id))||[Xt]:[Xt]};if(re.shiftKey){const Xt=Ye?[Te]:Ke(Te);if(Xt.every(Pt=>s.includes(Pt)))je=s.filter(Pt=>!Xt.includes(Pt));else{const Pt=Xt.filter(Un=>!s.includes(Un));je=[...s,...Pt]}A(je)}else if(Ye)A([Te],!1);else if(Xe!=null&&Xe.groupId){const Xt=Ke(Te);A(Xt,!0)}else s.includes(Te)||A([Te],!0);if(Z==="direct-select"){(Xe==null?void 0:Xe.type)==="path"?kn(Xt=>(Xt==null?void 0:Xt.elementId)===Te?Xt:{elementId:Te,selection:{anchors:[],handle:null}}):kn(null);return}let Dt=je;re.shiftKey?Dt=je:Ye?Dt=[Te]:Xe!=null&&Xe.groupId?Dt=Ke(Te):s.includes(Te)?Dt=s:Dt=[Te];const rr=fs(qe,Dt);rr.length>0&&(Dt=rr);let Er=Te;if(re.altKey&&Dt.length>0){A(Dt,!1);const Xt=Oe.duplicateSelectionInPlace();Xt.length>0&&(Dt=Xt,Er=Xt[0])}if(re.pointerType==="touch"){Ue.current={kind:"drag",dragSelectionIds:Dt,activeDragId:Er,pageId:at};return}const ar=Oe.getSnapshot().pages.find(Xt=>Xt.id===at)||qe,Dr={};ar==null||ar.elements.forEach(Xt=>{Dt.includes(Xt.id)&&(Dr[Xt.id]={x:Xt.x,y:Xt.y,width:Xt.width,height:Xt.height,rotation:Xt.rotation})}),Vt(Dr),R(!0),cn(Er),gt({x:re.clientX,y:re.clientY}),on(null),Nt.current=null,Rt.current=null,_e(null),X(Dt,{clientX:re.clientX,clientY:re.clientY})},Es=(re,Te,at,qe,Xe="frame")=>{if(re.pointerType==="touch"&&Xr.current||kt)return;const Qt=t.find(Ye=>Ye.id===qe),vt=Qt==null?void 0:Qt.elements.find(Ye=>Ye.id===Te);if(vt!=null&&vt.locked)return;if(re.stopPropagation(),Yt.current=!1,re.target.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"resize",id:Te,handle:at,pageId:qe,source:Xe};return}const nt=["t","b","l","r"].includes(at),ft=re.ctrlKey&&re.shiftKey&&nt,je=(vt==null?void 0:vt.type)==="image"&&Yn===Te;if(Nt.current=ft?"clip":je?"crop":"resize",Rt.current=je?"handle":null,_r.current=Xe,R(!0),cn(Te),on(at),gt({x:re.clientX,y:re.clientY}),_e(je?Te:null),(vt==null?void 0:vt.type)==="text"&&(at.includes("l")||at.includes("r"))&&f(Te,{autoWidth:!1},!1),vt){const Ye=vt.type==="image"?Sn(Te):{width:0,height:0},Ke=Ye.width||vt.width,Dt=Ye.height||vt.height,rr=vt.type==="image"?ta(vt,Ke,Dt):void 0;Vt({[Te]:{x:vt.x,y:vt.y,width:vt.width,height:vt.height,rotation:vt.rotation,fontSize:vt.fontSize,cropRect:rr,naturalWidth:vt.type==="image"?Ke:void 0,naturalHeight:vt.type==="image"?Dt:void 0,path:vt.type==="path"&&vt.path?JSON.parse(JSON.stringify(vt.path)):void 0,clip:vt.clip?{...vt.clip}:{top:0,right:0,bottom:0,left:0}}}),vt.type==="image"&&rr&&(Ht.current={id:Te,crop:rr})}},bA=(re,Te,at)=>{if(re.pointerType==="touch"&&Xr.current||kt)return;const qe=t.find(vt=>vt.id===at),Xe=qe==null?void 0:qe.elements.find(vt=>vt.id===Te);if(Xe!=null&&Xe.locked)return;if(re.stopPropagation(),re.target.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"rotate",id:Te,pageId:at};return}if(ae(!0),cn(Te),Xe){const vt=Yn===Te?"image":"element",Gt=vt==="image"?Xe.imageRotation??0:Xe.rotation;Vt({[Te]:{x:Xe.x,y:Xe.y,width:Xe.width,height:Xe.height,rotation:Xe.rotation}});const nt=document.querySelector(`[data-element-id="${Te}"]`);if(nt){const ft=nt.getBoundingClientRect();let je=ft.left+ft.width/2,Ye=ft.top+ft.height/2;if(Xe.clip&&(Xe.clip.top>0||Xe.clip.right>0||Xe.clip.bottom>0||Xe.clip.left>0)){const Dt=Xe.width-Xe.clip.left-Xe.clip.right,rr=Xe.height-Xe.clip.top-Xe.clip.bottom,Er=Xe.clip.left+Dt/2,Cr=Xe.clip.top+rr/2,ar=ft.width/Xe.width,Dr=ft.height/Xe.height;je=ft.left+Er*ar,Ye=ft.top+Cr*Dr}const Ke=Math.atan2(re.clientY-Ye,re.clientX-je)*(180/Math.PI);et({startAngle:Ke,initialRotation:Gt,mode:vt})}}},es=(re,Te,at,qe,Xe,Qt)=>{if(re.pointerType==="touch"&&Xr.current||kt)return;const vt=t.find(ft=>ft.id===qe),Gt=vt==null?void 0:vt.elements.find(ft=>ft.id===Te);if(Gt!=null&&Gt.locked)return;if(re.stopPropagation(),re.target.setPointerCapture(re.pointerId),re.pointerType==="touch"){Ue.current={kind:"radius",id:Te,vector:at,pageId:qe,activeCorners:Xe,allCorners:Qt};return}if(ce(!0),cn(Te),sn(at),en(Xe),tn(Qt),gt({x:re.clientX,y:re.clientY}),Gt){const ft=Gt.cornerRadius?typeof Gt.cornerRadius=="object"?{...Gt.cornerRadius}:Gt.cornerRadius:0;Vt({[Te]:{x:Gt.x,y:Gt.y,width:Gt.width,height:Gt.height,rotation:Gt.rotation,cornerRadius:ft}})}},ui=(re,Te,at,qe,Xe,Qt)=>{const vt=Qt??5,Gt=[{value:0,type:"page-edge"},{value:at/2,type:"page-center"},{value:at,type:"page-edge"}],nt=[{value:0,type:"page-edge"},{value:qe/2,type:"page-center"},{value:qe,type:"page-edge"}];if(a.showBleed){const ar=a.bleed;Gt.push({value:-ar,type:"bleed"},{value:at+ar,type:"bleed"}),nt.push({value:-ar,type:"bleed"},{value:qe+ar,type:"bleed"})}if(a.showSafeArea){const ar=a.safeArea;Gt.push({value:ar,type:"safe"},{value:at-ar,type:"safe"},{value:at/2,type:"safe"}),nt.push({value:ar,type:"safe"},{value:qe-ar,type:"safe"},{value:qe/2,type:"safe"})}Te.forEach(ar=>{ar.visible&&(Gt.push({value:ar.x,type:"element-edge"},{value:ar.x+ar.width/2,type:"element-center"},{value:ar.x+ar.width,type:"element-edge"}),nt.push({value:ar.y,type:"element-edge"},{value:ar.y+ar.height/2,type:"element-center"},{value:ar.y+ar.height,type:"element-edge"}))});const ft=[{value:re.x,anchor:"left"},{value:re.x+re.width/2,anchor:"center"},{value:re.x+re.width,anchor:"right"}];let je=null,Ye=vt,Ke=[];Gt.forEach(ar=>{ft.forEach(Dr=>{if(Xe&&!Xe.includes(Dr.anchor))return;const Xt=ar.value-Dr.value;Math.abs(Xt)<=Ye&&(Math.abs(Xt)<Ye-.01&&(Ke=[],Ye=Math.abs(Xt),je=Xt),Math.abs(Xt-(je||0))<.01&&Ke.push({orientation:"vertical",position:ar.value,start:a.showBleed?-a.bleed:0,end:a.showBleed?qe+a.bleed:qe,type:ar.type}))})});const Dt=[{value:re.y,anchor:"top"},{value:re.y+re.height/2,anchor:"middle"},{value:re.y+re.height,anchor:"bottom"}];let rr=null,Er=vt,Cr=[];return nt.forEach(ar=>{Dt.forEach(Dr=>{if(Xe&&!Xe.includes(Dr.anchor))return;const Xt=ar.value-Dr.value;Math.abs(Xt)<=Er&&(Math.abs(Xt)<Er-.01&&(Cr=[],Er=Math.abs(Xt),rr=Xt),Math.abs(Xt-(rr||0))<.01&&Cr.push({orientation:"horizontal",position:ar.value,start:a.showBleed?-a.bleed:0,end:a.showBleed?at+a.bleed:at,type:ar.type}))})}),{snapX:je||0,snapY:rr||0,lines:[...Ke,...Cr]}},zs=(re,Te=!1)=>{const at=Object.keys(re);at.length!==0&&(typeof Oe.updateElementsById=="function"?Oe.updateElementsById(re,Te):at.forEach(qe=>f(qe,re[qe],Te)),D())},Ra=ne.useCallback(re=>{for(const Te of P.current){const at=Te.elements.find(qe=>qe.id===re);if(at)return at}return null},[]),Vo=ne.useCallback(re=>{if(!re||!re.visible||re.locked)return!1;if(re.type==="image")return!0;if(re.type==="shape"){const Te=ew(re.content);return!!Te&&Te!=="line"}return re.type==="path"?!!re.path:!1},[]),$o=ne.useCallback((re,Te)=>{if(re.type==="image")return{content:Te.content};if(re.type==="shape"){const at=ew(re.content);if(!at||at==="line")return null;const qe=at==="rect"||at==="rectangle"||at==="square";return{type:"image",content:Te.content,clipShape:qe?void 0:at,backgroundColor:void 0,crop:re.crop??OA(re.width,re.height,Te.width,Te.height)}}return re.type==="path"&&re.path?{type:"image",content:Te.content,clipShape:"path",backgroundColor:void 0,crop:re.crop??OA(re.width,re.height,Te.width,Te.height)}:null},[]),Cs=ne.useCallback((re,Te,at=300)=>{let qe=re>0?re:at,Xe=Te>0?Te:at;return qe>Xe?qe>at&&(Xe=Xe*(at/qe),qe=at):Xe>at&&(qe=qe*(at/Xe),Xe=at),{width:qe,height:Xe}},[]),Js=ne.useCallback(re=>Oe.getSnapshot().uploads.find(at=>at.id===re)??null,[]),ts=ne.useCallback(re=>{En.current!==re&&(En.current=re,bn(re))},[]),Sa=ne.useCallback(()=>{qn.current=null,ts(null),wn.current!==null&&(cancelAnimationFrame(wn.current),wn.current=null)},[ts]);ne.useEffect(()=>{const re=()=>{On.current=!0,Sa()},Te=()=>{On.current=!1,Sa()};return window.addEventListener(hg,re),window.addEventListener(pg,Te),window.addEventListener(mg,re),window.addEventListener(vg,Te),()=>{window.removeEventListener(hg,re),window.removeEventListener(pg,Te),window.removeEventListener(mg,re),window.removeEventListener(vg,Te)}},[Sa]);const Lo=ne.useCallback(re=>{if(On.current)return!0;if(!re)return!1;const Te=Array.from(re.types||[]);return Te.includes(dg)||Te.includes(gg)},[]),Ss=ne.useCallback((re,Te)=>{const at=document.getElementById(`page-canvas-${e}`);if(!at)return null;const qe=at.getBoundingClientRect();if(re<qe.left||re>qe.right||Te<qe.top||Te>qe.bottom)return null;const Xe=r/100;return{x:(re-qe.left)/Xe,y:(Te-qe.top)/Xe}},[e,r]),Ii=ne.useCallback(()=>{const re=qn.current;if(!re)return;const Te=Ss(re.clientX,re.clientY);if(!Te){ts(null);return}const at=z(Te.x,Te.y);if(!at.elementId){ts(null);return}const qe=P.current.find(Qt=>Qt.id===e),Xe=(qe==null?void 0:qe.elements.find(Qt=>Qt.id===at.elementId))??null;ts(Vo(Xe)?at.elementId:null)},[e,Ss,z,Vo,ts]),it=ne.useCallback((re,Te,at=!1)=>{const qe=Ra(re);if(!qe)return;const Xe=UL(qe,Te);f(re,{x:Xe.x,y:Xe.y,width:Xe.width,height:Xe.height,path:Xe.path,strokeColor:Xe.path.strokeColor,strokeWidth:Xe.path.strokeWidth,backgroundColor:Xe.path.fillColor??void 0},at)},[Ra,f]),Ut=ne.useCallback((re,Te,at)=>{A([re],!1),kn(qe=>{const Xe=(qe==null?void 0:qe.elementId)===re?qe.selection:{anchors:[]},Qt=at?Xe.anchors.includes(Te)?Xe.anchors.filter(vt=>vt!==Te):[...Xe.anchors,Te]:[Te];return{elementId:re,selection:{anchors:Qt,handle:null}}})},[A]),qt=ne.useCallback((re,Te,at,qe)=>{A([re],!1),kn(Xe=>{var ft,je;const Qt=(Xe==null?void 0:Xe.elementId)===re?Xe.selection:{anchors:[],handle:null},vt=((ft=Qt.handle)==null?void 0:ft.anchorId)===Te&&((je=Qt.handle)==null?void 0:je.type)===at,Gt=qe&&vt?null:{anchorId:Te,type:at},nt=qe?Qt.anchors:[];return{elementId:re,selection:{anchors:nt,handle:Gt}}})},[A]),bt=ne.useCallback(re=>{const Te=w7(re);Oe.addElement({type:"path",name:"Path",content:"",x:Te.x,y:Te.y,width:Te.width,height:Te.height,rotation:0,opacity:1,visible:!0,strokeColor:Te.path.strokeColor,strokeWidth:Te.path.strokeWidth,backgroundColor:Te.path.fillColor??void 0,path:Te.path})},[]),ir=ne.useCallback(re=>{const Te=P.current.find(nt=>nt.elements.some(ft=>ft.id===re)),at=Te==null?void 0:Te.elements.find(nt=>nt.id===re);if(!Te||!at||at.type!=="image")return;const qe=Te.width??a.width,Xe=Te.height??a.height,Qt=(nt,ft)=>{f(re,{x:0,y:0,width:qe,height:Xe,crop:OA(qe,Xe,nt,ft)},!0)},vt=document.querySelector(`[data-element-id="${re}"] img`);if(vt!=null&&vt.naturalWidth&&vt.naturalHeight){Qt(vt.naturalWidth,vt.naturalHeight);return}const Gt=new Image;Gt.onload=()=>{Qt(Gt.naturalWidth||at.width,Gt.naturalHeight||at.height)},Gt.onerror=()=>{Qt(at.width,at.height)},Gt.src=at.content},[a.height,a.width,f]),U=ne.useCallback((re,Te,at=!1)=>{const qe=w7(Te);f(re,{x:qe.x,y:qe.y,width:qe.width,height:qe.height,path:qe.path,strokeColor:qe.path.strokeColor,strokeWidth:qe.path.strokeWidth,backgroundColor:qe.path.fillColor??void 0},at)},[f]),oe=ne.useCallback(re=>{A([re],!1),kn(null)},[A]),xe=ne.useCallback(re=>{Lo(re.dataTransfer)&&(re.preventDefault(),re.dataTransfer.dropEffect="copy",qn.current={clientX:re.clientX,clientY:re.clientY},wn.current===null&&(wn.current=requestAnimationFrame(()=>{wn.current=null,Ii()})))},[Lo,Ii]),Fe=ne.useCallback(re=>{if(!Lo(re.dataTransfer))return;const Te=re.relatedTarget;Te&&re.currentTarget instanceof Node&&re.currentTarget.contains(Te)||Sa()},[Sa,Lo]),Pe=ne.useCallback(re=>{if(!Lo(re.dataTransfer))return;re.preventDefault();const Te=re.dataTransfer.getData(dg),at=re.dataTransfer.getData(gg);let qe=null;if(at)try{qe=JSON.parse(at)}catch{qe=null}let Xe=null,Qt=!1;if(Te){const Ye=Js(Te);Ye&&(Xe=Ye)}else if(qe)Xe={content:qe.url,width:qe.width,height:qe.height,name:qe.name},Qt=!0;else{const Ye=re.dataTransfer.getData("text/plain"),Ke=Ye?Js(Ye):null;Ke&&(Xe=Ke)}if(!Xe){Sa();return}const vt=Ss(re.clientX,re.clientY);if(!vt){Sa();return}const Gt=P.current.find(Ye=>Ye.id===e);if(!Gt){Sa();return}let nt=En.current,ft=nt?Gt.elements.find(Ye=>Ye.id===nt):null;if(ft||(nt=z(vt.x,vt.y).elementId,ft=nt?Gt.elements.find(Ke=>Ke.id===nt):null),ft&&Vo(ft)){const Ye=$o(ft,Xe);if(Ye){Qt&&(qe!=null&&qe.downloadLocation)&&Ud(qe.downloadLocation),f(ft.id,Ye,!0),Sa();return}Sa();return}const je=(Ye,Ke)=>{const Dt=Ye>0?Ye:Xe.width,rr=Ke>0?Ke:Xe.height,{width:Er,height:Cr}=Cs(Dt,rr),ar=vt.x-Er/2,Dr=vt.y-Cr/2;Qt&&(qe!=null&&qe.downloadLocation)&&Ud(qe.downloadLocation),Oe.addElement({type:"image",name:Xe.name||"Image",content:Xe.content,x:ar,y:Dr,width:Er,height:Cr,rotation:0,opacity:1,visible:!0,zIndex:Gt.elements.length+1,locked:!1,crop:OA(Er,Cr,Dt,rr),effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}})};if(qe!=null&&qe.probeUrl){const Ye=new Image;Ye.onload=()=>{je(Ye.naturalWidth||Xe.width,Ye.naturalHeight||Xe.height)},Ye.onerror=()=>{je(Xe.width,Xe.height)},Ye.src=qe.probeUrl,Sa();return}je(Xe.width,Xe.height),Sa()},[e,Sa,Ss,Js,Cs,$o,Vo,Lo,Ud,f]),dt=re=>{const Te=re.pointerType==="touch";if(Te){const nt=jr.current;if(nt.has(re.pointerId)&&nt.set(re.pointerId,{x:re.clientX,y:re.clientY}),nt.size===2){ds();const ft=Array.from(nt.values()),je=Math.hypot(ft[1].x-ft[0].x,ft[1].y-ft[0].y);if(pa.current){const Ye=je/pa.current.distance,Ke=Math.max(10,Math.min(200,pa.current.zoom*Ye));n(Math.round(Ke))}}if(Xr.current&&er.current&&V.current&&nt.size>=2){const ft=Io(nt),je=ft.x-er.current.x,Ye=ft.y-er.current.y;V.current.scrollLeft=er.current.scrollLeft-je,V.current.scrollTop=er.current.scrollTop-Ye;const Ke=performance.now(),Dt=Re.current;if(Dt){const rr=Ke-Dt.time;rr>0&&(Za.current={vx:-(ft.x-Dt.x)/rr,vy:-(ft.y-Dt.y)/rr})}Re.current={x:ft.x,y:ft.y,time:Ke};return}}if(!(()=>{if(!Te||Ne.current)return!0;const nt=be.current;if(!nt)return Ne.current=!0,!0;const ft=re.clientX-nt.x,je=re.clientY-nt.y;return Math.hypot(ft,je)>=HO?(Ne.current=!0,ds(),!0):!1})()&&(sr||_||ie||ge||Ae||Jt||Ue.current))return;if(Te&&Ue.current){const nt=Ue.current;if(Ue.current=null,nt.kind==="drag"){const je=Oe.getSnapshot().pages.find(Ke=>Ke.id===nt.pageId)||t.find(Ke=>Ke.id===nt.pageId),Ye={};je==null||je.elements.forEach(Ke=>{nt.dragSelectionIds.includes(Ke.id)&&(Ye[Ke.id]={x:Ke.x,y:Ke.y,width:Ke.width,height:Ke.height,rotation:Ke.rotation})}),Vt(Ye),R(!0),cn(nt.activeDragId),gt({x:re.clientX,y:re.clientY}),on(null),Nt.current=null,Rt.current=null,_e(null),X(nt.dragSelectionIds,{clientX:re.clientX,clientY:re.clientY}),dr(re);return}if(nt.kind==="crop-pan"){const ft=t.find(Ye=>Ye.id===nt.pageId),je=ft==null?void 0:ft.elements.find(Ye=>Ye.id===nt.id);if(je){const Ye=Sn(nt.id),Ke=Ye.width||je.width,Dt=Ye.height||je.height,rr=ta(je,Ke,Dt);R(!0),cn(nt.id),_e(nt.id),Rt.current="pan",Nt.current=null,gt({x:re.clientX,y:re.clientY}),Vt({[nt.id]:{x:je.x,y:je.y,width:je.width,height:je.height,rotation:je.rotation,cropRect:rr,naturalWidth:Ke,naturalHeight:Dt}}),Ht.current={id:nt.id,crop:rr},dr(re)}return}if(nt.kind==="resize"){const ft=t.find(Cr=>Cr.id===nt.pageId),je=ft==null?void 0:ft.elements.find(Cr=>Cr.id===nt.id);if(!je||je.locked)return;["t","b","l","r"].includes(nt.handle);const Ye=je.type==="image"&&Yn===nt.id;Nt.current=Ye?"crop":"resize",Rt.current=Ye?"handle":null,_r.current=nt.source,R(!0),cn(nt.id),on(nt.handle),gt({x:re.clientX,y:re.clientY}),_e(Ye?nt.id:null),je.type==="text"&&(nt.handle.includes("l")||nt.handle.includes("r"))&&f(nt.id,{autoWidth:!1},!1);const Ke=je.type==="image"?Sn(nt.id):{width:0,height:0},Dt=Ke.width||je.width,rr=Ke.height||je.height,Er=je.type==="image"?ta(je,Dt,rr):void 0;Vt({[nt.id]:{x:je.x,y:je.y,width:je.width,height:je.height,rotation:je.rotation,fontSize:je.fontSize,cropRect:Er,naturalWidth:je.type==="image"?Dt:void 0,naturalHeight:je.type==="image"?rr:void 0,path:je.type==="path"&&je.path?JSON.parse(JSON.stringify(je.path)):void 0,clip:je.clip?{...je.clip}:{top:0,right:0,bottom:0,left:0}}}),je.type==="image"&&Er&&(Ht.current={id:nt.id,crop:Er}),dr(re);return}if(nt.kind==="rotate"){const ft=t.find(rr=>rr.id===nt.pageId),je=ft==null?void 0:ft.elements.find(rr=>rr.id===nt.id);if(!je||je.locked)return;ae(!0),cn(nt.id);const Ye=Yn===nt.id?"image":"element",Ke=Ye==="image"?je.imageRotation??0:je.rotation;Vt({[nt.id]:{x:je.x,y:je.y,width:je.width,height:je.height,rotation:je.rotation}});const Dt=document.querySelector(`[data-element-id="${nt.id}"]`);if(Dt){const rr=Dt.getBoundingClientRect();let Er=rr.left+rr.width/2,Cr=rr.top+rr.height/2;if(je.clip&&(je.clip.top>0||je.clip.right>0||je.clip.bottom>0||je.clip.left>0)){const Dr=je.width-je.clip.left-je.clip.right,Xt=je.height-je.clip.top-je.clip.bottom,mr=je.clip.left+Dr/2,Pt=je.clip.top+Xt/2,Un=rr.width/je.width,fn=rr.height/je.height;Er=rr.left+mr*Un,Cr=rr.top+Pt*fn}const ar=Math.atan2(re.clientY-Cr,re.clientX-Er)*(180/Math.PI);et({startAngle:ar,initialRotation:Ke,mode:Ye})}dr(re);return}if(nt.kind==="radius"){const ft=t.find(Ke=>Ke.id===nt.pageId),je=ft==null?void 0:ft.elements.find(Ke=>Ke.id===nt.id);if(!je||je.locked)return;ce(!0),cn(nt.id),sn(nt.vector),en(nt.activeCorners),tn(nt.allCorners),gt({x:re.clientX,y:re.clientY});const Ye=je.cornerRadius?typeof je.cornerRadius=="object"?{...je.cornerRadius}:je.cornerRadius:0;Vt({[nt.id]:{x:je.x,y:je.y,width:je.width,height:je.height,rotation:je.rotation,cornerRadius:Ye}}),dr(re);return}if(nt.kind==="group-move"||nt.kind==="group-rotate"||nt.kind==="group-resize"){const ft=t.find(Ke=>Ke.id===e);if(!ft)return;const je=Ju(ft.elements,s);if(!je)return;const Ye={};s.forEach(Ke=>{const Dt=ft.elements.find(rr=>rr.id===Ke);Dt&&(Ye[Ke]=JSON.parse(JSON.stringify(Dt)))}),nt.kind==="group-move"?ue({type:"move",startBounds:je,startMouse:{x:re.clientX,y:re.clientY},elementSnapshots:Ye}):nt.kind==="group-rotate"?ue({type:"rotate",startBounds:je,startMouse:{x:re.clientX,y:re.clientY},elementSnapshots:Ye,rotation:0}):ue({type:"resize",handle:nt.handle,startBounds:je,startMouse:{x:re.clientX,y:re.clientY},elementSnapshots:Ye}),dr(re);return}}if(Te&&De.current&&Ne.current&&!sr){const nt=De.current;De.current=null;const{x:ft,y:je}=Da(re.clientX,re.clientY,nt.pageId);xr(!0),Br({startX:nt.startX,startY:nt.startY,currentX:ft,currentY:je})}if(Te&&Ze.current&&!We.current&&st.current){const nt=re.clientX-st.current.x,ft=re.clientY-st.current.y;Math.hypot(nt,ft)>=3&&pr(!1)}const qe=Te&&We.current?.35:1,Xe=(nt,ft,je,Ye,Ke)=>{if(!Te)return ui(nt,ft,je,Ye,Ke);const Dt=performance.now();if(Dt-rt.current<50)return Ie.current;const rr=ui(nt,ft,je,Ye,Ke,PO);return rt.current=Dt,Ie.current=rr,rr};if(Le&&V.current){const nt=re.clientX-Ct.x,ft=re.clientY-Ct.y;V.current.scrollLeft=Ct.scrollLeft-nt,V.current.scrollTop=Ct.scrollTop-ft;return}const Qt=r/100,vt=ve.current;if(sr&&Tr){const{x:nt,y:ft}=Da(re.clientX,re.clientY);Br({...Tr,currentX:nt,currentY:ft})}const Gt=(nt,ft)=>{if(!Te||nt===0&&ft===0)return;const je=performance.now();je-Ge.current<120||(Ge.current=je,mn(re.clientX,re.clientY,"snap"))};if(Ae){const nt=(re.clientX-Ae.startMouse.x)/Qt*qe,ft=(re.clientY-Ae.startMouse.y)/Qt*qe,{startBounds:je,elementSnapshots:Ye}=Ae;if(Ae.type==="move"){const Ke={};s.forEach(Dt=>{const rr=Ye[Dt];rr&&(Ke[Dt]={x:rr.x+nt,y:rr.y+ft})}),zs(Ke,!1)}else if(Ae.type==="rotate"){const Ke=document.getElementById(`page-canvas-${e}`);if(!Ke)return;const Dt=Ke.getBoundingClientRect(),rr=je.x+je.width/2,Er=je.y+je.height/2,Cr=a.showBleed?a.bleed*Qt:0,ar=Dt.left+Cr+rr*Qt,Dr=Dt.top+Cr+Er*Qt,Xt=Math.atan2(Ae.startMouse.y-Dr,Ae.startMouse.x-ar);let Pt=(Math.atan2(re.clientY-Dr,re.clientX-ar)-Xt)*(180/Math.PI);re.shiftKey&&(Pt=Math.round(Pt/15)*15),ue(fn=>fn?{...fn,rotation:Pt}:null);const Un={};s.forEach(fn=>{const na=Ye[fn];if(!na)return;const Na=Pt*Math.PI/180,Ja=Math.cos(Na),Do=Math.sin(Na),ei=na.x+na.width/2-rr,vn=na.y+na.height/2-Er,eo=ei*Ja-vn*Do,Gr=ei*Do+vn*Ja;Un[fn]={rotation:na.rotation+Pt,x:rr+eo-na.width/2,y:Er+Gr-na.height/2}}),zs(Un,!1)}else if(Ae.type==="resize"&&Ae.handle){let Ke={...je};const Dt=Ae.handle,rr=je.x+je.width/2,Er=je.y+je.height/2;if(re.shiftKey&&re.altKey){const Xt=je.width/je.height;let mr=0;if(Dt.includes("r")?mr=nt:Dt.includes("l")?mr=-nt:Dt.includes("b")?mr=ft:Dt.includes("t")&&(mr=-ft),Dt.length===2){const Un=Dt.includes("r")?nt:-nt,fn=Dt.includes("b")?ft:-ft;mr=Math.abs(Un)>Math.abs(fn)?Un:fn}const Pt=mr*2;Ke.width=je.width+Pt,Ke.height=Ke.width/Xt,Ke.x=rr-Ke.width/2,Ke.y=Er-Ke.height/2}else if(re.altKey)Dt.includes("r")&&(Ke.width+=nt*2,Ke.x=rr-Ke.width/2),Dt.includes("l")&&(Ke.width-=nt*2,Ke.x=rr-Ke.width/2),Dt.includes("b")&&(Ke.height+=ft*2,Ke.y=Er-Ke.height/2),Dt.includes("t")&&(Ke.height-=ft*2,Ke.y=Er-Ke.height/2);else if(re.shiftKey){Dt.includes("r")&&(Ke.width+=nt),Dt.includes("l")&&(Ke.x+=nt,Ke.width-=nt),Dt.includes("b")&&(Ke.height+=ft),Dt.includes("t")&&(Ke.y+=ft,Ke.height-=ft);const Xt=je.width/je.height;(Dt==="br"||Dt==="tl"||Dt==="bl"||Dt==="tr")&&(Ke.height=Ke.width/Xt),Dt.includes("t")&&(Ke.y=je.y+je.height-Ke.height),Dt.includes("l")&&(Ke.x=je.x+je.width-Ke.width)}else Dt.includes("r")&&(Ke.width+=nt),Dt.includes("l")&&(Ke.x+=nt,Ke.width-=nt),Dt.includes("b")&&(Ke.height+=ft),Dt.includes("t")&&(Ke.y+=ft,Ke.height-=ft);const Cr=Ke.width/je.width,ar=Ke.height/je.height;if(Cr<=.1||ar<=.1)return;const Dr={};s.forEach(Xt=>{const mr=Ye[Xt];if(!mr)return;const Pt=(mr.x-je.x)/je.width,Un=(mr.y-je.y)/je.height,fn=mr.width/je.width,na=mr.height/je.height,Na=Ke.width*fn,Ja=Ke.height*na,Do=Ke.x+Pt*Ke.width,ei=Ke.y+Un*Ke.height,vn={x:Do,y:ei,width:Na,height:Ja,fontSize:mr.fontSize?mr.fontSize*Math.min(Cr,ar):void 0};if(mr.type==="path"&&mr.path){const eo=mr.width?Na/mr.width:1,Gr=mr.height?Ja/mr.height:1;vn.path=Kb(mr.path,eo,Gr)}Dr[Xt]=vn}),zs(Dr,!1)}return}if(ie&&Pr&&pt){const nt=document.querySelector(`[data-element-id="${Pr}"]`),ft=t.find(Ye=>Ye.id===e),je=ft==null?void 0:ft.elements.find(Ye=>Ye.id===Pr);if(nt&&je){const Ye=nt.getBoundingClientRect();let Ke=Ye.left+Ye.width/2,Dt=Ye.top+Ye.height/2;if(je.clip&&(je.clip.top>0||je.clip.right>0||je.clip.bottom>0||je.clip.left>0)){const Dr=je.width-je.clip.left-je.clip.right,Xt=je.height-je.clip.top-je.clip.bottom,mr=je.clip.left+Dr/2,Pt=je.clip.top+Xt/2,Un=Ye.width/je.width,fn=Ye.height/je.height;Ke=Ye.left+mr*Un,Dt=Ye.top+Pt*fn}let Er=Math.atan2(re.clientY-Dt,re.clientX-Ke)*(180/Math.PI)-pt.startAngle,Cr=pt.initialRotation+Er;(re.shiftKey||pt.mode==="image")&&(Cr=Math.round(Cr/15)*15),pt.mode==="image"?f(Pr,{imageRotation:Cr},!1):f(Pr,{rotation:Cr},!1)}return}if(ge&&Pr&&Bn){const nt=Mt.current[Pr];if(!nt)return;const ft=(re.clientX-vt.x)/Qt*qe,je=(re.clientY-vt.y)/Qt*qe,Ye=nt.rotation*Math.PI/180,Ke=ft*Math.cos(Ye)+je*Math.sin(Ye),Dt=-ft*Math.sin(Ye)+je*Math.cos(Ye),rr=(Ke*Bn.x+Dt*Bn.y)/1.5;let Er={};const Cr=Zr.length>0?Zr:["tl","tr","bl","br"];if(typeof nt.cornerRadius=="number"){const mr=nt.cornerRadius||0;Cr.forEach(Pt=>Er[Pt]=mr)}else Er={...nt.cornerRadius},Cr.forEach(mr=>{Er[mr]===void 0&&(Er[mr]=0)});const ar=Math.min(nt.width,nt.height)/2,Dr={...Er};($r.length>0?$r:Cr).forEach(mr=>{let Pt=(Er[mr]||0)+rr;Pt=Math.max(0,Math.min(ar,Pt)),Dr[mr]=Pt}),f(Pr,{cornerRadius:Dr},!1);return}if(_&&Pr){Y(Pr,re.clientX,re.clientY,r);const nt=(re.clientX-vt.x)/Qt*qe,ft=(re.clientY-vt.y)/Qt*qe,je=Mt.current[Pr];if(!je)return;let Ye,Ke=a.width,Dt=a.height,rr=[];if(t.forEach(Er=>{const Cr=Er.elements.find(ar=>ar.id===Pr);Cr&&(Ye=Cr,Ke=Er.width??a.width,Dt=Er.height??a.height,rr=Er.elements.filter(ar=>!s.includes(ar.id)))}),Rt.current==="pan"&&(Ye==null?void 0:Ye.type)==="image"){const Er=je.cropRect??ta(Ye,je.naturalWidth??Ye.width,je.naturalHeight??Ye.height),Cr=(je.rotation||0)*(Math.PI/180),ar=Math.cos(Cr),Dr=Math.sin(Cr),Xt=nt*ar+ft*Dr,mr=-nt*Dr+ft*ar,Pt=Ye.flipX?-1:1,Un=Ye.flipY?-1:1,fn=Xt*Pt,na=mr*Un,Na=je.naturalWidth??Ye.width,Ja=je.naturalHeight??Ye.height,Do=KO(Er,fn,na,Ye.width,Ye.height,Na,Ja,Ye.clip);Se([]),f(Pr,{crop:Do},!1);return}if(Jt){const Er=(Ye==null?void 0:Ye.type)==="image",Cr=!!Er&&Yn===Pr,ar=Nt.current??"resize",Dr=Cr?"crop":"resize";let Xt=nt,mr=ft;if(Er&&Ye&&ar!==Dr&&ar!=="clip"){Nt.current=Dr,Rt.current=Dr==="crop"?"handle":null,_e(Dr==="crop"?Pr:null);const _n=Sn(Pr),sa=_n.width||Ye.width,ya=_n.height||Ye.height,fo=ta(Ye,sa,ya);Vt({[Pr]:{x:Ye.x,y:Ye.y,width:Ye.width,height:Ye.height,rotation:Ye.rotation,fontSize:Ye.fontSize,cropRect:fo,naturalWidth:sa,naturalHeight:ya,path:Ye.type==="path"&&Ye.path?JSON.parse(JSON.stringify(Ye.path)):void 0}}),gt({x:re.clientX,y:re.clientY}),Xt=0,mr=0}const Pt=Mt.current[Pr]??je;if(Er&&Ye&&Nt.current==="crop"){const _n=Pt.cropRect??ta(Ye,Pt.naturalWidth??Ye.width,Pt.naturalHeight??Ye.height),sa=(Pt.rotation||0)*(Math.PI/180),ya=Math.cos(sa),fo=Math.sin(sa),to=Xt*ya+mr*fo,Xo=-Xt*fo+mr*ya,Tn=Ye.flipX?-1:1,xn=Ye.flipY?-1:1,Hn=to*Tn,$n=Xo*xn,ja=Pt.naturalWidth??Ye.width,js=Pt.naturalHeight??Ye.height,Zi=re.shiftKey||!re.altKey&&Jt.length===2,VA=_r.current??"frame";let Bl=Hn,dc=$n;if(VA==="image"&&(Ye.imageRotation??0)!==0){const pu=(Ye.imageRotation??0)*(Math.PI/180),hc=Math.cos(pu),pc=Math.sin(pu);Bl=Hn*hc+$n*pc,dc=-Hn*pc+$n*hc}const mf=VA==="image"?jO(_n,Jt,Bl,dc,Ye.width,Ye.height,ja,js,re.altKey,Zi):zO(_n,Jt,Bl,dc,Ye.width,Ye.height,ja,js,re.altKey,Zi);Se([]),f(Pr,{crop:mf},!1);return}if(Nt.current==="clip"&&Ye){const _n=(Pt.rotation||0)*(Math.PI/180),sa=Math.cos(_n),ya=Math.sin(_n),fo=Xt*sa+mr*ya,to=-Xt*ya+mr*sa,Xo=Ye.flipX?-1:1,Tn=Ye.flipY?-1:1,xn=fo*Xo,Hn=to*Tn,$n=Pt.clip??{top:0,right:0,bottom:0,left:0},ja={...$n};Jt==="l"?ja.left=Math.max(0,Math.min(Ye.width-ja.right-10,$n.left+xn)):Jt==="r"?ja.right=Math.max(0,Math.min(Ye.width-ja.left-10,$n.right-xn)):Jt==="t"?ja.top=Math.max(0,Math.min(Ye.height-ja.bottom-10,$n.top+Hn)):Jt==="b"&&(ja.bottom=Math.max(0,Math.min(Ye.height-ja.top-10,$n.bottom-Hn))),Se([]),f(Pr,{clip:ja},!1);return}const Un=(Pt.rotation||0)*(Math.PI/180),fn=Math.cos(Un),na=Math.sin(Un),Na=Xt*fn+mr*na,Ja=-Xt*na+mr*fn,Do=re.altKey,ei=re.shiftKey;let vn=Pt.width,eo=Pt.height,Gr={x:Pt.x,y:Pt.y,width:Pt.width,height:Pt.height,fontSize:Pt.fontSize};if(Do?(Jt.includes("l")&&(vn=Pt.width-Na*2),Jt.includes("r")&&(vn=Pt.width+Na*2),Jt.includes("t")&&(eo=Pt.height-Ja*2),Jt.includes("b")&&(eo=Pt.height+Ja*2)):(Jt.includes("l")&&(vn=Pt.width-Na),Jt.includes("r")&&(vn=Pt.width+Na),Jt.includes("t")&&(eo=Pt.height-Ja),Jt.includes("b")&&(eo=Pt.height+Ja)),vn=Math.max(10,vn),eo=Math.max(10,eo),(ei||Do||(Ye==null?void 0:Ye.type)==="image"||(Ye==null?void 0:Ye.type)==="text")&&["tl","tr","bl","br"].includes(Jt)){const _n=Pt.width/Pt.height;Jt.includes("l")||Jt.includes("r")?eo=vn/_n:vn=eo*_n}if(Do){const _n=Pt.x+Pt.width/2,sa=Pt.y+Pt.height/2;Gr.x=_n-vn/2,Gr.y=sa-eo/2,Gr.width=vn,Gr.height=eo}else{const _n=vn-Pt.width,sa=eo-Pt.height;let ya=0,fo=0;Jt.includes("l")?ya=-_n/2:Jt.includes("r")&&(ya=_n/2),Jt.includes("t")?fo=-sa/2:Jt.includes("b")&&(fo=sa/2);const to=ya*fn-fo*na,Xo=ya*na+fo*fn,Tn=Pt.x+Pt.width/2,xn=Pt.y+Pt.height/2,Hn=Tn+to,$n=xn+Xo;Gr.x=Hn-vn/2,Gr.y=$n-eo/2,Gr.width=vn,Gr.height=eo}let za=[];Jt.includes("l")&&za.push("left"),Jt.includes("r")&&za.push("right"),Jt.includes("t")&&za.push("top"),Jt.includes("b")&&za.push("bottom");const{snapX:Ro,snapY:hs,lines:GA}=Xe(Gr,rr,Ke,Dt,za);if(re.pointerType!=="touch"?Se(GA):Se([]),Gt(Ro,hs),Ro!==0&&(Do?Jt.includes("r")?(Gr.width+=Ro*2,Gr.x-=Ro):Jt.includes("l")&&(Gr.width-=Ro*2,Gr.x+=Ro):Jt.includes("r")?Gr.width+=Ro:Jt.includes("l")&&(Gr.x+=Ro,Gr.width-=Ro)),hs!==0&&(Do?Jt.includes("b")?(Gr.height+=hs*2,Gr.y-=hs):Jt.includes("t")&&(Gr.height-=hs*2,Gr.y+=hs):Jt.includes("b")?Gr.height+=hs:Jt.includes("t")&&(Gr.y+=hs,Gr.height-=hs)),(Ye==null?void 0:Ye.type)==="text"){if(["tl","tr","bl","br"].includes(Jt)){const _n=Gr.width/Pt.width,sa=(Pt.fontSize||16)*_n;Gr.fontSize=sa}else if(["t","b"].includes(Jt)){const _n=Gr.height/Pt.height,sa=(Pt.fontSize||16)*_n;Gr.fontSize=sa,Gr.width=Pt.width*_n}}const ti={x:Gr.x,y:Gr.y,width:Gr.width,height:Gr.height,fontSize:Gr.fontSize},Ho=Pt.clip;if(Ho&&(Ho.top>0||Ho.right>0||Ho.bottom>0||Ho.left>0)){const _n=Pt.width?Gr.width/Pt.width:1,sa=Pt.height?Gr.height/Pt.height:1;ti.clip={top:Ho.top*sa,right:Ho.right*_n,bottom:Ho.bottom*sa,left:Ho.left*_n}}if((Ye==null?void 0:Ye.type)==="path"&&Pt.path){const _n=Pt.width?Gr.width/Pt.width:1,sa=Pt.height?Gr.height/Pt.height:1;ti.path=Kb(Pt.path,_n,sa)}f(Pr,ti,!1)}else{const Er=je.x+nt,Cr=je.y+ft,ar={x:Er,y:Cr,width:je.width,height:je.height},{snapX:Dr,snapY:Xt,lines:mr}=Xe(ar,rr,Ke,Dt);re.pointerType!=="touch"?Se(mr):Se([]),Gt(Dr,Xt);const Pt=nt+Dr,Un=ft+Xt,fn={};Object.keys(Mt.current).forEach(na=>{const Na=Mt.current[na];fn[na]={x:Na.x+Pt,y:Na.y+Un}}),zs(fn,!1)}}};ne.useLayoutEffect(()=>{I.current=dt});const Bt=()=>{Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null);const re=N.current;re&&(N.current=null,I.current(re))},Ar=re=>{N.current={clientX:re.clientX,clientY:re.clientY,pointerId:re.pointerId,pointerType:re.pointerType,shiftKey:re.shiftKey,altKey:re.altKey},Q.current===null&&(Q.current=requestAnimationFrame(()=>{Q.current=null;const Te=N.current;Te&&(N.current=null,I.current(Te))}))},hr=re=>{if(Bt(),ds(),De.current=null,re.pointerType==="touch"){const Te=jr.current;Te.delete(re.pointerId),Te.size<2&&Xr.current&&(Xr.current=!1,er.current=null,pa.current=null,$t(!1),Mr())}if(sr&&Tr){re.target.releasePointerCapture(re.pointerId);const Te=Math.min(Tr.startX,Tr.currentX),at=Math.min(Tr.startY,Tr.currentY),qe=Math.abs(Tr.currentX-Tr.startX),Xe=Math.abs(Tr.currentY-Tr.startY),Qt=Te+qe,vt=at+Xe,Gt=t.find(ft=>ft.id===e),nt=[];if(Gt==null||Gt.elements.forEach(ft=>{if(!ft.visible||ft.locked)return;const je=ft.clip||{top:0,right:0,bottom:0,left:0},Ye=ft.x+je.left,Ke=ft.y+je.top,Dt=ft.width-je.left-je.right,rr=ft.height-je.top-je.bottom;if(Dt<=0||rr<=0)return;const Er=Ye+Dt,Cr=Ke+rr;!(Ye>Qt||Er<Te||Ke>vt||Cr<at)&&nt.push(ft.id)}),re.shiftKey){const ft=Array.from(new Set([...s,...nt]));A(ft)}else A(nt);xr(!1),Br(null)}if(!Yt.current&&(Pr||Ae)){const Te=Ae?Object.keys(Ae.elementSnapshots):[Pr];if(Te.length>0){if(Pr){const at=t.flatMap(qe=>qe.elements).find(qe=>qe.id===Pr);at&&f(at.id,{},!0)}if(Ae){const at=Te[0];at&&f(at,{},!0)}}}Yt.current=!1,W(),R(!1),ae(!1),ce(!1),$t(!1),cn(null),_e(null),on(null),sn(null),en([]),tn([]),Se([]),ue(null),yt(!1),et(null),Rt.current=null,Nt.current=null,_r.current=null,Ht.current=null,be.current=null,Ne.current=!0,Ue.current=null,pr(!0),rt.current=0,Ie.current={snapX:0,snapY:0,lines:[]},Ge.current=0,ke(null),Sr()},lr=zt!=null&&zt.targetId?t.flatMap(re=>re.elements).find(re=>re.id===zt.targetId):null,Yr=zt?{store:Oe,selection:s,element:lr??void 0,menuType:zt.type,closeMenu:()=>Lr(null)}:null,un=zt!=null&&zt.targetId?Oe.canPasteStyle([zt.targetId]):Oe.canPasteStyle(s),Nn=(fe==null?void 0:fe.elements.filter(re=>s.includes(re.id)))||[],la=s.length>=2,Dn=Nn.some(re=>re.groupId),ra=a.safeArea,An=100/r,Rn=Xc(),Wn=Math.max(1,An),Oo=["tl","tr","bl","br","t","b","l","r"];return d.createElement("div",{ref:V,className:`flex-1 bg-[#f0f1f5] overflow-auto relative flex flex-col items-center select-none touch-none pt-6 md:pt-12 ${Le||kt||Z==="hand"?"cursor-grab active:cursor-grabbing":""}`,onPointerDownCapture:wo,onPointerDown:Pa,onPointerMove:Ar,onPointerUp:hr,onPointerLeave:hr,onPointerCancel:hr,onDragOver:xe,onDragLeave:Fe,onDrop:Pe,onWheel:re=>{re.ctrlKey&&(re.preventDefault(),n(Math.max(10,Math.min(200,r-re.deltaY*.5))))},onContextMenu:uo},zt&&d.createElement(TL,{x:zt.x,y:zt.y,type:zt.type,onClose:()=>Lr(null),customItems:h,context:Yr||void 0,actions:{onCopy:()=>Oe.copy(),onCopyStyle:()=>Oe.copyStyle(),onPaste:()=>Oe.paste(),onPasteStyle:()=>Oe.pasteStyle(),canPasteStyle:un,onDuplicate:()=>zt.targetId&&g(zt.targetId),onDelete:()=>zt.targetId&&v(zt.targetId),onBringToFront:()=>zt.targetId&&m(zt.targetId),onBringForward:()=>zt.targetId&&Oe.reorderElement(zt.targetId,"forward"),onSendToBack:()=>zt.targetId&&x(zt.targetId),onSendBackward:()=>zt.targetId&&Oe.reorderElement(zt.targetId,"backward"),onLock:()=>zt.targetId&&f(zt.targetId,{locked:!(lr!=null&&lr.locked)}),isLocked:lr==null?void 0:lr.locked,onResetZoom:w,onFitToScreen:co,onFitToPage:(lr==null?void 0:lr.type)==="image"&&zt.targetId?()=>ir(zt.targetId):void 0,onAlign:re=>Oe.alignSelection(re),onGroup:()=>Oe.groupSelection(),onUngroup:()=>Oe.ungroupSelection(),canGroup:la,canUngroup:Dn,onFlipX:()=>zt.targetId&&f(zt.targetId,{flipX:!(lr!=null&&lr.flipX)}),onFlipY:()=>zt.targetId&&f(zt.targetId,{flipY:!(lr!=null&&lr.flipY)}),onSetBlendMode:re=>zt.targetId&&f(zt.targetId,{blendMode:re}),blendMode:lr==null?void 0:lr.blendMode}}),pe&&d.createElement("div",{"data-no-export":"true",className:"fixed pointer-events-none z-[120]",style:{left:pe.x,top:pe.y,transform:"translate(-50%, -50%)"}},d.createElement("div",{className:"relative w-8 h-8"},d.createElement("div",{className:`absolute inset-0 rounded-full animate-ping ${pe.type==="snap"?"bg-fuchsia-500/30":"bg-emerald-500/30"}`}),d.createElement("div",{className:`absolute left-1/2 top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full ${pe.type==="snap"?"bg-fuchsia-500":"bg-emerald-500"}`}))),K&&d.createElement("div",{className:"fixed bottom-12 right-4 z-[100] bg-white/80 backdrop-blur-[2px] px-2 py-1 rounded text-[10px] font-bold text-slate-400 shadow-sm pointer-events-none select-none"},"Powered by Fraczled SDK"),t.map((re,Te)=>{const at=re.width??a.width,qe=re.height??a.height;re.unit??a.unit;const Qt=Math.max(50,a.bleed),vt=(at+Qt*2)*(r/100),Gt=(qe+Qt*2)*(r/100),nt=Qt*(r/100),ft=e===re.id?Ju(re.elements,s):null,Ye=re.elements.reduce((Ke,Dt)=>Math.max(Ke,Dt.zIndex??0),0)+100;return d.createElement("div",{key:re.id,id:`page-wrapper-${re.id}`,className:"relative z-10 group/page my-10"},d.createElement("div",{"data-no-export":"true",className:"absolute -top-10 flex items-center gap-1 transition-opacity z-[60]",style:{right:`${nt}px`}},d.createElement("input",{type:"text",value:re.name,onChange:Ke=>L(re.id,Ke.target.value),className:"text-xs text-slate-500 font-medium mr-2 bg-transparent border border-transparent hover:border-gray-200 focus:border-blue-400 focus:bg-white rounded px-1.5 py-0.5 outline-none w-32 text-right transition-all",placeholder:`Page ${Te+1}`}),d.createElement("button",{onClick:()=>F(re.id),className:"p-1.5 bg-white border border-gray-200 rounded-md text-slate-600 hover:text-blue-600 hover:border-blue-300 shadow-sm transition-colors group/btn relative"},d.createElement(s1,{size:14})," ",d.createElement("div",{className:"absolute -top-8 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover/btn:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[70]"},"Duplicate Page")),d.createElement("button",{onClick:()=>S(re.id),className:"p-1.5 bg-white border border-gray-200 rounded-md text-slate-600 hover:text-blue-600 hover:border-blue-300 shadow-sm transition-colors group/btn relative"},d.createElement(zQ,{size:14})," ",d.createElement("div",{className:"absolute -top-8 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover/btn:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[70]"},"Add Page")),t.length>1&&d.createElement("button",{onClick:()=>M(re.id),className:"p-1.5 bg-white border border-gray-200 rounded-md text-slate-600 hover:text-red-600 hover:border-red-300 shadow-sm transition-colors group/btn relative"}," ",d.createElement(zi,{size:14})," ",d.createElement("div",{className:"absolute -top-8 left-1/2 -translate-x-1/2 px-2 py-1 bg-slate-800 text-white text-[10px] rounded opacity-0 group-hover/btn:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[70]"},"Delete Page")," ")),d.createElement("div",{className:"relative shrink-0 box-content transition-all duration-200 ease-out",style:{width:`${vt}px`,height:`${Gt}px`,overflow:"visible"}},d.createElement("div",{id:`page-canvas-${re.id}`,className:"shadow-xl origin-top-left hover:ring-4 hover:ring-[#8a38ff] transition-shadow relative",style:{width:`${at}px`,height:`${qe}px`,transform:`scale(${r/100})`,boxSizing:"content-box",backgroundColor:a.backgroundColor==="transparent"?"transparent":a.backgroundColor||"#ffffff",border:"none",margin:`${nt}px`,overflow:"visible",isolation:"isolate"},onPointerDown:Ke=>Wi(Ke,re.id),onDoubleClick:Qi},a.backgroundColor==="transparent"&&d.createElement("div",{"data-no-export":"true",className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"linear-gradient(45deg, #e0e0e0 25%, transparent 25%), linear-gradient(-45deg, #e0e0e0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e0e0e0 75%), linear-gradient(-45deg, transparent 75%, #e0e0e0 75%)",backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px",zIndex:0}}),sr&&Tr&&e===re.id&&d.createElement("div",{"data-no-export":"true",className:`absolute z-[70] pointer-events-none ${Rn?"border-purple-500/90 bg-purple-500/15":"border-purple-500 bg-purple-500/20"}`,style:{left:Math.min(Tr.startX,Tr.currentX),top:Math.min(Tr.startY,Tr.currentY),width:Math.abs(Tr.currentX-Tr.startX),height:Math.abs(Tr.currentY-Tr.startY),borderStyle:"solid",borderWidth:`${(Rn?2.5:1.5)*Math.max(1,An)}px`,borderRadius:`${(Rn?4:2)*Math.max(1,An)}px`}}),d.createElement("div",{"data-no-export":"true",className:"absolute inset-0 pointer-events-none z-[100]",style:{boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 0 2px rgba(255,255,255,0.6)"}}),a.showBleed&&d.createElement(d.Fragment,null,d.createElement("div",{"data-no-export":"true",className:"absolute border border-solid border-red-500/30 pointer-events-none z-50",style:{inset:`-${a.bleed}px`,borderWidth:`${a.bleed}px`}}),d.createElement("div",{"data-no-export":"true",className:"absolute inset-0 border border-dashed border-gray-400 pointer-events-none z-50 opacity-50",style:{borderWidth:`${1*Math.max(1,An)}px`}}),d.createElement("div",{"data-no-export":"true",className:"absolute w-full flex justify-center pointer-events-none select-none z-50",style:{top:`-${a.bleed}px`,height:`${a.bleed}px`,alignItems:"center"}},d.createElement("span",{className:"font-bold text-red-600 tracking-wider uppercase bg-white/70 px-2 rounded-sm backdrop-blur-[1px] border border-red-200 shadow-sm",style:{fontSize:`${10*Math.max(1,An)}px`}},"Bleed Area"))),a.showSafeArea&&d.createElement("div",{"data-no-export":"true",className:"absolute border-cyan-400 pointer-events-none z-50 opacity-80",style:{top:ra,left:ra,right:ra,bottom:ra,borderWidth:`${1.5*Math.max(1,An)}px`,borderStyle:"solid"}},d.createElement("span",{className:"absolute left-0 text-cyan-700 uppercase tracking-wider font-bold bg-white/80 px-1 rounded-sm shadow-sm",style:{top:`-${20*Math.max(1,An)}px`,fontSize:`${10*Math.max(1,An)}px`}},"Safe Area")),d.createElement("div",{className:"absolute",style:{inset:0,overflow:"visible"}},ft&&e===re.id&&s.length>1&&d.createElement("div",{"data-no-export":"true",className:"absolute border-purple-600 z-[60]",style:{left:(Ae==null?void 0:Ae.type)==="rotate"?Ae.startBounds.x:ft.x,top:(Ae==null?void 0:Ae.type)==="rotate"?Ae.startBounds.y:ft.y,width:(Ae==null?void 0:Ae.type)==="rotate"?Ae.startBounds.width:ft.width,height:(Ae==null?void 0:Ae.type)==="rotate"?Ae.startBounds.height:ft.height,transform:(Ae==null?void 0:Ae.type)==="rotate"?`rotate(${Ae.rotation||0}deg)`:"none",pointerEvents:"none",borderWidth:`${3*Math.max(1,An)}px`,zIndex:Ye+5},"data-group-center":!0},d.createElement("span",{className:"absolute left-0 bg-indigo-600 text-white px-1.5 py-0.5 rounded-t-sm font-medium",style:{top:`-${24*Math.max(1,An)}px`,fontSize:`${10*Math.max(1,An)}px`,transform:(Ae==null?void 0:Ae.type)==="rotate"?`rotate(-${Ae.rotation||0}deg)`:"none",transformOrigin:"bottom left"}},"Group"),d.createElement("div",{className:"absolute inset-0 pointer-events-none"},Oo.map(Ke=>{const Dt=Ke.length===2,rr=Ke==="l"||Ke==="r",Er=Dt?Rn?16:12:rr?Rn?12:8:Rn?28:24,Cr=Dt?Rn?16:12:rr?Rn?28:24:Rn?12:8,ar=Dt?"50%":"4px";let Dr="move";(Ke==="t"||Ke==="b")&&(Dr="ns-resize"),(Ke==="l"||Ke==="r")&&(Dr="ew-resize"),(Ke==="tl"||Ke==="br")&&(Dr="nwse-resize"),(Ke==="tr"||Ke==="bl")&&(Dr="nesw-resize");const Xt={position:"absolute",width:`${Er*Wn}px`,height:`${Cr*Wn}px`,borderRadius:ar,backgroundColor:"white",border:`${2*Math.max(1,An)}px solid #a855f7`,boxShadow:"0 2px 4px rgba(0,0,0,0.2)",transform:"translate(-50%, -50%)",pointerEvents:"auto",cursor:Dr};return Ke.includes("t")&&(Xt.top="0%"),Ke.includes("b")&&(Xt.top="100%"),(Ke==="l"||Ke==="r")&&(Xt.top="50%"),Ke.includes("l")&&(Xt.left="0%"),Ke.includes("r")&&(Xt.left="100%"),(Ke==="t"||Ke==="b")&&(Xt.left="50%"),d.createElement("div",{key:Ke,onPointerDown:mr=>Bs(mr,Ke),style:Xt})}),d.createElement("div",{className:"absolute left-1/2 -translate-x-1/2 flex items-center gap-4 pointer-events-auto",style:{top:`calc(100% + ${24*Math.max(1,An)}px)`,transform:"translate(-50%, 0)",transformOrigin:"top center"}},d.createElement("div",{className:"bg-white border border-gray-200 text-slate-700 rounded-full flex items-center justify-center cursor-grab active:cursor-grabbing hover:bg-gray-50 shadow-md",style:{width:`${40*Math.max(1,An)}px`,height:`${40*Math.max(1,An)}px`},onPointerDown:Or}," ",d.createElement(ag,{size:18*Math.max(1,An)})," "),d.createElement("div",{className:"bg-white border border-gray-200 text-slate-700 rounded-full flex items-center justify-center cursor-grab active:cursor-grabbing hover:bg-gray-50 shadow-md",style:{width:`${40*Math.max(1,An)}px`,height:`${40*Math.max(1,An)}px`},onPointerDown:Yi}," ",d.createElement(Ib,{size:18*Math.max(1,An)})," ")))),e===re.id&&$e.map((Ke,Dt)=>{const rr=Ke.type==="safe"||Ke.type.includes("element")?"bg-cyan-500":"bg-[#ff00ff]";return d.createElement("div",{"data-no-export":"true",key:Dt,className:`absolute z-[60] pointer-events-none ${rr}`,style:{left:Ke.orientation==="vertical"?Ke.position:Ke.start,top:Ke.orientation==="horizontal"?Ke.position:Ke.start,width:Ke.orientation==="vertical"?"1px":Ke.end-Ke.start+"px",height:Ke.orientation==="horizontal"?"1px":Ke.end-Ke.start+"px"}})}),d.createElement("div",{className:"absolute inset-0",style:a.clipOutsideCutline?{clipPath:`inset(${a.showBleed?-a.bleed:0}px)`,WebkitClipPath:`inset(${a.showBleed?-a.bleed:0}px)`}:void 0},re.elements.map(Ke=>Ke.visible?d.createElement(FO,{key:Ke.id,element:Ke,isSelected:s.includes(Ke.id),isMultiSelect:s.length>1,isEditing:rn===Ke.id,isCropping:Yn===Ke.id||or===Ke.id,isClipping:Nt.current==="clip"&&Pr===Ke.id,isReplaceTarget:Ca===Ke.id,isInteracting:_&&Nt.current!=="clip"||ie||ge||!!Ae,isDirectSelecting:Z==="direct-select",pathSelection:(Vr==null?void 0:Vr.elementId)===Ke.id?Vr.selection:null,activeGroupId:l,pageId:re.id,zoom:r,unit:a.unit,selectionZIndex:Ye,onPointerDown:ci,onDoubleClick:Go,onResizePointerDown:Es,onRotatePointerDown:bA,onCornerRadiusPointerDown:es,updateElement:f,onPathUpdate:it,onPathAnchorSelect:Ut,onPathHandleSelect:qt,onDuplicate:g,onDelete:v,setEditingId:ma,setCropModeId:Ln}):null),ee&&Wt&&d.createElement("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none z-[55]",style:{opacity:Ir}},d.createElement("img",{src:Wt,alt:"",className:"max-w-[60%] max-h-[60%] object-contain select-none",draggable:!1})))),Z==="pen"&&e===re.id&&d.createElement(_O,{zoom:r,pageWidth:at,pageHeight:qe,elements:re.elements,settings:a,onCreatePath:bt,onUpdatePathElement:U,onSelectElement:oe}))))}),d.createElement("div",{className:"h-96 w-full flex-shrink-0"}))},GO=({zoom:t,setZoom:e,pageCount:r,activePage:n,planLabel:a,sdkVersion:s,showThumbnails:A,onToggleThumbnails:l,pageSize:c})=>{const f=lA(AA(c.width,c.unit)),h=lA(AA(c.height,c.unit));return d.createElement("div",{className:"h-10 bg-white border-t border-gray-200 flex items-center justify-between px-4 text-slate-600 flex-shrink-0 z-20 text-xs relative"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("button",{onClick:l,className:`flex items-center gap-2 px-2 py-1 rounded transition-colors ${A?"bg-indigo-50 text-indigo-600":"hover:bg-gray-100 text-slate-700"}`,title:A?"Hide page thumbnails":"Show page thumbnails"},d.createElement(kQ,{size:16}),d.createElement("span",{className:"font-medium"},"Pages ",n," / ",r))),d.createElement("div",{className:"hidden lg:flex items-center gap-3 absolute left-1/2 -translate-x-1/2 text-slate-400 font-medium"},a&&d.createElement("span",{className:"px-2 py-0.5 rounded-full border border-slate-200 text-slate-500 uppercase tracking-wide text-[10px]"},a),s&&d.createElement("span",{className:"px-2 py-0.5 rounded-full border border-slate-200 text-slate-500 uppercase tracking-wide text-[10px]"},"SDK v",s)),d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"hidden lg:flex items-center text-slate-400 font-medium"},f," x ",h," ",c.unit," @ ",c.dpi," DPI"),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-1 hidden lg:block"}),d.createElement("div",{className:"flex items-center gap-2 bg-slate-100 rounded-full px-3 py-1"},d.createElement("button",{onClick:()=>e(Math.max(10,t-10)),className:"p-0.5 hover:text-blue-600"},d.createElement(tg,{size:12})),d.createElement("input",{type:"range",min:"10",max:"200",value:t,onChange:g=>e(Number(g.target.value)),className:"w-24 h-1 bg-slate-300 rounded-lg appearance-none cursor-pointer accent-slate-800"}),d.createElement("span",{className:"w-9 text-right font-medium"},t,"%"),d.createElement("button",{onClick:()=>e(Math.min(200,t+10)),className:"p-0.5 hover:text-blue-600"},d.createElement(LA,{size:12}))),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-1"}),d.createElement("button",{className:"hover:text-blue-600 transition-colors",title:"Presentation Mode"},d.createElement(Qb,{size:16}))))},VO=[{name:"None",adjustments:{hue:0,saturation:0,brightness:0,contrast:0}},{name:"Epic",adjustments:{hue:0,saturation:20,brightness:10,contrast:20}},{name:"Retro",adjustments:{hue:-10,saturation:-20,brightness:0,contrast:10}},{name:"Street",adjustments:{hue:0,saturation:-50,brightness:0,contrast:40}},{name:"Grayscale",adjustments:{hue:0,saturation:-100,brightness:0,contrast:0}},{name:"Nordic",adjustments:{hue:0,saturation:-40,brightness:20,contrast:-10}},{name:"Drama",adjustments:{hue:0,saturation:0,brightness:-20,contrast:40}},{name:"Pop",adjustments:{hue:0,saturation:40,brightness:10,contrast:10}},{name:"Golden",adjustments:{hue:-5,saturation:30,brightness:10,contrast:10}},{name:"Warm",adjustments:{hue:-15,saturation:10,brightness:5,contrast:0}},{name:"Cool",adjustments:{hue:15,saturation:0,brightness:5,contrast:0}},{name:"Afterglow",adjustments:{hue:-10,saturation:20,brightness:-10,contrast:20}}],$O=({effect:t,onChange:e,onClose:r,position:n})=>{const a=t.adjustments||{hue:0,saturation:0,brightness:0,contrast:0},s=l=>a.hue===l.hue&&a.saturation===l.saturation&&a.brightness===l.brightness&&a.contrast===l.contrast,A=l=>{e({...t,adjustments:{...l.adjustments}})};return d.createElement("div",{className:`${n?"fixed":"absolute top-12 left-0"} w-80 bg-white rounded-xl shadow-xl border border-gray-200 z-[9999] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-100 max-h-[500px]`,style:n?{top:n.top,left:n.left}:void 0},d.createElement("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-white sticky top-0 z-10"},d.createElement("h3",{className:"font-bold text-slate-800 text-sm"},"Filters"),d.createElement("button",{onClick:r,className:"text-slate-400 hover:bg-gray-100 rounded-full p-1 transition-colors"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"flex-1 overflow-y-auto p-4 custom-scrollbar"},d.createElement("div",{className:"grid grid-cols-3 gap-3"},VO.map(l=>{const c=s(l.adjustments),{hue:f,saturation:h,brightness:g,contrast:v}=l.adjustments,m=`hue-rotate(${f}deg) saturate(${100+h}%) brightness(${100+g}%) contrast(${100+v}%)`;return d.createElement("button",{key:l.name,onClick:()=>A(l),className:"flex flex-col items-center gap-2 group"},d.createElement("div",{className:`
937
937
  w-full aspect-square rounded-lg overflow-hidden border transition-all relative
938
938
  ${c?"border-2 border-indigo-600 ring-1 ring-indigo-100":"border-gray-200 hover:border-gray-300"}
939
- `},d.createElement("div",{className:"w-full h-full bg-cover bg-center",style:{backgroundImage:"url(https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=150&q=80)",filter:m}}),c&&d.createElement("div",{className:"absolute inset-0 flex items-center justify-center bg-indigo-600/10"},d.createElement("div",{className:"bg-white rounded-full p-0.5 shadow-sm"},d.createElement(ul,{size:12,className:"text-indigo-600"})))),d.createElement("span",{className:`text-[10px] font-medium ${c?"text-indigo-600":"text-slate-500"}`},l.name))}))))},tw=({element:t,onChange:e,onClose:r,position:n})=>{const a=t.strokeStyle||"solid",s=t.strokeWidth||0,A=t.type==="image"&&!!t.isIcon;let l=0;typeof t.cornerRadius=="number"?l=t.cornerRadius:t.cornerRadius&&(l=t.cornerRadius.tl||0);const c=f=>{let h="0";return f==="dashed"&&(h="6,4"),f==="dotted"&&(h="2,2"),d.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"text-slate-700"},d.createElement("line",{x1:"2",y1:"12",x2:"22",y2:"12",stroke:"currentColor",strokeWidth:"2",strokeDasharray:h,strokeLinecap:"round"}))};return d.createElement("div",{className:`${n?"fixed":"absolute top-12 left-0"} w-72 bg-white rounded-xl shadow-xl border border-gray-200 z-[9999] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-100 font-sans`,style:n?{top:n.top,left:n.left}:void 0},d.createElement("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-white sticky top-0 z-10"},d.createElement("h3",{className:"font-bold text-slate-800 text-sm"},"Border"),d.createElement("button",{onClick:r,className:"text-slate-400 hover:bg-gray-100 rounded-full p-1 transition-colors"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"p-4 space-y-5"},d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Style"),d.createElement("div",{className:"grid grid-cols-4 gap-2"},d.createElement("button",{onClick:()=>e({strokeWidth:0,strokeStyle:"none"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s===0||a==="none"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"No Border"},d.createElement(QA,{size:18,className:"text-slate-600"})),d.createElement("button",{onClick:()=>e({strokeWidth:Math.max(1,s),strokeStyle:"solid"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s>0&&a==="solid"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"Solid"},c("solid")),d.createElement("button",{onClick:()=>e({strokeWidth:Math.max(1,s),strokeStyle:"dashed"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s>0&&a==="dashed"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"Dashed"},c("dashed")),d.createElement("button",{onClick:()=>e({strokeWidth:Math.max(1,s),strokeStyle:"dotted"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s>0&&a==="dotted"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"Dotted"},c("dotted")))),d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex justify-between items-center"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Weight"),d.createElement("div",{className:"w-8 h-6 flex items-center justify-center bg-gray-100 rounded text-xs font-mono text-slate-600"},s)),d.createElement("input",{type:"range",min:"0",max:"50",value:s,onChange:f=>{const h=parseInt(f.target.value);e({strokeWidth:h,strokeStyle:h===0?"none":a==="none"?"solid":a})},className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})),!A&&d.createElement("div",{className:"space-y-2 pt-2 border-t border-gray-100"},d.createElement("div",{className:"flex justify-between items-center"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Corner Rounding"),d.createElement("div",{className:"w-8 h-6 flex items-center justify-center bg-gray-100 rounded text-xs font-mono text-slate-600"},Math.round(l))),d.createElement("input",{type:"range",min:"0",max:"100",value:l,onChange:f=>e({cornerRadius:parseInt(f.target.value)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}))))},XO=({element:t,onChange:e,onClose:r,position:n})=>{const a=t.textStrokeWidth||0,s=t.textStrokePosition||"behind",A=t.textStrokeStyle||"round";return d.createElement("div",{className:`${n?"fixed":"absolute top-12 left-0"} w-72 bg-white rounded-xl shadow-xl border border-gray-200 z-[9999] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-100 font-sans`,style:n?{top:n.top,left:n.left}:void 0},d.createElement("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-white sticky top-0 z-10"},d.createElement("h3",{className:"font-bold text-slate-800 text-sm"},"Text Stroke"),d.createElement("button",{onClick:r,className:"text-slate-400 hover:bg-gray-100 rounded-full p-1 transition-colors"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"p-4 space-y-5"},d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex items-center justify-between"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Stroke"),d.createElement("button",{onClick:()=>e({textStrokeWidth:0}),className:"h-7 w-7 rounded-md border border-gray-200 flex items-center justify-center hover:border-gray-300 transition-all",title:"Disable Stroke"},d.createElement(QA,{size:14,className:"text-slate-500"}))),d.createElement("div",{className:"flex items-center gap-3"},d.createElement("input",{type:"range",min:"0",max:"20",value:a,onChange:l=>e({textStrokeWidth:parseInt(l.target.value,10)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),d.createElement("div",{className:"w-8 h-6 flex items-center justify-center bg-gray-100 rounded text-xs font-mono text-slate-600"},a))),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Position"),d.createElement("div",{className:"grid grid-cols-2 gap-2"},d.createElement("button",{onClick:()=>e({textStrokePosition:"behind"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${s==="behind"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"Behind"),d.createElement("button",{onClick:()=>e({textStrokePosition:"front"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${s==="front"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"On top"))),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Edges"),d.createElement("div",{className:"grid grid-cols-2 gap-2"},d.createElement("button",{onClick:()=>e({textStrokeStyle:"round"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${A==="round"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"Round"),d.createElement("button",{onClick:()=>e({textStrokeStyle:"flat"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${A==="flat"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"Flat")))))},YO=({selection:t,elements:e,updateElement:r,updateElements:n,deleteElement:a,reorderElement:s,settings:A,onDuplicate:l,activeBrandKit:c,setActiveTool:f,onOpenColorPanel:h,activeTool:g,activeColorMode:v,customToolbarItems:m})=>{var Bn,sn,$r,en,Zr,tn,rn,ma,Yn,Ln,or,_e,$e;const[x,w]=ne.useState(!1),[C,S]=ne.useState(!1),[F,M]=ne.useState(!1),[L,Z]=ne.useState(!1),[J,K]=ne.useState(!1),[ee,V]=ne.useState(!1),[fe,j]=ne.useState(!1),[te,z]=ne.useState(null),[D,se]=ne.useState(null),[q,X]=ne.useState(null),[Y,W]=ne.useState(null),[P,O]=ne.useState(null),[k,Q]=ne.useState(null),[N,I]=ne.useState(null),_=ne.useRef(null),R=ne.useRef(null),ie=ne.useRef(null),ae=ne.useRef(null),ge=ne.useRef(null),ce=ne.useRef(null),Ae=ne.useRef(null),ue=ne.useRef(null),Be=ne.useRef(null),$=[6,8,10,12,14,16,18,21,24,28,32,36,42,48,56,64,72,80,96,128];if(ne.useEffect(()=>{w(!1),S(!1),M(!1),Z(!1),K(!1),V(!1),j(!1)},[t]),ne.useEffect(()=>{if(!ee)return;const Se=kt=>{var Ct;const yt=kt.target,Le=Ae.current&&Ae.current.contains(yt),$t=(Ct=yt.closest)==null?void 0:Ct.call(yt,"[data-font-size-dropdown]");!Le&&!$t&&V(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[ee]),ne.useEffect(()=>{if(!J)return;const Se=kt=>{var Ct;const yt=kt.target,Le=R.current&&R.current.contains(yt),$t=(Ct=yt.closest)==null?void 0:Ct.call(yt,"[data-flip-menu]");!Le&&!$t&&K(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[J]),ne.useEffect(()=>{if(!fe)return;const Se=kt=>{var Ct;const yt=kt.target,Le=Be.current&&Be.current.contains(yt),$t=(Ct=yt.closest)==null?void 0:Ct.call(yt,"[data-blend-mode-menu]");!Le&&!$t&&j(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[fe]),t.length===2){const Se=e.filter(Le=>t.includes(Le.id)),kt=Se.find(Le=>Le.type==="image"),yt=Se.find(Le=>Le.type==="shape");if(kt&&yt){const Le=()=>{const $t=document.querySelector(`[data-element-id="${kt.id}"] img`),Ct=($t==null?void 0:$t.naturalWidth)??kt.width,fr=($t==null?void 0:$t.naturalHeight)??kt.height;r(kt.id,{x:yt.x,y:yt.y,width:yt.width,height:yt.height,rotation:yt.rotation,clipShape:yt.content,cornerRadius:yt.cornerRadius,strokeColor:yt.strokeColor,strokeWidth:yt.strokeWidth,strokeStyle:yt.strokeStyle,crop:OA(yt.width,yt.height,Ct,fr)}),a(yt.id)};return d.createElement("div",{className:"flex items-center gap-2 px-2 h-full animate-in fade-in zoom-in-95 duration-200 whitespace-nowrap"},d.createElement("span",{className:"text-sm font-semibold text-slate-500 mr-2"},"2 selected"),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2"}),d.createElement("button",{onClick:Le,className:"flex items-center gap-2 bg-indigo-50 text-indigo-700 px-3 py-1.5 rounded-lg text-sm font-medium hover:bg-indigo-100 transition-colors flex-shrink-0"},d.createElement(LQ,{size:16}),"Mask"),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2"}),d.createElement("button",{onClick:()=>a(yt.id),className:"p-1.5 hover:bg-red-50 text-red-500 rounded flex-shrink-0"},d.createElement(zi,{size:16})))}}if(t.length===0)return null;const ve=t[0],be=e.find(Se=>Se.id===ve);if(!be)return null;const Ne={store:Oe,selection:t,element:be},Ue=(m||[]).filter(Se=>(Se==null?void 0:Se.id)&&(Se==null?void 0:Se.label)).filter(Se=>Se.location==="object-toolbar"||Se.location==="both").filter(Se=>!Se.showFor||Se.showFor.length===0?!0:Se.showFor.includes(be.type)),We=Se=>{if(Se.render){const yt=Se.render;return d.createElement(d.Fragment,{key:Se.id},d.createElement(yt,{...Ne}))}const kt=Se.icon;return d.createElement("button",{key:Se.id,onClick:()=>{var yt;return(yt=Se.onClick)==null?void 0:yt.call(Se,Ne)},className:"flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium text-slate-600 hover:bg-gray-100 transition-colors"},kt&&d.createElement(kt,{size:14}),d.createElement("span",null,Se.label))},Ze=e.filter(Se=>t.includes(Se.id)),st=((Bn=Ze[0])==null?void 0:Bn.blendMode)??"normal",rt=Ze.some(Se=>(Se.blendMode??"normal")!==st),Ie=rt?"Mixed":x7(st),De=Se=>{n?n(t,Se):r(ve,Se)},pe=Se=>{const kt=Math.max(1,Se);if(t.length===1&&be&&be.type==="text"){const yt={fontSize:kt};be.autoWidth&&(yt.autoWidth=!1),r(ve,yt);return}De({fontSize:kt})},ke=be.type==="text",Qe=be.type==="path",Ge=be.type==="shape"||Qe,pt=be.type==="image",et=pt&&!!be.isIcon,_t=et&&be.iconVariant!=="color",Tt=be.type==="qrcode",Mt=be.textStrokeWidth||0,Nt=be.textStrokeColor||"#000000",Rt=Ge?be.backgroundColor??(Qe?((sn=be.path)==null?void 0:sn.fillColor)??null:null):be.backgroundColor,Ht=Qe?be.strokeColor??(($r=be.path)==null?void 0:$r.strokeColor)??"#000000":be.strokeColor||"#000000",Yt=Qe?be.strokeWidth??((en=be.path)==null?void 0:en.strokeWidth)??0:be.strokeWidth||0,Wt=!!Rt&&Rt!=="transparent",Zt=Yt>0&&Ht!=="transparent",Ir=Se=>{De({effect:Se})},ur=()=>{et||window.dispatchEvent(new CustomEvent("toggle-crop-mode",{detail:{id:ve}}))},gt=()=>{De({clipShape:void 0,cornerRadius:0,strokeWidth:0})},Vt=()=>{if(!be||be.type!=="image")return;const Se=A.width,kt=A.height,yt=document.querySelector(`[data-element-id="${be.id}"] img`),Le=(yt==null?void 0:yt.naturalWidth)??be.width,$t=(yt==null?void 0:yt.naturalHeight)??be.height,Ct=(jr,er)=>{r(be.id,{x:0,y:0,width:Se,height:kt,crop:OA(Se,kt,jr,er)})};if(yt!=null&&yt.naturalWidth&&yt.naturalHeight){Ct(yt.naturalWidth,yt.naturalHeight);return}const fr=new Image;fr.onload=()=>{Ct(fr.naturalWidth||Le,fr.naturalHeight||$t)},fr.onerror=()=>{Ct(Le,$t)},fr.src=be.content},mn=()=>{f(cr.FONT)},Sr=Se=>{h?h(Se):f(cr.COLOR)},Mr=()=>{f(cr.EFFECTS)},pr=be.type==="path"&&!!be.path&&t.length===1,dr=Ht==="transparent"?"#000000":Ht,Sn=Rt&&Rt!=="transparent"?Rt:dr,ta=Yt>0?Yt:2,Pr=()=>{if(pr&&be.path){De({backgroundColor:"transparent",path:{...be.path,fillColor:null}});return}De({backgroundColor:"transparent"})},cn=()=>{const Se={strokeWidth:0,strokeColor:"transparent"};if(pr&&be.path){De({...Se,path:{...be.path,strokeWidth:0,strokeColor:"transparent"}});return}De(Se)},Jt=()=>{if(pr&&be.path){De({backgroundColor:Sn,path:{...be.path,fillColor:Sn}});return}De({backgroundColor:Sn})},on=()=>{const Se={strokeWidth:ta,strokeColor:dr};if(pr&&be.path){De({...Se,path:{...be.path,strokeWidth:ta,strokeColor:dr}});return}De(Se)};return d.createElement("div",{ref:_,className:"flex items-center gap-3 md:gap-4 px-1 md:px-2 animate-in fade-in zoom-in-95 duration-200 h-full whitespace-nowrap"},ke&&d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},d.createElement("div",{className:"relative group"},d.createElement("button",{onClick:mn,className:`flex items-center gap-2 px-2 py-1.5 rounded-lg text-sm font-medium transition-colors w-32 justify-between border ${g===cr.FONT?"bg-indigo-50 border-indigo-200 text-indigo-700":"hover:bg-gray-100 border-transparent text-slate-700"}`},d.createElement("span",{className:"truncate",style:{fontFamily:be.fontFamily}},be.fontFamily||"Inter"),d.createElement(Gl,{size:14,className:"text-slate-400"}))),d.createElement("div",{ref:Ae,className:"flex items-center bg-gray-50 rounded border border-gray-200 h-8 flex-shrink-0 relative"},d.createElement("button",{onClick:()=>pe((be.fontSize||16)-1),className:"px-2 hover:bg-gray-200 h-full flex items-center text-slate-600"},"-"),d.createElement("button",{onClick:Se=>{const kt=Se.currentTarget.getBoundingClientRect();z({top:kt.bottom+4,left:kt.left}),V(!ee)},className:"w-12 text-center text-sm text-slate-700 font-medium hover:bg-gray-100 h-full flex items-center justify-center"},Math.round(be.fontSize||16)),d.createElement("button",{onClick:()=>pe((be.fontSize||16)+1),className:"px-2 hover:bg-gray-200 h-full flex items-center text-slate-600"},"+"),ee&&te&&Gu.createPortal(d.createElement("div",{"data-font-size-dropdown":!0,className:"fixed bg-white border border-gray-200 rounded-lg shadow-xl z-[9999] py-1 w-20 max-h-64 overflow-y-auto",style:{top:te.top,left:te.left}},$.map(Se=>d.createElement("button",{key:Se,onClick:()=>{pe(Se),V(!1)},className:`w-full px-3 py-1.5 text-left text-sm hover:bg-indigo-50 hover:text-indigo-600 ${Math.round(be.fontSize||16)===Se?"bg-indigo-50 text-indigo-600 font-medium":"text-slate-700"}`},Se))),document.body))),d.createElement("div",{className:"flex items-center gap-1 border-r border-gray-200 pr-4 text-slate-600 relative flex-shrink-0"},d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>Sr("text"),className:`w-6 h-6 rounded-md border border-gray-300 flex items-center justify-center relative overflow-hidden hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="text"?"ring-2 ring-indigo-500":""}`,style:{background:be.color}},d.createElement("span",{className:"sr-only"},"Color"))),d.createElement("div",{className:"w-px h-4 bg-gray-300 mx-1 hidden sm:block"}),d.createElement("button",{onClick:()=>De({fontWeight:be.fontWeight==="bold"?"normal":"bold"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.fontWeight==="bold"?"bg-indigo-50 text-indigo-600":""}`,title:"Bold"},d.createElement(Nb,{size:16})),d.createElement("button",{onClick:()=>De({fontStyle:be.fontStyle==="italic"?"normal":"italic"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.fontStyle==="italic"?"bg-indigo-50 text-indigo-600":""}`,title:"Italic"},d.createElement(Mb,{size:16})),d.createElement("button",{onClick:()=>De({textDecoration:be.textDecoration==="underline"?"none":"underline"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.textDecoration==="underline"?"bg-indigo-50 text-indigo-600":""}`,title:"Underline"},d.createElement(Pb,{size:16})),d.createElement("button",{onClick:()=>De({textDecoration:be.textDecoration==="line-through"?"none":"line-through"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.textDecoration==="line-through"?"bg-indigo-50 text-indigo-600":""}`,title:"Strikethrough"},d.createElement(Hb,{size:16})),d.createElement("div",{className:"flex items-center bg-gray-50 rounded-lg p-0.5 border border-gray-200 ml-1 flex-shrink-0"},d.createElement("button",{onClick:()=>De({textAlign:"left"}),className:`p-1 rounded hover:bg-white transition-all ${be.textAlign==="left"||!be.textAlign?"bg-white shadow-sm text-indigo-600":"text-slate-500"}`},d.createElement(GQ,{size:14})),d.createElement("button",{onClick:()=>De({textAlign:"center"}),className:`p-1 rounded hover:bg-white transition-all ${be.textAlign==="center"?"bg-white shadow-sm text-indigo-600":"text-slate-500"}`},d.createElement(KQ,{size:14})),d.createElement("button",{onClick:()=>De({textAlign:"right"}),className:`p-1 rounded hover:bg-white transition-all ${be.textAlign==="right"?"bg-white shadow-sm text-indigo-600":"text-slate-500"}`},d.createElement(qQ,{size:14}))),d.createElement("div",{className:"relative ml-1 flex items-center gap-1 flex-shrink-0"},d.createElement("button",{ref:ie,onClick:()=>{if(!x&&ie.current){const Se=ie.current.getBoundingClientRect();W({top:Se.bottom+8,left:Se.left-100})}w(!x)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${x?"bg-indigo-50 text-indigo-600":"text-slate-500"}`,title:"Spacing"},d.createElement(FQ,{size:16})),d.createElement("button",{onClick:()=>De({textTransform:be.textTransform==="uppercase"?"none":"uppercase"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.textTransform==="uppercase"?"bg-indigo-50 text-indigo-600":"text-slate-500"}`,title:"Uppercase"},d.createElement(JM,{size:16})),x&&Y&&d.createElement("div",{className:"fixed w-64 bg-white rounded-xl shadow-xl border border-gray-200 p-4 z-[9999] animate-in fade-in zoom-in-95 duration-100",style:{top:Y.top,left:Y.left}},d.createElement("div",{className:"space-y-4"},d.createElement("div",null,d.createElement("div",{className:"flex justify-between items-center mb-1"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider"},"Letter Spacing"),d.createElement("span",{className:"text-xs text-slate-700 font-mono"},Math.round((be.letterSpacing||0)*1e3))),d.createElement("input",{type:"range",min:"-0.1",max:"0.8",step:"0.01",value:be.letterSpacing||0,onChange:Se=>De({letterSpacing:parseFloat(Se.target.value)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})),d.createElement("div",null,d.createElement("div",{className:"flex justify-between items-center mb-1"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider"},"Line Spacing"),d.createElement("span",{className:"text-xs text-slate-700 font-mono"},((Zr=be.lineHeight)==null?void 0:Zr.toFixed(2))||1.4)),d.createElement("input",{type:"range",min:"0.5",max:"2.5",step:"0.05",value:be.lineHeight||1.4,onChange:Se=>De({lineHeight:parseFloat(Se.target.value)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}))))),d.createElement("div",{className:"relative ml-1 flex items-center gap-1 flex-shrink-0"},d.createElement("button",{ref:ue,onClick:()=>{if(!L&&ue.current){const Se=ue.current.getBoundingClientRect();I({top:Se.bottom+8,left:Se.left})}Z(!L)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${L||Mt>0?"bg-indigo-50 text-indigo-600":"text-slate-500"}`,title:"Text Stroke"},d.createElement(sg,{size:16,className:"rotate-90"})),L&&N&&d.createElement(XO,{element:be,onChange:De,onClose:()=>Z(!1),position:N}),Mt>0&&d.createElement("button",{onClick:()=>Sr("stroke"),className:`w-6 h-6 rounded-full border-2 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="stroke"?"ring-2 ring-indigo-500":"border-gray-300"}`,style:{borderColor:Nt},title:"Stroke Color"},d.createElement("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Nt}}))),d.createElement("div",{className:"w-px h-4 bg-gray-300 mx-1 hidden sm:block"}),d.createElement("div",{className:"relative flex-shrink-0"},d.createElement("button",{onClick:Mr,className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${g===cr.EFFECTS||((rn=(tn=be.effect)==null?void 0:tn.style)==null?void 0:rn.type)!=="none"||((Yn=(ma=be.effect)==null?void 0:ma.shape)==null?void 0:Yn.type)!=="none"?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement($l,{size:14}),d.createElement("span",null,"Effects"))))),Ge&&d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"Color"),d.createElement("div",{className:"relative flex items-center gap-1"},d.createElement("button",{onClick:()=>{Wt||Jt(),Sr("fill")},className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="fill"?"ring-2 ring-indigo-500":""}`,style:{background:Rt??"transparent"},title:"Fill Color"},!Wt&&d.createElement(QA,{size:12,className:"text-slate-400"})),d.createElement("button",{onClick:Pr,className:`w-6 h-6 rounded-full border border-gray-200 flex items-center justify-center transition-colors ${Wt?"text-slate-500 hover:text-red-500 hover:bg-slate-100":"bg-slate-100 text-slate-400"}`,title:"No Fill"},d.createElement(QA,{size:12})))),d.createElement("div",{className:"flex items-center gap-2 relative ml-2"},d.createElement("div",{className:"relative flex items-center gap-1"},d.createElement("button",{ref:ge,onClick:()=>{if(!F&&ge.current){const Se=ge.current.getBoundingClientRect();Q({top:Se.bottom+8,left:Se.left})}M(!F)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors border border-transparent ${F?"bg-indigo-50 text-indigo-600 border-indigo-100":"text-slate-600"}`,title:"Border Style"},d.createElement(sg,{size:18,className:"rotate-90"})),d.createElement("button",{onClick:cn,className:`w-7 h-7 rounded-full border border-gray-200 flex items-center justify-center transition-colors ${Zt?"text-slate-500 hover:text-red-500 hover:bg-slate-100":"bg-slate-100 text-slate-400"}`,title:"No Stroke"},d.createElement(QA,{size:12})),F&&k&&d.createElement(tw,{element:be,onChange:De,onClose:()=>M(!1),position:k})),d.createElement("div",{className:"relative animate-in fade-in zoom-in-95 duration-200"},d.createElement("button",{onClick:()=>{Zt||on(),Sr("stroke")},className:`w-6 h-6 rounded-full border-2 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="stroke"?"ring-2 ring-indigo-500":"border-gray-300"}`,style:{borderColor:Zt?Ht:"#cbd5f5"},title:"Stroke Color"},Zt?d.createElement("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ht}}):d.createElement(QA,{size:12,className:"text-slate-400"})))),d.createElement("div",{className:"relative ml-2 flex-shrink-0"},d.createElement("button",{onClick:Mr,className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${g===cr.EFFECTS||((or=(Ln=be.effect)==null?void 0:Ln.style)==null?void 0:or.type)!=="none"?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement($l,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Effects")))),pt&&d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},!et&&d.createElement("button",{onClick:ur,className:"flex items-center gap-2 hover:bg-gray-100 px-3 py-1.5 rounded-lg text-sm font-medium text-slate-700 transition-colors flex-shrink-0",title:"Crop Image (Double Click)"},d.createElement(vQ,{size:16}),d.createElement("span",{className:"hidden sm:inline"},"Crop")),d.createElement("button",{onClick:Vt,className:"p-2 hover:bg-gray-100 rounded-lg text-slate-700 transition-colors flex items-center justify-center",title:"Fit to page"},d.createElement(eg,{size:16})),_t&&d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"Color"),d.createElement("button",{onClick:()=>Sr("text"),className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="text"?"ring-2 ring-indigo-500":""}`,style:{background:be.color||"#000000"},title:"Icon Color"})),be.clipShape&&d.createElement("button",{onClick:gt,className:"flex items-center gap-2 hover:bg-gray-100 px-3 py-1.5 rounded-lg text-sm font-medium text-slate-700 transition-colors flex-shrink-0",title:"Detach Mask"},d.createElement(IQ,{size:16}),d.createElement("span",{className:"hidden sm:inline"},"Detach Image")),d.createElement("div",{className:"relative flex-shrink-0"},d.createElement("button",{onClick:Mr,className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${g===cr.EFFECTS||(($e=(_e=be.effect)==null?void 0:_e.style)==null?void 0:$e.type)!=="none"?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement($l,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Effects"))),d.createElement("div",{className:"relative flex-shrink-0"},d.createElement("button",{ref:ae,onClick:()=>{if(!C&&ae.current){const Se=ae.current.getBoundingClientRect();O({top:Se.bottom+8,left:Se.left})}S(!C)},className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${C?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement(YQ,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Filters")),C&&P&&d.createElement($O,{effect:be.effect,onChange:Ir,onClose:()=>S(!1),position:P})),be.clipShape&&d.createElement("div",{className:"flex items-center gap-2 relative ml-2"},d.createElement("div",{className:"relative"},d.createElement("button",{ref:ce,onClick:()=>{if(!F&&ce.current){const Se=ce.current.getBoundingClientRect();Q({top:Se.bottom+8,left:Se.left})}M(!F)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors border border-transparent ${F?"bg-indigo-50 text-indigo-600 border-indigo-100":"text-slate-600"}`,title:"Border Style"},d.createElement(sg,{size:18,className:"rotate-90"})),F&&k&&d.createElement(tw,{element:be,onChange:De,onClose:()=>M(!1),position:k})),(be.strokeWidth||0)>0&&d.createElement("div",{className:"relative animate-in fade-in zoom-in-95 duration-200"},d.createElement("button",{onClick:()=>Sr("stroke"),className:`w-6 h-6 rounded-full border-2 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="stroke"?"ring-2 ring-indigo-500":"border-gray-300"}`,style:{borderColor:be.strokeColor||"#000000"}},d.createElement("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:be.strokeColor||"#000000"}}))))),Tt&&d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>f(cr.QR_CODE),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors hover:bg-gray-100 text-slate-700"},d.createElement(i1,{size:16}),d.createElement("span",{className:"hidden sm:inline"},"Edit QR Code"))),d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"Color"),d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>Sr("text"),className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="text"?"ring-2 ring-indigo-500":""}`,style:{background:be.color}}))),d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"BG"),d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>Sr("fill"),className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="fill"?"ring-2 ring-indigo-500":""}`,style:{background:be.backgroundColor}})))),d.createElement("div",{className:"flex items-center gap-2 text-slate-600 flex-shrink-0"},d.createElement("div",{className:"relative"},d.createElement("button",{ref:Be,onClick:()=>{if(!fe&&Be.current){const Se=Be.current.getBoundingClientRect();X({top:Se.bottom+8,left:Se.left})}j(!fe)},className:`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${fe?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-700"}`},d.createElement("span",null,"Blend"),d.createElement("span",{className:"text-xs text-slate-500 hidden sm:inline"},Ie),d.createElement(Gl,{size:14,className:"text-slate-400"})),fe&&q&&Gu.createPortal(d.createElement("div",{"data-blend-mode-menu":!0,className:"fixed w-56 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-[9999] max-h-80 overflow-y-auto",style:{top:q.top,left:q.left},onMouseDown:Se=>Se.stopPropagation()},y1.map((Se,kt)=>d.createElement("div",{key:Se.label},d.createElement("div",{className:"px-3 py-1 text-[10px] font-bold uppercase tracking-wider text-slate-400"},Se.label),Se.options.map(yt=>d.createElement("button",{key:yt.value,onClick:()=>{De({blendMode:yt.value}),j(!1)},className:`w-full px-3 py-1.5 text-left text-sm hover:bg-indigo-50 hover:text-indigo-600 ${!rt&&yt.value===st?"bg-indigo-50 text-indigo-600 font-medium":"text-slate-700"}`},yt.label)),kt<y1.length-1&&d.createElement("div",{className:"h-px bg-gray-100 my-1"})))),document.body)),d.createElement("div",{className:"relative"},d.createElement("button",{ref:R,onClick:()=>{if(!J&&R.current){const Se=R.current.getBoundingClientRect();se({top:Se.bottom+8,left:Se.left})}K(!J)},className:`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${J?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-700"}`},d.createElement("span",null,"Flip")),J&&D&&d.createElement("div",{"data-flip-menu":!0,className:"fixed w-48 bg-white rounded-xl shadow-xl border border-gray-100 p-1 z-[9999] animate-in fade-in zoom-in-95 duration-100 flex flex-col",style:{top:D.top,left:D.left},onMouseDown:Se=>Se.stopPropagation()},d.createElement("button",{onClick:()=>{De({flipX:!be.flipX}),K(!1)},className:"flex items-center gap-3 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 rounded-lg text-left"},d.createElement(Zp,{size:16}),d.createElement("span",null,"Flip horizontal")),d.createElement("button",{onClick:()=>{De({flipY:!be.flipY}),K(!1)},className:"flex items-center gap-3 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 rounded-lg text-left"},d.createElement(Jp,{size:16}),d.createElement("span",null,"Flip vertical")))),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2 hidden sm:block"}),d.createElement("div",{className:"flex items-center gap-2 hidden sm:flex"},d.createElement("span",{className:"text-xs font-medium text-slate-400"},"Opacity"),d.createElement("input",{type:"range",min:"0",max:"1",step:"0.1",value:be.opacity,onChange:Se=>De({opacity:parseFloat(Se.target.value)}),className:"w-16 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-slate-800"})),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2 hidden sm:block"}),d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>f(cr.POSITION),className:"flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors hover:bg-gray-100"},d.createElement(Cd,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Position"))),d.createElement("button",{onClick:()=>De({locked:!be.locked}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.locked?"text-red-500 bg-red-50":""}`,title:be.locked?"Unlock":"Lock"},be.locked?d.createElement(Ku,{size:16}):d.createElement(ju,{size:16})),d.createElement("button",{onClick:()=>l(ve),className:"p-1.5 hover:bg-gray-100 rounded transition-colors",title:"Duplicate"},d.createElement(s1,{size:16})),d.createElement("button",{onClick:()=>a(ve),className:"p-1.5 hover:bg-red-50 text-red-500 rounded transition-colors"},d.createElement(zi,{size:16})),Ue.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2 hidden sm:block"}),d.createElement("div",{className:"flex items-center gap-1"},Ue.map(We)))))},Pg=80,WO=({pages:t,activePageId:e,setActivePage:r,addPage:n,duplicatePage:a,deletePage:s,settings:A,onClose:l})=>{ne.useRef(null);const c=Pg/A.height,f=A.width*c;return d.createElement("div",{className:"h-32 bg-white border-t border-gray-200 flex flex-col shadow-[-4px_0_15px_rgba(0,0,0,0.05)] animate-in slide-in-from-bottom-10 duration-200 z-10 relative"},d.createElement("div",{className:"h-8 flex items-center justify-between px-4 bg-gray-50 border-b border-gray-100"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide"},"Pages (",t.length,")"),d.createElement("button",{onClick:l,className:"p-1 hover:bg-gray-200 rounded text-slate-400 hover:text-slate-600"},d.createElement(dQ,{size:16,className:"rotate-180"}))),d.createElement("div",{className:"flex-1 flex items-center overflow-x-auto px-4 gap-4 py-2 custom-scrollbar"},t.map((h,g)=>{const v=h.id===e;return d.createElement("div",{key:h.id,className:"group relative flex flex-col gap-1 items-center"},d.createElement("div",{onClick:()=>r(h.id),className:`relative border-2 rounded-md overflow-hidden cursor-pointer transition-all ${v?"border-indigo-600 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,style:{width:f,height:Pg}},d.createElement("div",{className:"bg-white origin-top-left pointer-events-none select-none",style:{width:A.width,height:A.height,transform:`scale(${c})`}},h.elements.map(m=>d.createElement("div",{key:m.id,style:{position:"absolute",left:m.x,top:m.y,width:m.width,height:m.height,transform:`rotate(${m.rotation}deg)`,backgroundColor:m.type==="shape"?m.backgroundColor||"#ccc":void 0,opacity:m.opacity,color:m.color,fontSize:m.fontSize,display:"flex",alignItems:"center",overflow:"hidden"}},m.type==="image"&&d.createElement("img",{src:m.content,className:"w-full h-full object-cover"}),m.type==="shape"&&d.createElement("div",{className:"w-full h-full",style:{borderRadius:m.content==="circle"?"50%":0,clipPath:m.content==="triangle"?"polygon(50% 0%, 0% 100%, 100% 100%)":void 0,background:m.backgroundColor}}),m.type==="text"&&d.createElement("span",{className:"whitespace-nowrap"},m.content)))),d.createElement("div",{className:"absolute inset-0 bg-black/5 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},d.createElement("button",{onClick:m=>{m.stopPropagation(),a(h.id)},className:"p-1.5 bg-white rounded-full text-slate-600 shadow-sm hover:text-blue-600 hover:scale-110 transition-all",title:"Duplicate"},d.createElement(s1,{size:12})),t.length>1&&d.createElement("button",{onClick:m=>{m.stopPropagation(),s(h.id)},className:"p-1.5 bg-white rounded-full text-slate-600 shadow-sm hover:text-red-600 hover:scale-110 transition-all",title:"Delete"},d.createElement(zi,{size:12})))),d.createElement("div",{className:"text-[10px] text-slate-500 font-medium truncate max-w-[80px]"},g+1,". ",h.name))}),d.createElement("button",{onClick:n,className:"flex-shrink-0 flex flex-col items-center justify-center gap-2 text-slate-400 hover:text-indigo-600 group",style:{width:f,height:Pg}},d.createElement("div",{className:"w-10 h-10 rounded-full border border-gray-300 group-hover:border-indigo-300 flex items-center justify-center transition-colors"},d.createElement(LA,{size:20})),d.createElement("span",{className:"text-[10px] font-medium"},"Add Page"))))},ZO=({open:t,title:e,description:r,upgradeUrl:n,onClose:a})=>t?d.createElement("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/40 px-4","data-no-export":!0},d.createElement("div",{className:"w-full max-w-md rounded-2xl bg-white shadow-2xl border border-slate-200 overflow-hidden"},d.createElement("div",{className:"flex items-center justify-between px-5 py-4 border-b border-slate-100"},d.createElement("div",{className:"flex items-center gap-3"},d.createElement("div",{className:"h-9 w-9 rounded-full bg-amber-50 text-amber-600 flex items-center justify-center"},d.createElement(IA,{size:18})),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-900"},e),d.createElement("div",{className:"text-xs text-slate-500"},"Fraczled Pro"))),d.createElement("button",{onClick:a,className:"p-1.5 rounded-full text-slate-400 hover:text-slate-600 hover:bg-slate-100"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"px-5 py-4 text-sm text-slate-600"},r),d.createElement("div",{className:"px-5 pb-5 flex items-center justify-end gap-2"},d.createElement("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800"},"Not now"),n?d.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"px-4 py-2 rounded-lg bg-slate-900 text-white text-sm font-semibold hover:bg-slate-800"},"Upgrade"):d.createElement("button",{disabled:!0,className:"px-4 py-2 rounded-lg bg-slate-300 text-white text-sm font-semibold cursor-not-allowed"},"Upgrade")))):null,JO=[{name:"Instagram Post",width:1080,height:1080,unit:"px",dpi:72,icon:d.createElement(Tb,{size:20})},{name:"Instagram Story",width:1080,height:1920,unit:"px",dpi:72,icon:d.createElement(HQ,{size:20})},{name:"Facebook Post",width:1200,height:630,unit:"px",dpi:72,icon:d.createElement(bQ,{size:20})},{name:"Twitter Post",width:1200,height:675,unit:"px",dpi:72,icon:d.createElement($Q,{size:20})},{name:"LinkedIn Banner",width:1584,height:396,unit:"px",dpi:72,icon:d.createElement(Qb,{size:20})},{name:"YouTube Thumbnail",width:1280,height:720,unit:"px",dpi:72,icon:d.createElement(Vl,{size:20})}],eD=[{name:"Business Card",width:3.5,height:2,unit:"in",dpi:300,bleed:.25,icon:d.createElement(mQ,{size:20})},{name:"Postcard (4x6)",width:6,height:4,unit:"in",dpi:300,bleed:.25,icon:d.createElement(zu,{size:20})},{name:"Flyer (Letter)",width:8.5,height:11,unit:"in",dpi:300,bleed:.25,icon:d.createElement(zu,{size:20})},{name:"Poster (11x17)",width:11,height:17,unit:"in",dpi:300,bleed:.25,icon:d.createElement(ng,{size:20})},{name:"A4 Document",width:210,height:297,unit:"mm",dpi:300,bleed:6,icon:d.createElement(zu,{size:20})},{name:"A5 Flyer",width:148,height:210,unit:"mm",dpi:300,bleed:6,icon:d.createElement(zu,{size:20})}],tD=({open:t,onClose:e,onSkipFuture:r,customTemplates:n,newDesignModal:a,canCustomizeNewDesignModal:s,canCustomizeTemplateSizes:A})=>{const l=Xc(),[c,f]=ne.useState("templates"),[h,g]=ne.useState(800),[v,m]=ne.useState(600),[x,w]=ne.useState("px"),[C,S]=ne.useState(72),[F,M]=ne.useState(!1),[L,Z]=ne.useState(!1),[J,K]=ne.useState(""),[ee,V]=ne.useState("all"),[fe,j]=ne.useState([]),[te,z]=ne.useState(!1),D=ne.useMemo(()=>A7(n),[n]);ne.useEffect(()=>{t&&(c==="templates"||!!(s&&(a!=null&&a.render)))&&(Sg(n),z(!0),i7().then(j).finally(()=>z(!1)))},[t,c,n,a,s]),ne.useEffect(()=>{ee!=="all"&&(D.some(_=>_.id===ee)||V("all"))},[ee,D]);const se=ne.useMemo(()=>{const _=fe,R=J.toLowerCase().trim();let ie=ee==="all"?_:_.filter(ae=>ae.category===ee);return R&&(ie=ie.filter(ae=>ae.name.toLowerCase().includes(R)||ae.tags.some(ge=>ge.toLowerCase().includes(R)))),ie},[J,ee,fe]),q=fe.length>0,X=(_,R)=>{Oe.loadTemplateAsNewDesign(_,{preserveLibraries:!0}),((R==null?void 0:R.transparentBackground)??L)&&Oe.updateSettings({backgroundColor:"transparent"}),((R==null?void 0:R.skipFuture)??F)&&r(),e()},Y=(_,R)=>{const ie=Xa(_.width,_.unit),ae=Xa(_.height,_.unit),ge=typeof _.bleed=="number"?Xa(_.bleed,_.unit):0,ce=typeof _.dpi=="number"?_.dpi:ge>0?300:72,Ae=typeof _.safeArea=="number"?Xa(_.safeArea,_.unit):ce>=150?Xa(.25,"in"):0,ue=ge>0,Be=Ae>0,$=(R==null?void 0:R.transparentBackground)??L;Oe.updateSettings({width:ie,height:ae,unit:_.unit,dpi:ce,bleed:ge,showBleed:ue,safeArea:Ae,showSafeArea:Be,backgroundColor:$?"transparent":"#ffffff"});const ve=Oe.getSnapshot();ve.activePageId&&Oe.updatePageDimensions(ve.activePageId,{width:ie,height:ae,unit:_.unit}),((R==null?void 0:R.skipFuture)??F)&&r(),e()},W=_=>{Y(_)},P=()=>{const _=Xa(h,x),R=Xa(v,x);Oe.updateSettings({width:_,height:R,unit:x,dpi:C,bleed:0,showBleed:!1,safeArea:0,showSafeArea:!1,backgroundColor:L?"transparent":"#ffffff"});const ie=Oe.getSnapshot();ie.activePageId&&Oe.updatePageDimensions(ie.activePageId,{width:_,height:R,unit:x}),F&&r(),e()},O=(_,R,ie)=>!A||!_||_.length===0?R:_.map((ae,ge)=>({id:ae.id,name:ae.name,width:ae.width,height:ae.height,unit:ae.unit,dpi:typeof ae.dpi=="number"?ae.dpi:ie.dpi,bleed:ae.bleed,safeArea:ae.safeArea,icon:ae.icon??ie.icon})),k=ne.useMemo(()=>{var _;return O((_=a==null?void 0:a.sizePresets)==null?void 0:_.social,JO,{dpi:72,icon:d.createElement(Vl,{size:20})})},[a,A]),Q=ne.useMemo(()=>{var _;return O((_=a==null?void 0:a.sizePresets)==null?void 0:_.print,eD,{dpi:300,icon:d.createElement(zu,{size:20})})},[a,A]),N=c==="social"?k:Q,I={store:Oe,getState:()=>Oe.getSnapshot(),onClose:e,onSkipFuture:r,applyTemplate:(_,R)=>X(_,R),applySizePreset:(_,R)=>Y(_,R),createCustom:({width:_,height:R,unit:ie,dpi:ae,bleed:ge,safeArea:ce,transparentBackground:Ae})=>{const ue=Xa(_,ie),Be=Xa(R,ie),$=typeof ge=="number"?Xa(ge,ie):0,ve=typeof ce=="number"?Xa(ce,ie):0;Oe.updateSettings({width:ue,height:Be,unit:ie,dpi:typeof ae=="number"?ae:C,bleed:$,showBleed:$>0,safeArea:ve,showSafeArea:ve>0,backgroundColor:Ae?"transparent":"#ffffff"});const be=Oe.getSnapshot();be.activePageId&&Oe.updatePageDimensions(be.activePageId,{width:ue,height:Be,unit:ie})}};if(!t)return null;if(s&&(a!=null&&a.render)){const _=a.render;return d.createElement(_,{...I})}return d.createElement("div",{className:`fixed inset-0 z-[9999] flex ${l?"items-end":"items-center justify-center"} bg-black/50 backdrop-blur-sm animate-in fade-in duration-200`},d.createElement("div",{className:`bg-white shadow-2xl w-full flex flex-col animate-in ${l?"rounded-t-3xl max-h-[92vh] slide-in-from-bottom duration-300":"rounded-2xl max-w-3xl max-h-[85vh] zoom-in-95 duration-200"} overflow-hidden`},d.createElement("div",{className:`flex items-center justify-between ${l?"px-4 py-3":"px-6 py-4"} border-b border-gray-100`},l&&d.createElement("div",{className:"w-12 h-1 bg-slate-300 rounded-full absolute top-2 left-1/2 -translate-x-1/2"}),d.createElement("h2",{className:`${l?"text-lg":"text-xl"} font-bold text-slate-800`},"Create New Design"),d.createElement("button",{onClick:e,className:`${l?"p-2.5":"p-2"} hover:bg-gray-100 rounded-full transition-colors text-slate-400 hover:text-slate-600`},d.createElement(Ls,{size:l?24:20}))),d.createElement("div",{className:`flex gap-2 ${l?"px-4 py-2 overflow-x-auto scrollbar-hide":"px-6 py-3"} border-b border-gray-100 bg-gray-50/50`},d.createElement("button",{onClick:()=>f("templates"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="templates"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Templates"),d.createElement("button",{onClick:()=>f("social"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="social"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Social Media"),d.createElement("button",{onClick:()=>f("print"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="print"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Print"),d.createElement("button",{onClick:()=>f("custom"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="custom"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Custom")),d.createElement("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`},c==="templates"?d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"relative"},d.createElement(Fi,{className:"absolute left-3 top-3 text-slate-400",size:16}),d.createElement("input",{type:"text",placeholder:"Search templates...",className:`w-full pl-9 pr-4 ${l?"py-3 text-base":"py-2.5 text-sm"} bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 transition-all placeholder:text-slate-400`,value:J,onChange:_=>K(_.target.value)})),d.createElement("div",{className:`flex gap-1.5 ${l?"overflow-x-auto pb-1 scrollbar-hide -mx-4 px-4":"flex-wrap"}`},d.createElement("button",{onClick:()=>V("all"),className:`${l?"px-3 py-2 flex-shrink-0":"px-3 py-1.5"} text-xs font-medium rounded-lg transition-colors ${ee==="all"?"bg-slate-900 text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`},"All"),D.map(_=>d.createElement("button",{key:_.id,onClick:()=>V(_.id),className:`${l?"px-3 py-2 flex-shrink-0 whitespace-nowrap":"px-3 py-1.5"} text-xs font-medium rounded-lg transition-colors ${ee===_.id?"bg-slate-900 text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`},_.name))),te?d.createElement("div",{className:"flex flex-col items-center justify-center py-12 text-center"},d.createElement($c,{size:32,className:"text-indigo-500 mb-4 animate-spin"}),d.createElement("p",{className:"text-sm text-slate-500"},"Loading templates...")):q?se.length===0?d.createElement("div",{className:"flex flex-col items-center justify-center py-8 text-center"},d.createElement(Fi,{size:32,className:"text-slate-300 mb-3"}),d.createElement("p",{className:"text-sm text-slate-500"},"No templates found"),d.createElement("p",{className:"text-xs text-slate-400 mt-1"},"Try a different search term")):d.createElement("div",{className:`grid ${l?"grid-cols-2 gap-2":"grid-cols-2 sm:grid-cols-3 gap-3"}`},se.map(_=>d.createElement("button",{key:_.id,onClick:()=>X(_),className:"group relative flex flex-col rounded-xl border border-slate-200 hover:border-indigo-400 hover:shadow-lg transition-all bg-white overflow-hidden active:scale-[0.98]"},d.createElement("div",{className:"aspect-square bg-slate-50 flex items-center justify-center overflow-hidden"},_.thumbnail?d.createElement("img",{src:_.thumbnail,alt:_.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-200"}):d.createElement(Vc,{size:32,className:"text-slate-300"})),d.createElement("div",{className:"p-2 border-t border-slate-100"},d.createElement("span",{className:`${l?"text-[11px]":"text-xs"} font-medium text-slate-700 group-hover:text-slate-900 line-clamp-1`},_.name),d.createElement("span",{className:"text-[10px] text-slate-400 capitalize block"},_.category.replace("-"," ")))))):d.createElement("div",{className:"flex flex-col items-center justify-center py-12 text-center"},d.createElement(Vc,{size:48,className:"text-slate-300 mb-4"}),d.createElement("h3",{className:"text-sm font-semibold text-slate-700 mb-2"},"No Templates Yet"),d.createElement("p",{className:"text-xs text-slate-500 max-w-[200px]"},"Choose a blank canvas size from Social Media or Print tabs."))):c!=="custom"?d.createElement("div",{className:`grid ${l?"grid-cols-2 gap-3":"grid-cols-2 sm:grid-cols-3 gap-4"}`},N.map((_,R)=>d.createElement("button",{key:_.id??`${_.name}-${R}`,onClick:()=>W(_),className:`group flex flex-col items-center ${l?"p-3":"p-4"} rounded-xl border border-gray-200 hover:border-indigo-300 hover:bg-indigo-50/50 transition-all text-left active:scale-[0.98]`},d.createElement("div",{className:`${l?"w-12 h-12":"w-16 h-16"} rounded-xl bg-gradient-to-br from-indigo-100 to-purple-100 flex items-center justify-center text-indigo-600 mb-2 group-hover:from-indigo-200 group-hover:to-purple-200 transition-colors`},_.icon||d.createElement(Vl,{size:20})),d.createElement("span",{className:`font-semibold text-slate-800 ${l?"text-xs text-center":"text-sm"}`},_.name),d.createElement("span",{className:`${l?"text-[10px]":"text-xs"} text-slate-400 mt-0.5`},_.width," x ",_.height," ",_.unit),_.dpi===300&&d.createElement("span",{className:"text-[10px] bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full mt-1.5 font-medium"},"300 DPI")))):d.createElement("div",{className:`${l?"":"max-w-md mx-auto"} space-y-5`},d.createElement("div",{className:"grid grid-cols-2 gap-3"},d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"Width"),d.createElement("input",{type:"number",value:h,onChange:_=>g(Number(_.target.value)),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent`})),d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"Height"),d.createElement("input",{type:"number",value:v,onChange:_=>m(Number(_.target.value)),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent`}))),d.createElement("div",{className:"grid grid-cols-2 gap-3"},d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"Unit"),d.createElement("select",{value:x,onChange:_=>w(_.target.value),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white`},d.createElement("option",{value:"px"},"Pixels (px)"),d.createElement("option",{value:"in"},"Inches (in)"),d.createElement("option",{value:"mm"},"Millimeters (mm)"),d.createElement("option",{value:"pt"},"Points (pt)"))),d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"DPI"),d.createElement("select",{value:C,onChange:_=>S(Number(_.target.value)),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white`},d.createElement("option",{value:72},"72 (Web)"),d.createElement("option",{value:150},"150 (Medium)"),d.createElement("option",{value:300},"300 (Print)")))),d.createElement("button",{onClick:P,className:`w-full ${l?"py-4 text-base":"py-3"} bg-indigo-600 text-white font-semibold rounded-lg hover:bg-indigo-700 transition-colors active:scale-[0.98]`},"Create Custom Document"))),d.createElement("div",{className:`${l?"flex flex-col gap-3 px-4 py-4":"flex items-center justify-between px-6 py-4"} border-t border-gray-100 bg-gray-50/50`},d.createElement("div",{className:`flex ${l?"flex-col gap-3":"items-center gap-4"}`},d.createElement("label",{className:`flex items-center gap-2.5 ${l?"text-sm py-1":"text-sm"} text-slate-600 cursor-pointer select-none`},d.createElement("input",{type:"checkbox",checked:L,onChange:_=>Z(_.target.checked),className:`${l?"w-5 h-5":"w-4 h-4"} rounded border-gray-300 text-indigo-600 focus:ring-indigo-500`}),"Transparent background"),d.createElement("label",{className:`flex items-center gap-2.5 ${l?"text-sm py-1":"text-sm"} text-slate-400 cursor-pointer select-none`},d.createElement("input",{type:"checkbox",checked:F,onChange:_=>M(_.target.checked),className:`${l?"w-5 h-5":"w-4 h-4"} rounded border-gray-300 text-indigo-600 focus:ring-indigo-500`}),"Don't show this again")),d.createElement("button",{onClick:e,className:`${l?"w-full py-3 text-center":"px-4 py-2"} text-sm text-slate-600 hover:bg-gray-100 rounded-lg transition-colors`},"Skip for now"))))},Zl={mobilePixelRatioCap:2,tileSize:2048,tileOverlap:0},rD={tileWidth:2048,tileHeight:2048,overlap:0};function zg(t,e,r={}){const{tileWidth:n,tileHeight:a,overlap:s}={...rD,...r},A=n-s,l=a-s,c=Math.ceil(t/A),f=Math.ceil(e/l),h=[];for(let g=0;g<f;g++)for(let v=0;v<c;v++){const m=v*A,x=g*l,w=Math.min(n,t-m),C=Math.min(a,e-x);h.push({row:g,col:v,x:m,y:x,width:w,height:C,captureX:m,captureY:x,captureWidth:w,captureHeight:C})}return{rows:f,cols:c,tiles:h,totalWidth:t,totalHeight:e}}function rw(t,e,r,n=8192,a=67108864){const s=t*r,A=e*r,l=s*A;return s>n||A>n||l>a}function nD(t,e,r){const n=t*e*r*r*4;return{bytes:n,mb:n/(1024*1024)}}function jg(t,e,r,n=1){const a=document.createElement("canvas");a.width=Math.max(1,Math.ceil(e*n)),a.height=Math.max(1,Math.ceil(r*n));const s=a.getContext("2d");if(!s)throw new Error("Failed to get canvas context");for(const{rect:A,canvas:l}of t)s.drawImage(l,A.x*n,A.y*n,A.width*n,A.height*n);return a}const aD={format:"png",quality:1,includeBleed:!1,progressive:!1,tileSize:2048};class nw{constructor(e,r){this.abortController=null,this.cache=e??U7(),this.config={...aD,...r}}shouldUseTiling(e,r,n){const a=f1()?4096:8192,s=f1()?16777216:67108864;return rw(e,r,n,a,s)}getSafePixelRatio(e,r,n){return Jb({kind:this.config.format==="png"||this.config.format==="jpeg"?"web":"print",width:e,height:r,dpi:n??this.config.dpi,pixelRatio:this.config.pixelRatio})}estimateMemory(e,r,n){return nD(e,r,n)}async warmCache(e,r,n){var s;const a=e.filter(A=>this.cache.shouldCache(A));if(a.length===0){n==null||n({stage:"caching",percent:100,message:"No elements to cache"});return}for(let A=0;A<a.length;A++){const l=a[A];if(!this.cache.get(l,r)&&(n==null||n({stage:"caching",percent:(A+1)/a.length*100,message:`Caching element ${A+1} of ${a.length}`}),(s=this.abortController)!=null&&s.signal.aborted))throw new Error("Export aborted")}}async exportWithFallback(e,r,n,a,s){this.abortController=new AbortController;try{s==null||s({stage:"preparing",percent:0,message:"Preparing export..."});const A=this.estimateMemory(r,n,a);if(this.shouldUseTiling(r,n,a)&&this.config.progressive){const f=fg(a,r,n,{maxCanvasSize:f1()?4096:8192,clampForIOS:!0});s==null||s({stage:"preparing",percent:10,message:`Adjusted pixel ratio to ${f.toFixed(2)} for memory constraints`})}s==null||s({stage:"rendering",percent:20,message:"Capturing design..."});const c=await e();if(this.abortController.signal.aborted)throw new Error("Export aborted");return s==null||s({stage:"encoding",percent:90,message:"Encoding output..."}),s==null||s({stage:"complete",percent:100,message:"Export complete"}),c}finally{this.abortController=null}}async exportPages(e,r,n,a){this.abortController=new AbortController;const s=[];try{for(let A=0;A<e.length;A++){const l=e[A];if(a==null||a({stage:"rendering",percent:A/e.length*100,currentPage:A+1,totalPages:e.length,message:`Exporting page ${A+1} of ${e.length}`}),this.abortController.signal.aborted)throw new Error("Export aborted");const c=await n(l.id);s.push(c)}return a==null||a({stage:"complete",percent:100,totalPages:e.length,message:"All pages exported"}),s}finally{this.abortController=null}}abort(){var e;(e=this.abortController)==null||e.abort()}isExporting(){return this.abortController!==null}}let Kg=null;function oD(){return Kg||(Kg=new nw),Kg}function sD(t={}){const{useGlobal:e=!0,...r}=t,n=ne.useRef(e?oD():new nw(void 0,r));F7();const[a,s]=ne.useState(null),[A,l]=ne.useState(!1),c=ne.useCallback(async(m,x,w,C)=>{l(!0),s({stage:"preparing",percent:0});try{return await n.current.exportWithFallback(m,x,w,C,s)}finally{l(!1),setTimeout(()=>s(null),500)}},[]),f=ne.useCallback(()=>{n.current.abort(),l(!1),s(null)},[]),h=ne.useCallback((m,x,w)=>n.current.shouldUseTiling(m,x,w),[]),g=ne.useCallback((m,x,w)=>n.current.getSafePixelRatio(m,x,w),[]),v=ne.useCallback((m,x,w)=>n.current.estimateMemory(m,x,w),[]);return{exportWithProgress:c,progress:a,isExporting:A,cancel:f,shouldUseTiling:h,getSafePixelRatio:g,estimateMemory:v,pipeline:n.current}}const iD=3e3,AD="AaBbCcDdEeFfGgHhIiJj",lD=t=>t.split(",").map(e=>e.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean),aw=async(t,e=iD)=>{var s;if(!t||!("fonts"in t)||!((s=t.fonts)!=null&&s.ready))return{status:"unsupported",ready:!1,timedOut:!1};const r=A=>Promise.race([A,new Promise(l=>setTimeout(l,e))]),n=t.fonts.status;try{await r(t.fonts.ready)}catch{return{status:t.fonts.status||n,ready:!1,timedOut:!0}}const a=t.fonts.status;return{status:a,ready:a==="loaded",timedOut:!1}},ow=(t,e)=>{if(!e)return;const r=t.defaultView;if(!r)return;e.querySelectorAll('[data-text-export="true"]').forEach(a=>{const s=a,A=r.getComputedStyle(s),l=Number.parseFloat(s.dataset.textFontSize||A.fontSize||"0"),c=Number.parseFloat(s.dataset.textLineHeight||"");l>0&&!Number.isNaN(c)?s.style.lineHeight=`${c*l}px`:A.lineHeight&&A.lineHeight!=="normal"&&(s.style.lineHeight=A.lineHeight);const f=Number.parseFloat(s.dataset.textLetterSpacing||"0");if(l>0&&!Number.isNaN(f)?s.style.letterSpacing=`${f*l}px`:A.letterSpacing&&A.letterSpacing!=="normal"&&(s.style.letterSpacing=A.letterSpacing),(()=>{var v;const g=((v=r.navigator)==null?void 0:v.userAgent)||"";return/iPad|iPhone|iPod/.test(g)})()){const g=A.fontFamily||"sans-serif",v=A.fontWeight||"normal",m=A.fontStyle||"normal",x=Number.parseFloat(A.lineHeight||"");if(l>0&&Number.isFinite(x)&&x>0){const C=t.createElement("canvas").getContext("2d");if(C){C.font=`${m} ${v} ${l}px ${g}`;const S=C.measureText("Hg"),F=S.actualBoundingBoxAscent??l*.8,M=S.actualBoundingBoxDescent??l*.2,L=Math.max(0,F+M-x);L>.5&&(s.style.transform=`translateY(${-L/2}px)`,s.style.transformOrigin="top left")}}}})},cD=(t,e,r=AD)=>{if(!e||!t||!t.fonts||typeof t.fonts.check!="function")return{missing:[],checked:[]};const n=t.defaultView;if(!n)return{missing:[],checked:[]};const a=new Map;e.querySelectorAll('[data-text-export="true"]').forEach(c=>{const f=c,h=n.getComputedStyle(f),g=h.fontSize||"16px";lD(h.fontFamily||"").forEach(m=>{a.has(m)||a.set(m,g)})});const A=[],l=[];return a.forEach((c,f)=>{const h=`${c} ${f}`;l.push(h),t.fonts.check(h,r)||A.push(h)}),{missing:A,checked:l}},uD=(t,e)=>{const{missing:r}=cD(t,e);r.length!==0&&console.warn(`Export font fallback detected for: ${r.join(", ")}`)};/*!
939
+ `},d.createElement("div",{className:"w-full h-full bg-cover bg-center",style:{backgroundImage:"url(https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=150&q=80)",filter:m}}),c&&d.createElement("div",{className:"absolute inset-0 flex items-center justify-center bg-indigo-600/10"},d.createElement("div",{className:"bg-white rounded-full p-0.5 shadow-sm"},d.createElement(ul,{size:12,className:"text-indigo-600"})))),d.createElement("span",{className:`text-[10px] font-medium ${c?"text-indigo-600":"text-slate-500"}`},l.name))}))))},tw=({element:t,onChange:e,onClose:r,position:n})=>{const a=t.strokeStyle||"solid",s=t.strokeWidth||0,A=t.type==="image"&&!!t.isIcon;let l=0;typeof t.cornerRadius=="number"?l=t.cornerRadius:t.cornerRadius&&(l=t.cornerRadius.tl||0);const c=f=>{let h="0";return f==="dashed"&&(h="6,4"),f==="dotted"&&(h="2,2"),d.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"text-slate-700"},d.createElement("line",{x1:"2",y1:"12",x2:"22",y2:"12",stroke:"currentColor",strokeWidth:"2",strokeDasharray:h,strokeLinecap:"round"}))};return d.createElement("div",{className:`${n?"fixed":"absolute top-12 left-0"} w-72 bg-white rounded-xl shadow-xl border border-gray-200 z-[9999] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-100 font-sans`,style:n?{top:n.top,left:n.left}:void 0},d.createElement("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-white sticky top-0 z-10"},d.createElement("h3",{className:"font-bold text-slate-800 text-sm"},"Border"),d.createElement("button",{onClick:r,className:"text-slate-400 hover:bg-gray-100 rounded-full p-1 transition-colors"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"p-4 space-y-5"},d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Style"),d.createElement("div",{className:"grid grid-cols-4 gap-2"},d.createElement("button",{onClick:()=>e({strokeWidth:0,strokeStyle:"none"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s===0||a==="none"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"No Border"},d.createElement(QA,{size:18,className:"text-slate-600"})),d.createElement("button",{onClick:()=>e({strokeWidth:Math.max(1,s),strokeStyle:"solid"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s>0&&a==="solid"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"Solid"},c("solid")),d.createElement("button",{onClick:()=>e({strokeWidth:Math.max(1,s),strokeStyle:"dashed"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s>0&&a==="dashed"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"Dashed"},c("dashed")),d.createElement("button",{onClick:()=>e({strokeWidth:Math.max(1,s),strokeStyle:"dotted"}),className:`h-10 rounded-lg border flex items-center justify-center transition-all ${s>0&&a==="dotted"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50":"border-gray-200 hover:border-gray-300"}`,title:"Dotted"},c("dotted")))),d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex justify-between items-center"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Weight"),d.createElement("div",{className:"w-8 h-6 flex items-center justify-center bg-gray-100 rounded text-xs font-mono text-slate-600"},s)),d.createElement("input",{type:"range",min:"0",max:"50",value:s,onChange:f=>{const h=parseInt(f.target.value);e({strokeWidth:h,strokeStyle:h===0?"none":a==="none"?"solid":a})},className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})),!A&&d.createElement("div",{className:"space-y-2 pt-2 border-t border-gray-100"},d.createElement("div",{className:"flex justify-between items-center"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Corner Rounding"),d.createElement("div",{className:"w-8 h-6 flex items-center justify-center bg-gray-100 rounded text-xs font-mono text-slate-600"},Math.round(l))),d.createElement("input",{type:"range",min:"0",max:"100",value:l,onChange:f=>e({cornerRadius:parseInt(f.target.value)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}))))},XO=({element:t,onChange:e,onClose:r,position:n})=>{const a=t.textStrokeWidth||0,s=t.textStrokePosition||"behind",A=t.textStrokeStyle||"round";return d.createElement("div",{className:`${n?"fixed":"absolute top-12 left-0"} w-72 bg-white rounded-xl shadow-xl border border-gray-200 z-[9999] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-100 font-sans`,style:n?{top:n.top,left:n.left}:void 0},d.createElement("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-white sticky top-0 z-10"},d.createElement("h3",{className:"font-bold text-slate-800 text-sm"},"Text Stroke"),d.createElement("button",{onClick:r,className:"text-slate-400 hover:bg-gray-100 rounded-full p-1 transition-colors"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"p-4 space-y-5"},d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex items-center justify-between"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Stroke"),d.createElement("button",{onClick:()=>e({textStrokeWidth:0}),className:"h-7 w-7 rounded-md border border-gray-200 flex items-center justify-center hover:border-gray-300 transition-all",title:"Disable Stroke"},d.createElement(QA,{size:14,className:"text-slate-500"}))),d.createElement("div",{className:"flex items-center gap-3"},d.createElement("input",{type:"range",min:"0",max:"20",value:a,onChange:l=>e({textStrokeWidth:parseInt(l.target.value,10)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),d.createElement("div",{className:"w-8 h-6 flex items-center justify-center bg-gray-100 rounded text-xs font-mono text-slate-600"},a))),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Position"),d.createElement("div",{className:"grid grid-cols-2 gap-2"},d.createElement("button",{onClick:()=>e({textStrokePosition:"behind"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${s==="behind"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"Behind"),d.createElement("button",{onClick:()=>e({textStrokePosition:"front"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${s==="front"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"On top"))),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider"},"Edges"),d.createElement("div",{className:"grid grid-cols-2 gap-2"},d.createElement("button",{onClick:()=>e({textStrokeStyle:"round"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${A==="round"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"Round"),d.createElement("button",{onClick:()=>e({textStrokeStyle:"flat"}),className:`h-9 rounded-lg border flex items-center justify-center text-xs font-medium transition-all ${A==="flat"?"border-indigo-600 ring-1 ring-indigo-100 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300 text-slate-600"}`},"Flat")))))},YO=({selection:t,elements:e,updateElement:r,updateElements:n,deleteElement:a,reorderElement:s,settings:A,onDuplicate:l,activeBrandKit:c,setActiveTool:f,onOpenColorPanel:h,activeTool:g,activeColorMode:v,customToolbarItems:m})=>{var Bn,sn,$r,en,Zr,tn,rn,ma,Yn,Ln,or,_e,$e;const[x,w]=ne.useState(!1),[C,S]=ne.useState(!1),[F,M]=ne.useState(!1),[L,Z]=ne.useState(!1),[J,K]=ne.useState(!1),[ee,V]=ne.useState(!1),[fe,j]=ne.useState(!1),[te,z]=ne.useState(null),[D,se]=ne.useState(null),[q,X]=ne.useState(null),[Y,W]=ne.useState(null),[P,O]=ne.useState(null),[k,Q]=ne.useState(null),[N,I]=ne.useState(null),_=ne.useRef(null),R=ne.useRef(null),ie=ne.useRef(null),ae=ne.useRef(null),ge=ne.useRef(null),ce=ne.useRef(null),Ae=ne.useRef(null),ue=ne.useRef(null),Be=ne.useRef(null),$=[6,8,10,12,14,16,18,21,24,28,32,36,42,48,56,64,72,80,96,128];if(ne.useEffect(()=>{w(!1),S(!1),M(!1),Z(!1),K(!1),V(!1),j(!1)},[t]),ne.useEffect(()=>{if(!ee)return;const Se=kt=>{var Ct;const yt=kt.target,Le=Ae.current&&Ae.current.contains(yt),$t=(Ct=yt.closest)==null?void 0:Ct.call(yt,"[data-font-size-dropdown]");!Le&&!$t&&V(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[ee]),ne.useEffect(()=>{if(!J)return;const Se=kt=>{var Ct;const yt=kt.target,Le=R.current&&R.current.contains(yt),$t=(Ct=yt.closest)==null?void 0:Ct.call(yt,"[data-flip-menu]");!Le&&!$t&&K(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[J]),ne.useEffect(()=>{if(!fe)return;const Se=kt=>{var Ct;const yt=kt.target,Le=Be.current&&Be.current.contains(yt),$t=(Ct=yt.closest)==null?void 0:Ct.call(yt,"[data-blend-mode-menu]");!Le&&!$t&&j(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[fe]),t.length===2){const Se=e.filter(Le=>t.includes(Le.id)),kt=Se.find(Le=>Le.type==="image"),yt=Se.find(Le=>Le.type==="shape");if(kt&&yt){const Le=()=>{const $t=document.querySelector(`[data-element-id="${kt.id}"] img`),Ct=($t==null?void 0:$t.naturalWidth)??kt.width,fr=($t==null?void 0:$t.naturalHeight)??kt.height;r(kt.id,{x:yt.x,y:yt.y,width:yt.width,height:yt.height,rotation:yt.rotation,clipShape:yt.content,cornerRadius:yt.cornerRadius,strokeColor:yt.strokeColor,strokeWidth:yt.strokeWidth,strokeStyle:yt.strokeStyle,crop:OA(yt.width,yt.height,Ct,fr)}),a(yt.id)};return d.createElement("div",{className:"flex flex-wrap items-center gap-2 px-2 animate-in fade-in zoom-in-95 duration-200 w-full md:justify-center"},d.createElement("span",{className:"text-sm font-semibold text-slate-500 mr-2"},"2 selected"),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2"}),d.createElement("button",{onClick:Le,className:"flex items-center gap-2 bg-indigo-50 text-indigo-700 px-3 py-1.5 rounded-lg text-sm font-medium hover:bg-indigo-100 transition-colors flex-shrink-0"},d.createElement(LQ,{size:16}),"Mask"),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2"}),d.createElement("button",{onClick:()=>a(yt.id),className:"p-1.5 hover:bg-red-50 text-red-500 rounded flex-shrink-0"},d.createElement(zi,{size:16})))}}if(t.length===0)return null;const ve=t[0],be=e.find(Se=>Se.id===ve);if(!be)return null;const Ne={store:Oe,selection:t,element:be},Ue=(m||[]).filter(Se=>(Se==null?void 0:Se.id)&&(Se==null?void 0:Se.label)).filter(Se=>Se.location==="object-toolbar"||Se.location==="both").filter(Se=>!Se.showFor||Se.showFor.length===0?!0:Se.showFor.includes(be.type)),We=Se=>{if(Se.render){const yt=Se.render;return d.createElement(d.Fragment,{key:Se.id},d.createElement(yt,{...Ne}))}const kt=Se.icon;return d.createElement("button",{key:Se.id,onClick:()=>{var yt;return(yt=Se.onClick)==null?void 0:yt.call(Se,Ne)},className:"flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium text-slate-600 hover:bg-gray-100 transition-colors"},kt&&d.createElement(kt,{size:14}),d.createElement("span",null,Se.label))},Ze=e.filter(Se=>t.includes(Se.id)),st=((Bn=Ze[0])==null?void 0:Bn.blendMode)??"normal",rt=Ze.some(Se=>(Se.blendMode??"normal")!==st),Ie=rt?"Mixed":x7(st),De=Se=>{n?n(t,Se):r(ve,Se)},pe=Se=>{const kt=Math.max(1,Se);if(t.length===1&&be&&be.type==="text"){const yt={fontSize:kt};be.autoWidth&&(yt.autoWidth=!1),r(ve,yt);return}De({fontSize:kt})},ke=be.type==="text",Qe=be.type==="path",Ge=be.type==="shape"||Qe,pt=be.type==="image",et=pt&&!!be.isIcon,_t=et&&be.iconVariant!=="color",Tt=be.type==="qrcode",Mt=be.textStrokeWidth||0,Nt=be.textStrokeColor||"#000000",Rt=Ge?be.backgroundColor??(Qe?((sn=be.path)==null?void 0:sn.fillColor)??null:null):be.backgroundColor,Ht=Qe?be.strokeColor??(($r=be.path)==null?void 0:$r.strokeColor)??"#000000":be.strokeColor||"#000000",Yt=Qe?be.strokeWidth??((en=be.path)==null?void 0:en.strokeWidth)??0:be.strokeWidth||0,Wt=!!Rt&&Rt!=="transparent",Zt=Yt>0&&Ht!=="transparent",Ir=Se=>{De({effect:Se})},ur=()=>{et||window.dispatchEvent(new CustomEvent("toggle-crop-mode",{detail:{id:ve}}))},gt=()=>{De({clipShape:void 0,cornerRadius:0,strokeWidth:0})},Vt=()=>{if(!be||be.type!=="image")return;const Se=A.width,kt=A.height,yt=document.querySelector(`[data-element-id="${be.id}"] img`),Le=(yt==null?void 0:yt.naturalWidth)??be.width,$t=(yt==null?void 0:yt.naturalHeight)??be.height,Ct=(jr,er)=>{r(be.id,{x:0,y:0,width:Se,height:kt,crop:OA(Se,kt,jr,er)})};if(yt!=null&&yt.naturalWidth&&yt.naturalHeight){Ct(yt.naturalWidth,yt.naturalHeight);return}const fr=new Image;fr.onload=()=>{Ct(fr.naturalWidth||Le,fr.naturalHeight||$t)},fr.onerror=()=>{Ct(Le,$t)},fr.src=be.content},mn=()=>{f(cr.FONT)},Sr=Se=>{h?h(Se):f(cr.COLOR)},Mr=()=>{f(cr.EFFECTS)},pr=be.type==="path"&&!!be.path&&t.length===1,dr=Ht==="transparent"?"#000000":Ht,Sn=Rt&&Rt!=="transparent"?Rt:dr,ta=Yt>0?Yt:2,Pr=()=>{if(pr&&be.path){De({backgroundColor:"transparent",path:{...be.path,fillColor:null}});return}De({backgroundColor:"transparent"})},cn=()=>{const Se={strokeWidth:0,strokeColor:"transparent"};if(pr&&be.path){De({...Se,path:{...be.path,strokeWidth:0,strokeColor:"transparent"}});return}De(Se)},Jt=()=>{if(pr&&be.path){De({backgroundColor:Sn,path:{...be.path,fillColor:Sn}});return}De({backgroundColor:Sn})},on=()=>{const Se={strokeWidth:ta,strokeColor:dr};if(pr&&be.path){De({...Se,path:{...be.path,strokeWidth:ta,strokeColor:dr}});return}De(Se)};return d.createElement("div",{ref:_,className:"flex flex-wrap items-center gap-2 md:gap-4 px-1 md:px-2 animate-in fade-in zoom-in-95 duration-200 w-full md:justify-center"},ke&&d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},d.createElement("div",{className:"relative group"},d.createElement("button",{onClick:mn,className:`flex items-center gap-2 px-2 py-1.5 rounded-lg text-sm font-medium transition-colors w-32 justify-between border ${g===cr.FONT?"bg-indigo-50 border-indigo-200 text-indigo-700":"hover:bg-gray-100 border-transparent text-slate-700"}`},d.createElement("span",{className:"truncate",style:{fontFamily:be.fontFamily}},be.fontFamily||"Inter"),d.createElement(Gl,{size:14,className:"text-slate-400"}))),d.createElement("div",{ref:Ae,className:"flex items-center bg-gray-50 rounded border border-gray-200 h-8 flex-shrink-0 relative"},d.createElement("button",{onClick:()=>pe((be.fontSize||16)-1),className:"px-2 hover:bg-gray-200 h-full flex items-center text-slate-600"},"-"),d.createElement("button",{onClick:Se=>{const kt=Se.currentTarget.getBoundingClientRect();z({top:kt.bottom+4,left:kt.left}),V(!ee)},className:"w-12 text-center text-sm text-slate-700 font-medium hover:bg-gray-100 h-full flex items-center justify-center"},Math.round(be.fontSize||16)),d.createElement("button",{onClick:()=>pe((be.fontSize||16)+1),className:"px-2 hover:bg-gray-200 h-full flex items-center text-slate-600"},"+"),ee&&te&&Gu.createPortal(d.createElement("div",{"data-font-size-dropdown":!0,className:"fixed bg-white border border-gray-200 rounded-lg shadow-xl z-[9999] py-1 w-20 max-h-64 overflow-y-auto",style:{top:te.top,left:te.left}},$.map(Se=>d.createElement("button",{key:Se,onClick:()=>{pe(Se),V(!1)},className:`w-full px-3 py-1.5 text-left text-sm hover:bg-indigo-50 hover:text-indigo-600 ${Math.round(be.fontSize||16)===Se?"bg-indigo-50 text-indigo-600 font-medium":"text-slate-700"}`},Se))),document.body))),d.createElement("div",{className:"flex items-center gap-1 border-r border-gray-200 pr-4 text-slate-600 relative flex-shrink-0"},d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>Sr("text"),className:`w-6 h-6 rounded-md border border-gray-300 flex items-center justify-center relative overflow-hidden hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="text"?"ring-2 ring-indigo-500":""}`,style:{background:be.color}},d.createElement("span",{className:"sr-only"},"Color"))),d.createElement("div",{className:"w-px h-4 bg-gray-300 mx-1 hidden sm:block"}),d.createElement("button",{onClick:()=>De({fontWeight:be.fontWeight==="bold"?"normal":"bold"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.fontWeight==="bold"?"bg-indigo-50 text-indigo-600":""}`,title:"Bold"},d.createElement(Nb,{size:16})),d.createElement("button",{onClick:()=>De({fontStyle:be.fontStyle==="italic"?"normal":"italic"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.fontStyle==="italic"?"bg-indigo-50 text-indigo-600":""}`,title:"Italic"},d.createElement(Mb,{size:16})),d.createElement("button",{onClick:()=>De({textDecoration:be.textDecoration==="underline"?"none":"underline"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.textDecoration==="underline"?"bg-indigo-50 text-indigo-600":""}`,title:"Underline"},d.createElement(Pb,{size:16})),d.createElement("button",{onClick:()=>De({textDecoration:be.textDecoration==="line-through"?"none":"line-through"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.textDecoration==="line-through"?"bg-indigo-50 text-indigo-600":""}`,title:"Strikethrough"},d.createElement(Hb,{size:16})),d.createElement("div",{className:"flex items-center bg-gray-50 rounded-lg p-0.5 border border-gray-200 ml-1 flex-shrink-0"},d.createElement("button",{onClick:()=>De({textAlign:"left"}),className:`p-1 rounded hover:bg-white transition-all ${be.textAlign==="left"||!be.textAlign?"bg-white shadow-sm text-indigo-600":"text-slate-500"}`},d.createElement(GQ,{size:14})),d.createElement("button",{onClick:()=>De({textAlign:"center"}),className:`p-1 rounded hover:bg-white transition-all ${be.textAlign==="center"?"bg-white shadow-sm text-indigo-600":"text-slate-500"}`},d.createElement(KQ,{size:14})),d.createElement("button",{onClick:()=>De({textAlign:"right"}),className:`p-1 rounded hover:bg-white transition-all ${be.textAlign==="right"?"bg-white shadow-sm text-indigo-600":"text-slate-500"}`},d.createElement(qQ,{size:14}))),d.createElement("div",{className:"relative ml-1 flex items-center gap-1 flex-shrink-0"},d.createElement("button",{ref:ie,onClick:()=>{if(!x&&ie.current){const Se=ie.current.getBoundingClientRect();W({top:Se.bottom+8,left:Se.left-100})}w(!x)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${x?"bg-indigo-50 text-indigo-600":"text-slate-500"}`,title:"Spacing"},d.createElement(FQ,{size:16})),d.createElement("button",{onClick:()=>De({textTransform:be.textTransform==="uppercase"?"none":"uppercase"}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.textTransform==="uppercase"?"bg-indigo-50 text-indigo-600":"text-slate-500"}`,title:"Uppercase"},d.createElement(JM,{size:16})),x&&Y&&d.createElement("div",{className:"fixed w-64 bg-white rounded-xl shadow-xl border border-gray-200 p-4 z-[9999] animate-in fade-in zoom-in-95 duration-100",style:{top:Y.top,left:Y.left}},d.createElement("div",{className:"space-y-4"},d.createElement("div",null,d.createElement("div",{className:"flex justify-between items-center mb-1"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider"},"Letter Spacing"),d.createElement("span",{className:"text-xs text-slate-700 font-mono"},Math.round((be.letterSpacing||0)*1e3))),d.createElement("input",{type:"range",min:"-0.1",max:"0.8",step:"0.01",value:be.letterSpacing||0,onChange:Se=>De({letterSpacing:parseFloat(Se.target.value)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})),d.createElement("div",null,d.createElement("div",{className:"flex justify-between items-center mb-1"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider"},"Line Spacing"),d.createElement("span",{className:"text-xs text-slate-700 font-mono"},((Zr=be.lineHeight)==null?void 0:Zr.toFixed(2))||1.4)),d.createElement("input",{type:"range",min:"0.5",max:"2.5",step:"0.05",value:be.lineHeight||1.4,onChange:Se=>De({lineHeight:parseFloat(Se.target.value)}),className:"w-full h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}))))),d.createElement("div",{className:"relative ml-1 flex items-center gap-1 flex-shrink-0"},d.createElement("button",{ref:ue,onClick:()=>{if(!L&&ue.current){const Se=ue.current.getBoundingClientRect();I({top:Se.bottom+8,left:Se.left})}Z(!L)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${L||Mt>0?"bg-indigo-50 text-indigo-600":"text-slate-500"}`,title:"Text Stroke"},d.createElement(sg,{size:16,className:"rotate-90"})),L&&N&&d.createElement(XO,{element:be,onChange:De,onClose:()=>Z(!1),position:N}),Mt>0&&d.createElement("button",{onClick:()=>Sr("stroke"),className:`w-6 h-6 rounded-full border-2 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="stroke"?"ring-2 ring-indigo-500":"border-gray-300"}`,style:{borderColor:Nt},title:"Stroke Color"},d.createElement("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Nt}}))),d.createElement("div",{className:"w-px h-4 bg-gray-300 mx-1 hidden sm:block"}),d.createElement("div",{className:"relative flex-shrink-0"},d.createElement("button",{onClick:Mr,className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${g===cr.EFFECTS||((rn=(tn=be.effect)==null?void 0:tn.style)==null?void 0:rn.type)!=="none"||((Yn=(ma=be.effect)==null?void 0:ma.shape)==null?void 0:Yn.type)!=="none"?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement($l,{size:14}),d.createElement("span",null,"Effects"))))),Ge&&d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"Color"),d.createElement("div",{className:"relative flex items-center gap-1"},d.createElement("button",{onClick:()=>{Wt||Jt(),Sr("fill")},className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="fill"?"ring-2 ring-indigo-500":""}`,style:{background:Rt??"transparent"},title:"Fill Color"},!Wt&&d.createElement(QA,{size:12,className:"text-slate-400"})),d.createElement("button",{onClick:Pr,className:`w-6 h-6 rounded-full border border-gray-200 flex items-center justify-center transition-colors ${Wt?"text-slate-500 hover:text-red-500 hover:bg-slate-100":"bg-slate-100 text-slate-400"}`,title:"No Fill"},d.createElement(QA,{size:12})))),d.createElement("div",{className:"flex items-center gap-2 relative ml-2"},d.createElement("div",{className:"relative flex items-center gap-1"},d.createElement("button",{ref:ge,onClick:()=>{if(!F&&ge.current){const Se=ge.current.getBoundingClientRect();Q({top:Se.bottom+8,left:Se.left})}M(!F)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors border border-transparent ${F?"bg-indigo-50 text-indigo-600 border-indigo-100":"text-slate-600"}`,title:"Border Style"},d.createElement(sg,{size:18,className:"rotate-90"})),d.createElement("button",{onClick:cn,className:`w-7 h-7 rounded-full border border-gray-200 flex items-center justify-center transition-colors ${Zt?"text-slate-500 hover:text-red-500 hover:bg-slate-100":"bg-slate-100 text-slate-400"}`,title:"No Stroke"},d.createElement(QA,{size:12})),F&&k&&d.createElement(tw,{element:be,onChange:De,onClose:()=>M(!1),position:k})),d.createElement("div",{className:"relative animate-in fade-in zoom-in-95 duration-200"},d.createElement("button",{onClick:()=>{Zt||on(),Sr("stroke")},className:`w-6 h-6 rounded-full border-2 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="stroke"?"ring-2 ring-indigo-500":"border-gray-300"}`,style:{borderColor:Zt?Ht:"#cbd5f5"},title:"Stroke Color"},Zt?d.createElement("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ht}}):d.createElement(QA,{size:12,className:"text-slate-400"})))),d.createElement("div",{className:"relative ml-2 flex-shrink-0"},d.createElement("button",{onClick:Mr,className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${g===cr.EFFECTS||((or=(Ln=be.effect)==null?void 0:Ln.style)==null?void 0:or.type)!=="none"?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement($l,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Effects")))),pt&&d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},!et&&d.createElement("button",{onClick:ur,className:"flex items-center gap-2 hover:bg-gray-100 px-3 py-1.5 rounded-lg text-sm font-medium text-slate-700 transition-colors flex-shrink-0",title:"Crop Image (Double Click)"},d.createElement(vQ,{size:16}),d.createElement("span",{className:"hidden sm:inline"},"Crop")),d.createElement("button",{onClick:Vt,className:"p-2 hover:bg-gray-100 rounded-lg text-slate-700 transition-colors flex items-center justify-center",title:"Fit to page"},d.createElement(eg,{size:16})),_t&&d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"Color"),d.createElement("button",{onClick:()=>Sr("text"),className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="text"?"ring-2 ring-indigo-500":""}`,style:{background:be.color||"#000000"},title:"Icon Color"})),be.clipShape&&d.createElement("button",{onClick:gt,className:"flex items-center gap-2 hover:bg-gray-100 px-3 py-1.5 rounded-lg text-sm font-medium text-slate-700 transition-colors flex-shrink-0",title:"Detach Mask"},d.createElement(IQ,{size:16}),d.createElement("span",{className:"hidden sm:inline"},"Detach Image")),d.createElement("div",{className:"relative flex-shrink-0"},d.createElement("button",{onClick:Mr,className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${g===cr.EFFECTS||(($e=(_e=be.effect)==null?void 0:_e.style)==null?void 0:$e.type)!=="none"?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement($l,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Effects"))),d.createElement("div",{className:"relative flex-shrink-0"},d.createElement("button",{ref:ae,onClick:()=>{if(!C&&ae.current){const Se=ae.current.getBoundingClientRect();O({top:Se.bottom+8,left:Se.left})}S(!C)},className:`flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ${C?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-600"}`},d.createElement(YQ,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Filters")),C&&P&&d.createElement($O,{effect:be.effect,onChange:Ir,onClose:()=>S(!1),position:P})),be.clipShape&&d.createElement("div",{className:"flex items-center gap-2 relative ml-2"},d.createElement("div",{className:"relative"},d.createElement("button",{ref:ce,onClick:()=>{if(!F&&ce.current){const Se=ce.current.getBoundingClientRect();Q({top:Se.bottom+8,left:Se.left})}M(!F)},className:`p-1.5 hover:bg-gray-100 rounded transition-colors border border-transparent ${F?"bg-indigo-50 text-indigo-600 border-indigo-100":"text-slate-600"}`,title:"Border Style"},d.createElement(sg,{size:18,className:"rotate-90"})),F&&k&&d.createElement(tw,{element:be,onChange:De,onClose:()=>M(!1),position:k})),(be.strokeWidth||0)>0&&d.createElement("div",{className:"relative animate-in fade-in zoom-in-95 duration-200"},d.createElement("button",{onClick:()=>Sr("stroke"),className:`w-6 h-6 rounded-full border-2 hover:ring-2 hover:ring-indigo-100 transition-all flex items-center justify-center ${g===cr.COLOR&&v==="stroke"?"ring-2 ring-indigo-500":"border-gray-300"}`,style:{borderColor:be.strokeColor||"#000000"}},d.createElement("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:be.strokeColor||"#000000"}}))))),Tt&&d.createElement("div",{className:"flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0"},d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>f(cr.QR_CODE),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors hover:bg-gray-100 text-slate-700"},d.createElement(i1,{size:16}),d.createElement("span",{className:"hidden sm:inline"},"Edit QR Code"))),d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"Color"),d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>Sr("text"),className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="text"?"ring-2 ring-indigo-500":""}`,style:{background:be.color}}))),d.createElement("div",{className:"flex items-center gap-2 relative"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 hidden sm:inline"},"BG"),d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>Sr("fill"),className:`w-6 h-6 rounded-md border border-gray-300 hover:ring-2 hover:ring-indigo-100 transition-all ${g===cr.COLOR&&v==="fill"?"ring-2 ring-indigo-500":""}`,style:{background:be.backgroundColor}})))),d.createElement("div",{className:"flex items-center gap-2 text-slate-600 flex-shrink-0"},d.createElement("div",{className:"relative"},d.createElement("button",{ref:Be,onClick:()=>{if(!fe&&Be.current){const Se=Be.current.getBoundingClientRect();X({top:Se.bottom+8,left:Se.left})}j(!fe)},className:`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${fe?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-700"}`},d.createElement("span",null,"Blend"),d.createElement("span",{className:"text-xs text-slate-500 hidden sm:inline"},Ie),d.createElement(Gl,{size:14,className:"text-slate-400"})),fe&&q&&Gu.createPortal(d.createElement("div",{"data-blend-mode-menu":!0,className:"fixed w-56 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-[9999] max-h-80 overflow-y-auto",style:{top:q.top,left:q.left},onMouseDown:Se=>Se.stopPropagation()},y1.map((Se,kt)=>d.createElement("div",{key:Se.label},d.createElement("div",{className:"px-3 py-1 text-[10px] font-bold uppercase tracking-wider text-slate-400"},Se.label),Se.options.map(yt=>d.createElement("button",{key:yt.value,onClick:()=>{De({blendMode:yt.value}),j(!1)},className:`w-full px-3 py-1.5 text-left text-sm hover:bg-indigo-50 hover:text-indigo-600 ${!rt&&yt.value===st?"bg-indigo-50 text-indigo-600 font-medium":"text-slate-700"}`},yt.label)),kt<y1.length-1&&d.createElement("div",{className:"h-px bg-gray-100 my-1"})))),document.body)),d.createElement("div",{className:"relative"},d.createElement("button",{ref:R,onClick:()=>{if(!J&&R.current){const Se=R.current.getBoundingClientRect();se({top:Se.bottom+8,left:Se.left})}K(!J)},className:`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${J?"bg-indigo-50 text-indigo-700":"hover:bg-gray-100 text-slate-700"}`},d.createElement("span",null,"Flip")),J&&D&&d.createElement("div",{"data-flip-menu":!0,className:"fixed w-48 bg-white rounded-xl shadow-xl border border-gray-100 p-1 z-[9999] animate-in fade-in zoom-in-95 duration-100 flex flex-col",style:{top:D.top,left:D.left},onMouseDown:Se=>Se.stopPropagation()},d.createElement("button",{onClick:()=>{De({flipX:!be.flipX}),K(!1)},className:"flex items-center gap-3 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 rounded-lg text-left"},d.createElement(Zp,{size:16}),d.createElement("span",null,"Flip horizontal")),d.createElement("button",{onClick:()=>{De({flipY:!be.flipY}),K(!1)},className:"flex items-center gap-3 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 rounded-lg text-left"},d.createElement(Jp,{size:16}),d.createElement("span",null,"Flip vertical")))),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2 hidden sm:block"}),d.createElement("div",{className:"flex items-center gap-2 hidden sm:flex"},d.createElement("span",{className:"text-xs font-medium text-slate-400"},"Opacity"),d.createElement("input",{type:"range",min:"0",max:"1",step:"0.1",value:be.opacity,onChange:Se=>De({opacity:parseFloat(Se.target.value)}),className:"w-16 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-slate-800"})),d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2 hidden sm:block"}),d.createElement("div",{className:"relative"},d.createElement("button",{onClick:()=>f(cr.POSITION),className:"flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors hover:bg-gray-100"},d.createElement(Cd,{size:14}),d.createElement("span",{className:"hidden sm:inline"},"Position"))),d.createElement("button",{onClick:()=>De({locked:!be.locked}),className:`p-1.5 hover:bg-gray-100 rounded transition-colors ${be.locked?"text-red-500 bg-red-50":""}`,title:be.locked?"Unlock":"Lock"},be.locked?d.createElement(Ku,{size:16}):d.createElement(ju,{size:16})),d.createElement("button",{onClick:()=>l(ve),className:"p-1.5 hover:bg-gray-100 rounded transition-colors",title:"Duplicate"},d.createElement(s1,{size:16})),d.createElement("button",{onClick:()=>a(ve),className:"p-1.5 hover:bg-red-50 text-red-500 rounded transition-colors"},d.createElement(zi,{size:16})),Ue.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"h-4 w-px bg-gray-300 mx-2 hidden sm:block"}),d.createElement("div",{className:"flex items-center gap-1"},Ue.map(We)))))},Pg=80,WO=({pages:t,activePageId:e,setActivePage:r,addPage:n,duplicatePage:a,deletePage:s,settings:A,onClose:l})=>{ne.useRef(null);const c=Pg/A.height,f=A.width*c;return d.createElement("div",{className:"h-32 bg-white border-t border-gray-200 flex flex-col shadow-[-4px_0_15px_rgba(0,0,0,0.05)] animate-in slide-in-from-bottom-10 duration-200 z-10 relative"},d.createElement("div",{className:"h-8 flex items-center justify-between px-4 bg-gray-50 border-b border-gray-100"},d.createElement("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide"},"Pages (",t.length,")"),d.createElement("button",{onClick:l,className:"p-1 hover:bg-gray-200 rounded text-slate-400 hover:text-slate-600"},d.createElement(dQ,{size:16,className:"rotate-180"}))),d.createElement("div",{className:"flex-1 flex items-center overflow-x-auto px-4 gap-4 py-2 custom-scrollbar"},t.map((h,g)=>{const v=h.id===e;return d.createElement("div",{key:h.id,className:"group relative flex flex-col gap-1 items-center"},d.createElement("div",{onClick:()=>r(h.id),className:`relative border-2 rounded-md overflow-hidden cursor-pointer transition-all ${v?"border-indigo-600 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,style:{width:f,height:Pg}},d.createElement("div",{className:"bg-white origin-top-left pointer-events-none select-none",style:{width:A.width,height:A.height,transform:`scale(${c})`}},h.elements.map(m=>d.createElement("div",{key:m.id,style:{position:"absolute",left:m.x,top:m.y,width:m.width,height:m.height,transform:`rotate(${m.rotation}deg)`,backgroundColor:m.type==="shape"?m.backgroundColor||"#ccc":void 0,opacity:m.opacity,color:m.color,fontSize:m.fontSize,display:"flex",alignItems:"center",overflow:"hidden"}},m.type==="image"&&d.createElement("img",{src:m.content,className:"w-full h-full object-cover"}),m.type==="shape"&&d.createElement("div",{className:"w-full h-full",style:{borderRadius:m.content==="circle"?"50%":0,clipPath:m.content==="triangle"?"polygon(50% 0%, 0% 100%, 100% 100%)":void 0,background:m.backgroundColor}}),m.type==="text"&&d.createElement("span",{className:"whitespace-nowrap"},m.content)))),d.createElement("div",{className:"absolute inset-0 bg-black/5 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},d.createElement("button",{onClick:m=>{m.stopPropagation(),a(h.id)},className:"p-1.5 bg-white rounded-full text-slate-600 shadow-sm hover:text-blue-600 hover:scale-110 transition-all",title:"Duplicate"},d.createElement(s1,{size:12})),t.length>1&&d.createElement("button",{onClick:m=>{m.stopPropagation(),s(h.id)},className:"p-1.5 bg-white rounded-full text-slate-600 shadow-sm hover:text-red-600 hover:scale-110 transition-all",title:"Delete"},d.createElement(zi,{size:12})))),d.createElement("div",{className:"text-[10px] text-slate-500 font-medium truncate max-w-[80px]"},g+1,". ",h.name))}),d.createElement("button",{onClick:n,className:"flex-shrink-0 flex flex-col items-center justify-center gap-2 text-slate-400 hover:text-indigo-600 group",style:{width:f,height:Pg}},d.createElement("div",{className:"w-10 h-10 rounded-full border border-gray-300 group-hover:border-indigo-300 flex items-center justify-center transition-colors"},d.createElement(LA,{size:20})),d.createElement("span",{className:"text-[10px] font-medium"},"Add Page"))))},ZO=({open:t,title:e,description:r,upgradeUrl:n,onClose:a})=>t?d.createElement("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/40 px-4","data-no-export":!0},d.createElement("div",{className:"w-full max-w-md rounded-2xl bg-white shadow-2xl border border-slate-200 overflow-hidden"},d.createElement("div",{className:"flex items-center justify-between px-5 py-4 border-b border-slate-100"},d.createElement("div",{className:"flex items-center gap-3"},d.createElement("div",{className:"h-9 w-9 rounded-full bg-amber-50 text-amber-600 flex items-center justify-center"},d.createElement(IA,{size:18})),d.createElement("div",null,d.createElement("div",{className:"text-sm font-semibold text-slate-900"},e),d.createElement("div",{className:"text-xs text-slate-500"},"Fraczled Pro"))),d.createElement("button",{onClick:a,className:"p-1.5 rounded-full text-slate-400 hover:text-slate-600 hover:bg-slate-100"},d.createElement(Ls,{size:18}))),d.createElement("div",{className:"px-5 py-4 text-sm text-slate-600"},r),d.createElement("div",{className:"px-5 pb-5 flex items-center justify-end gap-2"},d.createElement("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800"},"Not now"),n?d.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"px-4 py-2 rounded-lg bg-slate-900 text-white text-sm font-semibold hover:bg-slate-800"},"Upgrade"):d.createElement("button",{disabled:!0,className:"px-4 py-2 rounded-lg bg-slate-300 text-white text-sm font-semibold cursor-not-allowed"},"Upgrade")))):null,JO=[{name:"Instagram Post",width:1080,height:1080,unit:"px",dpi:72,icon:d.createElement(Tb,{size:20})},{name:"Instagram Story",width:1080,height:1920,unit:"px",dpi:72,icon:d.createElement(HQ,{size:20})},{name:"Facebook Post",width:1200,height:630,unit:"px",dpi:72,icon:d.createElement(bQ,{size:20})},{name:"Twitter Post",width:1200,height:675,unit:"px",dpi:72,icon:d.createElement($Q,{size:20})},{name:"LinkedIn Banner",width:1584,height:396,unit:"px",dpi:72,icon:d.createElement(Qb,{size:20})},{name:"YouTube Thumbnail",width:1280,height:720,unit:"px",dpi:72,icon:d.createElement(Vl,{size:20})}],eD=[{name:"Business Card",width:3.5,height:2,unit:"in",dpi:300,bleed:.25,icon:d.createElement(mQ,{size:20})},{name:"Postcard (4x6)",width:6,height:4,unit:"in",dpi:300,bleed:.25,icon:d.createElement(zu,{size:20})},{name:"Flyer (Letter)",width:8.5,height:11,unit:"in",dpi:300,bleed:.25,icon:d.createElement(zu,{size:20})},{name:"Poster (11x17)",width:11,height:17,unit:"in",dpi:300,bleed:.25,icon:d.createElement(ng,{size:20})},{name:"A4 Document",width:210,height:297,unit:"mm",dpi:300,bleed:6,icon:d.createElement(zu,{size:20})},{name:"A5 Flyer",width:148,height:210,unit:"mm",dpi:300,bleed:6,icon:d.createElement(zu,{size:20})}],tD=({open:t,onClose:e,onSkipFuture:r,customTemplates:n,newDesignModal:a,canCustomizeNewDesignModal:s,canCustomizeTemplateSizes:A})=>{const l=Xc(),[c,f]=ne.useState("templates"),[h,g]=ne.useState(800),[v,m]=ne.useState(600),[x,w]=ne.useState("px"),[C,S]=ne.useState(72),[F,M]=ne.useState(!1),[L,Z]=ne.useState(!1),[J,K]=ne.useState(""),[ee,V]=ne.useState("all"),[fe,j]=ne.useState([]),[te,z]=ne.useState(!1),D=ne.useMemo(()=>A7(n),[n]);ne.useEffect(()=>{t&&(c==="templates"||!!(s&&(a!=null&&a.render)))&&(Sg(n),z(!0),i7().then(j).finally(()=>z(!1)))},[t,c,n,a,s]),ne.useEffect(()=>{ee!=="all"&&(D.some(_=>_.id===ee)||V("all"))},[ee,D]);const se=ne.useMemo(()=>{const _=fe,R=J.toLowerCase().trim();let ie=ee==="all"?_:_.filter(ae=>ae.category===ee);return R&&(ie=ie.filter(ae=>ae.name.toLowerCase().includes(R)||ae.tags.some(ge=>ge.toLowerCase().includes(R)))),ie},[J,ee,fe]),q=fe.length>0,X=(_,R)=>{Oe.loadTemplateAsNewDesign(_,{preserveLibraries:!0}),((R==null?void 0:R.transparentBackground)??L)&&Oe.updateSettings({backgroundColor:"transparent"}),((R==null?void 0:R.skipFuture)??F)&&r(),e()},Y=(_,R)=>{const ie=Xa(_.width,_.unit),ae=Xa(_.height,_.unit),ge=typeof _.bleed=="number"?Xa(_.bleed,_.unit):0,ce=typeof _.dpi=="number"?_.dpi:ge>0?300:72,Ae=typeof _.safeArea=="number"?Xa(_.safeArea,_.unit):ce>=150?Xa(.25,"in"):0,ue=ge>0,Be=Ae>0,$=(R==null?void 0:R.transparentBackground)??L;Oe.updateSettings({width:ie,height:ae,unit:_.unit,dpi:ce,bleed:ge,showBleed:ue,safeArea:Ae,showSafeArea:Be,backgroundColor:$?"transparent":"#ffffff"});const ve=Oe.getSnapshot();ve.activePageId&&Oe.updatePageDimensions(ve.activePageId,{width:ie,height:ae,unit:_.unit}),((R==null?void 0:R.skipFuture)??F)&&r(),e()},W=_=>{Y(_)},P=()=>{const _=Xa(h,x),R=Xa(v,x);Oe.updateSettings({width:_,height:R,unit:x,dpi:C,bleed:0,showBleed:!1,safeArea:0,showSafeArea:!1,backgroundColor:L?"transparent":"#ffffff"});const ie=Oe.getSnapshot();ie.activePageId&&Oe.updatePageDimensions(ie.activePageId,{width:_,height:R,unit:x}),F&&r(),e()},O=(_,R,ie)=>!A||!_||_.length===0?R:_.map((ae,ge)=>({id:ae.id,name:ae.name,width:ae.width,height:ae.height,unit:ae.unit,dpi:typeof ae.dpi=="number"?ae.dpi:ie.dpi,bleed:ae.bleed,safeArea:ae.safeArea,icon:ae.icon??ie.icon})),k=ne.useMemo(()=>{var _;return O((_=a==null?void 0:a.sizePresets)==null?void 0:_.social,JO,{dpi:72,icon:d.createElement(Vl,{size:20})})},[a,A]),Q=ne.useMemo(()=>{var _;return O((_=a==null?void 0:a.sizePresets)==null?void 0:_.print,eD,{dpi:300,icon:d.createElement(zu,{size:20})})},[a,A]),N=c==="social"?k:Q,I={store:Oe,getState:()=>Oe.getSnapshot(),onClose:e,onSkipFuture:r,applyTemplate:(_,R)=>X(_,R),applySizePreset:(_,R)=>Y(_,R),createCustom:({width:_,height:R,unit:ie,dpi:ae,bleed:ge,safeArea:ce,transparentBackground:Ae})=>{const ue=Xa(_,ie),Be=Xa(R,ie),$=typeof ge=="number"?Xa(ge,ie):0,ve=typeof ce=="number"?Xa(ce,ie):0;Oe.updateSettings({width:ue,height:Be,unit:ie,dpi:typeof ae=="number"?ae:C,bleed:$,showBleed:$>0,safeArea:ve,showSafeArea:ve>0,backgroundColor:Ae?"transparent":"#ffffff"});const be=Oe.getSnapshot();be.activePageId&&Oe.updatePageDimensions(be.activePageId,{width:ue,height:Be,unit:ie})}};if(!t)return null;if(s&&(a!=null&&a.render)){const _=a.render;return d.createElement(_,{...I})}return d.createElement("div",{className:`fixed inset-0 z-[9999] flex ${l?"items-end":"items-center justify-center"} bg-black/50 backdrop-blur-sm animate-in fade-in duration-200`},d.createElement("div",{className:`bg-white shadow-2xl w-full flex flex-col animate-in ${l?"rounded-t-3xl max-h-[92vh] slide-in-from-bottom duration-300":"rounded-2xl max-w-3xl max-h-[85vh] zoom-in-95 duration-200"} overflow-hidden`},d.createElement("div",{className:`flex items-center justify-between ${l?"px-4 py-3":"px-6 py-4"} border-b border-gray-100`},l&&d.createElement("div",{className:"w-12 h-1 bg-slate-300 rounded-full absolute top-2 left-1/2 -translate-x-1/2"}),d.createElement("h2",{className:`${l?"text-lg":"text-xl"} font-bold text-slate-800`},"Create New Design"),d.createElement("button",{onClick:e,className:`${l?"p-2.5":"p-2"} hover:bg-gray-100 rounded-full transition-colors text-slate-400 hover:text-slate-600`},d.createElement(Ls,{size:l?24:20}))),d.createElement("div",{className:`flex gap-2 ${l?"px-4 py-2 overflow-x-auto scrollbar-hide":"px-6 py-3"} border-b border-gray-100 bg-gray-50/50`},d.createElement("button",{onClick:()=>f("templates"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="templates"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Templates"),d.createElement("button",{onClick:()=>f("social"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="social"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Social Media"),d.createElement("button",{onClick:()=>f("print"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="print"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Print"),d.createElement("button",{onClick:()=>f("custom"),className:`${l?"px-3 py-2 text-xs whitespace-nowrap flex-shrink-0":"px-4 py-2 text-sm"} rounded-lg font-medium transition-colors ${c==="custom"?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-gray-100 border border-gray-200"}`},"Custom")),d.createElement("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`},c==="templates"?d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"relative"},d.createElement(Fi,{className:"absolute left-3 top-3 text-slate-400",size:16}),d.createElement("input",{type:"text",placeholder:"Search templates...",className:`w-full pl-9 pr-4 ${l?"py-3 text-base":"py-2.5 text-sm"} bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 transition-all placeholder:text-slate-400`,value:J,onChange:_=>K(_.target.value)})),d.createElement("div",{className:`flex gap-1.5 ${l?"overflow-x-auto pb-1 scrollbar-hide -mx-4 px-4":"flex-wrap"}`},d.createElement("button",{onClick:()=>V("all"),className:`${l?"px-3 py-2 flex-shrink-0":"px-3 py-1.5"} text-xs font-medium rounded-lg transition-colors ${ee==="all"?"bg-slate-900 text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`},"All"),D.map(_=>d.createElement("button",{key:_.id,onClick:()=>V(_.id),className:`${l?"px-3 py-2 flex-shrink-0 whitespace-nowrap":"px-3 py-1.5"} text-xs font-medium rounded-lg transition-colors ${ee===_.id?"bg-slate-900 text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`},_.name))),te?d.createElement("div",{className:"flex flex-col items-center justify-center py-12 text-center"},d.createElement($c,{size:32,className:"text-indigo-500 mb-4 animate-spin"}),d.createElement("p",{className:"text-sm text-slate-500"},"Loading templates...")):q?se.length===0?d.createElement("div",{className:"flex flex-col items-center justify-center py-8 text-center"},d.createElement(Fi,{size:32,className:"text-slate-300 mb-3"}),d.createElement("p",{className:"text-sm text-slate-500"},"No templates found"),d.createElement("p",{className:"text-xs text-slate-400 mt-1"},"Try a different search term")):d.createElement("div",{className:`grid ${l?"grid-cols-2 gap-2":"grid-cols-2 sm:grid-cols-3 gap-3"}`},se.map(_=>d.createElement("button",{key:_.id,onClick:()=>X(_),className:"group relative flex flex-col rounded-xl border border-slate-200 hover:border-indigo-400 hover:shadow-lg transition-all bg-white overflow-hidden active:scale-[0.98]"},d.createElement("div",{className:"aspect-square bg-slate-50 flex items-center justify-center overflow-hidden"},_.thumbnail?d.createElement("img",{src:_.thumbnail,alt:_.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-200"}):d.createElement(Vc,{size:32,className:"text-slate-300"})),d.createElement("div",{className:"p-2 border-t border-slate-100"},d.createElement("span",{className:`${l?"text-[11px]":"text-xs"} font-medium text-slate-700 group-hover:text-slate-900 line-clamp-1`},_.name),d.createElement("span",{className:"text-[10px] text-slate-400 capitalize block"},_.category.replace("-"," ")))))):d.createElement("div",{className:"flex flex-col items-center justify-center py-12 text-center"},d.createElement(Vc,{size:48,className:"text-slate-300 mb-4"}),d.createElement("h3",{className:"text-sm font-semibold text-slate-700 mb-2"},"No Templates Yet"),d.createElement("p",{className:"text-xs text-slate-500 max-w-[200px]"},"Choose a blank canvas size from Social Media or Print tabs."))):c!=="custom"?d.createElement("div",{className:`grid ${l?"grid-cols-2 gap-3":"grid-cols-2 sm:grid-cols-3 gap-4"}`},N.map((_,R)=>d.createElement("button",{key:_.id??`${_.name}-${R}`,onClick:()=>W(_),className:`group flex flex-col items-center ${l?"p-3":"p-4"} rounded-xl border border-gray-200 hover:border-indigo-300 hover:bg-indigo-50/50 transition-all text-left active:scale-[0.98]`},d.createElement("div",{className:`${l?"w-12 h-12":"w-16 h-16"} rounded-xl bg-gradient-to-br from-indigo-100 to-purple-100 flex items-center justify-center text-indigo-600 mb-2 group-hover:from-indigo-200 group-hover:to-purple-200 transition-colors`},_.icon||d.createElement(Vl,{size:20})),d.createElement("span",{className:`font-semibold text-slate-800 ${l?"text-xs text-center":"text-sm"}`},_.name),d.createElement("span",{className:`${l?"text-[10px]":"text-xs"} text-slate-400 mt-0.5`},_.width," x ",_.height," ",_.unit),_.dpi===300&&d.createElement("span",{className:"text-[10px] bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full mt-1.5 font-medium"},"300 DPI")))):d.createElement("div",{className:`${l?"":"max-w-md mx-auto"} space-y-5`},d.createElement("div",{className:"grid grid-cols-2 gap-3"},d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"Width"),d.createElement("input",{type:"number",value:h,onChange:_=>g(Number(_.target.value)),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent`})),d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"Height"),d.createElement("input",{type:"number",value:v,onChange:_=>m(Number(_.target.value)),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent`}))),d.createElement("div",{className:"grid grid-cols-2 gap-3"},d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"Unit"),d.createElement("select",{value:x,onChange:_=>w(_.target.value),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white`},d.createElement("option",{value:"px"},"Pixels (px)"),d.createElement("option",{value:"in"},"Inches (in)"),d.createElement("option",{value:"mm"},"Millimeters (mm)"),d.createElement("option",{value:"pt"},"Points (pt)"))),d.createElement("div",null,d.createElement("label",{className:"block text-xs font-bold text-slate-500 uppercase mb-2"},"DPI"),d.createElement("select",{value:C,onChange:_=>S(Number(_.target.value)),className:`w-full px-3 ${l?"py-3 text-base":"py-2"} border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white`},d.createElement("option",{value:72},"72 (Web)"),d.createElement("option",{value:150},"150 (Medium)"),d.createElement("option",{value:300},"300 (Print)")))),d.createElement("button",{onClick:P,className:`w-full ${l?"py-4 text-base":"py-3"} bg-indigo-600 text-white font-semibold rounded-lg hover:bg-indigo-700 transition-colors active:scale-[0.98]`},"Create Custom Document"))),d.createElement("div",{className:`${l?"flex flex-col gap-3 px-4 py-4":"flex items-center justify-between px-6 py-4"} border-t border-gray-100 bg-gray-50/50`},d.createElement("div",{className:`flex ${l?"flex-col gap-3":"items-center gap-4"}`},d.createElement("label",{className:`flex items-center gap-2.5 ${l?"text-sm py-1":"text-sm"} text-slate-600 cursor-pointer select-none`},d.createElement("input",{type:"checkbox",checked:L,onChange:_=>Z(_.target.checked),className:`${l?"w-5 h-5":"w-4 h-4"} rounded border-gray-300 text-indigo-600 focus:ring-indigo-500`}),"Transparent background"),d.createElement("label",{className:`flex items-center gap-2.5 ${l?"text-sm py-1":"text-sm"} text-slate-400 cursor-pointer select-none`},d.createElement("input",{type:"checkbox",checked:F,onChange:_=>M(_.target.checked),className:`${l?"w-5 h-5":"w-4 h-4"} rounded border-gray-300 text-indigo-600 focus:ring-indigo-500`}),"Don't show this again")),d.createElement("button",{onClick:e,className:`${l?"w-full py-3 text-center":"px-4 py-2"} text-sm text-slate-600 hover:bg-gray-100 rounded-lg transition-colors`},"Skip for now"))))},Zl={mobilePixelRatioCap:2,tileSize:2048,tileOverlap:0},rD={tileWidth:2048,tileHeight:2048,overlap:0};function zg(t,e,r={}){const{tileWidth:n,tileHeight:a,overlap:s}={...rD,...r},A=n-s,l=a-s,c=Math.ceil(t/A),f=Math.ceil(e/l),h=[];for(let g=0;g<f;g++)for(let v=0;v<c;v++){const m=v*A,x=g*l,w=Math.min(n,t-m),C=Math.min(a,e-x);h.push({row:g,col:v,x:m,y:x,width:w,height:C,captureX:m,captureY:x,captureWidth:w,captureHeight:C})}return{rows:f,cols:c,tiles:h,totalWidth:t,totalHeight:e}}function rw(t,e,r,n=8192,a=67108864){const s=t*r,A=e*r,l=s*A;return s>n||A>n||l>a}function nD(t,e,r){const n=t*e*r*r*4;return{bytes:n,mb:n/(1024*1024)}}function jg(t,e,r,n=1){const a=document.createElement("canvas");a.width=Math.max(1,Math.ceil(e*n)),a.height=Math.max(1,Math.ceil(r*n));const s=a.getContext("2d");if(!s)throw new Error("Failed to get canvas context");for(const{rect:A,canvas:l}of t)s.drawImage(l,A.x*n,A.y*n,A.width*n,A.height*n);return a}const aD={format:"png",quality:1,includeBleed:!1,progressive:!1,tileSize:2048};class nw{constructor(e,r){this.abortController=null,this.cache=e??U7(),this.config={...aD,...r}}shouldUseTiling(e,r,n){const a=f1()?4096:8192,s=f1()?16777216:67108864;return rw(e,r,n,a,s)}getSafePixelRatio(e,r,n){return Jb({kind:this.config.format==="png"||this.config.format==="jpeg"?"web":"print",width:e,height:r,dpi:n??this.config.dpi,pixelRatio:this.config.pixelRatio})}estimateMemory(e,r,n){return nD(e,r,n)}async warmCache(e,r,n){var s;const a=e.filter(A=>this.cache.shouldCache(A));if(a.length===0){n==null||n({stage:"caching",percent:100,message:"No elements to cache"});return}for(let A=0;A<a.length;A++){const l=a[A];if(!this.cache.get(l,r)&&(n==null||n({stage:"caching",percent:(A+1)/a.length*100,message:`Caching element ${A+1} of ${a.length}`}),(s=this.abortController)!=null&&s.signal.aborted))throw new Error("Export aborted")}}async exportWithFallback(e,r,n,a,s){this.abortController=new AbortController;try{s==null||s({stage:"preparing",percent:0,message:"Preparing export..."});const A=this.estimateMemory(r,n,a);if(this.shouldUseTiling(r,n,a)&&this.config.progressive){const f=fg(a,r,n,{maxCanvasSize:f1()?4096:8192,clampForIOS:!0});s==null||s({stage:"preparing",percent:10,message:`Adjusted pixel ratio to ${f.toFixed(2)} for memory constraints`})}s==null||s({stage:"rendering",percent:20,message:"Capturing design..."});const c=await e();if(this.abortController.signal.aborted)throw new Error("Export aborted");return s==null||s({stage:"encoding",percent:90,message:"Encoding output..."}),s==null||s({stage:"complete",percent:100,message:"Export complete"}),c}finally{this.abortController=null}}async exportPages(e,r,n,a){this.abortController=new AbortController;const s=[];try{for(let A=0;A<e.length;A++){const l=e[A];if(a==null||a({stage:"rendering",percent:A/e.length*100,currentPage:A+1,totalPages:e.length,message:`Exporting page ${A+1} of ${e.length}`}),this.abortController.signal.aborted)throw new Error("Export aborted");const c=await n(l.id);s.push(c)}return a==null||a({stage:"complete",percent:100,totalPages:e.length,message:"All pages exported"}),s}finally{this.abortController=null}}abort(){var e;(e=this.abortController)==null||e.abort()}isExporting(){return this.abortController!==null}}let Kg=null;function oD(){return Kg||(Kg=new nw),Kg}function sD(t={}){const{useGlobal:e=!0,...r}=t,n=ne.useRef(e?oD():new nw(void 0,r));F7();const[a,s]=ne.useState(null),[A,l]=ne.useState(!1),c=ne.useCallback(async(m,x,w,C)=>{l(!0),s({stage:"preparing",percent:0});try{return await n.current.exportWithFallback(m,x,w,C,s)}finally{l(!1),setTimeout(()=>s(null),500)}},[]),f=ne.useCallback(()=>{n.current.abort(),l(!1),s(null)},[]),h=ne.useCallback((m,x,w)=>n.current.shouldUseTiling(m,x,w),[]),g=ne.useCallback((m,x,w)=>n.current.getSafePixelRatio(m,x,w),[]),v=ne.useCallback((m,x,w)=>n.current.estimateMemory(m,x,w),[]);return{exportWithProgress:c,progress:a,isExporting:A,cancel:f,shouldUseTiling:h,getSafePixelRatio:g,estimateMemory:v,pipeline:n.current}}const iD=3e3,AD="AaBbCcDdEeFfGgHhIiJj",lD=t=>t.split(",").map(e=>e.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean),aw=async(t,e=iD)=>{var s;if(!t||!("fonts"in t)||!((s=t.fonts)!=null&&s.ready))return{status:"unsupported",ready:!1,timedOut:!1};const r=A=>Promise.race([A,new Promise(l=>setTimeout(l,e))]),n=t.fonts.status;try{await r(t.fonts.ready)}catch{return{status:t.fonts.status||n,ready:!1,timedOut:!0}}const a=t.fonts.status;return{status:a,ready:a==="loaded",timedOut:!1}},ow=(t,e)=>{if(!e)return;const r=t.defaultView;if(!r)return;e.querySelectorAll('[data-text-export="true"]').forEach(a=>{const s=a,A=r.getComputedStyle(s),l=Number.parseFloat(s.dataset.textFontSize||A.fontSize||"0"),c=Number.parseFloat(s.dataset.textLineHeight||"");l>0&&!Number.isNaN(c)?s.style.lineHeight=`${c*l}px`:A.lineHeight&&A.lineHeight!=="normal"&&(s.style.lineHeight=A.lineHeight);const f=Number.parseFloat(s.dataset.textLetterSpacing||"0");if(l>0&&!Number.isNaN(f)?s.style.letterSpacing=`${f*l}px`:A.letterSpacing&&A.letterSpacing!=="normal"&&(s.style.letterSpacing=A.letterSpacing),(()=>{var v;const g=((v=r.navigator)==null?void 0:v.userAgent)||"";return/iPad|iPhone|iPod/.test(g)})()){const g=A.fontFamily||"sans-serif",v=A.fontWeight||"normal",m=A.fontStyle||"normal",x=Number.parseFloat(A.lineHeight||"");if(l>0&&Number.isFinite(x)&&x>0){const C=t.createElement("canvas").getContext("2d");if(C){C.font=`${m} ${v} ${l}px ${g}`;const S=C.measureText("Hg"),F=S.actualBoundingBoxAscent??l*.8,M=S.actualBoundingBoxDescent??l*.2,L=Math.max(0,F+M-x);L>.5&&(s.style.transform=`translateY(${-L/2}px)`,s.style.transformOrigin="top left")}}}})},cD=(t,e,r=AD)=>{if(!e||!t||!t.fonts||typeof t.fonts.check!="function")return{missing:[],checked:[]};const n=t.defaultView;if(!n)return{missing:[],checked:[]};const a=new Map;e.querySelectorAll('[data-text-export="true"]').forEach(c=>{const f=c,h=n.getComputedStyle(f),g=h.fontSize||"16px";lD(h.fontFamily||"").forEach(m=>{a.has(m)||a.set(m,g)})});const A=[],l=[];return a.forEach((c,f)=>{const h=`${c} ${f}`;l.push(h),t.fonts.check(h,r)||A.push(h)}),{missing:A,checked:l}},uD=(t,e)=>{const{missing:r}=cD(t,e);r.length!==0&&console.warn(`Export font fallback detected for: ${r.join(", ")}`)};/*!
940
940
  * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
941
941
  * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
942
942
  * Released under MIT License
@@ -968,7 +968,7 @@ end`};e.events.push(["putFont",function(s){(function(A){var l=A.font,c=A.out,f=A
968
968
  .exporting [data-no-export] {
969
969
  visibility: hidden !important;
970
970
  }
971
- `,t.head.appendChild(a)}},zj=(t,e)=>{e&&(e.classList.remove("exporting"),delete e.dataset.exportDpr,delete e.dataset.exporting);const r=t.getElementById(j5);r&&r.remove()},jj=async(t,e)=>{const r=e!=null&&e.isMobile?8e3:3e3,n=g=>Promise.race([g,new Promise(v=>setTimeout(v,r))]),a=()=>new Promise(requestAnimationFrame),s=(e==null?void 0:e.enforceFreshEffects)??!1,A=(e==null?void 0:e.expectedImageCount)??0;let l=Date.now();const c=new MutationObserver(()=>{l=Date.now()});c.observe(t,{attributes:!0,childList:!0,subtree:!0});const f=async()=>{let v=0,m={images:-1,effects:-1};const x=Date.now();for(;Date.now()-x<500;){const w={images:t.querySelectorAll("img").length,effects:t.querySelectorAll('[data-effect-canvas="true"]').length};if(w.images===m.images&&w.effects===m.effects?v+=1:(v=0,m=w),v>=2)return;await a()}},h=async()=>{if(A<=0)return;const g=Date.now();for(;Date.now()-g<r;){if(t.querySelectorAll("img").length>=A)return;await a()}};try{if(await f(),await h(),typeof document<"u"){const S=await aw(document,r);S.ready||console.warn("Font readiness check failed or timed out",S),uD(document,t)}const g=Array.from(t.querySelectorAll("img"));await n(Promise.all(g.map(S=>S.complete&&S.naturalWidth!==0?Promise.resolve():new Promise(F=>{const M=()=>F();S.addEventListener("load",M,{once:!0}),S.addEventListener("error",M,{once:!0})})))),await Promise.all(g.map(S=>typeof S.decode!="function"?Promise.resolve():S.decode().catch(()=>{}))),await a(),await a();const v=Date.now(),m=Math.max((e==null?void 0:e.effectsRenderedAfter)??0,l,v),x=()=>Array.from(t.querySelectorAll('[data-effect-canvas="true"]'));let w=x();if(w.length>0){const S=()=>(w=x(),w.every(L=>{const Z=L.getAttribute("data-effect-ready")==="true",J=parseInt(L.getAttribute("data-effect-rendered-at")||"0",10);return Z?s?J>=m:!0:!1})),F=Date.now();for(;!S()&&Date.now()-F<r;)await new Promise(L=>setTimeout(L,16));await a(),await a(),await a(),await a();const M=Date.now();for(;!S()&&Date.now()-M<500;)await new Promise(L=>setTimeout(L,16))}const C=t.getBoundingClientRect();if(C.width<=0||C.height<=0){await a(),await a();const S=t.getBoundingClientRect();if(S.width<=0||S.height<=0)throw new Error("Export layout not ready")}}finally{c.disconnect()}};class Kj{async export(e){const{node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,isMobile:c,expectedImageCount:f,enforceFreshEffects:h,effectsRenderedAfter:g,forceEngine:v}=e;fx(document,r,l);try{await jj(r,{enforceFreshEffects:h,expectedImageCount:f,isMobile:c,effectsRenderedAfter:g});const m=v??(c?"html2canvas":"html-to-image"),x=(w,C)=>{fx(w,C,l),ow(w,C)};try{return m==="html2canvas"?{canvas:await lx({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html2canvas"}:{canvas:await ux({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html-to-image"}}catch(w){return console.warn("Primary export engine failed, falling back",w),m==="html2canvas"?{canvas:await ux({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html-to-image"}:{canvas:await lx({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html2canvas"}}}finally{zj(document,r)}}}const K5=()=>Math.random().toString(36).substring(2,9),dx={undo:["mod+z"],redo:["mod+shift+z","mod+y"],copy:["mod+c"],paste:["mod+v"],copyStyle:["mod+alt+c"],pasteStyle:["mod+alt+v"],duplicate:["mod+d"],delete:["delete","backspace"],selectAll:["mod+a"],deselect:["escape"],group:["mod+g"],ungroup:["mod+shift+g"],bringForward:["mod+]"],sendBackward:["mod+["],bringToFront:["mod+shift+]"],sendToBack:["mod+shift+["],zoomIn:["mod+=","mod+plus"],zoomOut:["mod+-"],fitToScreen:["mod+0"],toolSelect:["v"],toolText:["t"],toolPen:["p"],toolHand:["h"],toolZoom:["z"]},qj=t=>{const e=t.toLowerCase();return e==="+"?"plus":e==="="?"equals":e==="esc"?"escape":e==="del"?"delete":e},hx=t=>{if(!t)return null;const e=t.toLowerCase().split("+").map(n=>n.trim()).filter(Boolean),r={key:"",ctrl:!1,meta:!1,shift:!1,alt:!1,mod:!1};return e.forEach(n=>{switch(n){case"ctrl":case"control":r.ctrl=!0;return;case"cmd":case"command":case"meta":r.meta=!0;return;case"shift":r.shift=!0;return;case"alt":case"option":r.alt=!0;return;case"mod":case"cmdorctrl":case"cmdorcontrol":r.mod=!0;return;default:r.key=qj(n)}}),r.key?r:null},Gj=t=>{const e=t.toLowerCase();return e===" "?"space":e==="+"?"plus":e==="="?"equals":e==="-"?"minus":e==="esc"?"escape":e==="del"?"delete":e},Vj=(t,e)=>{const r=Gj(e.key),n=t.key==="plus"||t.key==="equals",a=e.ctrlKey||e.metaKey;return t.mod&&!a||!t.mod&&(t.ctrl!==e.ctrlKey||t.meta!==e.metaKey)||t.alt!==e.altKey||!n&&t.shift!==e.shiftKey||n&&t.shift&&!e.shiftKey?!1:t.key===r||t.key==="plus"&&r==="equals"||t.key==="equals"&&r==="plus"},$j=({apiKey:t,className:e,showCredit:r,customPanels:n,customContextMenuItems:a,customToolbarItems:s,keyboardShortcuts:A,customFonts:l,customTemplates:c,customExportFormats:f,customElementTypes:h,theme:g,ui:v,sdkVersion:m,getLicenseStatus:x,subscribeLicense:w})=>{const C=ne.useSyncExternalStore(Re=>Oe.subscribe(Re),()=>Oe.getSnapshot()),S=x||(()=>Oe.getLicenseStatus()),F=w||(Re=>Oe.subscribeLicense(Re)),[M,L]=ne.useState(()=>S());ne.useEffect(()=>(L(S()),F(()=>{L(S())})),[S,F]);const Z=Xc(),[J]=ne.useState("canvas"),[K,ee]=ne.useState(null),V=K??J;ne.useEffect(()=>{typeof window>"u"||(window.__FRACZLED_EFFECTS_PIPELINE__=V)},[V]),ne.useEffect(()=>{typeof window>"u"||window.__FRACZLED_EXPORT_PIPELINE__||(window.__FRACZLED_EXPORT_PIPELINE__="dom")},[]);const{isExporting:fe}=sD(),j=Oe.canUndo(),te=Oe.canRedo(),z=M.entitlements.ai,D=M.entitlements.export.web,se=M.entitlements.export.print,q=M.showWatermark||r!==!1,X=M.showWatermark,Y=M.upgradeUrl,W=M.entitlements.features||{},P=M.entitlements.limits||{},k=M.isValid&&W.topbarActions===!0&&(v==null?void 0:v.topbarMode)==="custom"?"custom":"default",Q=v==null?void 0:v.exportMenu,N=W.saveLoad!==!1,I=M.isValid&&W.templateSave!==!1,_=M.isValid&&W.newDesignModal===!0,R=M.isValid&&W.templateSizes===!0,ie=M.state??(M.isValid?"valid":"invalid"),ae=ie==="pending"?"VALIDATING...":ie==="invalid"?"INVALID LICENSE":ie==="offline"?"OFFLINE":M.plan?M.plan.toUpperCase():"FREE",[ge,ce]=ne.useState(null),Ae={[cr.TEMPLATES]:"Templates",[cr.DESIGN]:"Design",[cr.ELEMENTS]:"Elements",[cr.TEXT]:"Text",[cr.IMAGES]:"Images",[cr.ICONS]:"Icons",[cr.BRAND]:"Brand",[cr.UPLOADS]:"Uploads",[cr.QR_CODE]:"QR Codes",[cr.LAYERS]:"Layers",[cr.COLOR]:"Color",[cr.FONT]:"Fonts",[cr.EFFECTS]:"Effects",[cr.POSITION]:"Position",[cr.PROJECTS]:"Projects",[cr.DRAW]:"Draw"},ue={[cr.TEMPLATES]:"templates",[cr.DESIGN]:"design",[cr.ELEMENTS]:"elements",[cr.DRAW]:"draw",[cr.TEXT]:"text",[cr.IMAGES]:"images",[cr.ICONS]:"icons",[cr.BRAND]:"brand",[cr.UPLOADS]:"uploads",[cr.QR_CODE]:"qrcode",[cr.LAYERS]:"layers"},Be=ne.useMemo(()=>{const Re=new Map;return(n||[]).forEach(ht=>{ht!=null&&ht.id&&Re.set(ht.id,ht)}),Re},[n]);ne.useEffect(()=>{n!=null&&n.length&&n.forEach(Re=>{Re!=null&&Re.id&&Object.values(cr).includes(Re.id)&&console.warn(`[Editor] Custom panel id "${Re.id}" conflicts with a built-in tool id.`)})},[n]);const $=ne.useCallback(Re=>{if(!Re)return"";const ht=Be.get(Re);return ht!=null&&ht.label?ht.label:Ae[Re]||String(Re)},[Be,Ae]),ve=Re=>{if(!M.isValid)return!1;if(!Re)return!0;const ht=Be.get(Re);if(ht!=null&&ht.feature)return W[ht.feature]!==!1;const tr=ue[Re];return tr?W[tr]!==!1:!0},be=(Re,ht)=>{switch(Re){case"ai":ce({title:"Unlock Magic Write",description:"Upgrade to generate headlines, rewrites, and AI-assisted copy inside the editor."});break;case"export-web":ce({title:"Unlock Web Exports",description:"Upgrade to export assets for web usage without restrictions."});break;case"export-print":default:ce({title:"Unlock Print Exports",description:"Upgrade to export print-ready PDFs and high-resolution PNGs."});break;case"feature":ce({title:`Unlock ${ht||"this feature"}`,description:"Upgrade to access this feature for your workspace."});break}},[Ne,Ue]=ne.useState(null),[We,Ze]=ne.useState(null),[st,rt]=ne.useState("select"),[Ie,De]=ne.useState(!1),[pe,ke]=ne.useState(!1),[Qe,Ge]=ne.useState(()=>typeof window<"u"?localStorage.getItem("fraczled_skip_new_doc_modal")!=="true":!0),[pt,et]=ne.useState(!1),[_t,Tt]=ne.useState(""),[Mt,Nt]=ne.useState(!1),[Rt,Ht]=ne.useState(!1),[Yt,Wt]=ne.useState(null),Zt=ne.useRef(null),Ir=ne.useMemo(()=>new Kj,[]),[ur,gt]=ne.useState(!1),[Vt,mn]=ne.useState(null),Sr=ne.useMemo(()=>C.pages.some(Re=>{var ht;return(((ht=Re.elements)==null?void 0:ht.length)??0)>0}),[C.pages]),Mr=ne.useCallback(Re=>{Re.type==="modal"?(Oe.reset({transparent:!1}),Ge(!0)):Oe.loadTemplateAsNewDesign(Re.template,{preserveLibraries:!0})},[]),pr=ne.useCallback(Re=>{mn(Re),gt(!0)},[]),dr=()=>{Sr?pr({type:"modal"}):Ge(!0)},Sn=Re=>{Sr?pr({type:"template",template:Re}):Oe.loadTemplateAsNewDesign(Re,{preserveLibraries:!0})},ta=()=>{gt(!1),Tt(C.title||"My Design"),et(!0)},Pr=()=>{gt(!1),Vt?(Mr(Vt),mn(null)):(Oe.reset({transparent:!1}),Ge(!0))},cn=()=>{gt(!1),mn(null)},Jt=()=>{localStorage.setItem("fraczled_skip_new_doc_modal","true")},on=ne.useMemo(()=>{const Re=C.brandKits.find(ht=>ht.id===C.activeBrandKitId);return Re?Re.colors:[]},[C.brandKits,C.activeBrandKitId]),Bn=ne.useMemo(()=>C.brandKits.find(Re=>Re.id===C.activeBrandKitId),[C.brandKits,C.activeBrandKitId]),sn=C.pages.find(Re=>Re.id===C.activePageId),$r=ne.useMemo(()=>sn?sn.elements:[],[sn]),en=ne.useMemo(()=>{if(!C.selection.length)return;const Re=C.selection[0];return $r.find(ht=>ht.id===Re)},[C.selection,$r]),Zr=ne.useMemo(()=>C.pages.findIndex(Re=>Re.id===C.activePageId)+1,[C.pages,C.activePageId]),tn=ne.useMemo(()=>sn?{...C.settings,width:sn.width??C.settings.width,height:sn.height??C.settings.height,unit:sn.unit??C.settings.unit}:C.settings,[C.settings,sn]);ne.useEffect(()=>{$6(l)},[l]),ne.useEffect(()=>{Sg(c)},[c]),ne.useEffect(()=>{C.pages.forEach(Re=>{Re.elements.forEach(ht=>{ht.fontFamily&&ku(ht.fontFamily)})})},[]),ne.useEffect(()=>{Bn!=null&&Bn.customFonts&&Bn.customFonts.forEach(Re=>{rp(Re.name,Re.url)})},[Bn]);const rn=Re=>{if(Re&&!ve(Re)){be("feature",$(Re)||"this feature");return}if(Re===cr.QR_CODE&&Ne!==cr.QR_CODE&&!C.selection.some(tr=>$r.some(_r=>_r.id===tr&&_r.type==="qrcode"))){const tr=(sn==null?void 0:sn.width)??C.settings.width,_r=(sn==null?void 0:sn.height)??C.settings.height,zt={id:K5(),type:"qrcode",name:"QR Code",visible:!0,content:"https://example.com",x:tr/2-75,y:_r/2-75,width:150,height:150,rotation:0,opacity:1,zIndex:$r.length+1,locked:!1,color:"#000000",backgroundColor:"#ffffff",effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}};Oe.addElement(zt),rt("select")}Re===cr.DRAW?rt("pen"):(st==="pen"||st==="direct-select")&&rt("select"),Ue(Re)},ma=Re=>{Ze(Re),Ue(cr.COLOR)},Yn=ne.useMemo(()=>({store:Oe,selection:C.selection}),[C.selection]),Ln=ne.useMemo(()=>{const Re=ht=>{C.selection.forEach(tr=>Oe.reorderElement(tr,ht))};return{undo:()=>Oe.undo(),redo:()=>Oe.redo(),copy:()=>Oe.copy(),paste:()=>Oe.paste(),copyStyle:()=>Oe.copyStyle(),pasteStyle:()=>Oe.pasteStyle(),duplicate:()=>Oe.duplicateSelection(),delete:()=>Oe.deleteSelection(),selectAll:()=>Oe.selectAll(),deselect:()=>{Oe.deselectAll(),Ue(null),De(!1),rt("select")},group:()=>Oe.groupSelection(),ungroup:()=>Oe.ungroupSelection(),bringForward:()=>Re("forward"),sendBackward:()=>Re("backward"),bringToFront:()=>Re("front"),sendToBack:()=>Re("back"),zoomIn:()=>Oe.setZoom(Math.min(200,C.zoom+10)),zoomOut:()=>Oe.setZoom(Math.max(10,C.zoom-10)),fitToScreen:()=>window.dispatchEvent(new CustomEvent("canvas-fit-to-screen")),toolSelect:()=>rt("select"),toolText:()=>rt("text"),toolPen:()=>rt("pen"),toolHand:()=>rt("hand"),toolZoom:()=>rt("zoom")}},[C.selection,C.zoom]),or=ne.useMemo(()=>{const Re=[],ht=(A==null?void 0:A.overrides)||{};return((A==null?void 0:A.disableDefaults)??!1)||Object.keys(dx).forEach(_r=>{const zt=ht[_r];if(zt===!1)return;(zt?[zt]:dx[_r]).forEach(sr=>{const xr=hx(sr);xr&&Re.push({keys:sr,parsed:xr,handler:Ln[_r]})})}),((A==null?void 0:A.custom)||[]).forEach(_r=>{const zt=hx(_r.keys);zt&&Re.push({keys:_r.keys,parsed:zt,handler:()=>_r.action(Yn)})}),Re},[A,Ln,Yn]);ne.useEffect(()=>{const Re=ht=>{const tr=ht.target;if(tr&&(tr.tagName==="INPUT"||tr.tagName==="TEXTAREA"||tr.isContentEditable))return;for(const xr of or)if(Vj(xr.parsed,ht)){ht.preventDefault(),xr.handler();return}const zt=ht.metaKey||ht.ctrlKey,Lr=ht.shiftKey,sr=ht.key.toLowerCase();if(!zt&&!ht.altKey)switch(sr){case"r":rt("rotate");return;case"s":rt("scale");return;case"a":rt("direct-select");return}if(zt&&sr==="n"&&(ht.preventDefault(),dr()),zt&&sr==="x"&&(ht.preventDefault(),Oe.cut()),C.selection.length>0){const xr=Lr?10:1;ht.key==="ArrowUp"&&(ht.preventDefault(),Oe.nudgeSelection(0,-xr)),ht.key==="ArrowDown"&&(ht.preventDefault(),Oe.nudgeSelection(0,xr)),ht.key==="ArrowLeft"&&(ht.preventDefault(),Oe.nudgeSelection(-xr,0)),ht.key==="ArrowRight"&&(ht.preventDefault(),Oe.nudgeSelection(xr,0))}if(zt&&sr==="l"&&(ht.preventDefault(),C.selection.forEach(xr=>{const Tr=$r.find(Br=>Br.id===xr);Tr&&Oe.updateElement(xr,{locked:!Tr.locked})})),zt&&Lr)switch(sr){case"l":ht.preventDefault(),Oe.alignSelection("left");break;case"c":ht.preventDefault(),Oe.alignSelection("center");break;case"r":ht.preventDefault(),Oe.alignSelection("right");break;case"t":ht.preventDefault(),Oe.alignSelection("top");break;case"m":ht.preventDefault(),Oe.alignSelection("middle");break;case"b":ht.preventDefault(),Oe.alignSelection("bottom");break}};return window.addEventListener("keydown",Re),()=>window.removeEventListener("keydown",Re)},[or,C.selection,C.pages,$r]),ne.useEffect(()=>{const Re=Oe.on("toast",ht=>{ht!=null&&ht.message&&(Wt({message:ht.message,tone:ht.tone}),Zt.current&&window.clearTimeout(Zt.current),Zt.current=window.setTimeout(()=>{Wt(null),Zt.current=null},2400))});return()=>{Re==null||Re(),Zt.current&&(window.clearTimeout(Zt.current),Zt.current=null)}},[]);const _e=(Re,ht,tr,_r,zt)=>{const Lr=ht==="heading"?32:ht==="subheading"?24:14,sr=ht==="heading"?"bold":ht==="subheading"?"semibold":"normal",xr=(sn==null?void 0:sn.width)??C.settings.width;(sn==null?void 0:sn.height)??C.settings.height;const Br=xr-40*2;let Vr=200,kn=Lr*1.5,Ca=Vr;try{const qn=document.createElement("canvas").getContext("2d");if(qn){qn.font=`${sr==="bold"?"bold":sr==="semibold"?"600":"normal"} ${Lr}px ${(zt==null?void 0:zt.fontFamily)||"Inter"}, sans-serif`;const On=qn.measureText(Re);Ca=Math.ceil(On.width)+10,Vr=Ca}}catch(wn){console.warn("Could not measure text width automatically",wn)}const bn=Ca>Br;if(bn){Vr=Br;const wn=Math.ceil(Ca/Br);kn=Lr*1.5*wn}const En={id:K5(),type:"text",name:Re.substring(0,20),visible:!0,content:Re,x:tr!==void 0?tr:-1,y:_r!==void 0?_r:-1,width:Vr,height:kn,fontSize:Lr,fontWeight:sr,fontFamily:(zt==null?void 0:zt.fontFamily)||"Inter",color:(zt==null?void 0:zt.color)||"#1e293b",rotation:0,opacity:1,zIndex:$r.length+1,locked:!1,autoWidth:!bn,textStrokeWidth:0,textStrokeColor:"#000000",textStrokePosition:"behind",textStrokeStyle:"round",effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}};Oe.addElement(En)},$e=Re=>{const ht=Yu(Re),tr=Re==="line"||ht?200:100,_r=Re==="line"?4:ht?200:100,zt=(ht==null?void 0:ht.name)||Re.charAt(0).toUpperCase()+Re.slice(1),Lr={id:K5(),type:"shape",name:zt,visible:!0,content:(ht==null?void 0:ht.id)||Re,x:-1,y:-1,width:tr,height:_r,backgroundColor:Re==="line"?"transparent":"#cbd5e1",strokeColor:Re==="line"?"#000000":void 0,strokeWidth:Re==="line"?4:0,rotation:0,opacity:1,zIndex:$r.length+1,locked:!1,effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}};Oe.addElement(Lr)},Se=async Re=>{const{pageId:ht,width:tr,height:_r,bleed:zt,backgroundColor:Lr,kind:sr,dpi:xr,pixelRatio:Tr,enforceFreshEffects:Br,effectsRenderedAfter:Vr}=Re,kn=document.getElementById(`page-canvas-${ht}`);if(!kn)throw new Error(`Page ${ht} not found`);const bn=(typeof window<"u"?window.__FRACZLED_EXPORT_PIPELINE__??"dom":"dom")==="canvas"?"canvas":"dom",En=C.pages.find(va=>va.id===ht),wn=En?En.elements.filter(va=>va.type==="image"&&va.visible!==!1).length:0,qn=En?En.elements.some(va=>(va.blendMode??"normal")!=="normal"&&va.visible!==!1):!1,On=En?En.elements.some(va=>{var ds,uo;return va.type==="text"&&((uo=(ds=va.effect)==null?void 0:ds.shape)==null?void 0:uo.type)==="curve"&&va.visible!==!1}):!1,Qo=En?En.elements.some(va=>va.type==="text"&&va.visible!==!1):!1,lo=tr+zt*2,co=_r+zt*2;let Da=Jb({kind:sr,width:lo,height:co,dpi:xr,pixelRatio:Tr,maxPixelRatio:Z?Zl.mobilePixelRatioCap:void 0,maxCanvasSize:8192,clampForIOS:!0});const fs=f1(),bo=fs?4096:8192,Io=fs?16777216:67108864,gr=Math.max(lo,co),wo=bo/gr,Bs=Math.sqrt(Io/(lo*co)),Or=Math.min(Da,wo,Bs);if(Or<Da&&(console.warn(`Clamped export pixel ratio from ${Da.toFixed(2)} to ${Or.toFixed(2)} for memory safety.`),Da=Math.max(.1,Or)),bn==="canvas"){const{capturePageCanvas:va}=await Promise.resolve().then(()=>iV),ds=C.pages.find(Pa=>Pa.id===ht);if(!ds)throw new Error(`Page ${ht} not found for canvas export`);return{kind:"canvas",value:await va({page:ds,settings:C.settings,width:lo,height:co,bleed:zt,backgroundColor:Lr,pixelRatio:Da})}}const{canvas:Yi}=await Ir.export({node:kn,exportWidth:lo,exportHeight:co,bleed:zt,backgroundColor:Lr,pixelRatio:Da,isMobile:Z,expectedImageCount:wn,enforceFreshEffects:Br,effectsRenderedAfter:Vr,forceEngine:qn||On||fs&&Qo?"html-to-image":void 0});return{kind:"canvas",value:Yi}},kt=Re=>{const ht=P.maxExportsPerDay;if(typeof window<"u"&&ht){const _r=`fraczled_exports_${new Date().toISOString().slice(0,10)}`;if(Number.parseInt(localStorage.getItem(_r)||"0",10)>=ht)return be("feature","Daily exports"),!1}return Re==="print"&&!se?(be("export-print"),!1):Re==="web"&&!D||Re==="other"&&!D&&!se?(be("export-web"),!1):!0},yt=()=>{if(typeof window<"u"&&P.maxExportsPerDay){const ht=`fraczled_exports_${new Date().toISOString().slice(0,10)}`,tr=Number.parseInt(localStorage.getItem(ht)||"0",10);localStorage.setItem(ht,String(tr+1))}},Le=async()=>{const ht=V!=="canvas";ht&&ee("canvas"),setEditingId(null),Oe.deselectAll(),await new Promise(_r=>setTimeout(_r,Z?200:100)),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),Z&&(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame));const tr=Date.now();return{forceCanvasPipeline:ht,effectsReadyAfter:tr}},$t=async Re=>{Re&&(ee(null),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame))},Ct=async Re=>{try{return Re.toDataURL("image/png",1)}catch(ht){if(!Re.toBlob)throw ht;const tr=await new Promise(_r=>{Re.toBlob(zt=>_r(zt),"image/png",1)});if(!tr)throw new Error("Failed to encode export");return await new Promise((_r,zt)=>{const Lr=new FileReader;Lr.onload=()=>_r(Lr.result),Lr.onerror=()=>zt(Lr.error),Lr.readAsDataURL(tr)})}},fr=async Re=>{if(Re==="json"){const xr=Oe.exportJSON(),Tr=new Blob([xr],{type:"application/json"}),Br=URL.createObjectURL(Tr),Vr=document.createElement("a");Vr.href=Br,Vr.download=`${C.title||"design"}.json`,document.body.appendChild(Vr),Vr.click(),document.body.removeChild(Vr),URL.revokeObjectURL(Br);return}const tr=Re.startsWith("print")?"print":"web";if(!kt(tr))return;Ht(!0);const{forceCanvasPipeline:_r,effectsReadyAfter:zt}=await Le(),Lr=Re.startsWith("print"),sr=Re.includes("pdf");try{const xr=C.pages,Tr=Lr&&tn.showBleed?tn.bleed:0,Br=async Vr=>{if(Vr.width===0||Vr.height===0)throw new Error("Export canvas is empty");if(typeof Vr.toBlob=="function"){const kn=await new Promise(Ca=>{Vr.toBlob(bn=>Ca(bn),"image/png",1)});if(kn)return{href:URL.createObjectURL(kn),revoke:!0}}try{return{href:Vr.toDataURL("image/png",1),revoke:!1}}catch{const bn=document.createElement("canvas");bn.width=Math.max(1,Math.floor(Vr.width*.75)),bn.height=Math.max(1,Math.floor(Vr.height*.75));const En=bn.getContext("2d");if(!En)throw new Error("Failed to encode export");if(En.drawImage(Vr,0,0,bn.width,bn.height),typeof bn.toBlob=="function"){const wn=await new Promise(qn=>{bn.toBlob(On=>qn(On),"image/png",1)});if(wn)return{href:URL.createObjectURL(wn),revoke:!0}}return{href:bn.toDataURL("image/png",1),revoke:!1}}};if(sr){const Vr=xr[0],kn=Vr.width??C.settings.width,Ca=Vr.height??C.settings.height,bn=kn>Ca?"landscape":"portrait",En=new Rr({orientation:bn,unit:"px",format:[kn,Ca],hotfixes:["px_scaling"]});for(let wn=0;wn<xr.length;wn++){const qn=xr[wn],On=qn.width??C.settings.width,Qo=qn.height??C.settings.height;C.activePageId!==qn.id&&(Oe.setActivePage(qn.id),await new Promise(co=>setTimeout(co,50)));const lo=await Se({pageId:qn.id,width:On,height:Qo,bleed:Tr,backgroundColor:tn.backgroundColor||"#ffffff",kind:Lr?"print":"web",dpi:Lr?tn.dpi:void 0,enforceFreshEffects:_r,effectsRenderedAfter:zt});if(wn>0&&En.addPage([On,Qo],On>Qo?"landscape":"portrait"),lo.kind==="canvas")try{En.addImage(lo.value,"PNG",0,0,On,Qo)}catch{const Da=lo.value.toDataURL("image/png",1);En.addImage(Da,"PNG",0,0,On,Qo)}else En.addImage(lo.value,"PNG",0,0,On,Qo)}En.save(`${C.title.replace(/\s+/g,"-")}.pdf`)}else for(let Vr=0;Vr<xr.length;Vr++){const kn=xr[Vr];C.activePageId!==kn.id&&(Oe.setActivePage(kn.id),await new Promise(On=>setTimeout(On,50)));const Ca=kn.width??C.settings.width,bn=kn.height??C.settings.height,En=await Se({pageId:kn.id,width:Ca,height:bn,bleed:Tr,backgroundColor:tn.backgroundColor||"#ffffff",kind:Lr?"print":"web",dpi:Lr?tn.dpi:void 0,enforceFreshEffects:_r,effectsRenderedAfter:zt}),wn=document.createElement("a"),qn=xr.length>1?`-Page${Vr+1}`:"";if(wn.download=`${C.title.replace(/\s+/g,"-").toLowerCase()}${qn}.png`,En.kind==="canvas"){const On=await Br(En.value);wn.href=On.href,wn.click(),On.revoke&&URL.revokeObjectURL(On.href)}else wn.href=En.value,wn.click();xr.length>1&&await new Promise(On=>setTimeout(On,500))}yt()}catch(xr){console.error("Export failed",xr);const Tr=xr instanceof Error&&xr.message?`Failed to export: ${xr.message}`:"Failed to export. Please try again.";alert(Tr)}finally{await $t(_r),Ht(!1)}},jr=async Re=>{if(!(Re!=null&&Re.id))return;const ht=Re.section??"other";if(!kt(ht))return;Ht(!0);const{forceCanvasPipeline:tr,effectsReadyAfter:_r}=await Le();try{const zt=async(Lr,sr)=>{const xr=C.pages.find(wn=>wn.id===Lr);if(!xr)throw new Error(`Page ${Lr} not found`);const Tr=(sr==null?void 0:sr.kind)??(ht==="print"?"print":"web"),Br=(sr==null?void 0:sr.width)??xr.width??C.settings.width,Vr=(sr==null?void 0:sr.height)??xr.height??C.settings.height,kn=typeof(sr==null?void 0:sr.bleed)=="number"?sr.bleed:Tr==="print"&&tn.showBleed?tn.bleed:0,Ca=(sr==null?void 0:sr.backgroundColor)??tn.backgroundColor??"#ffffff",bn=(sr==null?void 0:sr.dpi)??(Tr==="print"?tn.dpi:void 0),En=await Se({pageId:Lr,width:Br,height:Vr,bleed:kn,backgroundColor:Ca,kind:Tr,dpi:bn,pixelRatio:sr==null?void 0:sr.pixelRatio,enforceFreshEffects:tr,effectsRenderedAfter:_r});return En.kind==="dataUrl"?En.value:Ct(En.value)};await Re.handler({store:Oe,pages:C.pages,settings:tn,captureCanvas:zt}),yt()}catch(zt){console.error("Custom export failed",zt);const Lr=zt instanceof Error&&zt.message?`Failed to export: ${zt.message}`:"Failed to export. Please try again.";alert(Lr)}finally{await $t(tr),Ht(!1)}},er=()=>{if(!M.isValid){be("design");return}Tt(C.title||"My Design"),et(!0)},Xr=async()=>{if(!_t.trim())return;Nt(!0);let Re="";try{const ht=C.activePageId,tr=document.getElementById(`page-canvas-${ht}`),_r=C.pages.find(zt=>zt.id===ht);if(tr&&_r){const zt=Fd({targetSize:200,width:_r.width??C.settings.width,height:_r.height??C.settings.height});Re=await ed(tr,{quality:.9,pixelRatio:zt,style:{margin:"0",overflow:"hidden",transform:"scale(1)",transformOrigin:"top left"},filter:Lr=>{var sr;return!((sr=Lr.hasAttribute)!=null&&sr.call(Lr,"data-no-export"))}})}}catch(ht){console.error("Failed to capture thumbnail:",ht)}if(Oe.saveDesign(_t.trim(),Re),Tt(""),et(!1),Nt(!1),Vt){const ht=Vt;mn(null),Mr(ht)}},pa=()=>{et(!1),Tt(""),mn(null)},Oa=ne.useMemo(()=>({onUndo:()=>Oe.undo(),onRedo:()=>Oe.redo(),canUndo:j,canRedo:te,onNewDesign:dr,onSaveDesign:er,onExport:fr,onCustomExport:jr,exportAccess:{web:D,print:se},canSaveLoadJson:N,upgradeUrl:Y,isExporting:fe||Rt}),[se,D,te,j,N,jr,fr,dr,er,Rt,fe,Y]),Za=ne.useMemo(()=>({store:Oe,selection:C.selection,element:en,topbar:Oa}),[en,C.selection,Oa]);return d.createElement("div",{className:`flex flex-col h-screen h-[100dvh] w-screen overflow-hidden bg-slate-50/50 text-slate-900 font-sans ${e||""}`},pt&&d.createElement("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[200]",onClick:pa},d.createElement("div",{className:"bg-white rounded-xl shadow-2xl p-6 w-[90%] max-w-md",onClick:Re=>Re.stopPropagation()},d.createElement("h2",{className:"text-lg font-bold text-slate-800 mb-4"},"Save Design"),d.createElement("input",{type:"text",value:_t,onChange:Re=>Tt(Re.target.value),placeholder:"Enter design name...",className:"w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 mb-4",autoFocus:!0,onKeyDown:Re=>{Re.key==="Enter"&&Xr()}}),d.createElement("div",{className:"flex gap-2"},d.createElement("button",{onClick:Xr,disabled:!_t.trim()||Mt,className:"flex-1 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-sm disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2"},Mt?"Saving...":"Save"),d.createElement("button",{onClick:pa,className:"px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-lg font-medium text-sm transition-colors"},"Cancel")))),d.createElement(JQ,{title:C.title,onTitleChange:Re=>Oe.setTitle(Re),onExport:fr,onUndo:()=>Oe.undo(),onRedo:()=>Oe.redo(),canUndo:j,canRedo:te,onToggleSettings:()=>De(!Ie),zoom:C.zoom,setZoom:Re=>Oe.setZoom(Re),showToolbar:C.selection.length>0,exportAccess:{web:D,print:se},canSaveLoadJson:N,upgradeUrl:Y,onRequestUpgrade:be,onSaveDesign:er,onNewDesign:dr,isExporting:fe||Rt,customToolbarItems:s,toolbarContext:Za,customExportFormats:f,onCustomExport:jr,topbarMode:k,exportMenu:Q},d.createElement(YO,{selection:C.selection,elements:$r,updateElement:(Re,ht)=>Oe.updateElement(Re,ht),updateElements:(Re,ht)=>Oe.updateElements(Re,ht),deleteElement:Re=>Oe.deleteElement(Re),reorderElement:(Re,ht)=>Oe.reorderElement(Re,ht),settings:tn,savedColors:C.savedColors,savedGradients:C.savedGradients,onSaveColor:Re=>Oe.addSavedColor(Re),onSaveGradient:Re=>Oe.addSavedGradient(Re),onDuplicate:Re=>Oe.duplicateElement(Re),brandColors:on,activeBrandKit:Bn,setActiveTool:rn,onOpenColorPanel:ma,activeTool:Ne,activeColorMode:We,customToolbarItems:s})),d.createElement("div",{className:"flex flex-1 overflow-hidden relative flex-col md:flex-row"},d.createElement(eI,{activeTool:Ne,setActiveTool:rn,featureAccess:W,onRequestUpgrade:Re=>be("feature",Re),isLicenseValid:M.isValid,customPanels:n,hideDefaultPanels:v==null?void 0:v.hideDefaultPanels,hiddenPanels:v==null?void 0:v.hiddenPanels}),Ne&&(Z?d.createElement(bg,{isOpen:!0,onClose:()=>Ue(null),title:$(Ne)||"Tools",height:"full"},d.createElement(b7,{activeTool:Ne,onClose:()=>Ue(null),onSetActivePanel:rn,onAddText:_e,onAddShape:$e,onStartTemplateDesign:Sn,activeColorMode:We,interactionMode:st,onSetInteractionMode:rt,canUseAI:z,isLicenseValid:M.isValid,onRequestUpgrade:be,customPanels:n,customFonts:l,customTemplates:c,canSaveTemplates:I,title:$(Ne)})):d.createElement("div",{className:"absolute left-0 right-0 bottom-16 md:bottom-0 md:left-[72px] md:right-auto top-0 z-20 shadow-2xl animate-in slide-in-from-left-4 duration-200"},d.createElement(b7,{activeTool:Ne,onClose:()=>Ue(null),onSetActivePanel:rn,onAddText:_e,onAddShape:$e,onStartTemplateDesign:Sn,activeColorMode:We,interactionMode:st,onSetInteractionMode:rt,canUseAI:z,isLicenseValid:M.isValid,onRequestUpgrade:be,customPanels:n,customFonts:l,customTemplates:c,canSaveTemplates:I,title:$(Ne)}))),d.createElement("div",{className:"flex-1 flex flex-col h-full overflow-hidden relative z-0"},d.createElement(qO,{pages:C.pages,activePageId:C.activePageId,interactionMode:st,zoom:C.zoom,setZoom:Re=>Oe.setZoom(Re),settings:C.settings,selection:C.selection,setSelection:(Re,ht)=>Oe.setSelection(Re,ht),activeGroupId:C.activeGroupId,onSetActiveGroupId:Re=>Oe.setActiveGroupId(Re),updateElement:(Re,ht,tr)=>Oe.updateElement(Re,ht,tr),customContextMenuItems:a,onDuplicate:Re=>Oe.duplicateElement(Re),onDelete:Re=>Oe.deleteElement(Re),onBringToFront:Re=>Oe.reorderElement(Re,"front"),onSendToBack:Re=>Oe.reorderElement(Re,"back"),onResetZoom:()=>Oe.setZoom(65),onSetActivePage:Re=>Oe.setActivePage(Re),onAddPage:Re=>{const ht=P.maxPages;if(ht&&C.pages.length>=ht){be("feature","Additional pages");return}Oe.addPage(Re)},onDuplicatePage:Re=>Oe.duplicatePage(Re),onDeletePage:Re=>Oe.deletePage(Re),onRenamePage:(Re,ht)=>Oe.renamePage(Re,ht),onAddText:_e,showCredit:q,showWatermark:X}),pe&&d.createElement(WO,{pages:C.pages,activePageId:C.activePageId,setActivePage:Re=>Oe.setActivePage(Re),addPage:()=>{const Re=P.maxPages;if(Re&&C.pages.length>=Re){be("feature","Additional pages");return}Oe.addPage()},duplicatePage:Re=>Oe.duplicatePage(Re),deletePage:Re=>Oe.deletePage(Re),settings:C.settings,onClose:()=>ke(!1)}),d.createElement("div",{className:"hidden md:block"},d.createElement(GO,{zoom:C.zoom,setZoom:Re=>Oe.setZoom(Re),pageCount:C.pages.length,activePage:Zr,planLabel:ae,sdkVersion:m,showThumbnails:pe,onToggleThumbnails:()=>ke(!pe),pageSize:tn}))),d.createElement(NL,{settings:C.settings,updateSettings:Re=>Oe.updateSettings(Re),isOpen:Ie,onClose:()=>De(!1),canLoadJson:N,onLoadJson:Re=>Oe.loadJSON(Re)}),d.createElement(ZO,{open:!!ge,title:(ge==null?void 0:ge.title)||"",description:(ge==null?void 0:ge.description)||"",upgradeUrl:Y,onClose:()=>ce(null)}),d.createElement(tD,{open:Qe,onClose:()=>Ge(!1),onSkipFuture:Jt,customTemplates:c,newDesignModal:v==null?void 0:v.newDesignModal,canCustomizeNewDesignModal:_,canCustomizeTemplateSizes:R}),Yt&&d.createElement("div",{"data-no-export":"true",className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-[300] px-4 py-2 rounded-lg text-xs font-semibold shadow-lg ${Yt.tone==="error"?"bg-red-600 text-white":Yt.tone==="info"?"bg-slate-800 text-white":"bg-amber-500 text-white"}`},Yt.message),ur&&d.createElement("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[200]",onClick:cn},d.createElement("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-sm mx-4 overflow-hidden",onClick:Re=>Re.stopPropagation()},d.createElement("div",{className:"p-6"},d.createElement("h3",{className:"text-lg font-semibold text-slate-800 mb-2"},"Unsaved Changes"),d.createElement("p",{className:"text-sm text-slate-600 mb-6"},"You have unsaved changes. Would you like to save your current design before creating a new one?"),d.createElement("div",{className:"flex flex-col gap-2"},d.createElement("button",{onClick:ta,className:"w-full py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-sm transition-colors"},"Save First"),d.createElement("button",{onClick:Pr,className:"w-full py-2.5 bg-red-50 hover:bg-red-100 text-red-600 rounded-lg font-medium text-sm transition-colors"},"Discard Changes"),d.createElement("button",{onClick:cn,className:"w-full py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-lg font-medium text-sm transition-colors"},"Cancel")))))))},Xj=({store:t,className:e,apiKey:r,showCredit:n,customPanels:a,customContextMenuItems:s,customToolbarItems:A,keyboardShortcuts:l,customFonts:c,customTemplates:f,customExportFormats:h,customElementTypes:g,theme:v,sdkVersion:m,ui:x})=>{const w=ne.useSyncExternalStore(L=>t.subscribeLicense(L),()=>t.getLicenseStatus()),C=w.showWatermark||n!==!1,S=w.state??(w.isValid?"valid":"invalid"),F=S==="pending",M=S==="invalid";return d.useEffect(()=>{if(t===Oe)return;Oe.services=t.services;const L=Object.getPrototypeOf(t),Z=Object.getOwnPropertyNames(L),J=[];Z.forEach(V=>{if(V==="constructor"||V==="subscribe"||V==="getSnapshot"||V==="notify"||V.startsWith("_"))return;if(typeof t[V]=="function"){const j=Oe[V];Oe[V]=(...te)=>t[V](...te),J.push(()=>{j?Oe[V]=j:delete Oe[V]})}});const K=()=>{Oe.state=t.state,Oe.services=t.services,Oe.notify&&Oe.notify()};Oe.state=t.state;const ee=t.subscribe(K);return()=>{ee(),J.forEach(V=>V())}},[t]),F?d.createElement("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 to-slate-900 flex items-center justify-center p-6"},d.createElement("div",{className:"max-w-md text-center"},d.createElement("div",{className:"w-16 h-16 mx-auto mb-6 rounded-2xl bg-blue-500/20 flex items-center justify-center"},d.createElement("svg",{className:"w-8 h-8 text-blue-300 animate-pulse",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6v6l4 2"}))),d.createElement("h1",{className:"text-2xl font-bold text-white mb-3"},"Validating License"),d.createElement("p",{className:"text-slate-300 leading-relaxed mb-6"},w.message||"Validating license. Please wait..."))):M?d.createElement("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 to-slate-900 flex items-center justify-center p-6"},d.createElement("div",{className:"max-w-md text-center"},d.createElement("div",{className:"w-16 h-16 mx-auto mb-6 rounded-2xl bg-red-500/20 flex items-center justify-center"},d.createElement("svg",{className:"w-8 h-8 text-red-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v4m0 4h.01M10.29 3.86L1.82 18a1 1 0 00.86 1.5h18.64a1 1 0 00.86-1.5L13.71 3.86a1 1 0 00-1.72 0z"}))),d.createElement("h1",{className:"text-2xl font-bold text-white mb-3"},"License Required"),d.createElement("p",{className:"text-slate-300 leading-relaxed mb-6"},w.message||"This editor is unavailable because the license is invalid or revoked."),w.upgradeUrl&&d.createElement("a",{href:w.upgradeUrl,className:"inline-flex items-center justify-center rounded-lg bg-white/10 px-4 py-2 text-sm font-semibold text-white hover:bg-white/20 transition-colors"},"Manage License"))):d.createElement(xk,{store:t},d.createElement("div",{className:`our-editor-sdk ${e||""}`},d.createElement(Yj,null,d.createElement($j,{apiKey:r,showCredit:C,customPanels:a,customContextMenuItems:s,customToolbarItems:A,keyboardShortcuts:l,customFonts:c,customTemplates:f,customExportFormats:h,customElementTypes:g,theme:v,sdkVersion:m,ui:x,getLicenseStatus:()=>t.getLicenseStatus(),subscribeLicense:L=>t.subscribeLicense(L)}))))};class Yj extends d.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,r){console.error("[Editor] Render error",e),console.error("[Editor] Component stack:",r.componentStack)}render(){return this.state.hasError?d.createElement("div",{className:"fixed inset-0 bg-slate-950 text-white flex items-center justify-center p-6"},d.createElement("div",{className:"max-w-md text-center space-y-3"},d.createElement("div",{className:"text-lg font-semibold"},"Editor failed to render"),d.createElement("div",{className:"text-sm text-slate-300"},"Check the console for the component stack to pinpoint the cause."),d.createElement("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center rounded-lg bg-white/10 px-4 py-2 text-sm font-semibold text-white hover:bg-white/20 transition-colors"},"Reload"))):this.props.children}}const Wj="https://cdn.tailwindcss.com",Zj="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap",Jj=".our-editor-sdk { font-family: 'Inter', sans-serif; }",eK="fraczled-sdk-loader-styles",tK=3500,rK=220,nK="1.30.55",aK='<svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 118.1846 24.1172"><defs><linearGradient id="linear-gradient" x1="109.7684" y1="15.3657" x2="116.6286" y2="22.226" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#99d1a7"/><stop offset="1" stop-color="#8fd4f0"/></linearGradient></defs><g id="Layer_1-2"><path d="M86.0219,13.5526c-.0564-.5503-.1717-1.0508-.3545-1.494-.2642-.6402-.6581-1.1357-1.1813-1.4864-.5236-.3506-1.1715-.5259-1.9438-.5259s-1.4254.1779-1.9588.5335c-.5336.3559-.9428.8385-1.2273,1.4482-.2133.4568-.3465.965-.3999,1.5245h7.0657Z" fill="none"/><path d="M29.4248,16.3577c-.315.0609-.6302.1143-.9452.16-.315.0458-.5997.0892-.8536.1296-.5591.0815-1.0468.211-1.4636.3888-.4168.1779-.7392.4168-.9679.7164-.2287.3-.3431.6735-.3431,1.1206,0,.6402.2337,1.1281.7013,1.4635.4674.3354,1.0671.5031,1.7988.5031.691,0,1.3036-.1396,1.837-.4193.5336-.2794.9502-.6555,1.2502-1.1281.2995-.4726.4497-1.0035.4497-1.5931v-1.8141c-.1426.0914-.3431.1779-.6023.2591-.259.0815-.5463.1525-.8613.2135Z" fill="none"/><path d="M100.9591,10.8924c-.5389-.4116-1.1891-.6173-1.9514-.6173-.7723,0-1.4228.2134-1.9512.6402-.5286.4268-.9299,1.0138-1.2044,1.7608-.2744.7469-.4116,1.6136-.4116,2.5992s.1371,1.8575.4116,2.6144c.2744.7573.6784,1.3492,1.212,1.7761s1.1815.6402,1.9436.6402,1.4102-.2108,1.9438-.6326c.5336-.4216.94-1.0085,1.2196-1.7608.2792-.752.4192-1.6312.4192-2.6373,0-1.0162-.1373-1.8979-.4116-2.645-.2744-.7469-.681-1.3262-1.2196-1.7379Z" fill="none"/><path d="M7.104,5.6101c0-.5793.1371-1.029.4116-1.3491s.7571-.4802,1.4483-.4802c.2947,0,.574.0255.8384.0762.2642.051.4929.1018.686.1525l.8233-3.5368c-.2847-.0812-.7294-.1803-1.3341-.2972-.6047-.1167-1.2728-.1754-2.0046-.1754-1.0671,0-2.0199.2034-2.8583.6098-.8386.4065-1.4993,1.0164-1.982,1.8294-.4828.8132-.7242,1.8346-.7242,3.0642v1.2348H0v3.5673h2.4086v13.4764h4.6955v-13.4764h3.3995v-3.5673h-3.3995v-1.1281Z" fill="#0f1925"/><path d="M33.3808,7.8891c-.676-.4624-1.4459-.8054-2.3096-1.029-.8639-.2234-1.7683-.3354-2.7135-.3354-1.362,0-2.5588.2058-3.5903.6175-1.0315.4116-1.8725.9961-2.523,1.7532-.3151.3668-.579.767-.7939,1.1993v-3.4175c-.2134-.061-.4549-.1041-.7242-.1296-.2692-.0253-.5258-.0381-.7697-.0381-.9452,0-1.7836.2721-2.5154.8156-.7318.5439-1.2554,1.3442-1.5702,2.401h-.1831v-2.988h-4.5581v17.0437h4.7107v-9.6347c0-.691.1548-1.3035.465-1.837.3098-.5335.7392-.9502,1.2881-1.2501.5489-.2996,1.1636-.4497,1.8446-.4497.3355,0,.6987.0228,1.0899.0686.2454.0287.4538.063.6332.1017-.091.2586-.1679.5265-.228.8054l4.3753.3506c.1624-.5691.4955-1.039.9986-1.4102.5031-.3708,1.1763-.5564,2.0199-.5564.8026,0,1.4254.1932,1.8675.5793.4421.3864.6631.9299.6631,1.6312v.0762c0,.3559-.1397.6277-.4192.8156-.2797.1882-.7191.3277-1.3188.4193-.5997.0914-1.3925.1829-2.378.2743-.8536.0815-1.6617.2237-2.424.4268-.7621.2035-1.4431.5031-2.0428.8995-.5997.3963-1.0723.9123-1.4178,1.5473-.3455.6353-.5182,1.4307-.5182,2.3858,0,1.1182.2439,2.0531.7318,2.8051.4876.7523,1.1608,1.3187,2.0199,1.6998.8587.3812,1.8267.5717,2.904.5717.8434,0,1.5854-.1143,2.2257-.343.6405-.2287,1.1891-.5436,1.6465-.9452.4573-.4013.8233-.8713,1.0976-1.4101h.1221v2.3781h4.4971v-11.4945c0-1.0061-.1982-1.8751-.5945-2.6068-.3963-.7318-.9326-1.3288-1.6083-1.7913ZM30.8884,17.6992c0,.5896-.1502,1.1205-.4497,1.5931-.3.4726-.7165.8487-1.2502,1.1281-.5334.2797-1.146.4193-1.837.4193-.7318,0-1.3315-.1677-1.7988-.5031-.4676-.3354-.7013-.8232-.7013-1.4635,0-.4471.1144-.8206.3431-1.1206.2287-.2996.5511-.5385.9679-.7164.4168-.1778.9044-.3073,1.4636-.3888.254-.0404.5387-.0838.8536-.1296.315-.0457.6302-.0991.9452-.16.315-.061.6023-.132.8613-.2135.2592-.0812.4597-.1676.6023-.2591v1.8141Z" fill="#0f1925"/><path d="M42.91,10.8009c.5434-.3911,1.1815-.5869,1.9133-.5869.5792,0,1.0873.117,1.5244.3506.4368.2339.7874.564,1.0518.9909.2642.4269.4368.9249.5184,1.494h4.4515c-.061-1.321-.417-2.4696-1.0673-3.4453-.6505-.9756-1.532-1.7326-2.6449-2.2714-1.1128-.5385-2.4114-.808-3.895-.808-1.728,0-3.2166.3711-4.4668,1.1129-1.2499.7419-2.213,1.7736-2.8888,3.0947-.676,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7279.3355,3.2497,1.0062,4.5658.6708,1.3162,1.6312,2.3476,2.8812,3.0947,1.2502.7469,2.744,1.1205,4.4821,1.1205,1.5244,0,2.8404-.2771,3.9484-.8309,1.1076-.5538,1.9765-1.3262,2.6067-2.3172.6302-.9909.9807-2.1366,1.052-3.4377h-4.4515c-.1321.9048-.4778,1.6136-1.0365,2.1267-.5591.5134-1.2452.7698-2.058.7698-.7318,0-1.3698-.2032-1.9133-.6097-.5439-.4064-.9657-.996-1.2654-1.7684-.2997-.7722-.4497-1.6972-.4497-2.7746s.15-1.9945.4497-2.7517c.2997-.757.7215-1.3313,1.2654-1.7227Z" fill="#0f1925"/><polygon points="59.2611 19.8792 67.0815 9.8328 67.0815 6.7381 53.3462 6.7381 53.3462 10.5188 61.4107 10.5188 61.4107 10.6408 53.0718 20.9616 53.0718 23.7818 67.3714 23.7818 67.3714 20.0011 59.2611 20.0011 59.2611 19.8792" fill="#0f1925"/><rect x="68.7445" y="1.0672" width="4.7105" height="22.7147" fill="#0f1925"/><path d="M88.2286,8.6818c-.7318-.7164-1.5854-1.2551-2.5612-1.6158-.9755-.3607-2.0275-.5413-3.1556-.5413-1.667,0-3.1175.3711-4.3524,1.1129-1.2349.7419-2.1901,1.7736-2.8659,3.0947-.6762,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7988.3377,3.3564,1.0139,4.6725.6758,1.3163,1.6486,2.3301,2.9193,3.0413,1.2702.7115,2.7796,1.0672,4.5276,1.0672,1.4025,0,2.6374-.216,3.7045-.6479s1.9386-1.0366,2.6146-1.8141c.6758-.7776,1.1205-1.6896,1.3339-2.7365l-4.36-.2896c-.1524.4168-.3839.7724-.6936,1.0672-.3102.2948-.6784.5183-1.1052.6708-.4268.1524-.9047.2287-1.4331.2287-.7623,0-1.4357-.1754-2.0199-.526-.5846-.3506-1.0394-.8536-1.3644-1.5092-.2927-.5895-.4523-1.2887-.4817-2.0961h11.6103v-1.2806c0-1.4532-.2034-2.7212-.6097-3.8036-.4065-1.0824-.9757-1.9818-1.7075-2.6984ZM80.5835,10.5799c.5334-.3556,1.1863-.5335,1.9588-.5335s1.4202.1753,1.9438.5259c.5232.3506.9171.8461,1.1813,1.4864.1829.4431.2982.9437.3545,1.494h-7.0657c.0534-.5595.1867-1.0677.3999-1.5245.2845-.6097.6936-1.0923,1.2273-1.4482Z" fill="#0f1925"/><path d="M102.4835,1.0672v8.5522h-.1371c-.2034-.4673-.5031-.9399-.8994-1.4177-.3963-.4776-.9147-.8766-1.5549-1.1968-.6405-.3201-1.4383-.4802-2.3935-.4802-1.2401,0-2.3835.3228-3.4301.9681-1.047.6455-1.8854,1.6186-2.5154,2.9193-.6302,1.3011-.9452,2.927-.9452,4.8784,0,1.8903.305,3.4887.9147,4.7944.6097,1.3061,1.4381,2.2943,2.4849,2.9651,1.0468.6709,2.2204,1.0062,3.5216,1.0062.9147,0,1.6894-.1525,2.3249-.4573.635-.305,1.156-.6884,1.5625-1.151.4063-.4624.7165-.9273.9299-1.3949h.2134v2.7288h4.6497V1.0672h-4.726ZM102.1711,17.9126c-.2797.7523-.686,1.3392-1.2196,1.7608-.5336.4218-1.1815.6326-1.9438.6326s-1.41-.2134-1.9436-.6402-.9376-1.0188-1.212-1.7761c-.2744-.757-.4116-1.6285-.4116-2.6144s.1371-1.8523.4116-2.5992c.2744-.747.6758-1.334,1.2044-1.7608.5284-.4268,1.1789-.6402,1.9512-.6402.7623,0,1.4126.2058,1.9514.6173.5387.4117.9452.991,1.2196,1.7379.2742.747.4116,1.6288.4116,2.645,0,1.0061-.1399,1.8854-.4192,2.6373Z" fill="#0f1925"/><circle cx="113.1907" cy="18.7881" r="4.9939" fill="url(#linear-gradient)"/></g></svg>',oK=`
971
+ `,t.head.appendChild(a)}},zj=(t,e)=>{e&&(e.classList.remove("exporting"),delete e.dataset.exportDpr,delete e.dataset.exporting);const r=t.getElementById(j5);r&&r.remove()},jj=async(t,e)=>{const r=e!=null&&e.isMobile?8e3:3e3,n=g=>Promise.race([g,new Promise(v=>setTimeout(v,r))]),a=()=>new Promise(requestAnimationFrame),s=(e==null?void 0:e.enforceFreshEffects)??!1,A=(e==null?void 0:e.expectedImageCount)??0;let l=Date.now();const c=new MutationObserver(()=>{l=Date.now()});c.observe(t,{attributes:!0,childList:!0,subtree:!0});const f=async()=>{let v=0,m={images:-1,effects:-1};const x=Date.now();for(;Date.now()-x<500;){const w={images:t.querySelectorAll("img").length,effects:t.querySelectorAll('[data-effect-canvas="true"]').length};if(w.images===m.images&&w.effects===m.effects?v+=1:(v=0,m=w),v>=2)return;await a()}},h=async()=>{if(A<=0)return;const g=Date.now();for(;Date.now()-g<r;){if(t.querySelectorAll("img").length>=A)return;await a()}};try{if(await f(),await h(),typeof document<"u"){const S=await aw(document,r);S.ready||console.warn("Font readiness check failed or timed out",S),uD(document,t)}const g=Array.from(t.querySelectorAll("img"));await n(Promise.all(g.map(S=>S.complete&&S.naturalWidth!==0?Promise.resolve():new Promise(F=>{const M=()=>F();S.addEventListener("load",M,{once:!0}),S.addEventListener("error",M,{once:!0})})))),await Promise.all(g.map(S=>typeof S.decode!="function"?Promise.resolve():S.decode().catch(()=>{}))),await a(),await a();const v=Date.now(),m=Math.max((e==null?void 0:e.effectsRenderedAfter)??0,l,v),x=()=>Array.from(t.querySelectorAll('[data-effect-canvas="true"]'));let w=x();if(w.length>0){const S=()=>(w=x(),w.every(L=>{const Z=L.getAttribute("data-effect-ready")==="true",J=parseInt(L.getAttribute("data-effect-rendered-at")||"0",10);return Z?s?J>=m:!0:!1})),F=Date.now();for(;!S()&&Date.now()-F<r;)await new Promise(L=>setTimeout(L,16));await a(),await a(),await a(),await a();const M=Date.now();for(;!S()&&Date.now()-M<500;)await new Promise(L=>setTimeout(L,16))}const C=t.getBoundingClientRect();if(C.width<=0||C.height<=0){await a(),await a();const S=t.getBoundingClientRect();if(S.width<=0||S.height<=0)throw new Error("Export layout not ready")}}finally{c.disconnect()}};class Kj{async export(e){const{node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,isMobile:c,expectedImageCount:f,enforceFreshEffects:h,effectsRenderedAfter:g,forceEngine:v}=e;fx(document,r,l);try{await jj(r,{enforceFreshEffects:h,expectedImageCount:f,isMobile:c,effectsRenderedAfter:g});const m=v??(c?"html2canvas":"html-to-image"),x=(w,C)=>{fx(w,C,l),ow(w,C)};try{return m==="html2canvas"?{canvas:await lx({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html2canvas"}:{canvas:await ux({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html-to-image"}}catch(w){return console.warn("Primary export engine failed, falling back",w),m==="html2canvas"?{canvas:await ux({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html-to-image"}:{canvas:await lx({node:r,exportWidth:n,exportHeight:a,bleed:s,backgroundColor:A,pixelRatio:l,onClone:x}),engine:"html2canvas"}}}finally{zj(document,r)}}}const K5=()=>Math.random().toString(36).substring(2,9),dx={undo:["mod+z"],redo:["mod+shift+z","mod+y"],copy:["mod+c"],paste:["mod+v"],copyStyle:["mod+alt+c"],pasteStyle:["mod+alt+v"],duplicate:["mod+d"],delete:["delete","backspace"],selectAll:["mod+a"],deselect:["escape"],group:["mod+g"],ungroup:["mod+shift+g"],bringForward:["mod+]"],sendBackward:["mod+["],bringToFront:["mod+shift+]"],sendToBack:["mod+shift+["],zoomIn:["mod+=","mod+plus"],zoomOut:["mod+-"],fitToScreen:["mod+0"],toolSelect:["v"],toolText:["t"],toolPen:["p"],toolHand:["h"],toolZoom:["z"]},qj=t=>{const e=t.toLowerCase();return e==="+"?"plus":e==="="?"equals":e==="esc"?"escape":e==="del"?"delete":e},hx=t=>{if(!t)return null;const e=t.toLowerCase().split("+").map(n=>n.trim()).filter(Boolean),r={key:"",ctrl:!1,meta:!1,shift:!1,alt:!1,mod:!1};return e.forEach(n=>{switch(n){case"ctrl":case"control":r.ctrl=!0;return;case"cmd":case"command":case"meta":r.meta=!0;return;case"shift":r.shift=!0;return;case"alt":case"option":r.alt=!0;return;case"mod":case"cmdorctrl":case"cmdorcontrol":r.mod=!0;return;default:r.key=qj(n)}}),r.key?r:null},Gj=t=>{const e=t.toLowerCase();return e===" "?"space":e==="+"?"plus":e==="="?"equals":e==="-"?"minus":e==="esc"?"escape":e==="del"?"delete":e},Vj=(t,e)=>{const r=Gj(e.key),n=t.key==="plus"||t.key==="equals",a=e.ctrlKey||e.metaKey;return t.mod&&!a||!t.mod&&(t.ctrl!==e.ctrlKey||t.meta!==e.metaKey)||t.alt!==e.altKey||!n&&t.shift!==e.shiftKey||n&&t.shift&&!e.shiftKey?!1:t.key===r||t.key==="plus"&&r==="equals"||t.key==="equals"&&r==="plus"},$j=({apiKey:t,className:e,showCredit:r,customPanels:n,customContextMenuItems:a,customToolbarItems:s,keyboardShortcuts:A,customFonts:l,customTemplates:c,customExportFormats:f,customElementTypes:h,theme:g,ui:v,sdkVersion:m,getLicenseStatus:x,subscribeLicense:w})=>{const C=ne.useSyncExternalStore(Re=>Oe.subscribe(Re),()=>Oe.getSnapshot()),S=x||(()=>Oe.getLicenseStatus()),F=w||(Re=>Oe.subscribeLicense(Re)),[M,L]=ne.useState(()=>S());ne.useEffect(()=>(L(S()),F(()=>{L(S())})),[S,F]);const Z=Xc(),[J]=ne.useState("canvas"),[K,ee]=ne.useState(null),V=K??J;ne.useEffect(()=>{typeof window>"u"||(window.__FRACZLED_EFFECTS_PIPELINE__=V)},[V]),ne.useEffect(()=>{typeof window>"u"||window.__FRACZLED_EXPORT_PIPELINE__||(window.__FRACZLED_EXPORT_PIPELINE__="dom")},[]);const{isExporting:fe}=sD(),j=Oe.canUndo(),te=Oe.canRedo(),z=M.entitlements.ai,D=M.entitlements.export.web,se=M.entitlements.export.print,q=M.showWatermark||r!==!1,X=M.showWatermark,Y=M.upgradeUrl,W=M.entitlements.features||{},P=M.entitlements.limits||{},k=M.isValid&&W.topbarActions===!0&&(v==null?void 0:v.topbarMode)==="custom"?"custom":"default",Q=v==null?void 0:v.exportMenu,N=W.saveLoad!==!1,I=M.isValid&&W.templateSave!==!1,_=M.isValid&&W.newDesignModal===!0,R=M.isValid&&W.templateSizes===!0,ie=M.state??(M.isValid?"valid":"invalid"),ae=ie==="pending"?"VALIDATING...":ie==="invalid"?"INVALID LICENSE":ie==="offline"?"OFFLINE":M.plan?M.plan.toUpperCase():"FREE",[ge,ce]=ne.useState(null),Ae={[cr.TEMPLATES]:"Templates",[cr.DESIGN]:"Design",[cr.ELEMENTS]:"Elements",[cr.TEXT]:"Text",[cr.IMAGES]:"Images",[cr.ICONS]:"Icons",[cr.BRAND]:"Brand",[cr.UPLOADS]:"Uploads",[cr.QR_CODE]:"QR Codes",[cr.LAYERS]:"Layers",[cr.COLOR]:"Color",[cr.FONT]:"Fonts",[cr.EFFECTS]:"Effects",[cr.POSITION]:"Position",[cr.PROJECTS]:"Projects",[cr.DRAW]:"Draw"},ue={[cr.TEMPLATES]:"templates",[cr.DESIGN]:"design",[cr.ELEMENTS]:"elements",[cr.DRAW]:"draw",[cr.TEXT]:"text",[cr.IMAGES]:"images",[cr.ICONS]:"icons",[cr.BRAND]:"brand",[cr.UPLOADS]:"uploads",[cr.QR_CODE]:"qrcode",[cr.LAYERS]:"layers"},Be=ne.useMemo(()=>{const Re=new Map;return(n||[]).forEach(ht=>{ht!=null&&ht.id&&Re.set(ht.id,ht)}),Re},[n]);ne.useEffect(()=>{n!=null&&n.length&&n.forEach(Re=>{Re!=null&&Re.id&&Object.values(cr).includes(Re.id)&&console.warn(`[Editor] Custom panel id "${Re.id}" conflicts with a built-in tool id.`)})},[n]);const $=ne.useCallback(Re=>{if(!Re)return"";const ht=Be.get(Re);return ht!=null&&ht.label?ht.label:Ae[Re]||String(Re)},[Be,Ae]),ve=Re=>{if(!M.isValid)return!1;if(!Re)return!0;const ht=Be.get(Re);if(ht!=null&&ht.feature)return W[ht.feature]!==!1;const tr=ue[Re];return tr?W[tr]!==!1:!0},be=(Re,ht)=>{switch(Re){case"ai":ce({title:"Unlock Magic Write",description:"Upgrade to generate headlines, rewrites, and AI-assisted copy inside the editor."});break;case"export-web":ce({title:"Unlock Web Exports",description:"Upgrade to export assets for web usage without restrictions."});break;case"export-print":default:ce({title:"Unlock Print Exports",description:"Upgrade to export print-ready PDFs and high-resolution PNGs."});break;case"feature":ce({title:`Unlock ${ht||"this feature"}`,description:"Upgrade to access this feature for your workspace."});break}},[Ne,Ue]=ne.useState(null),[We,Ze]=ne.useState(null),[st,rt]=ne.useState("select"),[Ie,De]=ne.useState(!1),[pe,ke]=ne.useState(!1),[Qe,Ge]=ne.useState(()=>typeof window<"u"?localStorage.getItem("fraczled_skip_new_doc_modal")!=="true":!0),[pt,et]=ne.useState(!1),[_t,Tt]=ne.useState(""),[Mt,Nt]=ne.useState(!1),[Rt,Ht]=ne.useState(!1),[Yt,Wt]=ne.useState(null),Zt=ne.useRef(null),Ir=ne.useMemo(()=>new Kj,[]),[ur,gt]=ne.useState(!1),[Vt,mn]=ne.useState(null),Sr=ne.useMemo(()=>C.pages.some(Re=>{var ht;return(((ht=Re.elements)==null?void 0:ht.length)??0)>0}),[C.pages]),Mr=ne.useCallback(Re=>{Re.type==="modal"?(Oe.reset({transparent:!1}),Ge(!0)):Oe.loadTemplateAsNewDesign(Re.template,{preserveLibraries:!0})},[]),pr=ne.useCallback(Re=>{mn(Re),gt(!0)},[]),dr=()=>{Sr?pr({type:"modal"}):Ge(!0)},Sn=Re=>{Sr?pr({type:"template",template:Re}):Oe.loadTemplateAsNewDesign(Re,{preserveLibraries:!0})},ta=()=>{gt(!1),Tt(C.title||"My Design"),et(!0)},Pr=()=>{gt(!1),Vt?(Mr(Vt),mn(null)):(Oe.reset({transparent:!1}),Ge(!0))},cn=()=>{gt(!1),mn(null)},Jt=()=>{localStorage.setItem("fraczled_skip_new_doc_modal","true")},on=ne.useMemo(()=>{const Re=C.brandKits.find(ht=>ht.id===C.activeBrandKitId);return Re?Re.colors:[]},[C.brandKits,C.activeBrandKitId]),Bn=ne.useMemo(()=>C.brandKits.find(Re=>Re.id===C.activeBrandKitId),[C.brandKits,C.activeBrandKitId]),sn=C.pages.find(Re=>Re.id===C.activePageId),$r=ne.useMemo(()=>sn?sn.elements:[],[sn]),en=ne.useMemo(()=>{if(!C.selection.length)return;const Re=C.selection[0];return $r.find(ht=>ht.id===Re)},[C.selection,$r]),Zr=ne.useMemo(()=>C.pages.findIndex(Re=>Re.id===C.activePageId)+1,[C.pages,C.activePageId]),tn=ne.useMemo(()=>sn?{...C.settings,width:sn.width??C.settings.width,height:sn.height??C.settings.height,unit:sn.unit??C.settings.unit}:C.settings,[C.settings,sn]);ne.useEffect(()=>{$6(l)},[l]),ne.useEffect(()=>{Sg(c)},[c]),ne.useEffect(()=>{C.pages.forEach(Re=>{Re.elements.forEach(ht=>{ht.fontFamily&&ku(ht.fontFamily)})})},[]),ne.useEffect(()=>{Bn!=null&&Bn.customFonts&&Bn.customFonts.forEach(Re=>{rp(Re.name,Re.url)})},[Bn]);const rn=Re=>{if(Re&&!ve(Re)){be("feature",$(Re)||"this feature");return}if(Re===cr.QR_CODE&&Ne!==cr.QR_CODE&&!C.selection.some(tr=>$r.some(_r=>_r.id===tr&&_r.type==="qrcode"))){const tr=(sn==null?void 0:sn.width)??C.settings.width,_r=(sn==null?void 0:sn.height)??C.settings.height,zt={id:K5(),type:"qrcode",name:"QR Code",visible:!0,content:"https://example.com",x:tr/2-75,y:_r/2-75,width:150,height:150,rotation:0,opacity:1,zIndex:$r.length+1,locked:!1,color:"#000000",backgroundColor:"#ffffff",effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}};Oe.addElement(zt),rt("select")}Re===cr.DRAW?rt("pen"):(st==="pen"||st==="direct-select")&&rt("select"),Ue(Re)},ma=Re=>{Ze(Re),Ue(cr.COLOR)},Yn=ne.useMemo(()=>({store:Oe,selection:C.selection}),[C.selection]),Ln=ne.useMemo(()=>{const Re=ht=>{C.selection.forEach(tr=>Oe.reorderElement(tr,ht))};return{undo:()=>Oe.undo(),redo:()=>Oe.redo(),copy:()=>Oe.copy(),paste:()=>Oe.paste(),copyStyle:()=>Oe.copyStyle(),pasteStyle:()=>Oe.pasteStyle(),duplicate:()=>Oe.duplicateSelection(),delete:()=>Oe.deleteSelection(),selectAll:()=>Oe.selectAll(),deselect:()=>{Oe.deselectAll(),Ue(null),De(!1),rt("select")},group:()=>Oe.groupSelection(),ungroup:()=>Oe.ungroupSelection(),bringForward:()=>Re("forward"),sendBackward:()=>Re("backward"),bringToFront:()=>Re("front"),sendToBack:()=>Re("back"),zoomIn:()=>Oe.setZoom(Math.min(200,C.zoom+10)),zoomOut:()=>Oe.setZoom(Math.max(10,C.zoom-10)),fitToScreen:()=>window.dispatchEvent(new CustomEvent("canvas-fit-to-screen")),toolSelect:()=>rt("select"),toolText:()=>rt("text"),toolPen:()=>rt("pen"),toolHand:()=>rt("hand"),toolZoom:()=>rt("zoom")}},[C.selection,C.zoom]),or=ne.useMemo(()=>{const Re=[],ht=(A==null?void 0:A.overrides)||{};return((A==null?void 0:A.disableDefaults)??!1)||Object.keys(dx).forEach(_r=>{const zt=ht[_r];if(zt===!1)return;(zt?[zt]:dx[_r]).forEach(sr=>{const xr=hx(sr);xr&&Re.push({keys:sr,parsed:xr,handler:Ln[_r]})})}),((A==null?void 0:A.custom)||[]).forEach(_r=>{const zt=hx(_r.keys);zt&&Re.push({keys:_r.keys,parsed:zt,handler:()=>_r.action(Yn)})}),Re},[A,Ln,Yn]);ne.useEffect(()=>{const Re=ht=>{const tr=ht.target;if(tr&&(tr.tagName==="INPUT"||tr.tagName==="TEXTAREA"||tr.isContentEditable))return;for(const xr of or)if(Vj(xr.parsed,ht)){ht.preventDefault(),xr.handler();return}const zt=ht.metaKey||ht.ctrlKey,Lr=ht.shiftKey,sr=ht.key.toLowerCase();if(!zt&&!ht.altKey)switch(sr){case"r":rt("rotate");return;case"s":rt("scale");return;case"a":rt("direct-select");return}if(zt&&sr==="n"&&(ht.preventDefault(),dr()),zt&&sr==="x"&&(ht.preventDefault(),Oe.cut()),C.selection.length>0){const xr=Lr?10:1;ht.key==="ArrowUp"&&(ht.preventDefault(),Oe.nudgeSelection(0,-xr)),ht.key==="ArrowDown"&&(ht.preventDefault(),Oe.nudgeSelection(0,xr)),ht.key==="ArrowLeft"&&(ht.preventDefault(),Oe.nudgeSelection(-xr,0)),ht.key==="ArrowRight"&&(ht.preventDefault(),Oe.nudgeSelection(xr,0))}if(zt&&sr==="l"&&(ht.preventDefault(),C.selection.forEach(xr=>{const Tr=$r.find(Br=>Br.id===xr);Tr&&Oe.updateElement(xr,{locked:!Tr.locked})})),zt&&Lr)switch(sr){case"l":ht.preventDefault(),Oe.alignSelection("left");break;case"c":ht.preventDefault(),Oe.alignSelection("center");break;case"r":ht.preventDefault(),Oe.alignSelection("right");break;case"t":ht.preventDefault(),Oe.alignSelection("top");break;case"m":ht.preventDefault(),Oe.alignSelection("middle");break;case"b":ht.preventDefault(),Oe.alignSelection("bottom");break}};return window.addEventListener("keydown",Re),()=>window.removeEventListener("keydown",Re)},[or,C.selection,C.pages,$r]),ne.useEffect(()=>{const Re=Oe.on("toast",ht=>{ht!=null&&ht.message&&(Wt({message:ht.message,tone:ht.tone}),Zt.current&&window.clearTimeout(Zt.current),Zt.current=window.setTimeout(()=>{Wt(null),Zt.current=null},2400))});return()=>{Re==null||Re(),Zt.current&&(window.clearTimeout(Zt.current),Zt.current=null)}},[]);const _e=(Re,ht,tr,_r,zt)=>{const Lr=ht==="heading"?32:ht==="subheading"?24:14,sr=ht==="heading"?"bold":ht==="subheading"?"semibold":"normal",xr=(sn==null?void 0:sn.width)??C.settings.width;(sn==null?void 0:sn.height)??C.settings.height;const Br=xr-40*2;let Vr=200,kn=Lr*1.5,Ca=Vr;try{const qn=document.createElement("canvas").getContext("2d");if(qn){qn.font=`${sr==="bold"?"bold":sr==="semibold"?"600":"normal"} ${Lr}px ${(zt==null?void 0:zt.fontFamily)||"Inter"}, sans-serif`;const On=qn.measureText(Re);Ca=Math.ceil(On.width)+10,Vr=Ca}}catch(wn){console.warn("Could not measure text width automatically",wn)}const bn=Ca>Br;if(bn){Vr=Br;const wn=Math.ceil(Ca/Br);kn=Lr*1.5*wn}const En={id:K5(),type:"text",name:Re.substring(0,20),visible:!0,content:Re,x:tr!==void 0?tr:-1,y:_r!==void 0?_r:-1,width:Vr,height:kn,fontSize:Lr,fontWeight:sr,fontFamily:(zt==null?void 0:zt.fontFamily)||"Inter",color:(zt==null?void 0:zt.color)||"#1e293b",rotation:0,opacity:1,zIndex:$r.length+1,locked:!1,autoWidth:!bn,textStrokeWidth:0,textStrokeColor:"#000000",textStrokePosition:"behind",textStrokeStyle:"round",effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}};Oe.addElement(En)},$e=Re=>{const ht=Yu(Re),tr=Re==="line"||ht?200:100,_r=Re==="line"?4:ht?200:100,zt=(ht==null?void 0:ht.name)||Re.charAt(0).toUpperCase()+Re.slice(1),Lr={id:K5(),type:"shape",name:zt,visible:!0,content:(ht==null?void 0:ht.id)||Re,x:-1,y:-1,width:tr,height:_r,backgroundColor:Re==="line"?"transparent":"#cbd5e1",strokeColor:Re==="line"?"#000000":void 0,strokeWidth:Re==="line"?4:0,rotation:0,opacity:1,zIndex:$r.length+1,locked:!1,effect:{style:{type:"none",params:{}},shape:{type:"none",params:{curve:0}}}};Oe.addElement(Lr)},Se=async Re=>{const{pageId:ht,width:tr,height:_r,bleed:zt,backgroundColor:Lr,kind:sr,dpi:xr,pixelRatio:Tr,enforceFreshEffects:Br,effectsRenderedAfter:Vr}=Re,kn=document.getElementById(`page-canvas-${ht}`);if(!kn)throw new Error(`Page ${ht} not found`);const bn=(typeof window<"u"?window.__FRACZLED_EXPORT_PIPELINE__??"dom":"dom")==="canvas"?"canvas":"dom",En=C.pages.find(va=>va.id===ht),wn=En?En.elements.filter(va=>va.type==="image"&&va.visible!==!1).length:0,qn=En?En.elements.some(va=>(va.blendMode??"normal")!=="normal"&&va.visible!==!1):!1,On=En?En.elements.some(va=>{var ds,uo;return va.type==="text"&&((uo=(ds=va.effect)==null?void 0:ds.shape)==null?void 0:uo.type)==="curve"&&va.visible!==!1}):!1,Qo=En?En.elements.some(va=>va.type==="text"&&va.visible!==!1):!1,lo=tr+zt*2,co=_r+zt*2;let Da=Jb({kind:sr,width:lo,height:co,dpi:xr,pixelRatio:Tr,maxPixelRatio:Z?Zl.mobilePixelRatioCap:void 0,maxCanvasSize:8192,clampForIOS:!0});const fs=f1(),bo=fs?4096:8192,Io=fs?16777216:67108864,gr=Math.max(lo,co),wo=bo/gr,Bs=Math.sqrt(Io/(lo*co)),Or=Math.min(Da,wo,Bs);if(Or<Da&&(console.warn(`Clamped export pixel ratio from ${Da.toFixed(2)} to ${Or.toFixed(2)} for memory safety.`),Da=Math.max(.1,Or)),bn==="canvas"){const{capturePageCanvas:va}=await Promise.resolve().then(()=>iV),ds=C.pages.find(Pa=>Pa.id===ht);if(!ds)throw new Error(`Page ${ht} not found for canvas export`);return{kind:"canvas",value:await va({page:ds,settings:C.settings,width:lo,height:co,bleed:zt,backgroundColor:Lr,pixelRatio:Da})}}const{canvas:Yi}=await Ir.export({node:kn,exportWidth:lo,exportHeight:co,bleed:zt,backgroundColor:Lr,pixelRatio:Da,isMobile:Z,expectedImageCount:wn,enforceFreshEffects:Br,effectsRenderedAfter:Vr,forceEngine:qn||On||fs&&Qo?"html-to-image":void 0});return{kind:"canvas",value:Yi}},kt=Re=>{const ht=P.maxExportsPerDay;if(typeof window<"u"&&ht){const _r=`fraczled_exports_${new Date().toISOString().slice(0,10)}`;if(Number.parseInt(localStorage.getItem(_r)||"0",10)>=ht)return be("feature","Daily exports"),!1}return Re==="print"&&!se?(be("export-print"),!1):Re==="web"&&!D||Re==="other"&&!D&&!se?(be("export-web"),!1):!0},yt=()=>{if(typeof window<"u"&&P.maxExportsPerDay){const ht=`fraczled_exports_${new Date().toISOString().slice(0,10)}`,tr=Number.parseInt(localStorage.getItem(ht)||"0",10);localStorage.setItem(ht,String(tr+1))}},Le=async()=>{const ht=V!=="canvas";ht&&ee("canvas"),setEditingId(null),Oe.deselectAll(),await new Promise(_r=>setTimeout(_r,Z?200:100)),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),Z&&(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame));const tr=Date.now();return{forceCanvasPipeline:ht,effectsReadyAfter:tr}},$t=async Re=>{Re&&(ee(null),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame))},Ct=async Re=>{try{return Re.toDataURL("image/png",1)}catch(ht){if(!Re.toBlob)throw ht;const tr=await new Promise(_r=>{Re.toBlob(zt=>_r(zt),"image/png",1)});if(!tr)throw new Error("Failed to encode export");return await new Promise((_r,zt)=>{const Lr=new FileReader;Lr.onload=()=>_r(Lr.result),Lr.onerror=()=>zt(Lr.error),Lr.readAsDataURL(tr)})}},fr=async Re=>{if(Re==="json"){const xr=Oe.exportJSON(),Tr=new Blob([xr],{type:"application/json"}),Br=URL.createObjectURL(Tr),Vr=document.createElement("a");Vr.href=Br,Vr.download=`${C.title||"design"}.json`,document.body.appendChild(Vr),Vr.click(),document.body.removeChild(Vr),URL.revokeObjectURL(Br);return}const tr=Re.startsWith("print")?"print":"web";if(!kt(tr))return;Ht(!0);const{forceCanvasPipeline:_r,effectsReadyAfter:zt}=await Le(),Lr=Re.startsWith("print"),sr=Re.includes("pdf");try{const xr=C.pages,Tr=Lr&&tn.showBleed?tn.bleed:0,Br=async Vr=>{if(Vr.width===0||Vr.height===0)throw new Error("Export canvas is empty");if(typeof Vr.toBlob=="function"){const kn=await new Promise(Ca=>{Vr.toBlob(bn=>Ca(bn),"image/png",1)});if(kn)return{href:URL.createObjectURL(kn),revoke:!0}}try{return{href:Vr.toDataURL("image/png",1),revoke:!1}}catch{const bn=document.createElement("canvas");bn.width=Math.max(1,Math.floor(Vr.width*.75)),bn.height=Math.max(1,Math.floor(Vr.height*.75));const En=bn.getContext("2d");if(!En)throw new Error("Failed to encode export");if(En.drawImage(Vr,0,0,bn.width,bn.height),typeof bn.toBlob=="function"){const wn=await new Promise(qn=>{bn.toBlob(On=>qn(On),"image/png",1)});if(wn)return{href:URL.createObjectURL(wn),revoke:!0}}return{href:bn.toDataURL("image/png",1),revoke:!1}}};if(sr){const Vr=xr[0],kn=Vr.width??C.settings.width,Ca=Vr.height??C.settings.height,bn=kn>Ca?"landscape":"portrait",En=new Rr({orientation:bn,unit:"px",format:[kn,Ca],hotfixes:["px_scaling"]});for(let wn=0;wn<xr.length;wn++){const qn=xr[wn],On=qn.width??C.settings.width,Qo=qn.height??C.settings.height;C.activePageId!==qn.id&&(Oe.setActivePage(qn.id),await new Promise(co=>setTimeout(co,50)));const lo=await Se({pageId:qn.id,width:On,height:Qo,bleed:Tr,backgroundColor:tn.backgroundColor||"#ffffff",kind:Lr?"print":"web",dpi:Lr?tn.dpi:void 0,enforceFreshEffects:_r,effectsRenderedAfter:zt});if(wn>0&&En.addPage([On,Qo],On>Qo?"landscape":"portrait"),lo.kind==="canvas")try{En.addImage(lo.value,"PNG",0,0,On,Qo)}catch{const Da=lo.value.toDataURL("image/png",1);En.addImage(Da,"PNG",0,0,On,Qo)}else En.addImage(lo.value,"PNG",0,0,On,Qo)}En.save(`${C.title.replace(/\s+/g,"-")}.pdf`)}else for(let Vr=0;Vr<xr.length;Vr++){const kn=xr[Vr];C.activePageId!==kn.id&&(Oe.setActivePage(kn.id),await new Promise(On=>setTimeout(On,50)));const Ca=kn.width??C.settings.width,bn=kn.height??C.settings.height,En=await Se({pageId:kn.id,width:Ca,height:bn,bleed:Tr,backgroundColor:tn.backgroundColor||"#ffffff",kind:Lr?"print":"web",dpi:Lr?tn.dpi:void 0,enforceFreshEffects:_r,effectsRenderedAfter:zt}),wn=document.createElement("a"),qn=xr.length>1?`-Page${Vr+1}`:"";if(wn.download=`${C.title.replace(/\s+/g,"-").toLowerCase()}${qn}.png`,En.kind==="canvas"){const On=await Br(En.value);wn.href=On.href,wn.click(),On.revoke&&URL.revokeObjectURL(On.href)}else wn.href=En.value,wn.click();xr.length>1&&await new Promise(On=>setTimeout(On,500))}yt()}catch(xr){console.error("Export failed",xr);const Tr=xr instanceof Error&&xr.message?`Failed to export: ${xr.message}`:"Failed to export. Please try again.";alert(Tr)}finally{await $t(_r),Ht(!1)}},jr=async Re=>{if(!(Re!=null&&Re.id))return;const ht=Re.section??"other";if(!kt(ht))return;Ht(!0);const{forceCanvasPipeline:tr,effectsReadyAfter:_r}=await Le();try{const zt=async(Lr,sr)=>{const xr=C.pages.find(wn=>wn.id===Lr);if(!xr)throw new Error(`Page ${Lr} not found`);const Tr=(sr==null?void 0:sr.kind)??(ht==="print"?"print":"web"),Br=(sr==null?void 0:sr.width)??xr.width??C.settings.width,Vr=(sr==null?void 0:sr.height)??xr.height??C.settings.height,kn=typeof(sr==null?void 0:sr.bleed)=="number"?sr.bleed:Tr==="print"&&tn.showBleed?tn.bleed:0,Ca=(sr==null?void 0:sr.backgroundColor)??tn.backgroundColor??"#ffffff",bn=(sr==null?void 0:sr.dpi)??(Tr==="print"?tn.dpi:void 0),En=await Se({pageId:Lr,width:Br,height:Vr,bleed:kn,backgroundColor:Ca,kind:Tr,dpi:bn,pixelRatio:sr==null?void 0:sr.pixelRatio,enforceFreshEffects:tr,effectsRenderedAfter:_r});return En.kind==="dataUrl"?En.value:Ct(En.value)};await Re.handler({store:Oe,pages:C.pages,settings:tn,captureCanvas:zt}),yt()}catch(zt){console.error("Custom export failed",zt);const Lr=zt instanceof Error&&zt.message?`Failed to export: ${zt.message}`:"Failed to export. Please try again.";alert(Lr)}finally{await $t(tr),Ht(!1)}},er=()=>{if(!M.isValid){be("design");return}Tt(C.title||"My Design"),et(!0)},Xr=async()=>{if(!_t.trim())return;Nt(!0);let Re="";try{const ht=C.activePageId,tr=document.getElementById(`page-canvas-${ht}`),_r=C.pages.find(zt=>zt.id===ht);if(tr&&_r){const zt=Fd({targetSize:200,width:_r.width??C.settings.width,height:_r.height??C.settings.height});Re=await ed(tr,{quality:.9,pixelRatio:zt,style:{margin:"0",overflow:"hidden",transform:"scale(1)",transformOrigin:"top left"},filter:Lr=>{var sr;return!((sr=Lr.hasAttribute)!=null&&sr.call(Lr,"data-no-export"))}})}}catch(ht){console.error("Failed to capture thumbnail:",ht)}if(Oe.saveDesign(_t.trim(),Re),Tt(""),et(!1),Nt(!1),Vt){const ht=Vt;mn(null),Mr(ht)}},pa=()=>{et(!1),Tt(""),mn(null)},Oa=ne.useMemo(()=>({onUndo:()=>Oe.undo(),onRedo:()=>Oe.redo(),canUndo:j,canRedo:te,onNewDesign:dr,onSaveDesign:er,onExport:fr,onCustomExport:jr,exportAccess:{web:D,print:se},canSaveLoadJson:N,upgradeUrl:Y,isExporting:fe||Rt}),[se,D,te,j,N,jr,fr,dr,er,Rt,fe,Y]),Za=ne.useMemo(()=>({store:Oe,selection:C.selection,element:en,topbar:Oa}),[en,C.selection,Oa]);return d.createElement("div",{className:`flex flex-col h-screen h-[100dvh] w-screen overflow-hidden bg-slate-50/50 text-slate-900 font-sans ${e||""}`},pt&&d.createElement("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[200]",onClick:pa},d.createElement("div",{className:"bg-white rounded-xl shadow-2xl p-6 w-[90%] max-w-md",onClick:Re=>Re.stopPropagation()},d.createElement("h2",{className:"text-lg font-bold text-slate-800 mb-4"},"Save Design"),d.createElement("input",{type:"text",value:_t,onChange:Re=>Tt(Re.target.value),placeholder:"Enter design name...",className:"w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 mb-4",autoFocus:!0,onKeyDown:Re=>{Re.key==="Enter"&&Xr()}}),d.createElement("div",{className:"flex gap-2"},d.createElement("button",{onClick:Xr,disabled:!_t.trim()||Mt,className:"flex-1 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-sm disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2"},Mt?"Saving...":"Save"),d.createElement("button",{onClick:pa,className:"px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-lg font-medium text-sm transition-colors"},"Cancel")))),d.createElement(JQ,{title:C.title,onTitleChange:Re=>Oe.setTitle(Re),onExport:fr,onUndo:()=>Oe.undo(),onRedo:()=>Oe.redo(),canUndo:j,canRedo:te,onToggleSettings:()=>De(!Ie),zoom:C.zoom,setZoom:Re=>Oe.setZoom(Re),showToolbar:C.selection.length>0,exportAccess:{web:D,print:se},canSaveLoadJson:N,upgradeUrl:Y,onRequestUpgrade:be,onSaveDesign:er,onNewDesign:dr,isExporting:fe||Rt,customToolbarItems:s,toolbarContext:Za,customExportFormats:f,onCustomExport:jr,topbarMode:k,exportMenu:Q},d.createElement(YO,{selection:C.selection,elements:$r,updateElement:(Re,ht)=>Oe.updateElement(Re,ht),updateElements:(Re,ht)=>Oe.updateElements(Re,ht),deleteElement:Re=>Oe.deleteElement(Re),reorderElement:(Re,ht)=>Oe.reorderElement(Re,ht),settings:tn,savedColors:C.savedColors,savedGradients:C.savedGradients,onSaveColor:Re=>Oe.addSavedColor(Re),onSaveGradient:Re=>Oe.addSavedGradient(Re),onDuplicate:Re=>Oe.duplicateElement(Re),brandColors:on,activeBrandKit:Bn,setActiveTool:rn,onOpenColorPanel:ma,activeTool:Ne,activeColorMode:We,customToolbarItems:s})),d.createElement("div",{className:"flex flex-1 overflow-hidden relative flex-col md:flex-row"},d.createElement(eI,{activeTool:Ne,setActiveTool:rn,featureAccess:W,onRequestUpgrade:Re=>be("feature",Re),isLicenseValid:M.isValid,customPanels:n,hideDefaultPanels:v==null?void 0:v.hideDefaultPanels,hiddenPanels:v==null?void 0:v.hiddenPanels}),Ne&&(Z?d.createElement(bg,{isOpen:!0,onClose:()=>Ue(null),title:$(Ne)||"Tools",height:"full"},d.createElement(b7,{activeTool:Ne,onClose:()=>Ue(null),onSetActivePanel:rn,onAddText:_e,onAddShape:$e,onStartTemplateDesign:Sn,activeColorMode:We,interactionMode:st,onSetInteractionMode:rt,canUseAI:z,isLicenseValid:M.isValid,onRequestUpgrade:be,customPanels:n,customFonts:l,customTemplates:c,canSaveTemplates:I,title:$(Ne)})):d.createElement("div",{className:"absolute left-0 right-0 bottom-16 md:bottom-0 md:left-[72px] md:right-auto top-0 z-20 shadow-2xl animate-in slide-in-from-left-4 duration-200"},d.createElement(b7,{activeTool:Ne,onClose:()=>Ue(null),onSetActivePanel:rn,onAddText:_e,onAddShape:$e,onStartTemplateDesign:Sn,activeColorMode:We,interactionMode:st,onSetInteractionMode:rt,canUseAI:z,isLicenseValid:M.isValid,onRequestUpgrade:be,customPanels:n,customFonts:l,customTemplates:c,canSaveTemplates:I,title:$(Ne)}))),d.createElement("div",{className:"flex-1 flex flex-col h-full overflow-hidden relative z-0"},d.createElement(qO,{pages:C.pages,activePageId:C.activePageId,interactionMode:st,zoom:C.zoom,setZoom:Re=>Oe.setZoom(Re),settings:C.settings,selection:C.selection,setSelection:(Re,ht)=>Oe.setSelection(Re,ht),activeGroupId:C.activeGroupId,onSetActiveGroupId:Re=>Oe.setActiveGroupId(Re),updateElement:(Re,ht,tr)=>Oe.updateElement(Re,ht,tr),customContextMenuItems:a,onDuplicate:Re=>Oe.duplicateElement(Re),onDelete:Re=>Oe.deleteElement(Re),onBringToFront:Re=>Oe.reorderElement(Re,"front"),onSendToBack:Re=>Oe.reorderElement(Re,"back"),onResetZoom:()=>Oe.setZoom(65),onSetActivePage:Re=>Oe.setActivePage(Re),onAddPage:Re=>{const ht=P.maxPages;if(ht&&C.pages.length>=ht){be("feature","Additional pages");return}Oe.addPage(Re)},onDuplicatePage:Re=>Oe.duplicatePage(Re),onDeletePage:Re=>Oe.deletePage(Re),onRenamePage:(Re,ht)=>Oe.renamePage(Re,ht),onAddText:_e,showCredit:q,showWatermark:X}),pe&&d.createElement(WO,{pages:C.pages,activePageId:C.activePageId,setActivePage:Re=>Oe.setActivePage(Re),addPage:()=>{const Re=P.maxPages;if(Re&&C.pages.length>=Re){be("feature","Additional pages");return}Oe.addPage()},duplicatePage:Re=>Oe.duplicatePage(Re),deletePage:Re=>Oe.deletePage(Re),settings:C.settings,onClose:()=>ke(!1)}),d.createElement("div",{className:"hidden md:block"},d.createElement(GO,{zoom:C.zoom,setZoom:Re=>Oe.setZoom(Re),pageCount:C.pages.length,activePage:Zr,planLabel:ae,sdkVersion:m,showThumbnails:pe,onToggleThumbnails:()=>ke(!pe),pageSize:tn}))),d.createElement(NL,{settings:C.settings,updateSettings:Re=>Oe.updateSettings(Re),isOpen:Ie,onClose:()=>De(!1),canLoadJson:N,onLoadJson:Re=>Oe.loadJSON(Re)}),d.createElement(ZO,{open:!!ge,title:(ge==null?void 0:ge.title)||"",description:(ge==null?void 0:ge.description)||"",upgradeUrl:Y,onClose:()=>ce(null)}),d.createElement(tD,{open:Qe,onClose:()=>Ge(!1),onSkipFuture:Jt,customTemplates:c,newDesignModal:v==null?void 0:v.newDesignModal,canCustomizeNewDesignModal:_,canCustomizeTemplateSizes:R}),Yt&&d.createElement("div",{"data-no-export":"true",className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-[300] px-4 py-2 rounded-lg text-xs font-semibold shadow-lg ${Yt.tone==="error"?"bg-red-600 text-white":Yt.tone==="info"?"bg-slate-800 text-white":"bg-amber-500 text-white"}`},Yt.message),ur&&d.createElement("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[200]",onClick:cn},d.createElement("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-sm mx-4 overflow-hidden",onClick:Re=>Re.stopPropagation()},d.createElement("div",{className:"p-6"},d.createElement("h3",{className:"text-lg font-semibold text-slate-800 mb-2"},"Unsaved Changes"),d.createElement("p",{className:"text-sm text-slate-600 mb-6"},"You have unsaved changes. Would you like to save your current design before creating a new one?"),d.createElement("div",{className:"flex flex-col gap-2"},d.createElement("button",{onClick:ta,className:"w-full py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-sm transition-colors"},"Save First"),d.createElement("button",{onClick:Pr,className:"w-full py-2.5 bg-red-50 hover:bg-red-100 text-red-600 rounded-lg font-medium text-sm transition-colors"},"Discard Changes"),d.createElement("button",{onClick:cn,className:"w-full py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-lg font-medium text-sm transition-colors"},"Cancel")))))))},Xj=({store:t,className:e,apiKey:r,showCredit:n,customPanels:a,customContextMenuItems:s,customToolbarItems:A,keyboardShortcuts:l,customFonts:c,customTemplates:f,customExportFormats:h,customElementTypes:g,theme:v,sdkVersion:m,ui:x})=>{const w=ne.useSyncExternalStore(L=>t.subscribeLicense(L),()=>t.getLicenseStatus()),C=w.showWatermark||n!==!1,S=w.state??(w.isValid?"valid":"invalid"),F=S==="pending",M=S==="invalid";return d.useEffect(()=>{if(t===Oe)return;Oe.services=t.services;const L=Object.getPrototypeOf(t),Z=Object.getOwnPropertyNames(L),J=[];Z.forEach(V=>{if(V==="constructor"||V==="subscribe"||V==="getSnapshot"||V==="notify"||V.startsWith("_"))return;if(typeof t[V]=="function"){const j=Oe[V];Oe[V]=(...te)=>t[V](...te),J.push(()=>{j?Oe[V]=j:delete Oe[V]})}});const K=()=>{Oe.state=t.state,Oe.services=t.services,Oe.notify&&Oe.notify()};Oe.state=t.state;const ee=t.subscribe(K);return()=>{ee(),J.forEach(V=>V())}},[t]),F?d.createElement("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 to-slate-900 flex items-center justify-center p-6"},d.createElement("div",{className:"max-w-md text-center"},d.createElement("div",{className:"w-16 h-16 mx-auto mb-6 rounded-2xl bg-blue-500/20 flex items-center justify-center"},d.createElement("svg",{className:"w-8 h-8 text-blue-300 animate-pulse",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6v6l4 2"}))),d.createElement("h1",{className:"text-2xl font-bold text-white mb-3"},"Validating License"),d.createElement("p",{className:"text-slate-300 leading-relaxed mb-6"},w.message||"Validating license. Please wait..."))):M?d.createElement("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 to-slate-900 flex items-center justify-center p-6"},d.createElement("div",{className:"max-w-md text-center"},d.createElement("div",{className:"w-16 h-16 mx-auto mb-6 rounded-2xl bg-red-500/20 flex items-center justify-center"},d.createElement("svg",{className:"w-8 h-8 text-red-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v4m0 4h.01M10.29 3.86L1.82 18a1 1 0 00.86 1.5h18.64a1 1 0 00.86-1.5L13.71 3.86a1 1 0 00-1.72 0z"}))),d.createElement("h1",{className:"text-2xl font-bold text-white mb-3"},"License Required"),d.createElement("p",{className:"text-slate-300 leading-relaxed mb-6"},w.message||"This editor is unavailable because the license is invalid or revoked."),w.upgradeUrl&&d.createElement("a",{href:w.upgradeUrl,className:"inline-flex items-center justify-center rounded-lg bg-white/10 px-4 py-2 text-sm font-semibold text-white hover:bg-white/20 transition-colors"},"Manage License"))):d.createElement(xk,{store:t},d.createElement("div",{className:`our-editor-sdk ${e||""}`},d.createElement(Yj,null,d.createElement($j,{apiKey:r,showCredit:C,customPanels:a,customContextMenuItems:s,customToolbarItems:A,keyboardShortcuts:l,customFonts:c,customTemplates:f,customExportFormats:h,customElementTypes:g,theme:v,sdkVersion:m,ui:x,getLicenseStatus:()=>t.getLicenseStatus(),subscribeLicense:L=>t.subscribeLicense(L)}))))};class Yj extends d.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,r){console.error("[Editor] Render error",e),console.error("[Editor] Component stack:",r.componentStack)}render(){return this.state.hasError?d.createElement("div",{className:"fixed inset-0 bg-slate-950 text-white flex items-center justify-center p-6"},d.createElement("div",{className:"max-w-md text-center space-y-3"},d.createElement("div",{className:"text-lg font-semibold"},"Editor failed to render"),d.createElement("div",{className:"text-sm text-slate-300"},"Check the console for the component stack to pinpoint the cause."),d.createElement("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center rounded-lg bg-white/10 px-4 py-2 text-sm font-semibold text-white hover:bg-white/20 transition-colors"},"Reload"))):this.props.children}}const Wj="https://cdn.tailwindcss.com",Zj="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap",Jj=".our-editor-sdk { font-family: 'Inter', sans-serif; }",eK="fraczled-sdk-loader-styles",tK=3500,rK=220,nK="1.30.56",aK='<svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 118.1846 24.1172"><defs><linearGradient id="linear-gradient" x1="109.7684" y1="15.3657" x2="116.6286" y2="22.226" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#99d1a7"/><stop offset="1" stop-color="#8fd4f0"/></linearGradient></defs><g id="Layer_1-2"><path d="M86.0219,13.5526c-.0564-.5503-.1717-1.0508-.3545-1.494-.2642-.6402-.6581-1.1357-1.1813-1.4864-.5236-.3506-1.1715-.5259-1.9438-.5259s-1.4254.1779-1.9588.5335c-.5336.3559-.9428.8385-1.2273,1.4482-.2133.4568-.3465.965-.3999,1.5245h7.0657Z" fill="none"/><path d="M29.4248,16.3577c-.315.0609-.6302.1143-.9452.16-.315.0458-.5997.0892-.8536.1296-.5591.0815-1.0468.211-1.4636.3888-.4168.1779-.7392.4168-.9679.7164-.2287.3-.3431.6735-.3431,1.1206,0,.6402.2337,1.1281.7013,1.4635.4674.3354,1.0671.5031,1.7988.5031.691,0,1.3036-.1396,1.837-.4193.5336-.2794.9502-.6555,1.2502-1.1281.2995-.4726.4497-1.0035.4497-1.5931v-1.8141c-.1426.0914-.3431.1779-.6023.2591-.259.0815-.5463.1525-.8613.2135Z" fill="none"/><path d="M100.9591,10.8924c-.5389-.4116-1.1891-.6173-1.9514-.6173-.7723,0-1.4228.2134-1.9512.6402-.5286.4268-.9299,1.0138-1.2044,1.7608-.2744.7469-.4116,1.6136-.4116,2.5992s.1371,1.8575.4116,2.6144c.2744.7573.6784,1.3492,1.212,1.7761s1.1815.6402,1.9436.6402,1.4102-.2108,1.9438-.6326c.5336-.4216.94-1.0085,1.2196-1.7608.2792-.752.4192-1.6312.4192-2.6373,0-1.0162-.1373-1.8979-.4116-2.645-.2744-.7469-.681-1.3262-1.2196-1.7379Z" fill="none"/><path d="M7.104,5.6101c0-.5793.1371-1.029.4116-1.3491s.7571-.4802,1.4483-.4802c.2947,0,.574.0255.8384.0762.2642.051.4929.1018.686.1525l.8233-3.5368c-.2847-.0812-.7294-.1803-1.3341-.2972-.6047-.1167-1.2728-.1754-2.0046-.1754-1.0671,0-2.0199.2034-2.8583.6098-.8386.4065-1.4993,1.0164-1.982,1.8294-.4828.8132-.7242,1.8346-.7242,3.0642v1.2348H0v3.5673h2.4086v13.4764h4.6955v-13.4764h3.3995v-3.5673h-3.3995v-1.1281Z" fill="#0f1925"/><path d="M33.3808,7.8891c-.676-.4624-1.4459-.8054-2.3096-1.029-.8639-.2234-1.7683-.3354-2.7135-.3354-1.362,0-2.5588.2058-3.5903.6175-1.0315.4116-1.8725.9961-2.523,1.7532-.3151.3668-.579.767-.7939,1.1993v-3.4175c-.2134-.061-.4549-.1041-.7242-.1296-.2692-.0253-.5258-.0381-.7697-.0381-.9452,0-1.7836.2721-2.5154.8156-.7318.5439-1.2554,1.3442-1.5702,2.401h-.1831v-2.988h-4.5581v17.0437h4.7107v-9.6347c0-.691.1548-1.3035.465-1.837.3098-.5335.7392-.9502,1.2881-1.2501.5489-.2996,1.1636-.4497,1.8446-.4497.3355,0,.6987.0228,1.0899.0686.2454.0287.4538.063.6332.1017-.091.2586-.1679.5265-.228.8054l4.3753.3506c.1624-.5691.4955-1.039.9986-1.4102.5031-.3708,1.1763-.5564,2.0199-.5564.8026,0,1.4254.1932,1.8675.5793.4421.3864.6631.9299.6631,1.6312v.0762c0,.3559-.1397.6277-.4192.8156-.2797.1882-.7191.3277-1.3188.4193-.5997.0914-1.3925.1829-2.378.2743-.8536.0815-1.6617.2237-2.424.4268-.7621.2035-1.4431.5031-2.0428.8995-.5997.3963-1.0723.9123-1.4178,1.5473-.3455.6353-.5182,1.4307-.5182,2.3858,0,1.1182.2439,2.0531.7318,2.8051.4876.7523,1.1608,1.3187,2.0199,1.6998.8587.3812,1.8267.5717,2.904.5717.8434,0,1.5854-.1143,2.2257-.343.6405-.2287,1.1891-.5436,1.6465-.9452.4573-.4013.8233-.8713,1.0976-1.4101h.1221v2.3781h4.4971v-11.4945c0-1.0061-.1982-1.8751-.5945-2.6068-.3963-.7318-.9326-1.3288-1.6083-1.7913ZM30.8884,17.6992c0,.5896-.1502,1.1205-.4497,1.5931-.3.4726-.7165.8487-1.2502,1.1281-.5334.2797-1.146.4193-1.837.4193-.7318,0-1.3315-.1677-1.7988-.5031-.4676-.3354-.7013-.8232-.7013-1.4635,0-.4471.1144-.8206.3431-1.1206.2287-.2996.5511-.5385.9679-.7164.4168-.1778.9044-.3073,1.4636-.3888.254-.0404.5387-.0838.8536-.1296.315-.0457.6302-.0991.9452-.16.315-.061.6023-.132.8613-.2135.2592-.0812.4597-.1676.6023-.2591v1.8141Z" fill="#0f1925"/><path d="M42.91,10.8009c.5434-.3911,1.1815-.5869,1.9133-.5869.5792,0,1.0873.117,1.5244.3506.4368.2339.7874.564,1.0518.9909.2642.4269.4368.9249.5184,1.494h4.4515c-.061-1.321-.417-2.4696-1.0673-3.4453-.6505-.9756-1.532-1.7326-2.6449-2.2714-1.1128-.5385-2.4114-.808-3.895-.808-1.728,0-3.2166.3711-4.4668,1.1129-1.2499.7419-2.213,1.7736-2.8888,3.0947-.676,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7279.3355,3.2497,1.0062,4.5658.6708,1.3162,1.6312,2.3476,2.8812,3.0947,1.2502.7469,2.744,1.1205,4.4821,1.1205,1.5244,0,2.8404-.2771,3.9484-.8309,1.1076-.5538,1.9765-1.3262,2.6067-2.3172.6302-.9909.9807-2.1366,1.052-3.4377h-4.4515c-.1321.9048-.4778,1.6136-1.0365,2.1267-.5591.5134-1.2452.7698-2.058.7698-.7318,0-1.3698-.2032-1.9133-.6097-.5439-.4064-.9657-.996-1.2654-1.7684-.2997-.7722-.4497-1.6972-.4497-2.7746s.15-1.9945.4497-2.7517c.2997-.757.7215-1.3313,1.2654-1.7227Z" fill="#0f1925"/><polygon points="59.2611 19.8792 67.0815 9.8328 67.0815 6.7381 53.3462 6.7381 53.3462 10.5188 61.4107 10.5188 61.4107 10.6408 53.0718 20.9616 53.0718 23.7818 67.3714 23.7818 67.3714 20.0011 59.2611 20.0011 59.2611 19.8792" fill="#0f1925"/><rect x="68.7445" y="1.0672" width="4.7105" height="22.7147" fill="#0f1925"/><path d="M88.2286,8.6818c-.7318-.7164-1.5854-1.2551-2.5612-1.6158-.9755-.3607-2.0275-.5413-3.1556-.5413-1.667,0-3.1175.3711-4.3524,1.1129-1.2349.7419-2.1901,1.7736-2.8659,3.0947-.6762,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7988.3377,3.3564,1.0139,4.6725.6758,1.3163,1.6486,2.3301,2.9193,3.0413,1.2702.7115,2.7796,1.0672,4.5276,1.0672,1.4025,0,2.6374-.216,3.7045-.6479s1.9386-1.0366,2.6146-1.8141c.6758-.7776,1.1205-1.6896,1.3339-2.7365l-4.36-.2896c-.1524.4168-.3839.7724-.6936,1.0672-.3102.2948-.6784.5183-1.1052.6708-.4268.1524-.9047.2287-1.4331.2287-.7623,0-1.4357-.1754-2.0199-.526-.5846-.3506-1.0394-.8536-1.3644-1.5092-.2927-.5895-.4523-1.2887-.4817-2.0961h11.6103v-1.2806c0-1.4532-.2034-2.7212-.6097-3.8036-.4065-1.0824-.9757-1.9818-1.7075-2.6984ZM80.5835,10.5799c.5334-.3556,1.1863-.5335,1.9588-.5335s1.4202.1753,1.9438.5259c.5232.3506.9171.8461,1.1813,1.4864.1829.4431.2982.9437.3545,1.494h-7.0657c.0534-.5595.1867-1.0677.3999-1.5245.2845-.6097.6936-1.0923,1.2273-1.4482Z" fill="#0f1925"/><path d="M102.4835,1.0672v8.5522h-.1371c-.2034-.4673-.5031-.9399-.8994-1.4177-.3963-.4776-.9147-.8766-1.5549-1.1968-.6405-.3201-1.4383-.4802-2.3935-.4802-1.2401,0-2.3835.3228-3.4301.9681-1.047.6455-1.8854,1.6186-2.5154,2.9193-.6302,1.3011-.9452,2.927-.9452,4.8784,0,1.8903.305,3.4887.9147,4.7944.6097,1.3061,1.4381,2.2943,2.4849,2.9651,1.0468.6709,2.2204,1.0062,3.5216,1.0062.9147,0,1.6894-.1525,2.3249-.4573.635-.305,1.156-.6884,1.5625-1.151.4063-.4624.7165-.9273.9299-1.3949h.2134v2.7288h4.6497V1.0672h-4.726ZM102.1711,17.9126c-.2797.7523-.686,1.3392-1.2196,1.7608-.5336.4218-1.1815.6326-1.9438.6326s-1.41-.2134-1.9436-.6402-.9376-1.0188-1.212-1.7761c-.2744-.757-.4116-1.6285-.4116-2.6144s.1371-1.8523.4116-2.5992c.2744-.747.6758-1.334,1.2044-1.7608.5284-.4268,1.1789-.6402,1.9512-.6402.7623,0,1.4126.2058,1.9514.6173.5387.4117.9452.991,1.2196,1.7379.2742.747.4116,1.6288.4116,2.645,0,1.0061-.1399,1.8854-.4192,2.6373Z" fill="#0f1925"/><circle cx="113.1907" cy="18.7881" r="4.9939" fill="url(#linear-gradient)"/></g></svg>',oK=`
972
972
  .fraczled-sdk-root {
973
973
  width: 100%;
974
974
  height: 100%;
@@ -10928,7 +10928,7 @@ endobj\r
10928
10928
  var c = l.getContext("2d");
10929
10929
  c.fillStyle = "#fff", c.fillRect(0, 0, l.width, l.height);
10930
10930
  var d = { ignoreMouse: !0, ignoreAnimation: !0, ignoreDimensions: !0 }, p = this;
10931
- return (Br.canvg ? Promise.resolve(Br.canvg) : import("./index.es-CDlHpWdc.js")).catch(function(g) {
10931
+ return (Br.canvg ? Promise.resolve(Br.canvg) : import("./index.es-C1ffE3jt.js")).catch(function(g) {
10932
10932
  return Promise.reject(new Error("Could not load canvg: " + g));
10933
10933
  }).then(function(g) {
10934
10934
  return g.default ? g.default : g;
@@ -13310,15 +13310,7 @@ const Da = () => Nb("(max-width: 767px)"), Ub = ({
13310
13310
  className: `md:hidden ${I ? "p-3" : "p-2"} hover:bg-gray-100 rounded-full text-slate-600`
13311
13311
  },
13312
13312
  /* @__PURE__ */ s.createElement(q9, { size: I ? 22 : 20 })
13313
- ), /* @__PURE__ */ s.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ s.createElement(
13314
- "input",
13315
- {
13316
- type: "text",
13317
- value: e,
13318
- onChange: (ie) => i(ie.target.value),
13319
- className: "font-bold text-lg text-slate-800 hover:border-gray-300 border border-transparent rounded px-2 -ml-1 focus:border-slate-500 focus:outline-none bg-transparent transition-all w-40 sm:w-64 md:w-auto hidden sm:block"
13320
- }
13321
- ))), /* @__PURE__ */ s.createElement("div", { className: "hidden md:flex flex-1 min-w-0 items-center" }, /* @__PURE__ */ s.createElement("div", { className: "w-full overflow-x-auto overflow-y-visible" }, /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-3 px-2 min-w-max mx-auto" }, g))), /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-1 md:gap-3 shrink-0 flex-1 justify-end" }, Oe ? /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-1 md:gap-3" }, we.map(ze)) : /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("div", { className: "md:hidden relative order-last ml-1", ref: re }, /* @__PURE__ */ s.createElement(
13313
+ )), /* @__PURE__ */ s.createElement("div", { className: "hidden md:flex flex-1 min-w-0 items-center" }, /* @__PURE__ */ s.createElement("div", { className: "w-full" }, g)), /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-1 md:gap-3 shrink-0 justify-end" }, Oe ? /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-1 md:gap-3" }, we.map(ze)) : /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("div", { className: "md:hidden relative order-last ml-1", ref: re }, /* @__PURE__ */ s.createElement(
13322
13314
  "button",
13323
13315
  {
13324
13316
  onClick: () => X(!O),
@@ -13451,7 +13443,7 @@ const Da = () => Nb("(max-width: 767px)"), Ub = ({
13451
13443
  className: "md:hidden fixed left-0 right-0 border-t border-gray-100 bg-white/95 backdrop-blur-sm shadow-lg z-[50]",
13452
13444
  style: { top: "calc(56px + env(safe-area-inset-top))" }
13453
13445
  },
13454
- /* @__PURE__ */ s.createElement("div", { className: "overflow-x-auto overflow-y-visible" }, /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-3 px-3 py-2 min-w-max" }, g))
13446
+ /* @__PURE__ */ s.createElement("div", { className: "px-3 py-2" }, /* @__PURE__ */ s.createElement("div", { className: "w-full" }, g))
13455
13447
  )
13456
13448
  );
13457
13449
  };
@@ -24732,7 +24724,7 @@ const Jc = 10, yx = 8, xx = 10, ta = (e, t, r) => Math.min(r, Math.max(t, e)), z
24732
24724
  crop: gs(ct.width, ct.height, lt, or)
24733
24725
  }), o(ct.id);
24734
24726
  };
24735
- return /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-2 px-2 h-full animate-in fade-in zoom-in-95 duration-200 whitespace-nowrap" }, /* @__PURE__ */ s.createElement("span", { className: "text-sm font-semibold text-slate-500 mr-2" }, "2 selected"), /* @__PURE__ */ s.createElement("div", { className: "h-4 w-px bg-gray-300 mx-2" }), /* @__PURE__ */ s.createElement(
24727
+ return /* @__PURE__ */ s.createElement("div", { className: "flex flex-wrap items-center gap-2 px-2 animate-in fade-in zoom-in-95 duration-200 w-full md:justify-center" }, /* @__PURE__ */ s.createElement("span", { className: "text-sm font-semibold text-slate-500 mr-2" }, "2 selected"), /* @__PURE__ */ s.createElement("div", { className: "h-4 w-px bg-gray-300 mx-2" }), /* @__PURE__ */ s.createElement(
24736
24728
  "button",
24737
24729
  {
24738
24730
  onClick: Me,
@@ -24876,7 +24868,7 @@ const Jc = 10, yx = 8, xx = 10, ta = (e, t, r) => Math.min(r, Math.max(t, e)), z
24876
24868
  "div",
24877
24869
  {
24878
24870
  ref: C,
24879
- className: "flex items-center gap-3 md:gap-4 px-1 md:px-2 animate-in fade-in zoom-in-95 duration-200 h-full whitespace-nowrap"
24871
+ className: "flex flex-wrap items-center gap-2 md:gap-4 px-1 md:px-2 animate-in fade-in zoom-in-95 duration-200 w-full md:justify-center"
24880
24872
  },
24881
24873
  ke && /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("div", { className: "flex items-center gap-2 border-r border-gray-200 pr-4 flex-shrink-0" }, /* @__PURE__ */ s.createElement("div", { className: "relative group" }, /* @__PURE__ */ s.createElement(
24882
24874
  "button",
@@ -31793,7 +31785,7 @@ const Y0 = () => Math.random().toString(36).substring(2, 9), Pp = {
31793
31785
  });
31794
31786
  const Do = tl(), No = Do ? 4096 : 8192, OA = Do ? 16777216 : 67108864, qt = Math.max(lo, ho), xo = No / qt, As = Math.sqrt(OA / (lo * ho)), pr = Math.min(zn, xo, As);
31795
31787
  if (pr < zn && (console.warn(`Clamped export pixel ratio from ${zn.toFixed(2)} to ${pr.toFixed(2)} for memory safety.`), zn = Math.max(0.1, pr)), Jr === "canvas") {
31796
- const { capturePageCanvas: _n } = await import("./canvasExportPipeline-D__JC6Ww.js"), Vo = B.pages.find((Wo) => Wo.id === Ze);
31788
+ const { capturePageCanvas: _n } = await import("./canvasExportPipeline-CT57uj_4.js"), Vo = B.pages.find((Wo) => Wo.id === Ze);
31797
31789
  if (!Vo)
31798
31790
  throw new Error(`Page ${Ze} not found for canvas export`);
31799
31791
  return { kind: "canvas", value: await _n({
@@ -32425,7 +32417,7 @@ class LS extends s.Component {
32425
32417
  ))) : this.props.children;
32426
32418
  }
32427
32419
  }
32428
- const MS = "https://cdn.tailwindcss.com", _S = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap", DS = ".our-editor-sdk { font-family: 'Inter', sans-serif; }", HS = "fraczled-sdk-loader-styles", PS = 3500, TS = 220, OS = "1.30.55", RS = '<svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 118.1846 24.1172"><defs><linearGradient id="linear-gradient" x1="109.7684" y1="15.3657" x2="116.6286" y2="22.226" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#99d1a7"/><stop offset="1" stop-color="#8fd4f0"/></linearGradient></defs><g id="Layer_1-2"><path d="M86.0219,13.5526c-.0564-.5503-.1717-1.0508-.3545-1.494-.2642-.6402-.6581-1.1357-1.1813-1.4864-.5236-.3506-1.1715-.5259-1.9438-.5259s-1.4254.1779-1.9588.5335c-.5336.3559-.9428.8385-1.2273,1.4482-.2133.4568-.3465.965-.3999,1.5245h7.0657Z" fill="none"/><path d="M29.4248,16.3577c-.315.0609-.6302.1143-.9452.16-.315.0458-.5997.0892-.8536.1296-.5591.0815-1.0468.211-1.4636.3888-.4168.1779-.7392.4168-.9679.7164-.2287.3-.3431.6735-.3431,1.1206,0,.6402.2337,1.1281.7013,1.4635.4674.3354,1.0671.5031,1.7988.5031.691,0,1.3036-.1396,1.837-.4193.5336-.2794.9502-.6555,1.2502-1.1281.2995-.4726.4497-1.0035.4497-1.5931v-1.8141c-.1426.0914-.3431.1779-.6023.2591-.259.0815-.5463.1525-.8613.2135Z" fill="none"/><path d="M100.9591,10.8924c-.5389-.4116-1.1891-.6173-1.9514-.6173-.7723,0-1.4228.2134-1.9512.6402-.5286.4268-.9299,1.0138-1.2044,1.7608-.2744.7469-.4116,1.6136-.4116,2.5992s.1371,1.8575.4116,2.6144c.2744.7573.6784,1.3492,1.212,1.7761s1.1815.6402,1.9436.6402,1.4102-.2108,1.9438-.6326c.5336-.4216.94-1.0085,1.2196-1.7608.2792-.752.4192-1.6312.4192-2.6373,0-1.0162-.1373-1.8979-.4116-2.645-.2744-.7469-.681-1.3262-1.2196-1.7379Z" fill="none"/><path d="M7.104,5.6101c0-.5793.1371-1.029.4116-1.3491s.7571-.4802,1.4483-.4802c.2947,0,.574.0255.8384.0762.2642.051.4929.1018.686.1525l.8233-3.5368c-.2847-.0812-.7294-.1803-1.3341-.2972-.6047-.1167-1.2728-.1754-2.0046-.1754-1.0671,0-2.0199.2034-2.8583.6098-.8386.4065-1.4993,1.0164-1.982,1.8294-.4828.8132-.7242,1.8346-.7242,3.0642v1.2348H0v3.5673h2.4086v13.4764h4.6955v-13.4764h3.3995v-3.5673h-3.3995v-1.1281Z" fill="#0f1925"/><path d="M33.3808,7.8891c-.676-.4624-1.4459-.8054-2.3096-1.029-.8639-.2234-1.7683-.3354-2.7135-.3354-1.362,0-2.5588.2058-3.5903.6175-1.0315.4116-1.8725.9961-2.523,1.7532-.3151.3668-.579.767-.7939,1.1993v-3.4175c-.2134-.061-.4549-.1041-.7242-.1296-.2692-.0253-.5258-.0381-.7697-.0381-.9452,0-1.7836.2721-2.5154.8156-.7318.5439-1.2554,1.3442-1.5702,2.401h-.1831v-2.988h-4.5581v17.0437h4.7107v-9.6347c0-.691.1548-1.3035.465-1.837.3098-.5335.7392-.9502,1.2881-1.2501.5489-.2996,1.1636-.4497,1.8446-.4497.3355,0,.6987.0228,1.0899.0686.2454.0287.4538.063.6332.1017-.091.2586-.1679.5265-.228.8054l4.3753.3506c.1624-.5691.4955-1.039.9986-1.4102.5031-.3708,1.1763-.5564,2.0199-.5564.8026,0,1.4254.1932,1.8675.5793.4421.3864.6631.9299.6631,1.6312v.0762c0,.3559-.1397.6277-.4192.8156-.2797.1882-.7191.3277-1.3188.4193-.5997.0914-1.3925.1829-2.378.2743-.8536.0815-1.6617.2237-2.424.4268-.7621.2035-1.4431.5031-2.0428.8995-.5997.3963-1.0723.9123-1.4178,1.5473-.3455.6353-.5182,1.4307-.5182,2.3858,0,1.1182.2439,2.0531.7318,2.8051.4876.7523,1.1608,1.3187,2.0199,1.6998.8587.3812,1.8267.5717,2.904.5717.8434,0,1.5854-.1143,2.2257-.343.6405-.2287,1.1891-.5436,1.6465-.9452.4573-.4013.8233-.8713,1.0976-1.4101h.1221v2.3781h4.4971v-11.4945c0-1.0061-.1982-1.8751-.5945-2.6068-.3963-.7318-.9326-1.3288-1.6083-1.7913ZM30.8884,17.6992c0,.5896-.1502,1.1205-.4497,1.5931-.3.4726-.7165.8487-1.2502,1.1281-.5334.2797-1.146.4193-1.837.4193-.7318,0-1.3315-.1677-1.7988-.5031-.4676-.3354-.7013-.8232-.7013-1.4635,0-.4471.1144-.8206.3431-1.1206.2287-.2996.5511-.5385.9679-.7164.4168-.1778.9044-.3073,1.4636-.3888.254-.0404.5387-.0838.8536-.1296.315-.0457.6302-.0991.9452-.16.315-.061.6023-.132.8613-.2135.2592-.0812.4597-.1676.6023-.2591v1.8141Z" fill="#0f1925"/><path d="M42.91,10.8009c.5434-.3911,1.1815-.5869,1.9133-.5869.5792,0,1.0873.117,1.5244.3506.4368.2339.7874.564,1.0518.9909.2642.4269.4368.9249.5184,1.494h4.4515c-.061-1.321-.417-2.4696-1.0673-3.4453-.6505-.9756-1.532-1.7326-2.6449-2.2714-1.1128-.5385-2.4114-.808-3.895-.808-1.728,0-3.2166.3711-4.4668,1.1129-1.2499.7419-2.213,1.7736-2.8888,3.0947-.676,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7279.3355,3.2497,1.0062,4.5658.6708,1.3162,1.6312,2.3476,2.8812,3.0947,1.2502.7469,2.744,1.1205,4.4821,1.1205,1.5244,0,2.8404-.2771,3.9484-.8309,1.1076-.5538,1.9765-1.3262,2.6067-2.3172.6302-.9909.9807-2.1366,1.052-3.4377h-4.4515c-.1321.9048-.4778,1.6136-1.0365,2.1267-.5591.5134-1.2452.7698-2.058.7698-.7318,0-1.3698-.2032-1.9133-.6097-.5439-.4064-.9657-.996-1.2654-1.7684-.2997-.7722-.4497-1.6972-.4497-2.7746s.15-1.9945.4497-2.7517c.2997-.757.7215-1.3313,1.2654-1.7227Z" fill="#0f1925"/><polygon points="59.2611 19.8792 67.0815 9.8328 67.0815 6.7381 53.3462 6.7381 53.3462 10.5188 61.4107 10.5188 61.4107 10.6408 53.0718 20.9616 53.0718 23.7818 67.3714 23.7818 67.3714 20.0011 59.2611 20.0011 59.2611 19.8792" fill="#0f1925"/><rect x="68.7445" y="1.0672" width="4.7105" height="22.7147" fill="#0f1925"/><path d="M88.2286,8.6818c-.7318-.7164-1.5854-1.2551-2.5612-1.6158-.9755-.3607-2.0275-.5413-3.1556-.5413-1.667,0-3.1175.3711-4.3524,1.1129-1.2349.7419-2.1901,1.7736-2.8659,3.0947-.6762,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7988.3377,3.3564,1.0139,4.6725.6758,1.3163,1.6486,2.3301,2.9193,3.0413,1.2702.7115,2.7796,1.0672,4.5276,1.0672,1.4025,0,2.6374-.216,3.7045-.6479s1.9386-1.0366,2.6146-1.8141c.6758-.7776,1.1205-1.6896,1.3339-2.7365l-4.36-.2896c-.1524.4168-.3839.7724-.6936,1.0672-.3102.2948-.6784.5183-1.1052.6708-.4268.1524-.9047.2287-1.4331.2287-.7623,0-1.4357-.1754-2.0199-.526-.5846-.3506-1.0394-.8536-1.3644-1.5092-.2927-.5895-.4523-1.2887-.4817-2.0961h11.6103v-1.2806c0-1.4532-.2034-2.7212-.6097-3.8036-.4065-1.0824-.9757-1.9818-1.7075-2.6984ZM80.5835,10.5799c.5334-.3556,1.1863-.5335,1.9588-.5335s1.4202.1753,1.9438.5259c.5232.3506.9171.8461,1.1813,1.4864.1829.4431.2982.9437.3545,1.494h-7.0657c.0534-.5595.1867-1.0677.3999-1.5245.2845-.6097.6936-1.0923,1.2273-1.4482Z" fill="#0f1925"/><path d="M102.4835,1.0672v8.5522h-.1371c-.2034-.4673-.5031-.9399-.8994-1.4177-.3963-.4776-.9147-.8766-1.5549-1.1968-.6405-.3201-1.4383-.4802-2.3935-.4802-1.2401,0-2.3835.3228-3.4301.9681-1.047.6455-1.8854,1.6186-2.5154,2.9193-.6302,1.3011-.9452,2.927-.9452,4.8784,0,1.8903.305,3.4887.9147,4.7944.6097,1.3061,1.4381,2.2943,2.4849,2.9651,1.0468.6709,2.2204,1.0062,3.5216,1.0062.9147,0,1.6894-.1525,2.3249-.4573.635-.305,1.156-.6884,1.5625-1.151.4063-.4624.7165-.9273.9299-1.3949h.2134v2.7288h4.6497V1.0672h-4.726ZM102.1711,17.9126c-.2797.7523-.686,1.3392-1.2196,1.7608-.5336.4218-1.1815.6326-1.9438.6326s-1.41-.2134-1.9436-.6402-.9376-1.0188-1.212-1.7761c-.2744-.757-.4116-1.6285-.4116-2.6144s.1371-1.8523.4116-2.5992c.2744-.747.6758-1.334,1.2044-1.7608.5284-.4268,1.1789-.6402,1.9512-.6402.7623,0,1.4126.2058,1.9514.6173.5387.4117.9452.991,1.2196,1.7379.2742.747.4116,1.6288.4116,2.645,0,1.0061-.1399,1.8854-.4192,2.6373Z" fill="#0f1925"/><circle cx="113.1907" cy="18.7881" r="4.9939" fill="url(#linear-gradient)"/></g></svg>', KS = `
32420
+ const MS = "https://cdn.tailwindcss.com", _S = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap", DS = ".our-editor-sdk { font-family: 'Inter', sans-serif; }", HS = "fraczled-sdk-loader-styles", PS = 3500, TS = 220, OS = "1.30.56", RS = '<svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 118.1846 24.1172"><defs><linearGradient id="linear-gradient" x1="109.7684" y1="15.3657" x2="116.6286" y2="22.226" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#99d1a7"/><stop offset="1" stop-color="#8fd4f0"/></linearGradient></defs><g id="Layer_1-2"><path d="M86.0219,13.5526c-.0564-.5503-.1717-1.0508-.3545-1.494-.2642-.6402-.6581-1.1357-1.1813-1.4864-.5236-.3506-1.1715-.5259-1.9438-.5259s-1.4254.1779-1.9588.5335c-.5336.3559-.9428.8385-1.2273,1.4482-.2133.4568-.3465.965-.3999,1.5245h7.0657Z" fill="none"/><path d="M29.4248,16.3577c-.315.0609-.6302.1143-.9452.16-.315.0458-.5997.0892-.8536.1296-.5591.0815-1.0468.211-1.4636.3888-.4168.1779-.7392.4168-.9679.7164-.2287.3-.3431.6735-.3431,1.1206,0,.6402.2337,1.1281.7013,1.4635.4674.3354,1.0671.5031,1.7988.5031.691,0,1.3036-.1396,1.837-.4193.5336-.2794.9502-.6555,1.2502-1.1281.2995-.4726.4497-1.0035.4497-1.5931v-1.8141c-.1426.0914-.3431.1779-.6023.2591-.259.0815-.5463.1525-.8613.2135Z" fill="none"/><path d="M100.9591,10.8924c-.5389-.4116-1.1891-.6173-1.9514-.6173-.7723,0-1.4228.2134-1.9512.6402-.5286.4268-.9299,1.0138-1.2044,1.7608-.2744.7469-.4116,1.6136-.4116,2.5992s.1371,1.8575.4116,2.6144c.2744.7573.6784,1.3492,1.212,1.7761s1.1815.6402,1.9436.6402,1.4102-.2108,1.9438-.6326c.5336-.4216.94-1.0085,1.2196-1.7608.2792-.752.4192-1.6312.4192-2.6373,0-1.0162-.1373-1.8979-.4116-2.645-.2744-.7469-.681-1.3262-1.2196-1.7379Z" fill="none"/><path d="M7.104,5.6101c0-.5793.1371-1.029.4116-1.3491s.7571-.4802,1.4483-.4802c.2947,0,.574.0255.8384.0762.2642.051.4929.1018.686.1525l.8233-3.5368c-.2847-.0812-.7294-.1803-1.3341-.2972-.6047-.1167-1.2728-.1754-2.0046-.1754-1.0671,0-2.0199.2034-2.8583.6098-.8386.4065-1.4993,1.0164-1.982,1.8294-.4828.8132-.7242,1.8346-.7242,3.0642v1.2348H0v3.5673h2.4086v13.4764h4.6955v-13.4764h3.3995v-3.5673h-3.3995v-1.1281Z" fill="#0f1925"/><path d="M33.3808,7.8891c-.676-.4624-1.4459-.8054-2.3096-1.029-.8639-.2234-1.7683-.3354-2.7135-.3354-1.362,0-2.5588.2058-3.5903.6175-1.0315.4116-1.8725.9961-2.523,1.7532-.3151.3668-.579.767-.7939,1.1993v-3.4175c-.2134-.061-.4549-.1041-.7242-.1296-.2692-.0253-.5258-.0381-.7697-.0381-.9452,0-1.7836.2721-2.5154.8156-.7318.5439-1.2554,1.3442-1.5702,2.401h-.1831v-2.988h-4.5581v17.0437h4.7107v-9.6347c0-.691.1548-1.3035.465-1.837.3098-.5335.7392-.9502,1.2881-1.2501.5489-.2996,1.1636-.4497,1.8446-.4497.3355,0,.6987.0228,1.0899.0686.2454.0287.4538.063.6332.1017-.091.2586-.1679.5265-.228.8054l4.3753.3506c.1624-.5691.4955-1.039.9986-1.4102.5031-.3708,1.1763-.5564,2.0199-.5564.8026,0,1.4254.1932,1.8675.5793.4421.3864.6631.9299.6631,1.6312v.0762c0,.3559-.1397.6277-.4192.8156-.2797.1882-.7191.3277-1.3188.4193-.5997.0914-1.3925.1829-2.378.2743-.8536.0815-1.6617.2237-2.424.4268-.7621.2035-1.4431.5031-2.0428.8995-.5997.3963-1.0723.9123-1.4178,1.5473-.3455.6353-.5182,1.4307-.5182,2.3858,0,1.1182.2439,2.0531.7318,2.8051.4876.7523,1.1608,1.3187,2.0199,1.6998.8587.3812,1.8267.5717,2.904.5717.8434,0,1.5854-.1143,2.2257-.343.6405-.2287,1.1891-.5436,1.6465-.9452.4573-.4013.8233-.8713,1.0976-1.4101h.1221v2.3781h4.4971v-11.4945c0-1.0061-.1982-1.8751-.5945-2.6068-.3963-.7318-.9326-1.3288-1.6083-1.7913ZM30.8884,17.6992c0,.5896-.1502,1.1205-.4497,1.5931-.3.4726-.7165.8487-1.2502,1.1281-.5334.2797-1.146.4193-1.837.4193-.7318,0-1.3315-.1677-1.7988-.5031-.4676-.3354-.7013-.8232-.7013-1.4635,0-.4471.1144-.8206.3431-1.1206.2287-.2996.5511-.5385.9679-.7164.4168-.1778.9044-.3073,1.4636-.3888.254-.0404.5387-.0838.8536-.1296.315-.0457.6302-.0991.9452-.16.315-.061.6023-.132.8613-.2135.2592-.0812.4597-.1676.6023-.2591v1.8141Z" fill="#0f1925"/><path d="M42.91,10.8009c.5434-.3911,1.1815-.5869,1.9133-.5869.5792,0,1.0873.117,1.5244.3506.4368.2339.7874.564,1.0518.9909.2642.4269.4368.9249.5184,1.494h4.4515c-.061-1.321-.417-2.4696-1.0673-3.4453-.6505-.9756-1.532-1.7326-2.6449-2.2714-1.1128-.5385-2.4114-.808-3.895-.808-1.728,0-3.2166.3711-4.4668,1.1129-1.2499.7419-2.213,1.7736-2.8888,3.0947-.676,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7279.3355,3.2497,1.0062,4.5658.6708,1.3162,1.6312,2.3476,2.8812,3.0947,1.2502.7469,2.744,1.1205,4.4821,1.1205,1.5244,0,2.8404-.2771,3.9484-.8309,1.1076-.5538,1.9765-1.3262,2.6067-2.3172.6302-.9909.9807-2.1366,1.052-3.4377h-4.4515c-.1321.9048-.4778,1.6136-1.0365,2.1267-.5591.5134-1.2452.7698-2.058.7698-.7318,0-1.3698-.2032-1.9133-.6097-.5439-.4064-.9657-.996-1.2654-1.7684-.2997-.7722-.4497-1.6972-.4497-2.7746s.15-1.9945.4497-2.7517c.2997-.757.7215-1.3313,1.2654-1.7227Z" fill="#0f1925"/><polygon points="59.2611 19.8792 67.0815 9.8328 67.0815 6.7381 53.3462 6.7381 53.3462 10.5188 61.4107 10.5188 61.4107 10.6408 53.0718 20.9616 53.0718 23.7818 67.3714 23.7818 67.3714 20.0011 59.2611 20.0011 59.2611 19.8792" fill="#0f1925"/><rect x="68.7445" y="1.0672" width="4.7105" height="22.7147" fill="#0f1925"/><path d="M88.2286,8.6818c-.7318-.7164-1.5854-1.2551-2.5612-1.6158-.9755-.3607-2.0275-.5413-3.1556-.5413-1.667,0-3.1175.3711-4.3524,1.1129-1.2349.7419-2.1901,1.7736-2.8659,3.0947-.6762,1.3212-1.0139,2.856-1.0139,4.6039,0,1.7988.3377,3.3564,1.0139,4.6725.6758,1.3163,1.6486,2.3301,2.9193,3.0413,1.2702.7115,2.7796,1.0672,4.5276,1.0672,1.4025,0,2.6374-.216,3.7045-.6479s1.9386-1.0366,2.6146-1.8141c.6758-.7776,1.1205-1.6896,1.3339-2.7365l-4.36-.2896c-.1524.4168-.3839.7724-.6936,1.0672-.3102.2948-.6784.5183-1.1052.6708-.4268.1524-.9047.2287-1.4331.2287-.7623,0-1.4357-.1754-2.0199-.526-.5846-.3506-1.0394-.8536-1.3644-1.5092-.2927-.5895-.4523-1.2887-.4817-2.0961h11.6103v-1.2806c0-1.4532-.2034-2.7212-.6097-3.8036-.4065-1.0824-.9757-1.9818-1.7075-2.6984ZM80.5835,10.5799c.5334-.3556,1.1863-.5335,1.9588-.5335s1.4202.1753,1.9438.5259c.5232.3506.9171.8461,1.1813,1.4864.1829.4431.2982.9437.3545,1.494h-7.0657c.0534-.5595.1867-1.0677.3999-1.5245.2845-.6097.6936-1.0923,1.2273-1.4482Z" fill="#0f1925"/><path d="M102.4835,1.0672v8.5522h-.1371c-.2034-.4673-.5031-.9399-.8994-1.4177-.3963-.4776-.9147-.8766-1.5549-1.1968-.6405-.3201-1.4383-.4802-2.3935-.4802-1.2401,0-2.3835.3228-3.4301.9681-1.047.6455-1.8854,1.6186-2.5154,2.9193-.6302,1.3011-.9452,2.927-.9452,4.8784,0,1.8903.305,3.4887.9147,4.7944.6097,1.3061,1.4381,2.2943,2.4849,2.9651,1.0468.6709,2.2204,1.0062,3.5216,1.0062.9147,0,1.6894-.1525,2.3249-.4573.635-.305,1.156-.6884,1.5625-1.151.4063-.4624.7165-.9273.9299-1.3949h.2134v2.7288h4.6497V1.0672h-4.726ZM102.1711,17.9126c-.2797.7523-.686,1.3392-1.2196,1.7608-.5336.4218-1.1815.6326-1.9438.6326s-1.41-.2134-1.9436-.6402-.9376-1.0188-1.212-1.7761c-.2744-.757-.4116-1.6285-.4116-2.6144s.1371-1.8523.4116-2.5992c.2744-.747.6758-1.334,1.2044-1.7608.5284-.4268,1.1789-.6402,1.9512-.6402.7623,0,1.4126.2058,1.9514.6173.5387.4117.9452.991,1.2196,1.7379.2742.747.4116,1.6288.4116,2.645,0,1.0061-.1399,1.8854-.4192,2.6373Z" fill="#0f1925"/><circle cx="113.1907" cy="18.7881" r="4.9939" fill="url(#linear-gradient)"/></g></svg>', KS = `
32429
32421
  .fraczled-sdk-root {
32430
32422
  width: 100%;
32431
32423
  height: 100%;
@@ -1,4 +1,4 @@
1
- import { q as Da, _ as Va, u as il } from "./index-Dx68n4Os.js";
1
+ import { q as Da, _ as Va, u as il } from "./index-DHugiMpj.js";
2
2
  var fn = {}, cn = {}, cr, vn;
3
3
  function Q() {
4
4
  if (vn) return cr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fraczled/sdk",
3
- "version": "1.30.55",
3
+ "version": "1.30.56",
4
4
  "description": "Fraczled Design Studio SDK - Embed a powerful design editor in your application",
5
5
  "scripts": {
6
6
  "build": "vite build --config ../vite.sdk.config.ts && vite build --config ../vite.sdk.umd.config.ts && node ../scripts/copy-sdk-icons.mjs",