1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,582894,e=>{"use strict";let t=(0,e.i(475254).default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);e.s(["default",0,t])},783395,e=>{"use strict";let t=(0,e.i(475254).default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);e.s(["default",0,t])},384282,e=>{"use strict";let t=(0,e.i(475254).default)("chart-bar-stacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);e.s(["default",0,t])},102040,367118,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);e.s(["default",0,i],102040);let a=(0,t.default)("chart-line",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);e.s(["default",0,a],367118)},827468,853298,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("chart-pie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);e.s(["default",0,i],827468);let a=(0,t.default)("chart-scatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);e.s(["default",0,a],853298)},664659,e=>{"use strict";var t=e.i(631171);e.s(["ChevronDown",()=>t.default])},655900,e=>{"use strict";var t=e.i(399219);e.s(["ChevronUp",()=>t.default])},339402,e=>{"use strict";let t=(0,e.i(475254).default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);e.s(["default",0,t])},195083,553789,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);e.s(["default",0,i],195083);let a=(0,t.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);e.s(["default",0,a],553789)},991124,e=>{"use strict";let t=(0,e.i(475254).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["default",0,t])},484023,e=>{"use strict";let t=(0,e.i(475254).default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);e.s(["default",0,t])},440160,e=>{"use strict";var t=e.i(484023);e.s(["Download",()=>t.default])},251485,e=>{"use strict";let t=(0,e.i(475254).default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);e.s(["default",0,t])},738125,e=>{"use strict";let t=(0,e.i(475254).default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);e.s(["default",0,t])},469582,744989,260345,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);e.s(["default",0,i],469582);let a=(0,t.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}
1]]);e.s(["default",0,a],744989);let s=(0,t.default)("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);e.s(["default",0,s],260345)},296497,e=>{"use strict";let t=(0,e.i(475254).default)("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);e.s(["default",0,t])},879664,e=>{"use strict";let t=(0,e.i(475254).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);e.s(["default",0,t])},192986,e=>{"use strict";let t=(0,e.i(475254).default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);e.s(["default",0,t])},775854,e=>{"use strict";let t=(0,e.i(475254).default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);e.s(["default",0,t])},526943,e=>{"use strict";let t=(0,e.i(475254).default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);e.s(["default",0,t])},335653,e=>{"use strict";let t=(0,e.i(475254).default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);e.s(["default",0,t])},57489,e=>{"use strict";let t=(0,e.i(475254).default)("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]);e.s(["default",0,t])},824678,e=>{"use strict";let t=(0,e.i(475254).default)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);e.s(["default",0,t])},140906,e=>{"use strict";let t=(0,e.i(475254).default)("lock-keyhole-open",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);e.s(["default",0,t])},242744,e=>{"use strict";let t=(0,e.i(475254).default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);e.s(["default",0,t])},923960,756217,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);e.s(["default",0,i],923960);let a=(0,t.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]);e.s(["default",0,a],756217)},642310,e=>{"use strict";let t=(0,e.i(475254).default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["default",0,t])},299023,e=>{"use strict";var t=e.i(642310);e.s(["Minus",()=>t.default])},640761,e=>{"use strict";let t=(0,e.i(475254).default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);e.s(["default",0,t])},574320,947875,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);e.s(["default",0,i],574320);let a=(0,t.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);e.s(["default",0,a],947875)},603908,e=>{"use strict";let t=(0,e.i(475254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["default",0,t])},107233,e=>{"use strict";var t=e.i(603908);e.s(["Plus",()=>t.default])},349191,e=>{"use strict";let t=(0,e.i(475254).default)("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);e.s(["default",0,t])},555436,54943,e=>{"use strict";let t=(0,e.i(475254).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);e.s(["default",0,t],54943),e.s(["Search",0,t],555436)},584526,e=>{"use strict";let t=(0,e.i(475254).default)("shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);e.s(["default",0,t])},814091,98740,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}
1],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);e.s(["default",0,i],814091);let a=(0,t.default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);e.s(["default",0,a],98740)},649582,761911,e=>{"use strict";var t=e.i(814091);e.s(["SlidersHorizontal",()=>t.default],649582);var i=e.i(98740);e.s(["Users",()=>i.default],761911)},576144,e=>{"use strict";let t=(0,e.i(475254).default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}
1],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["default",0,t])},497140,e=>{"use strict";let t=(0,e.i(475254).default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);e.s(["default",0,t])},406940,e=>{"use strict";let t=(0,e.i(475254).default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);e.s(["default",0,t])},977482,e=>{"use strict";let t=(0,e.i(475254).default)("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);e.s(["default",0,t])},393392,57522,778835,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("text-align-center",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]]);e.s(["default",0,i],393392);let a=(0,t.default)("text-align-end",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}
1]]);e.s(["default",0,a],57522);let s=(0,t.default)("text-align-justify",[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]]);e.s(["default",0,s],778835)},636368,e=>{"use strict";let t=(0,e.i(475254).default)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);e.s(["default",0,t])},612329,e=>{"use strict";let t=(0,e.i(475254).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["default",0,t])},582458,e=>{"use strict";let t=(0,e.i(475254).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["default",0,t])},851228,e=>{"use strict";let t=(0,e.i(475254).default)("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]);e.s(["default",0,t])},20623,e=>{"use strict";let t=(0,e.i(475254).default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);e.s(["default",0,t])},268586,e=>{"use strict";let t=(0,e.i(475254).default)("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);e.s(["default",0,t])},37727,e=>{"use strict";var t=e.i(841947);e.s(["X",()=>t.default])},500187,363689,e=>{"use strict";var t=e.i(475254);let i=(0,t.default)("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"}]]);e.s(["default",0,i],500187);let a=(0,t.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);e.s(["default",0,a],363689)},781623,9979,285957,e=>{"use strict";let t;var i=e.i(843476),a=e.i(500932),s=e.i(154920),r=e.i(271645),l=e.i(268586),l=l,o=e.i(349191),o=o,n=e.i(440160),d=e.i(923960),d=d,c=e.i(756217),c=c,u=e.i(500187),u=u,h=e.i(363689),h=h,p=e.i(667719),m=e.i(708584),f=e.i(510096),y=e.i(209165);function x(e){return e+1}let g="/api/v1/studio/library";e.i(785269);var b=e.i(322831),j=e.i(317230);function v({library:e,value:t,item:a,children:s,initiallyOpen:l=!1}){let{t:o}=(0,b.useTranslation)(),[n,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(!1);return(0,i.jsxs)("details",{className:"studio-property-section",open:l,children:[(0,i.jsx)("summary",{children:o(a?"studio.manageLibraryItem":"studio.saveToLibrary")}),(0,i.jsxs)("form",{onSubmit:async i=>{i.preventDefault();let s=i.currentTarget,r=new FormData(s);d(!0),u(!1);try{await e.save({...t,...a&&"brand"===t.kind?{data:{colors:String(r.get("colors")).split(",").map(e=>e.trim()),font:String(r.get("font")),logo_url:String(r.get("logo")||"")}}:{},title:String(r.get("title")),folder_id:String(r.get("folder")||"")||null,shared:r.has("shared")},a?.id),s.closest("details")?.removeAttribute("open")}catch{u(!0)}finally{d(!1)}},children:[(0,i.jsxs)("fieldset",{disabled:n,children:[(0,i.jsxs)("label",{children:[o("studio.itemName"),(0,i.jsx)("input",{name:"title",required:!0,maxLength:120,defaultValue:t.title})]}),"folder"!==t.kind&&(0,i.jsxs)("label",{children:[o("studio.folder"),(0,i.jsxs)("select",{name:"folder",defaultValue:t.folder_id||"",children:[(0,i.jsx)("option",{value:"",children:o("studio.libraryRoot")}),e.items.filter(e=>"folder"===e.kind).map(e=>(0,i.jsxs)("option",{value:e.id,children:[e.title,e.shared?` \xb7 ${o("studio.organizationLibrary")}`:""]},e.id))]})]}),(0,i.jsxs)("label",{className:"studio-check",children:[(0,i.jsx)("input",{name:"shared",type:"checkbox",defaultChecked:t.shared}),o("studio.shareLibraryItem")]}),(0,i.jsx)("p",{className:"studio-help",children:o("studio.libraryPrivacy")}),s,a&&"brand"===t.kind&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("label",{children:[o("studio.brandColors"),(0,i.jsx)("input",{name:"colors",required:!0,defaultValue:t.data.colors?.join(", ")})]}),(0,i.jsxs)("label",{children:[o("studio.fontFamily"),(0,i.jsx)("select",{name:"font",defaultValue:t.data.font,children:j.ST
1UDIO_FONTS.map(e=>(0,i.jsx)("option",{children:e},e))})]}),(0,i.jsxs)("label",{children:[o("studio.logoUrl"),(0,i.jsx)("input",{name:"logo",type:"url",defaultValue:t.data.logo_url})]})]}),(0,i.jsx)("button",{type:"submit",children:o("studio.save")}),a&&(0,i.jsx)("button",{type:"button",onClick:async()=>{if(window.confirm(o("studio.removeLibraryConfirm"))){d(!0);try{await e.remove(a.id)}catch{u(!0)}finally{d(!1)}}},children:o("studio.removeFromLibrary")})]}),c&&(0,i.jsx)("p",{role:"alert",children:o("studio.libraryFailed")})]})]})}function k(e){let t,s,l,o,n,d,c,u,h,p,m,f,y,x,g,k,N,A,E,D,T,$,F,z=(0,a.c)(59),{library:O,onApply:I,onLogo:P}=e,{t:L}=(0,b.useTranslation)(),[_,R]=(0,r.useState)("#2452ff"),[H,U]=(0,r.useState)("Arial"),[q,V]=(0,r.useState)("");return z[0]!==L?(t=L("studio.savedBrands"),z[0]=L,z[1]=t):t=z[1],z[2]!==t?(s=(0,i.jsx)("strong",{children:t}),z[2]=t,z[3]=s):s=z[3],z[4]!==O||z[5]!==I||z[6]!==P||z[7]!==L?(l=O.items.filter(M).map(e=>(0,i.jsxs)("div",{className:"studio-library-item",children:[(0,i.jsx)("strong",{children:e.title}),e.data.logo_url&&(0,i.jsx)("button",{onClick:()=>P(e.data.logo_url,e.title),children:(0,i.jsx)("img",{className:"studio-brand-logo",src:e.data.logo_url,alt:L("studio.brandLogo")})}),(0,i.jsx)("div",{className:"studio-swatches",children:e.data.colors?.map(C)}),(0,i.jsx)("button",{onClick:()=>I({accent:e.data.colors?.[0],font:e.data.font}),children:L("studio.applyBrand")}),e.editable&&(0,i.jsx)(v,{library:O,item:e,value:e})]},e.id)),z[4]=O,z[5]=I,z[6]=P,z[7]=L,z[8]=l):l=z[8],z[9]!==L?(o=L("studio.brandColors"),z[9]=L,z[10]=o):o=z[10],z[11]===Symbol.for("react.memo_cache_sentinel")?(n=e=>R(e.target.value),z[11]=n):n=z[11],z[12]!==_?(d=(0,i.jsx)("input",{value:_,onChange:n,placeholder:"#2452ff, #ffffff"}),z[12]=_,z[13]=d):d=z[13],z[14]!==o||z[15]!==d?(c=(0,i.jsxs)("label",{children:[o,d]}),z[14]=o,z[15]=d,z[16]=c):c=z[16],z[17]!==L?(u=L("studio.fontFamily"),z[17]=L,z[18]=u):u=z[18],z[19]===Symbol.for("react.memo_cache_sentinel")?(p=e=>U(e.target.value),h=j.STUDIO_FONTS.map(S),z[19]=h,z[20]=p):(h=z[19],p=z[20]),z[21]!==H?(m=(0,i.jsx)("select",{value:H,onChange:p,children:h}),z[21]=H,z[22]=m):m=z[22],z[23]!==m||z[24]!==u?(f=(0,i.jsxs)("label",{children:[u,m]}),z[23]=m,z[24]=u,z[25]=f):f=z[25],z[26]!==L?(y=L("studio.logoUrl"),z[26]=L,z[27]=y):y=z[27],z[28]===Symbol.for("react.memo_cache_sentinel")?(x=e=>V(e.target.value),z[28]=x):x=z[28],z[29]!==q?(g=(0,i.jsx)("input",{type:"url",value:q,onChange:x}),z[29]=q,z[30]=g):g=z[30],z[31]!==y||z[32]!==g?(k=(0,i.jsxs)("label",{children:[y,g]}),z[31]=y,z[32]=g,z[33]=k):k=z[33],z[34]!==L?(N=L("studio.newBrand"),z[34]=L,z[35]=N):N=z[35],z[36]!==_?(A=_.split(",").map(w),z[36]=_,z[37]=A):A=z[37],z[38]!==H||z[39]!==q||z[40]!==A?(E={colors:A,font:H,logo_url:q},z[38]=H,z[39]=q,z[40]=A,z[41]=E):E=z[41],z[42]!==N||z[43]!==E?(D={kind:"brand",title:N,folder_id:null,shared:!1,data:E},z[42]=N,z[43]=E,z[44]=D):D=z[44],z[45]!==O||z[46]!==D?(T=(0,i.jsx)(v,{library:O,value:D}),z[45]=O,z[46]=D,z[47]=T):T=z[47],z[48]!==O.error||z[49]!==L?($=O.error&&(0,i.jsx)("p",{role:"alert",children:L("studio.libraryFailed")}),z[48]=O.error,z[49]=L,z[50]=$):$=z[50],z[51]!==f||z[52]!==k||z[53]!==s||z[54]!==T||z[55]!==$||z[56]!==l||z[57]!==c?(F=(0,i.jsxs)("div",{className:"studio-property-section",children:[s,l,c,f,k,T,$]}),z[51]=f,z[52]=k,z[53]=s,z[54]=T,z[55]=$,z[56]=l,z[57]=c,z[58]=F):F=z[58],F}function w(e){return e.trim()}function S(e){return(0,i.jsx)("option",{children:e},e)}function C(e){return(0,i.jsx)("span",{style:{background:e},title:e},e)}function M(e){return"brand"===e.kind}function N({library:e,model:t,onApply:a}){let{t:s}=(0,b.useTranslation)(),[l,o]=(0,r.useState)(!1),[n,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(null);return"html"!==t.sourceFormat&&["document","presentation","design","spreadsheet","whiteboard"].includes(t.family)?(0,i.jsxs)("div",{className:"studio-property-section",children:[(0,i.jsx)("strong",{children:s("studio.savedTemplates")}),(0,i.jsx)("p",{className:"studio-help",children:s("studio.savedTemplateHint")}),(0,i.jsx)(v,{library:e,value:{kind:"template",title:s("studio.newTemplate"),folder_id:null,
1shared:!1,data:{model:t}}}),e.items.filter(e=>"template"===e.kind&&(e.data.family||e.data.model?.family)===t.family).map(t=>(0,i.jsxs)("div",{className:"studio-library-item",children:[(0,i.jsx)("strong",{children:t.title}),(0,i.jsx)("button",{disabled:n,onClick:async()=>{d(!0),o(!1);try{let i=await e.get(t.id);a((0,j.validateStructured)(i.data.model))}catch{o(!0)}finally{d(!1)}},children:s("studio.startFromTemplate")}),t.editable&&(0,i.jsx)("button",{disabled:n,onClick:async()=>{d(!0);try{u(await e.get(t.id))}catch{o(!0)}finally{d(!1)}},children:s("studio.manageLibraryItem")}),t.editable&&(0,i.jsx)("button",{disabled:n,onClick:async()=>{if(window.confirm(s("studio.removeLibraryConfirm")))try{await e.remove(t.id)}catch{o(!0)}},children:s("studio.removeFromLibrary")})]},t.id)),c&&e.items.some(e=>e.id===c.id)&&(0,i.jsx)(v,{initiallyOpen:!0,library:e,item:c,value:c},c.id),(l||e.error)&&(0,i.jsx)("p",{role:"alert",children:s("studio.libraryFailed")})]}):null}var A=e.i(972080),E=e.i(555436),D=e.i(283086);function T(e){let t,s,l,o,n,d,c,u,h,p,m,f,x,g=(0,a.c)(46),{model:v,onChange:k,onLogo:w}=e,{t:S}=(0,b.useTranslation)(),[C,M]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1);if(g[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{let e=!1;return(0,y.apiFetch)("/api/v1/org").then(F).then(t=>{e||M({...t.brand_kit,logo_url:t.logo_url})}).catch(()=>{e||A(!0)}),()=>{e=!0}},s=[],g[0]=t,g[1]=s):(t=g[0],s=g[1]),(0,r.useEffect)(t,s),N){let e,t;return g[2]!==S?(e=S("studio.brandUnavailable"),g[2]=S,g[3]=e):e=g[3],g[4]!==e?(t=(0,i.jsx)("p",{role:"alert",className:"studio-help",children:e}),g[4]=e,g[5]=t):t=g[5],t}if(!C){let e,t;return g[6]!==S?(e=S("studio.loading"),g[6]=S,g[7]=e):e=g[7],g[8]!==e?(t=(0,i.jsx)("p",{role:"status",className:"studio-help",children:e}),g[8]=e,g[9]=t):t=g[9],t}g[10]!==S?(l=S("studio.brandHint"),g[10]=S,g[11]=l):l=g[11],g[12]!==l?(o=(0,i.jsx)("p",{className:"studio-help",children:l}),g[12]=l,g[13]=o):o=g[13],g[14]!==C.logo_url||g[15]!==w||g[16]!==S?(n=C.logo_url&&(0,i.jsxs)("div",{className:"studio-tools",children:[(0,i.jsx)("img",{className:"studio-brand-logo",src:C.logo_url,alt:S("studio.brandLogo")}),(0,i.jsx)("button",{onClick:()=>w(C.logo_url,S("studio.brandLogo")),children:S("studio.insertLogo")})]}),g[14]=C.logo_url,g[15]=w,g[16]=S,g[17]=n):n=g[17],g[18]!==C.colors?(d=C.colors?.map($),g[18]=C.colors,g[19]=d):d=g[19],g[20]!==d?(c=(0,i.jsx)("div",{className:"studio-swatches",children:d}),g[20]=d,g[21]=c):c=g[21],g[22]!==C.font?(u=(0,i.jsx)("p",{children:C.font}),g[22]=C.font,g[23]=u):u=g[23];let E=!C.colors?.length;return g[24]!==C.colors?.[0]||g[25]!==C.font||g[26]!==v||g[27]!==k?(h=()=>k({...v,brand:{accent:C.colors?.[0],font:j.STUDIO_FONTS.includes(C.font||"")?C.font:"Arial"}}),g[24]=C.colors?.[0],g[25]=C.font,g[26]=v,g[27]=k,g[28]=h):h=g[28],g[29]!==S?(p=S("studio.applyBrand"),g[29]=S,g[30]=p):p=g[30],g[31]!==h||g[32]!==p||g[33]!==E?(m=(0,i.jsx)("button",{disabled:E,onClick:h,children:p}),g[31]=h,g[32]=p,g[33]=E,g[34]=m):m=g[34],g[35]!==v||g[36]!==k||g[37]!==S?(f=v.brand&&(0,i.jsx)("button",{onClick:()=>k({...v,brand:void 0}),children:S("studio.resetBrand")}),g[35]=v,g[36]=k,g[37]=S,g[38]=f):f=g[38],g[39]!==m||g[40]!==f||g[41]!==o||g[42]!==n||g[43]!==c||g[44]!==u?(x=(0,i.jsxs)("div",{className:"studio-property-section",children:[o,n,c,u,m,f]}),g[39]=m,g[40]=f,g[41]=o,g[42]=n,g[43]=c,g[44]=u,g[45]=x):x=g[45],x}function $(e){return(0,i.jsx)("span",{style:{background:e},title:e},e)}function F(e){return e.json()}function z({library:e,model:t,assets:a,images:s,onChange:l,disabled:o}){let{t:n}=(0,b.useTranslation)(),d=(0,p.useStudioTools)(),c=(e,t)=>d.insert.current?.(e,t),[u,h]=(0,r.useState)(""),[y,x]=(0,r.useState)(""),[g,j]=(0,r.useState)(""),[w,S]=(0,r.useState)(""),C=async(e,t)=>{let i=d.insert.current;S("");try{i?.(await e(),t)}catch{S(n("studio.imageFailed"))}};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(p.StudioPanel,{tool:"uploads",children:[(0,i.jsxs)("fieldset",{disabled:o||s.busy,children:[(0,i.jsxs)("label",{className:"studio-search poSearch",children:[(0,i.jsx)(E.Search,{size:16}),(0,i.jsx)("input",{className:"rlBare",placeholder:n("studio.searchAssets"),"aria-label":n("studio.searchAssets"),value:y,onChange:e=>x(e.target.value)})]}),(0,i.jsxs)("label",{className:"studio-import studio-upload-button",children:[(0,i.jsx)(A.ImagePlus,{size:18}),n("studio.uploadImage"),(0,i.jsx)("input",{className:"rlBare",type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",onChange:e=>{let t=e.target.files?.[0];e.target.value="",(0,f.isImageFile)(t)?C(()=>s.upload(t),t.name):S(n("studio.imageFailed"))}})]}),(0,i.jsxs)("label",{children:[n("studio.folder"),(0,i.jsxs)("select",{value:u,onChange:e=>h(e.target.value),children:[(0,i.jsx)("option",{value:"",children:n("studio.allAssets")}),e.items.filter(e=>"folder"===e.kind).map(e=>(0,i.jsx)("option",{value:e.id,children:e.title},e.id))]})]}),(0,i.jsx)(v,{library:e,value:{kind:"folder",title:n("studio.newFolder"),folder_id:null,
1shared:!1,data:{}}}),u&&e.items.find(e=>e.id===u)?.editable&&(0,i.jsx)(v,{library:e,item:e.items.find(e=>e.id===u),value:e.items.find(e=>e.id===u)}),(0,i.jsx)("p",{className:"studio-help",children:n("studio.assetDragHint")}),(0,i.jsx)("div",{className:"studio-asset-grid",children:a.filter(t=>t.title.toLowerCase().includes(y.toLowerCase())&&(!u||e.items.some(e=>"asset"===e.kind&&e.data.url===t.url&&e.folder_id===u))).map(t=>{let a=e.items.find(e=>"asset"===e.kind&&e.data.url===t.url);return(0,i.jsxs)("div",{className:"studio-library-asset",children:[(0,i.jsxs)("button",{draggable:!o,onDragStart:e=>{e.dataTransfer.setData(m.ASSET_MIME,t.url),e.dataTransfer.effectAllowed="copy"},onClick:()=>c(t.url,t.title),children:[(0,i.jsx)("img",{src:t.url,alt:""}),(0,i.jsx)("span",{children:t.title})]}),(!a||a.editable)&&/^https:\/\//.test(t.url)&&(0,i.jsx)(v,{library:e,item:a,value:a||{kind:"asset",title:t.title.slice(0,120),folder_id:u||null,shared:!1,data:{url:t.url}}})]},t.url)})}),e.error&&(0,i.jsxs)("p",{role:"alert",children:[n("studio.libraryFailed"),(0,i.jsx)("button",{onClick:e.reload,children:n("studio.retry")})]}),0===a.length&&(0,i.jsx)("p",{className:"studio-help",children:n("studio.noAssets")}),(0,i.jsxs)("div",{className:"studio-property-section",children:[(0,i.jsxs)("label",{children:[n("studio.imagePrompt"),(0,i.jsx)("textarea",{value:g,maxLength:600,onChange:e=>j(e.target.value)})]}),(0,i.jsxs)("button",{disabled:!g.trim()||s.busy||o,onClick:()=>void C(()=>s.generate(g,"16:9"),g),children:[(0,i.jsx)(D.Sparkles,{size:16}),n(s.busy?"studio.generating":"studio.generateImage")]})]})]}),w&&(0,i.jsx)("p",{role:"alert",className:"studio-notice",children:w})]}),(0,i.jsx)(p.StudioPanel,{tool:"brand",children:"html"===t.sourceFormat?(0,i.jsx)("p",{className:"studio-help",children:n("studio.originalDesign")}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(T,{model:t,onChange:l,onLogo:c}),(0,i.jsx)(k,{library:e,onApply:e=>l({...t,brand:e}),onLogo:c})]})})]})}var O=e.i(991124),O=O,I=e.i(107233),P=e.i(727612),L=e.i(242744),L=L,_=e.i(140906),_=_,R=e.i(750570),H=e.i(655900),U=e.i(664659),q=e.i(851228),q=q,V=e.i(453901),J=e.i(279743),B=e.i(330325),K=e.i(430796);function X(e){let t=Math.min(...e.map(e=>e.x)),i=Math.min(...e.map(e=>e.y));return{x:t,y:i,w:Math.max(...e.map(e=>e.x+(e.w??500)))-t,h:Math.max(...e.map(e=>e.y+(e.h??80)))-i}}function G(e,t,i,a,s,r=1200,l=675){let o=e.filter((e,i)=>t.includes(i)&&!e.locked);if(!o.length)return e;let n=X(o);return s&&(i=10*Math.round((n.x+i)/10)-n.x,a=10*Math.round((n.y+a)/10)-n.y),i=Math.max(-n.x,Math.min(r-n.x-n.w,i)),a=Math.max(-n.y,Math.min(l-n.y-n.h,a)),e.map((e,s)=>t.includes(s)&&!e.locked?{...e,x:e.x+i,y:e.y+a}:e)}function W(e,t,i){let a=e.map((e,t)=>({block:e,i:t})).filter(({block:e,i})=>t.includes(i)&&!e.locked).sort((e,t)=>e.block[i]-t.block[i]);if(a.length<3)return e;let s=X(a.map(e=>e.block)),r="x"===i?"w":"h",l="x"===i?500:80,o=(s[r]-a.reduce((e,{block:t})=>e+(t[r]??l),0))/(a.length-1),n=s[i],d=[...e];for(let{block:e,i:t}of a)d[t]={...e,[i]:n},n+=(e[r]??l)+o;return d}function Y({model:e,title:t,onChange:a,images:s,assets:l,zoom:o,collaboration:n}){let{t:d}=(0,b.useTranslation)(),c=(0,p.useStudioTools)(),[u,h]=(0,r.useState)(0),[y,x]=(0,r.useState)([]),[g,v]=(0,r.useState)(!0),[k,w]=(0,r.useState)(null),[S,C]=(0,r.useState)(null),[M,N]=(0,r.useState)(""),E=(0,r.useRef)(null),[D,T]=(0,r.useState)(1200),$=(0,r.useRef)(null),F=(0,r.useRef)(null),z=(0,r.useRef)(null),Z=(0,r.useRef)(null),Q=(0,r.useRef)(null),ee=(0,r.useRef)([]),et=e.deck;try{et=(0,j.layoutDeck)(e)}catch{}let ei=(et={...et,slides:et.slides.map((e,t)=>({...e,id:e.id||`page-${t}`,blocks:e.blocks.map((e,i)=>({...e,id:e.id||`page-${t}-element-${i}`}))}))}).width??1200,ea=et.height??675;(0,r.useEffect)(()=>{let e=E.current;if(!e)return;let t=new ResizeObserver(()=>{let t=getComputedStyle(e),i=e.clientWidth-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight),a=e.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom);i>0&&a>0&&T(Math.min(i,a*ei/ea))});return t.observe(e),()=>t.disconnect()},[ei,ea]);let es=Math.min(u,et.slides.length-1),er=et.slides[es],el=k||er.blocks,eo=y.filter(e=>el[e]),en=el[eo[0]],ed=t=>a({...e,freeform:!0,deck:{...et,slides:t}}),ec=e=>ed(et.slides.map((t,i)=>i===es?{...t,blocks:e}:t)),eu=e=>ec(el.map((t,i)=>eo.includes(i)&&!t.locked?{...t,...e}:t)),eh=(0,r.useRef)({model:e,deck:et,index:es,onChange:a});eh.current={model:e,deck:et,index:es,onChange:a};let ep=e=>{let t=eh.current,i=er.id?t.deck.slides.findIndex(e=>e.id===er.id):es;if(i<0||!t.deck.slides[i])return;let a=eo.map(e=>el[e].id);t.onChange({...t.model,freeform:!0,deck:{...t.deck,slides:t.deck.slides.map((t,s)=>s===i?{...t,blocks:t.blocks.map((t,i)=>(t.id?a.includes(t.id):eo.includes(i))&&!t.locked?{...t,props:{...t.props,...e}}:t)}:t)}})},em=(e,t,i=80,a=150,s=er.id,r=es)=>{let l=eh.current,o=s?l.deck.slides.findIndex(e=>e.id===s):r;if(o<0||!l.deck.slides[o])return;let n=Math.min(480,l.deck.width??1200),d=Math.min(320,l.deck.height??675),u={id:crypto.randomUUID(),type:"image",x:Math.min(i,(l.deck.width??1200)-n),y:Math.min(a,(l.deck.height??675)-d),w:n,h:d,props:{src:e,alt:t}};l.onChange({...l.model,freeform:!0,deck:{...l.deck,slides:l.deck.slides.map((e,t)=>t===o?{...e,blocks:[...e.blocks,u]}:e)}}),l.index===o&&x([l.deck.slides[o].blocks.length]),c.open("properties")};(0,r.useEffect)(()=>(c.insert.current=(e,t)=>
1em(e,t),()=>{c.insert.current=null}));let ef=(e,t=!1)=>{let i=el[e].groupId,a=el.flatMap((t,a)=>a===e||i&&t.groupId===i?[a]:[]),s=t?[...new Set([...eo,...a])]:a;return x(s),c.open("properties"),s},ey=()=>{ec(el.filter((e,t)=>!eo.includes(t)||e.locked)),x([])},ex=(e=el.filter((e,t)=>eo.includes(t)))=>{let t=new Map,i=e.map(e=>(e.groupId&&!t.has(e.groupId)&&t.set(e.groupId,crypto.randomUUID()),{...structuredClone(e),id:crypto.randomUUID(),groupId:e.groupId?t.get(e.groupId):void 0,locked:!1})),a=G(i,i.map((e,t)=>t),20,20,!1,ei,ea);ec([...el,...a]),x(a.map((e,t)=>el.length+t))},eg=e=>{w(e),$.current?.contentWindow?.postMessage({type:"studio:positions",blocks:e},"*")},eb=(e,t,i)=>{if(0!==e.button||el[t].locked||null!==S)return;e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId);let a=eo.includes(t)?eo:ef(t,e.shiftKey);z.current={x:e.clientX,y:e.clientY,scale:ei/F.current.getBoundingClientRect().width,blocks:structuredClone(el),indices:a,handle:i}},ej=e=>{let t=z.current;if(!t||!e.currentTarget.hasPointerCapture(e.pointerId))return;let i=(e.clientX-t.x)*t.scale,a=(e.clientY-t.y)*t.scale;if(!t.handle)return void eg(G(t.blocks,t.indices,i,a,g,ei,ea));let s=t.indices[0],r=t.blocks[s],l={x:r.x,y:r.y,w:r.w??500,h:r.h??80},{x:o,y:n,w:d,h:c}=l;if(t.handle.includes("e")&&(d=Math.max(24,Math.min(ei-o,d+i))),t.handle.includes("s")&&(c=Math.max(24,Math.min(ea-n,c+a))),t.handle.includes("w")&&(o=Math.max(0,Math.min(l.x+l.w-24,o+i)),d=l.x+l.w-o),t.handle.includes("n")&&(n=Math.max(0,Math.min(l.y+l.h-24,n+a)),c=l.y+l.h-n),e.shiftKey){let e=l.w/l.h;d=(c=Math.min(ea-n,d/e))*e}eg(t.blocks.map((e,t)=>t===s?{...e,x:o,y:n,w:d,h:c}:e))},ev=(e=!1)=>{let t=z.current;t&&(!e&&k&&JSON.stringify(k)!==JSON.stringify(t.blocks)?ec(k):$.current?.contentWindow?.postMessage({type:"studio:positions",blocks:t.blocks},"*"),z.current=null,w(null))},ek=(e,t)=>{if(e===t||t<0||t>=et.slides.length)return;let i=[...et.slides];i.splice(t,0,i.splice(e,1)[0]),ed(i),h(t),x([])},ew=(e,t)=>{if(e===t||t<0||t>=el.length||el[e].locked)return;let i=[...el];i.splice(t,0,i.splice(e,1)[0]),ec(i),x([t])},eS="";try{eS=(0,K.prepareArtifactHtml)((0,j.renderStructured)({...e,freeform:!0,deck:{...et,slides:[er]}},"",t,!0).replace("</head>","<style>.slide{margin:0!important}body{overflow:hidden}</style></head>").replace("</body>","<script>addEventListener('message',function(e){if(e.source!==parent||e.data?.type!=='studio:positions'||!Array.isArray(e.data.blocks))return;e.data.blocks.forEach(function(b,i){var el=document.querySelector('[data-studio-element=\"'+i+'\"]');if(!el)return;['x','y','w','h'].forEach(function(k){if(Number.isFinite(b[k]))el.style[{x:'left',y:'top',w:'width',h:'height'}[k]]=b[k]+'px'})})})</script></body>"))}catch{}let eC=eo.length?X(eo.map(e=>el[e])):null,eM=n?.provider,eN=n?.anchor,eA=er.id,eE=en?.id;return(0,r.useEffect)(()=>{if(eM&&eN)return eM.awareness?.setLocalStateField("selection",eE?{kind:"canvas",page:eA,block:eE}:null),eN.current=e=>{if("canvas"!==e.kind)return;let t=eh.current,i=t.deck.slides.findIndex(t=>t.id===e.page);if(i<0)return;let a=t.deck.slides[i].blocks.findIndex(t=>t.id===e.block);h(i),x(a<0?[]:[a]),F.current?.scrollIntoView({block:"nearest"})},()=>{eN.current=null}},[eM,eN,eA,eE]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"studio-tools",role:"toolbar","aria-label":d("studio.slides"),children:[(0,i.jsxs)("button",{onClick:()=>{x([]),c.open("properties")},children:[d("studio.pageSize")," · ",ei," à ",ea]}),(0,i.jsxs)("span",{children:[d("studio.slide")," ",es+1," / ",et.slides.length]}),(0,i.jsxs)("button",{onClick:()=>{let e=[...et.slides];e.splice(es+1,0,{id:crypto.randomUUID(),background:{},blocks:[]}),ed(e),h(es+1),x([])},children:[(0,i.jsx)(I.Plus,{size:16}),d("studio.addSlide")]}),(0,i.jsx)("button",{onClick:()=>{let e=[...et.slides];e.splice(es+1,0,{...structuredClone(er),id:crypto.randomUUID()}),ed(e),h(es+1),x([])},"aria-label":d("studio.duplicateSlide"),title:d("studio.duplicateSlide"),children:(0,i.jsx)(O.default,{size:16})}),(0,i.jsx)("button",{disabled:1===et.slides.length,onClick:()=>{ed(et.slides.filter((e,t)=>
1t!==es)),h(Math.max(0,es-1)),x([])},"aria-label":d("studio.deleteSlide"),title:d("studio.deleteSlide"),children:(0,i.jsx)(P.Trash2,{size:16})}),(0,i.jsxs)("label",{className:"studio-field studio-check",children:[(0,i.jsx)("input",{type:"checkbox",checked:g,onChange:e=>v(e.target.checked)}),d("studio.snap")]})]}),M&&(0,i.jsx)("p",{role:"alert",className:"studio-notice",children:M}),(0,i.jsx)("div",{className:"studio-canvas-scroll",ref:E,onKeyDown:e=>{if(!e.target.closest("textarea,input,[contenteditable=true]")){if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)&&eo.length){e.preventDefault();let t=e.shiftKey?10:1;ec(G(el,eo,"ArrowLeft"===e.key?-t:"ArrowRight"===e.key?t:0,"ArrowUp"===e.key?-t:"ArrowDown"===e.key?t:0,!1,ei,ea))}"Escape"===e.key&&(ev(!0),x([]),C(null)),["Delete","Backspace"].includes(e.key)&&eo.length&&(e.preventDefault(),ey()),(e.ctrlKey||e.metaKey)&&("d"===e.key.toLowerCase()&&(e.preventDefault(),ex()),"c"===e.key.toLowerCase()&&eo.length&&(e.preventDefault(),ee.current=structuredClone(el.filter((e,t)=>eo.includes(t)))),"v"===e.key.toLowerCase()&&ee.current.length&&(e.preventDefault(),ex(ee.current)),"a"===e.key.toLowerCase()&&(e.preventDefault(),x(el.map((e,t)=>t))))}},children:(0,i.jsxs)("div",{className:"studio-canvas",ref:F,style:{width:D*o/100,aspectRatio:`${ei}/${ea}`},onPointerDown:e=>{e.target===e.currentTarget&&x([])},onDragOver:e=>e.preventDefault(),onDrop:async e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(ei-Math.min(480,ei),(e.clientX-t.left)*ei/t.width)),a=Math.max(0,Math.min(ea-Math.min(320,ea),(e.clientY-t.top)*ea/t.height)),r=l.find(t=>t.url===e.dataTransfer.getData(m.ASSET_MIME)),o=e.dataTransfer.files[0];if(r)em(r.url,r.title,i,a);else if(o){if(!(0,f.isImageFile)(o))return void N(d("studio.imageFailed"));try{let e=await s.upload(o);em(e,o.name,i,a),N("")}catch{N(d("studio.imageFailed"))}}},children:[(0,i.jsx)("iframe",{ref:$,style:{width:ei,height:ea,transform:`scale(${D*o/100/ei})`},title:d("studio.canvas"),srcDoc:eS,sandbox:"allow-scripts"}),el.map((e,t)=>(0,i.jsx)("button",{"data-studio-select":!0,className:`studio-layer ${eo.includes(t)?"selected":""}${e.locked?" locked":""}`,style:{left:`${e.x/ei*100}%`,top:`${e.y/ea*100}%`,width:`${(e.w??500)/ei*100}%`,height:`${(e.h??80)/ea*100}%`,transform:`rotate(${e.rotation||0}deg)`},"aria-label":`${d("studio.element")} ${t+1}: ${String(e.props.text||e.props.alt||e.type).slice(0,50)}`,"aria-pressed":eo.includes(t),onClick:e=>ef(t,e.shiftKey),onDoubleClick:()=>{ef(t),e.locked||["image","chart","table","shape"].includes(e.type)||C(t)},onPointerDown:e=>eb(e,t),onPointerMove:ej,onPointerUp:()=>ev(),onPointerCancel:()=>ev(!0)},e.id||t)),eC&&1===eo.length&&!en?.locked&&null===S&&["nw","n","ne","e","se","s","sw","w"].map(e=>(0,i.jsx)("button",{className:`studio-resize-handle handle-${e}`,"aria-label":`${d("studio.resizeElement")} ${e}`,style:{left:`${(eC.x+(e.includes("w")?0:e.includes("e")?eC.w:eC.w/2))/ei*100}%`,top:`${(eC.y+(e.includes("n")?0:e.includes("s")?eC.h:eC.h/2))/ea*100}%`},onPointerDown:t=>eb(t,eo[0],e),onPointerMove:ej,onPointerUp:()=>ev(),onPointerCancel:()=>ev(!0)},e)),null!==S&&el[S]&&(0,i.jsx)("textarea",{autoFocus:!0,className:"studio-direct-text","aria-label":d("studio.text"),style:{left:`${el[S].x/ei*100}%`,top:`${el[S].y/ea*100}%`,width:`${(el[S].w??500)/ei*100}%`,height:`${(el[S].h??80)/ea*100}%`},value:String(el[S].props.text||""),onChange:e=>ep({text:e.target.value}),onBlur:()=>C(null),onKeyDown:e=>{"Escape"===e.key&&C(null)}})]})}),(0,i.jsx)("nav",{className:"studio-page-strip","aria-label":d("studio.slides"),children:et.slides.map((e,t)=>(0,i.jsxs)("button",{draggable:!0,"aria-current":t===es,onDragStart:()=>{Z.current=t},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),null!==Z.current&&ek(Z.current,t),Z.current=null},onKeyDown:e=>{e.altKey&&["ArrowLeft","ArrowRight"].includes(e.key)&&(e.preventDefault(),ek(t,t+("ArrowLeft"===e.key?-1:1)))},onClick:()=>{h(t),x([]),C(null)},children:[(0,i.jsx)("span",{children:t+1}),(0,i.jsx)("strong",{children:String(e.blocks.find(e=>"title"===e.type)?.props.text||d("studio.slide")).slice(0,32)})]},e.id||t))}),(0,i.jsx)(p.StudioPanel,{tool:"insert",children:(0,i.jsx)("div",{className:"studio-insert-grid",children:[["text",q.default],["image",A.ImagePlus],["chart",J.ChartColumn],["table",B.Table2],["shape",V.Shapes]].map(([e,t])=>(0,i.jsxs)("button",{onClick:()=>{var t;ec([...el,{...t={type:e,x:80,y:150,w:"text"===e?600:480,h:"text"===e?160:320,props:"text"===e?{text:d("studio.newText")}:"image"===e?{prompt:d("studio.newImage"),alt:d("studio.newImage"),aspect:"16:9"}:"chart"===e?{chart:structuredClone(f.DEFAULT_CHART)}:"table"===e?{rows:[["","",""],["","",""],["","",""]]}:{fill:"#d9e7e2"}},x:Math.min(t.x,ei-Math.min(t.w??500,ei)),y:Math.min(t.y,ea-Math.min(t.h??80,ea)),w:Math.min(t.w??500,ei),h:Math.min(t.h??80,ea),id:crypto.randomUUID()}]),x([el.length]),c.open("properties")},children:[(0,i.jsx)(t,{size:24}),d(`studio.add${e[0].toUpperCase()}${e.slice(1)}`)]},e))})}),(0,i.jsx)(p.StudioPanel,{tool:"layers",children:(0,i.jsx)("div",{className:"studio-outline",children:el.map((e,t)=>(0,i.jsxs)("div",{className:"studio-outline-row","data-selected":eo.includes(t),draggable:!e.locked,onDragStart:()=>{Q.current=t},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),null!==Q.current&&ew(Q.current,t),Q.current=null},children:[(0,i.jsx)(R.GripVertical,{size:14}),(0,i.jsx)("button",{onClick:e=>ef(t,e.shiftKey),children:String(e.props.text||e.props.alt||e.type).slice(0,50)}),(0,i.jsx)("button",{"aria-label":d(e.locked?"studio.unlock":"studio.lock"),onClick:()=>ec(el.map((e,i)=>i===t?{...e,locked:!e.locked}:e)),children:e.locked?(0,i.jsx)(L.default,{size:14}):(0,i.jsx)(_.default,{size:14})}),(0,i.jsx)("button",{"aria-label":d("studio.sendBackward"),disabled:0===t||e.locked,onClick:()=>ew(t,t-1),children:(0,i.jsx)(H.ChevronUp,{size:14})}),(0,i.jsx)("button",{"aria-label":d("studio.bringForward"),disabled:t===el.length-1||e.locked,onClick:()=>ew(t,t+1),children:(0,i.jsx)(U.ChevronDown,{size:14})})]},e.id||t))})}),(0,i.jsx)(p.StudioPanel,{tool:"properties",children:en?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"studio-tools",children:[(0,i.jsxs)("button",{onClick:()=>ex(),children:[(0,i.jsx)(O.default,{size:16}),d("studio.duplicateElement")]}),(0,i.jsxs)("button",{onClick:()=>ec(el.map((e,t)=>eo.includes(t)?{...e,locked:!en.locked}:e)),children:[en.locked?(0,i.jsx)(_.default,{size:16}):(0,i.jsx)(L.default,{size:16}),d(en.locked?"studio.unlock":"studio.lock")]}),(0,i.jsx)("button",{disabled:en.locked,onClick:ey,"aria-label":d("studio.deleteElement"),children:(0,i.jsx)(P.Trash2,{size:16})})]}),(0,i.jsxs)("fieldset",{disabled:!!en.locked,children:[1===eo.length&&(["chart","table","image","shape"].includes(en.type)?"image"===en.type?(0,i.jsx)(f.ImagePanel,{props:en.props,images:s,assets:l,t:d,onPatch:ep},en.id||eo[0]):"chart"===en.type?(0,i.jsx)(f.ChartEditor,{value:JSON.stringify(en.props.chart),onChange:e=>ep({chart:JSON.parse(e)})},en.id||eo[0]):"shape"===en.type?(0,i.jsxs)("label",{children:[d("studio.color"),(0,i.jsx)("input",{type:"color",value:String(en.props.fill||"#d9e7e2"),onChange:e=>ep({fill:e.target.value})})]}):(0,i.jsxs)("div",{className:"studio-table-editor",children:[(0,i.jsx)("table",{children:(0,i.jsx)("tbody",{children:en.props.rows.map((e,t)=>(0,i.jsx)("tr",{children:e.map((e,a)=>(0,i.jsx)("td",{children:(0,i.jsx)("input",{"aria-label":d("studio.cell",{row:t+1,column:a+1}
1),value:e,onChange:e=>ep({rows:en.props.rows.map((i,s)=>s===t?i.map((t,i)=>i===a?e.target.value:t):i)})})},a))},t))})}),(0,i.jsx)("button",{onClick:()=>ep({rows:[...en.props.rows,en.props.rows[0].map(()=>"")]}),children:d("studio.addRow")}),(0,i.jsx)("button",{onClick:()=>ep({rows:en.props.rows.map(e=>[...e,""])}),children:d("studio.addColumn")})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("label",{children:[d("studio.text"),(0,i.jsx)("textarea",{value:String(en.props.text||""),onChange:e=>ep({text:e.target.value})})]}),(0,i.jsxs)("label",{children:[d("studio.fontFamily"),(0,i.jsx)("select",{value:String(en.props.fontFamily||"Arial"),onChange:e=>ep({fontFamily:e.target.value}),children:j.STUDIO_FONTS.map(e=>(0,i.jsx)("option",{children:e},e))})]}),(0,i.jsxs)("div",{className:"studio-tools",children:[(0,i.jsx)("button",{"aria-pressed":Number(en.props.weight||("title"===en.type?700:400))>=600,onClick:()=>ep({weight:Number(en.props.weight||("title"===en.type?700:400))>=600?400:700}),children:d("studio.bold")}),(0,i.jsx)("button",{"aria-pressed":!!en.props.italic,onClick:()=>ep({italic:!en.props.italic}),children:d("studio.italic")}),(0,i.jsx)("button",{"aria-pressed":!!en.props.underline,onClick:()=>ep({underline:!en.props.underline}),children:d("studio.underline")})]}),(0,i.jsxs)("label",{children:[d("studio.fontSize"),(0,i.jsx)("input",{type:"number",min:12,max:160,value:Number(en.props.fontSize||24),onChange:e=>ep({fontSize:Number(e.target.value)})})]}),(0,i.jsxs)("label",{children:[d("studio.color"),(0,i.jsx)("input",{type:"color",value:String(en.props.color||"#172a27"),onChange:e=>ep({color:e.target.value})})]})]})),1===eo.length&&(0,i.jsx)("div",{className:"studio-geometry",children:["x","y","w","h"].map(e=>(0,i.jsxs)("label",{children:[d(`studio.${e}`),(0,i.jsx)("input",{type:"number",value:en[e]??("w"===e?500:80*("h"===e)),onChange:t=>eu({[e]:Number(t.target.value)})})]},e))}),1===eo.length&&!["chart","table"].includes(en.type)&&(0,i.jsxs)("label",{children:[d("studio.rotation"),(0,i.jsx)("input",{type:"number",min:-360,max:360,value:en.rotation||0,onChange:e=>eu({rotation:Math.max(-360,Math.min(360,Number(e.target.value)))})})]}),(0,i.jsxs)("div",{className:"studio-property-section",children:[(0,i.jsx)("strong",{children:d("studio.alignTo.label")}),(0,i.jsx)("div",{className:"studio-insert-grid",children:["left","center","right","top","middle","bottom"].map(e=>(0,i.jsx)("button",{onClick:()=>ec(function(e,t,i,a=1200,s=675){let r=e.filter((e,i)=>t.includes(i)&&!e.locked);if(!r.length)return e;let l=r.length>1?X(r):{x:0,y:0,w:a,h:s};return e.map((e,a)=>!t.includes(a)||e.locked?e:{...e,...["left","center","right"].includes(i)?{x:"left"===i?l.x:"right"===i?l.x+l.w-(e.w??500):l.x+(l.w-(e.w??500))/2}:{y:"top"===i?l.y:"bottom"===i?l.y+l.h-(e.h??80):l.y+(l.h-(e.h??80))/2}})}(el,eo,e,ei,ea)),children:d(`studio.alignTo.${e}`)},e))}),eo.length>2&&(0,i.jsxs)("div",{className:"studio-tools",children:[(0,i.jsx)("button",{onClick:()=>ec(W(el,eo,"x")),children:d("studio.distributeHorizontal")}),(0,i.jsx)("button",{onClick:()=>ec(W(el,eo,"y")),children:d("studio.distributeVertical")})]}),eo.length>1&&(0,i.jsx)("button",{onClick:()=>{let e=en.groupId?void 0:crypto.randomUUID();ec(el.map((t,i)=>eo.includes(i)?{...t,groupId:e}:t))},children:d(en.groupId?"studio.ungroup":"studio.group")})]})]})]}):(0,i.jsxs)("div",{children:[(0,i.jsxs)("form",{onSubmit:t=>{t.preventDefault();let i=new FormData(t.currentTarget);a({...e,version:2,freeform:!0,deck:(0,j.resizeDeck)(et,Number(i.get("width")),Number(i.get("height")))})},children:[(0,i.jsx)("strong",{children:d("studio.pageSize")}),(0,i.jsxs)("div",{className:"studio-geometry",children:[(0,i.jsxs)("label",{children:[d("studio.w"),(0,i.jsx)("input",{name:"width",type:"number",required:!0,min:320,max:2400,defaultValue:ei})]}),(0,i.jsxs)("label",{children:[d("studio.h"),(0,i.jsx)("input",{name:"height",type:"number",required:!0,min:320,max:2400,defaultValue:ea})]})]}),(0,i.jsx)("p",{className:"studio-help",children:d("studio.pageSizeHint")}),(0,i.jsx)("button",{type:"submit",children:d("studio.apply")})]},`${ei}-${ea}`),(0,i.jsx)("p",{className:"studio-help",children:d("studio.selectionHint")}),(0,i.jsxs)("label",{children:[d("studio.background"),(0,i.jsx)("input",{type:"color",value:String(er.background.color||j.TEMPLATES.find(t=>
1t.id===e.templateId)?.background||"#ffffff"),onChange:e=>ed(et.slides.map((t,i)=>i===es?{...t,background:{...t.background,color:e.target.value}}:t))})]}),(0,i.jsxs)("label",{children:[d("studio.notes"),(0,i.jsx)("textarea",{value:er.notes||"",maxLength:4e3,onChange:e=>ed(et.slides.map((t,i)=>i===es?{...t,notes:e.target.value}:t))})]})]})})]})}var Z=e.i(554293);let Q=e=>Array.from(e.querySelectorAll("main>section,body>section,h1,h2,h3,h4,h5,h6,p,li,td,th,span,a,strong,em,b,i,img,[data-chart]")).filter(e=>!e.parentElement?.closest("[data-chart],script,style")&&(e.matches("section,img,[data-chart]")||!e.children.length));function ee({model:e,source:t,title:a,onChange:s,images:l,assets:o,bound:n}){let{t:d}=(0,b.useTranslation)(),c=(0,p.useStudioTools)(),u=(0,r.useRef)(null),[h,m]=(0,r.useState)(null),[y,x]=(0,r.useState)(""),g=(0,r.useRef)(null),v=new DOMParser().parseFromString(t,"text/html"),k=Q(v),w=null===h?null:k[h],S=null;if(w?.hasAttribute("data-chart"))try{S=JSON.stringify((0,j.validateChart)(JSON.parse(w.getAttribute("data-studio-chart")||w.getAttribute("data-chart")||"{}")))}catch{}let C=k.map((e,t)=>({el:e,index:t})).filter(({el:e})=>e.matches("section")),M=t;if(e.panels)try{M=(0,Z.renderBoardHtml)(e)}catch{}else{let i=new DOMParser().parseFromString((0,j.renderStructured)(e,t,a),"text/html");
1Q(i).forEach((e,t)=>{e.setAttribute("data-studio-pick",String(t)),t===h&&e.setAttribute("data-studio-selected","")}),M=`<!doctype html>${i.documentElement.outerHTML}`.replace("</body>","<script>document.addEventListener('click',function(e){var el=e.target.closest('[data-studio-pick]');if(!el)return;e.preventDefault();e.stopImmediatePropagation();document.querySelectorAll('[data-studio-selected]').forEach(function(n){n.removeAttribute('data-studio-selected')});el.setAttribute('data-studio-selected','');parent.postMessage({type:'studio:select',index:Number(el.getAttribute('data-studio-pick'))},'*')},true)</script><style>[data-studio-pick]{cursor:pointer}[data-studio-pick]:hover{outline:1px dashed #17483d;outline-offset:3px}[data-studio-selected]{outline:2px solid #17483d!important;outline-offset:3px}</style></body>")}let N=(0,r.useRef)(()=>{});N.current=e=>{Number.isInteger(e)&&e>=0&&e<k.length&&(m(e),c.open("properties"))},(0,r.useEffect)(()=>{let e=e=>{e.source===u.current?.contentWindow&&e.data?.type==="studio:select"&&N.current(e.data.index)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let A=(0,r.useRef)({model:e,source:t,onChange:s});A.current={model:e,source:t,onChange:s},(0,r.useEffect)(()=>(c.insert.current=(e,t)=>{if(n||!(0,j.safeUrl)(e))return;let i=A.current,a=new DOMParser().parseFromString(i.source,"text/html"),s=a.createElement("img");s.src=e,s.alt=t,(a.querySelector("main")||a.body).appendChild(s),i.onChange(i.model,`<!doctype html>${a.documentElement.outerHTML}`)},()=>{c.insert.current=null}),[n,c.insert]);let E=e=>{if(!w||n)return;let t=A.current,i=new DOMParser().parseFromString(t.source,"text/html"),a=w.getAttribute("data-studio-id"),s=a?Q(i).find(e=>e.getAttribute("data-studio-id")===a):Q(i)[h];s&&s.tagName===w.tagName&&(s.setAttribute("data-studio-id",a||crypto.randomUUID()),e(s),t.onChange(t.model,`<!doctype html>${i.documentElement.outerHTML}`))},D=(t,i)=>{if(n||t===i||!C[t]||!C[i]||C[t].el.parentElement!==C[i].el.parentElement)return;let a=C[t].el;C[i].el.insertAdjacentElement(t<i?"afterend":"beforebegin",a),s(e,`<!doctype html>${v.documentElement.outerHTML}`),m(null)},T=(t,i)=>{if(!e.panels||t===i||i<0||i>=e.panels.length)return;let a=[...e.panels];a.splice(i,0,a.splice(t,1)[0]),s({...e,panels:a}),m(i)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("iframe",{ref:u,className:"studio-html-preview",title:d("studio.preview"),srcDoc:(0,K.prepareArtifactHtml)(M),sandbox:"allow-scripts"}),(0,i.jsxs)(p.StudioPanel,{tool:"layers",children:[(0,i.jsx)("p",{className:"studio-help",children:d("studio.blockDragHint")}),(0,i.jsx)("div",{className:"studio-outline",children:e.panels?e.panels.map((t,a)=>(0,i.jsxs)("div",{className:"studio-outline-row",draggable:!0,onDragStart:()=>{g.current=a},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),null!==g.current&&T(g.current,a),g.current=null},children:[(0,i.jsx)(R.GripVertical,{size:14}),(0,i.jsx)("button",{onClick:()=>{m(a),c.open("properties")},children:String(t.title||t.type).slice(0,60)}),(0,i.jsx)("button",{disabled:!a,"aria-label":d("studio.moveEarlier"),onClick:()=>T(a,a-1),children:(0,i.jsx)(H.ChevronUp,{size:14})}),(0,i.jsx)("button",{disabled:a===e.panels.length-1,"aria-label":d("studio.moveLater"),onClick:()=>T(a,a+1),children:(0,i.jsx)(U.ChevronDown,{size:14})})]},a)):k.map((e,t)=>(0,i.jsx)("div",{className:"studio-outline-row",children:(0,i.jsx)("button",{onClick:()=>{m(t),c.open("properties")},children:(e.getAttribute("alt")||e.textContent||d("studio.chart")).slice(0,70)})},t))})]}),(0,i.jsxs)(p.StudioPanel,{tool:"insert",children:[(0,i.jsx)("p",{className:"studio-help",children:d("studio.htmlInsertHint")}),C.map(({el:e},t)=>(0,i.jsxs)("div",{className:"studio-outline-row",draggable:!n,onDragStart:()=>{g.current=t},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),null!==g.current&&D(g.current,t),g.current=null},children:[(0,i.jsx)("span",{children:e.textContent?.slice(0,45)}),(0,i.jsx)("button",{disabled:n||0===t,onClick:()=>D(t,t-1),"aria-label":d("studio.moveEarlier"),children:(0,i.jsx)(H.ChevronUp,{size:14})}),(0,i.jsx)("button",{disabled:n||t===C.length-1,onClick:()=>D(t,t+1),"aria-label":d("studio.moveLater"),children:(0,i.jsx)(U.ChevronDown,{size:14})})]},t))]}),(0,i.jsxs)(p.StudioPanel,{tool:"properties",children:[e.panels?(0,i.jsxs)(i.Fragment,{children:[null!==h&&e.panels[h]?(0,i.jsxs)("label",{children:[d("studio.chartTitle"),(0,i.jsx)("input",{value:String(e.panels[h].title||""),onChange:t=>s({...e,panels:e.panels.map((e,i)=>i===h?{...e,title:t.target.value}:e)})})]}):(0,i.jsx)("p",{className:"studio-help",children:d("studio.selectionHint")}),(0,i.jsx)("p",{className:"studio-help",children:d("studio.liveDataNotice")})]}):w?(0,i.jsx)("fieldset",{disabled:n,children:w.hasAttribute("data-chart")?S?(0,i.jsx)(f.ChartEditor,{value:S,onChange:e=>E(t=>{t.setAttribute("data-studio-chart",e),t.setAttribute("data-chart",JSON.stringify((0,j.runtimeChart)(JSON.parse(e))))})},h):(0,i.jsx)("p",{className:"studio-help",children:d("studio.originalElementReadOnly")}):w.matches("img")?(0,i.jsx)(f.ImagePanel,{props:{src:w.getAttribute("src"),alt:w.getAttribute("alt"),prompt:w.getAttribute("data-studio-prompt"),aspect:w.getAttribute("data-studio-aspect")},images:l,assets:o,t:d,onPatch:e=>{void 0===e.src||(0,j.safeUrl)(e.src)?(E(t=>
1{for(let i of["src","alt","prompt","aspect"])void 0!==e[i]&&t.setAttribute(["prompt","aspect"].includes(i)?`data-studio-${i}`:i,String(e[i]))}),x("")):x(d("studio.imageFailed"))}},h):w.matches("section")?(0,i.jsx)("p",{className:"studio-help",children:d("studio.htmlInsertHint")}):(0,i.jsxs)("label",{children:[d("studio.text"),(0,i.jsx)("textarea",{value:w.textContent||"",onChange:e=>E(t=>{t.textContent=e.target.value})})]})}):(0,i.jsx)("p",{className:"studio-help",children:d("studio.selectionHint")}),y&&(0,i.jsx)("p",{role:"alert",className:"studio-notice",children:y})]})]})}function et({threadId:e,prepare:t}){let{t:a}=(0,b.useTranslation)(),[s,l]=(0,r.useState)("document-executive"),[o,n]=(0,r.useState)(""),[d,c]=(0,r.useState)(!1),[u,h]=(0,r.useState)(!1);return(0,i.jsxs)("details",{className:"studio-export-menu studio-new-project",children:[(0,i.jsx)("summary",{children:a("studio.newProject")}),(0,i.jsx)("div",{children:(0,i.jsxs)("form",{onSubmit:async i=>{i.preventDefault();let r=i.currentTarget;c(!0),h(!1);let l=window.open("about:blank","_blank");l&&(l.opener=null);try{if(!await t())return void l?.close();let i=(0,j.scaffold)(s,o,e=>a(`studio.skeleton.${e}`)),n=await (await (0,y.apiFetch)("/api/v1/studio/projects",{method:"POST",body:JSON.stringify({thread_id:e,title:o,structured:i})})).json(),d=`/studio/edit?thread=${encodeURIComponent(n.thread_id)}&artifact=${encodeURIComponent(n.artifact_slug)}`;l?l.location.href=d:window.location.assign(d),r.closest("details")?.removeAttribute("open")}catch{l?.close(),h(!0)}finally{c(!1)}},children:[(0,i.jsxs)("fieldset",{disabled:d,children:[(0,i.jsxs)("label",{children:[a("studio.projectName"),(0,i.jsx)("input",{required:!0,value:o,maxLength:120,onChange:e=>n(e.target.value)})]}),(0,i.jsxs)("label",{children:[a("studio.projectTemplate"),(0,i.jsx)("select",{"aria-label":a("studio.projectTemplate"),value:s,onChange:e=>l(e.target.value),children:j.TEMPLATES.filter(e=>(0,j.hasSkeleton)(e.id)).map(e=>(0,i.jsxs)("option",{value:e.id,children:[a(`studio.${e.family}`)," · ",a(`studio.templateNames.${e.name}`)]},e.id))})]}),(0,i.jsx)("button",{type:"submit",children:a(d?"studio.saving":"studio.createProject")})]}),u&&(0,i.jsx)("p",{role:"alert",children:a("studio.saveFailed")})]})})]})}function ei({onApply:e,family:t,children:a}){let{t:s}=(0,b.useTranslation)(),l=(0,r.useRef)(null),[o,n]=(0,r.useState)(null),[d,c]=(0,r.useState)(!1),[u,h]=(0,r.useState)(""),[p,m]=(0,r.useState)("");(0,r.useEffect)(()=>{if(!o)return;let e=URL.createObjectURL(o.file);return m(e),()=>URL.revokeObjectURL(e)},[o]);let f="",x="";if(o){try{(0,j.renderStructured)(o.model)}catch(e){x=String(e.message)}f=(0,K.prepareArtifactHtml)((0,j.renderStructured)(o.model,"",o.file.name,!0))}let g=()=>{l.current?.close(),n(null),h("")};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("details",{className:"studio-export-menu",children:[(0,i.jsx)("summary",{children:s("studio.importFile")}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("label",{className:"studio-import",children:["DOCX · PPTX · PDF · XLSX · CSV",(0,i.jsx)("input",{className:"rlBare",type:"file",accept:".docx,.pptx,.pdf,.xlsx,.csv",disabled:d,onChange:async e=>{let i=e.target.files?.[0];if(e.target.value="",i){n(null),h(""),c(!0),l.current?.showModal();try{if(i.size>2e7)throw Error(s("studio.importSize"));let e=new FormData;e.append("file",i);let a=await (await (0,y.apiFetch)("/api/v1/studio/import",{method:"POST",body:e})).json(),r=(0,j.validateStructured)(a.model);if(t&&r.family!==t)throw Error(s("studio.importFamily"));n({file:i,model:r,warnings:a.warnings||[]})}catch(e){h(e instanceof Error?e.message:s("studio.invalidDraft"))}finally{c(!1)}}}})]}),a]})]}),(0,i.jsxs)("dialog",{ref:l,className:"studio-import-review","aria-labelledby":"studio-import-heading",onCancel:e=>{d?e.preventDefault():g()},children:[(0,i.jsxs)("header",{className:"studio-header",children:[(0,i.jsxs)("div",{className:"studio-title",children:[(0,i.jsx)("strong",{id:"studio-import-heading",children:s("studio.reviewImport")}),(0,i.jsx)("p",{children:o?.file.name})]}),(0,i.jsx)("button",{disabled:d,onClick:g,children:s("studio.cancel")})]}),d?(0,i.jsx)("p",{role:"status",children:s("studio.importing")}):u?(0,i.jsx)("p",{role:"alert",children:u}):o&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"studio-import-warnings",children:[(0,i.jsx)("p",{children:s("studio.importReviewHint")}),(0,i.jsx)("ul",{children:o.warnings.map(e=>(0,i.jsx)("li",{children:e},e))}),x&&(0,i.jsx)("p",{role:"alert",children:x}),(0,i.jsx)("a",{href:p,download:o.file.name,children:s("studio.downloadOriginal")})]}),(0,i.jsx)("iframe",{title:s("studio.importPreview"),srcDoc:f,sandbox:"allow-scripts"}),(0,i.jsxs)("footer",{className:"studio-footer",children:[(0,i.jsx)("button",{onClick:g,children:s("studio.cancel")}),(0,i.jsx)("button",{className:"studio-primary",onClick:()=>{e(o.model),g()},children:s("studio.applyImport")})]})]})]})]})}var ea=e.i(10552),es=e.i(523278);function er(e,t,i,a){var s,r;let l=(s=e,r=t,"dashboard"===s?"dashboard":"image"===s||"svg"===s?"design":"report"===s||"newsletter"===s?"document":"carousel"===s||/class=["'][^"']*\bslide\b/.test(r)?"presentation":"website");return"document"===l?{version:1,family:l,templateId:"document-executive",s
1ourceFormat:"html"}:eo(l,t,i,a)}function el(e,t){let i=new DOMParser().parseFromString(e,"text/html");if(i.querySelector('svg,canvas,iframe,video,audio,object,embed,input,select,textarea,button,[rowspan]:not([rowspan="1"]),[colspan]:not([colspan="1"])')||/background(?:-image)?\s*:[^;}]*url\(/i.test(e))throw Error("studio.conversionUnsupported");let a=(0,j.validateStructured)({...eo("document",e,""),templateId:t}),s=new DOMParser().parseFromString((0,j.renderStructured)(a),"text/html"),r=e=>{let t=(t,i)=>Array.from(e.querySelectorAll(t)).map(e=>i.map(t=>e.getAttribute(t)||"")),i=t("img",["src","alt"]),a=t("a",["href"]),s=Array.from(e.querySelectorAll("table")).map(e=>Array.from(e.querySelectorAll("tr")).map(e=>Array.from(e.querySelectorAll("th,td")).map(e=>e.textContent?.replace(/\s+/g," ").trim()))),r=Array.from(e.querySelectorAll("[data-chart]")).map(e=>JSON.parse(e.getAttribute("data-studio-chart")||e.getAttribute("data-chart")||"{}"));return e.querySelectorAll("script,style,noscript,[data-chart]").forEach(e=>e.remove()),JSON.stringify({text:e.body.textContent?.replace(/\s/g,""),images:i,links:a,tables:s,charts:r})};if(r(i)!==r(s))throw Error("studio.conversionUnsupported");return a}function eo(e,t,i,a){let s={version:1,family:e,templateId:j.TEMPLATES.find(t=>t.family===e).id};if("document"===e)return{...s,doc:(0,ea.generateJSON)(t,es.documentExtensions)};let r=new DOMParser().parseFromString(t,"text/html");if("website"===e||"dashboard"===e)return{...s,sections:Array.from(r.querySelectorAll("main>section,body>section")).map((e,t)=>e.id||`section-${t}`)};if("design"===e&&r.querySelector("svg")&&!r.querySelector(".slide,[data-slide]")){let e=r.querySelector("svg").cloneNode(!0);for(let t of(e.querySelectorAll("script,foreignObject").forEach(e=>e.remove()),[e,...Array.from(e.querySelectorAll("*"))]))for(let e of Array.from(t.attributes))(/^on/i.test(e.name)||/^(href|xlink:href)$/i.test(e.name)&&!e.value.startsWith("#"))&&t.removeAttribute(e.name);e.setAttribute("xmlns","http://www.w3.org/2000/svg");let t=new TextEncoder().encode(new XMLSerializer().serializeToString(e)),a="";for(let e of t)a+=String.fromCharCode(e);return{...s,freeform:!0,deck:{slides:[{background:{},blocks:[{type:"image",x:0,y:0,w:1200,h:675,props:{src:`data:image/svg+xml;base64,${btoa(a)}`,alt:i}}]}]}}}let l=Array.from(r.querySelectorAll(".slide,[data-slide]")).filter(e=>!e.parentElement?.closest(".slide,[data-slide]")),o=(l.length?l:[r.body]).map((e,t)=>{let s=[];return!function e(t){if(!t.matches("script,style,nav,button,noscript")){if(t.hasAttribute("data-chart")){let e=JSON.parse(t.getAttribute("data-studio-chart")||t.getAttribute("data-chart")||"{}");s.push({type:"chart",x:0,y:0,props:{chart:e}});return}if(t.matches("table")){let e=Array.from(t.querySelectorAll("tr")).map(e=>Array.from(e.querySelectorAll("td,th")).map(e=>e.textContent||""));s.push({type:"table",x:0,y:0,props:{rows:e}});return}if(t.matches("img"))return void s.push({type:"image",x:0,y:0,props:{src:t.getAttribute("src"),alt:t.getAttribute("alt")||""}});if(t.matches("h1,h2,h3,p,li,blockquote,pre")||!t.children.length){t.textContent?.trim()&&s.push({type:t.matches("h1,h2,h3")?"title":"text",x:0,y:0,props:{text:t.textContent}});return}for(let i of Array.from(t.children))e(i)}}(e),s.length||a||s.push({type:"title",x:64,y:64,props:{text:i}}),a&&s.push({type:"image",x:64,y:64,w:1072,h:547,props:{src:a,alt:i}}),{id:`slide-${t}`,background:{inset:!1},blocks:s}});return{...s,deck:{slides:o}}}function en({path:e,revision:t,onRestore:a}){let{t:s}=(0,b.useTranslation)(),[l,o]=(0,r.useState)(null),[n,d]=(0,r.useState)(null),[c,u]=(0,r.useState)(!1),[h,p]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let t=!1;return(0,y.apiFetch)(`${e}/revisions`).then(e=>e.json()).then(e=>{t||o(e.revisions)}).catch(()=>{t||u(!0)}),()=>{t=!0}},[e,t]);let m=async t=>{p(!0),u(!1);try{let i=await (await (0,y.apiFetch)(`${e}/payload?revision=${t}`)).json(),a=i.content||"";d({revision:t,source:a,model:(0,j.validateStructured)(i.structured||er(i.kind,a,i.title,i.url))})}catch{u(!0)}finally{p(!1)}};return(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"studio-help",children:s("studio.historyHint")}),c&&(0,i.jsx)("p",{role:"alert",children:s("studio.loadFailed")}),!l&&!c&&(0,i.jsx)("p",{role:"status",children:s("studio.loading")}),(0,i.jsx)("div",{className:"studio-outline",children:l?.map(e=>(0,i.jsxs)("button",{disabled:h,"aria-pressed":n?.revision===e.revision,onClick:()=>void m(e.revision),children:[s("studio.revision",{revision:e.revision}
1)," · ",new Date(e.created_at).toLocaleString()]},e.revision))}),n&&(0,i.jsxs)("div",{className:"studio-property-section",children:[(0,i.jsx)("iframe",{className:"studio-history-preview",title:s("studio.revision",{revision:n.revision}),srcDoc:(0,K.prepareArtifactHtml)(n.source),sandbox:"allow-scripts"}),(0,i.jsx)("button",{disabled:h||n.revision===t,onClick:()=>a(n.model,n.source),children:s("studio.restoreRevision")})]})]})}e.s(["convertHtmlDocument",0,el,"importArtifact",0,eo,"openArtifactModel",0,er],9979);var ed=e.i(762603);function ec({threadId:e,slug:t,prepare:a}){let{t:s}=(0,b.useTranslation)(),[l,o]=(0,r.useState)(null),[n,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(""),[h,p]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=!1;return(0,y.apiFetch)("/api/v1/studio/config").then(e=>e.json()).then(t=>{e||o(!!t.collaboration_url)}).catch(()=>{e||o(!1)}),()=>{e=!0}},[]);let m=async()=>{d(!0),p(!1);try{if(!await a())return;let i=await (await (0,y.apiFetch)("/api/v1/studio/rooms",{method:"POST",body:JSON.stringify({thread_id:e,artifact_slug:t})})).json();u(i.id)}catch{p(!0)}finally{d(!1)}};return(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"studio-help",children:s("studio.collaborationHint")}),null===l?(0,i.jsx)("p",{role:"status",children:s("studio.loading")}):l?c?(0,i.jsx)("a",{className:"studio-collaboration-link",href:`/studio/${c}`,target:"_blank",rel:"noopener noreferrer",children:s("studio.openCollaboration")}):(0,i.jsx)("button",{disabled:n,onClick:()=>void m(),children:s(n?"studio.saving":"studio.startCollaboration")}):(0,i.jsx)("p",{role:"status",children:s("studio.collaborationUnavailable")}),h&&(0,i.jsx)("p",{role:"alert",children:s("studio.saveFailed")})]})}async function eu(e){let t=[];for(;;){let i=await (await (0,y.apiFetch)(`${e}/comments?offset=${t.length}`)).json();if(t.push(...i.comments),i.comments.length<1e3)return t}}e.s(["CollaborationLauncher",0,ec,"CollaborationPanel",0,function({roomId:e,session:t}){let{t:a}=(0,b.useTranslation)(),s="owner"===t.role,{members:l}=(0,ed.useOrgMembers)(s),[o,n]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[u,h]=(0,r.useState)(""),[p,m]=(0,r.useState)(null),[f,x]=(0,r.useState)(""),[g,j]=(0,r.useState)("editor"),[v,k]=(0,r.useState)(!1),[w,S]=(0,r.useState)(!1),[C,M]=(0,r.useState)(!1),N=`/api/v1/studio/rooms/${e}`,A=async()=>{let[e,t]=await Promise.all([(0,y.apiFetch)(`${N}/members`).then(e=>e.json()),eu(N)]);n(e.members),c(t)};(0,r.useEffect)(()=>{let e=!1,t=async()=>{try{let[t,i]=await Promise.all([(0,y.apiFetch)(`${N}/members`).then(e=>e.json()),eu(N)]);e||(n(t.members),c(i))}catch{e||S(!0)}};t();let i=setInterval(()=>void t(),5e3);return()=>{e=!0,clearInterval(i)}},[N]);let E=async e=>{k(!0),S(!1);try{await e(),await A()}catch{S(!0)}finally{k(!1)}};return(0,i.jsxs)("aside",{className:"artifact-studio studio-collaboration-panel",children:[(0,i.jsxs)("div",{className:"studio-panel-heading",children:[(0,i.jsx)("strong",{children:a("studio.toolsCollaborate")}),(0,i.jsx)("span",{role:"status",children:a(t.connected?t.pending?"studio.saving":"studio.liveSaved":"studio.offline")})]}),(0,i.jsxs)("div",{className:"studio-panel-body",children:[(0,i.jsx)("p",{className:"studio-help",children:a("studio.collaborationHint")}),(0,i.jsx)("div",{className:"studio-presence",children:t.people.map(e=>(0,i.jsx)("span",{title:e.name,children:e.name},e.id))}),s&&(0,i.jsxs)("details",{className:"studio-property-section",children:[(0,i.jsx)("summary",{children:a("studio.manageAccess")}),(0,i.jsxs)("fieldset",{disabled:v,children:[(0,i.jsxs)("label",{children:[a("studio.member"),(0,i.jsxs)("select",{"aria-label":a("studio.member"),value:f,onChange:e=>x(e.target.value),children:[(0,i.jsx)("option",{value:"",children:a("studio.selectMember")}),l.filter(e=>e.is_active&&e.id!==t.userId).map(e=>(0,i.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,i.jsxs)("label",{children:[a("studio.accessRole"),(0,i.jsx)("select",{"aria-label":a("studio.accessRole"),value:g,onChange:e=>j(e.target.value),children:["editor","commenter","viewer"].map(e=>(0,i.jsx)("option",{value:e,children:a(`studio.role${e}`)},e))})]}),(0,i.jsx)("button",{disabled:!f||v,onClick:()=>void E(()=>(0,y.apiFetch)(`${N}/members/${f}`,{method:"PUT",body:JSON.stringify({role:g})})),children:a("studio.grantAccess")}),o.map(e=>(0,i.jsxs)("div",{className:"studio-member-row",children:[(0,i.jsxs)("span",{children:[e.name," · ",a(`studio.role${e.role}`)]}),(0,i.jsx)("button",{"aria-label":`${a("studio.removeAccess")} ${e.name}`,onClick:()=>void E(()=>(0,y.apiFetch)(`${N}/members/${e.user_id}`,{method:"DELETE"})),children:a("studio.removeAccess")})]},e.user_id))]})]}),(0,i.jsxs)("div",{className:"studio-property-section",children:[(0,i.jsx)("strong",{children:a("studio.comments")}),(0,i.jsxs)("label",{className:"studio-field",children:[(0,i.jsx)("input",{type:"checkbox",checked:C,onChange:e=>M(e.target.checked)}),a("studio.showResolved")]}),d.filter(e=>!e.parent_id&&(C||!e.resolved)).map(e=>(0,i.jsxs)("article",{className:"studio-comment",children:[(0,i.jsx)("strong",{children:e.author}),(0,i.jsx)("time",{dateTime:e.created_at,children:new Date(e.created_at).toLocaleStr
1ing()}),e.anchor&&(0,i.jsx)("button",{onClick:()=>t.anchor.current?.(e.anchor),children:String(e.anchor.quote||a("studio.selectionComment"))}),(0,i.jsx)("p",{children:e.body}),d.filter(t=>t.parent_id===e.id).map(e=>(0,i.jsxs)("div",{className:"studio-comment-reply",children:[(0,i.jsx)("strong",{children:e.author}),(0,i.jsx)("p",{children:e.body})]},e.id)),(0,i.jsxs)("div",{className:"studio-tools",children:["viewer"!==t.role&&(0,i.jsx)("button",{onClick:()=>m(e.id),children:a("studio.reply")}),(s||"editor"===t.role||e.author_id===t.userId&&"viewer"!==t.role)&&(0,i.jsx)("button",{disabled:v,onClick:()=>void E(()=>(0,y.apiFetch)(`${N}/comments/${e.id}`,{method:"PATCH",body:JSON.stringify({resolved:!e.resolved})})),children:a(e.resolved?"studio.reopenComment":"studio.resolveComment")})]})]},e.id)),"viewer"!==t.role&&(0,i.jsxs)("form",{onSubmit:e=>{e.preventDefault(),E(async()=>{await (0,y.apiFetch)(`${N}/comments`,{method:"POST",body:JSON.stringify({body:u,parent_id:p,anchor:t.provider.awareness?.getLocalState()?.selection||null})}),h(""),m(null)})},children:[p&&(0,i.jsxs)("p",{children:[a("studio.replying")," ",(0,i.jsx)("button",{type:"button",onClick:()=>m(null),children:a("studio.cancelReply")})]}),(0,i.jsxs)("label",{children:[a("studio.addComment"),(0,i.jsx)("textarea",{value:u,maxLength:4e3,onChange:e=>h(e.target.value)})]}),(0,i.jsx)("button",{disabled:!u.trim()||v,type:"submit",children:a("studio.postComment")})]})]}),w&&(0,i.jsx)("p",{role:"alert",children:a("studio.saveFailed")})]})]})}],285957);var eh=e.i(846696),ep=e.i(296505),em=e.i(943094);let ef=["all","futuristic","reports","business","planning","creative","personal","reference"],ey=e=>{if(e&&"u">typeof ResizeObserver)return(t||=new ResizeObserver(e=>e.forEach(e=>e.target.style.setProperty("--st-w",String(e.contentRect.width))))).observe(e),()=>t?.unobserve?.(e)},ex=(0,r.lazy)(()=>e.A(476510)),eg=(0,r.lazy)(()=>e.A(766868)),eb=(0,r.lazy)(()=>e.A(186580)),ej=(e,t)=>`palette-studio-draft:${e}:${t}`;function ev(e){let{t}=(0,b.useTranslation)(),a=!!e.collaboration,[l]=(0,r.useState)(e.revision),[o,n]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(!1),[p,m]=(0,r.useState)(0);return((0,r.useEffect)(()=>{let t=!1,i=a||o||!l?"":`?revision=${l}`;return(0,y.apiFetch)(`${e.apiPath||`/api/v1/general-chat/threads/${e.threadId}/artifacts/${encodeURIComponent(e.artifactSlug)}`}/payload${i}`).then(e=>e.json()).then(s=>{let r;if(i&&s.revision!==l)throw Error("artifact_revision_mismatch");if(!(0,ep.canOpenArtifactStudio)(s.kind,s.structured)){t||c(s);return}let o=(0,j.validateStructured)(s.structured||er(s.kind,s.content||"",e.title,s.url));try{let t=a?null:JSON.parse(sessionStorage.getItem(ej(e.threadId,e.artifactSlug))||"null");
1t&&t.model?.family!=="dashboard"&&"string"==typeof t.source&&Number.isInteger(t.baseRevision)&&t.baseRevision>0&&(r={...t,model:(0,j.validateStructured)(t.model)})}catch{}t||c({...s,initialModel:o,recovered:r})}).catch(()=>{t||h(!0)}),()=>{t=!0}},[e.threadId,e.artifactSlug,e.title,e.apiPath,a,p,l,o]),d||u)?d?(0,ep.canOpenArtifactStudio)(d.kind,d.structured)?(0,i.jsx)(ew,{...e,payload:d,onReload:()=>{n(!0),c(null),m(e=>e+1)}}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("p",{role:"status",children:[t("studio.previewOnly")," ",(0,i.jsx)("button",{onClick:e.onClose,children:t("studio.done")})]}),(0,i.jsx)("iframe",{className:"studio-preview",title:e.title,srcDoc:(0,K.prepareArtifactHtml)(d.content||""),sandbox:"allow-scripts"})]}):(0,i.jsxs)("div",{className:"artifact-studio studio-loading",role:"status",children:[t("studio.loadFailed"),(0,i.jsx)("button",{onClick:()=>{h(!1),m(e=>e+1)},children:t("studio.retry")})]}):(0,i.jsx)(s.PaletteLoader,{className:"h-full",label:t("studio.loading")})}function ek(e){let t=[],i=(e,a)=>{e?.type==="image"&&t.push({path:[...a,"attrs"],props:e.attrs||{},label:String(e.attrs?.alt||e.attrs?.prompt||"image")}),e?.content?.forEach((e,t)=>i(e,[...a,"content",t]))};return e.doc&&i(e.doc,["doc"]),e.deck?.slides.forEach((e,i)=>e.blocks.forEach((e,a)=>{"image"===e.type&&t.push({path:["deck","slides",i,"blocks",a,"props"],props:e.props,label:String(e.props.alt||e.props.prompt||"image")})})),e.board?.nodes.forEach((e,i)=>{"image"===e.type&&e.src&&t.push({path:["board","nodes",i],props:e,label:e.text||"Image"})}),t}function ew({payload:e,onReload:t,...v}){let{t:k}=(0,b.useTranslation)(),w=v.apiPath||`/api/v1/general-chat/threads/${v.threadId}/artifacts/${encodeURIComponent(v.artifactSlug)}`,S=v.collaboration,C=function(){let[e,t]=(0,r.useState)([]),[i,a]=(0,r.useState)(!1),[s,l]=(0,r.useState)(!0),[o,n]=(0,r.useState)(0);return(0,r.useEffect)(()=>
1{l(!0),a(!1);let e=!1;return(async()=>{try{let i=[];for(;;){let e=await (await (0,y.apiFetch)(`${g}?offset=${i.length}`)).json();if(i.push(...e.items),e.items.length<100)break}e||t(i)}catch{e||a(!0)}finally{e||l(!1)}})(),()=>{e=!0}},[o]),{items:e,error:i,loading:s,reload:()=>n(e=>e+1),save:async(e,i)=>{let s=await (await (0,y.apiFetch)(i?`${g}/${i}`:g,{method:i?"PUT":"POST",body:JSON.stringify(e)})).json();return t(e=>[...e.filter(e=>e.id!==s.id).map(t=>"folder"===s.kind&&!s.shared&&e.find(e=>e.id===s.id)?.shared&&t.folder_id===s.id?{...t,folder_id:null}:t),s]),a(!1),s},remove:async e=>{await (0,y.apiFetch)(`${g}/${e}`,{method:"DELETE"}),t(t=>t.filter(t=>t.id!==e).map(t=>t.folder_id===e?{...t,folder_id:null}:t))},get:async e=>(await (0,y.apiFetch)(`${g}/${e}`)).json()}}(),M=function(e){let t,i,s,l,o,n,d,c,u,h=(0,a.c)(22),p=`studio-media-export:${e}`,[m,f]=(0,r.useState)(null),[g,b]=(0,r.useState)(!1),[j,v]=(0,r.useState)(0);h[0]!==p?(t=()=>{try{let e=sessionStorage.getItem(p);e&&f({id:e,status:"queued"})}catch{}},i=[p],h[0]=p,h[1]=t,h[2]=i):(t=h[1],i=h[2]),(0,r.useEffect)(t,i),h[3]!==m?(s=()=>{let e;if(!m?.id||["completed","cancelled","failed"].includes(m.status))return;let t=!1,i=async()=>{try{let a=await (await (0,y.apiFetch)(`/api/v1/studio/media/exports/${m.id}`)).json();!t&&(f(a),b(!1),["queued","running"].includes(a.status)&&(e=setTimeout(i,2e3)))}catch{t||b(!0)}};return i(),()=>{t=!0,clearTimeout(e)}},h[3]=m,h[4]=s):s=h[4];let k=m?.id,w=m?.status;h[5]!==j||h[6]!==k||h[7]!==w?(l=[k,w,j],h[5]=j,h[6]=k,h[7]=w,h[8]=l):l=h[8],(0,r.useEffect)(s,l),h[9]!==m?(o=m&&["queued","running"].includes(m.status),h[9]=m,h[10]=o):o=h[10];let S=!!o;return h[11]===Symbol.for("react.memo_cache_sentinel")?(n=()=>v(x),h[11]=n):n=h[11],h[12]!==p?(d=async(e,t,i)=>{let a=await (await (0,y.apiFetch)("/api/v1/studio/media/exports",{method:"POST",body:JSON.stringify({model:e,format:t,room_id:i})})).json();f(a),b(!1);try{sessionStorage.setItem(p,a.id)}catch{}},h[12]=p,h[13]=d):d=h[13],h[14]!==m?(c=async()=>{if(m)try{let e=await (await (0,y.apiFetch)(`/api/v1/studio/media/exports/${m.id}`,{method:"DELETE"})).json();f({...m,status:e.status}),b(!1)}catch{b(!0)}},h[14]=m,h[15]=c):c=h[15],h[16]!==g||h[17]!==m||h[18]!==c||h[19]!==S||h[20]!==d?(u={job:m,error:g,pending:S,retry:n,start:d,cancel:c},h[16]=g,h[17]=m,h[18]=c,h[19]=S,h[20]=d,h[21]=u):u=h[21],u}(`${v.threadId}:${v.artifactSlug}`),A=(0,r.useRef)(M);A.current=M;let E=v.apiPath?.match(/\/rooms\/([^/]+)/)?.[1],[T,$]=(0,r.useState)(e.recovered?.model||e.initialModel),[F,O]=(0,r.useState)(e.recovered?.source??e.content??""),[I,P]=(0,r.useState)("edit"),[L,_]=(0,r.useState)(!!e.recovered),[R,H]=(0,r.useState)(!1),[U,q]=(0,r.useState)(!!(e.recovered&&e.recovered.baseRevision!==e.revision)),[V,J]=(0,r.useState)(""),[B,X]=(0,r.useState)(S?.revision||e.revision),[G,W]=(0,r.useState)(!1),[Z,Q]=(0,r.useState)(null),[ea,es]=(0,r.useState)([]),[er,ed]=(0,r.useState)([]),[eu,ep]=(0,r.useState)(!1),ev=(0,r.useRef)(null),eS=(0,r.useCallback)(e=>{ev.current=e},[]),eC=(0,r.useRef)(null),eM=(0,r.useRef)(!1),[eN,eA]=(0,r.useState)(100),[eE,eD]=(0,r.useState)(!1),[eT,e$]=(0,r.useState)("all"),[eF,ez]=(0,r.useState)(""),eO=(0,r.useRef)(null),[eI,eP]=(0,r.useState)(null),eL=(0,r.useRef)(0),e_=(0,r.useRef)({model:T,source:F}),eR=(0,r.useRef)(S?.revision||e.recovered?.baseRevision||e.revision),eH=(0,r.useRef)(!1),eU=(0,r.useRef)(!!e.recovered),eq=(0,r.useDeferredValue)({model:T,source:F}),eV="",eJ="";try{eV=(0,j.renderStructured)(eq.model,eq.source,v.title)}catch(e){eJ=String(e.message)}let eB=(t,i=e_.current.source,a=!0)=>{if("dashboard"===t.family)return void J(k("studio.previewOnly"));if(e.refreshable&&"html"===e_.current.model.sourceFormat&&("html"!==t.sourceFormat||i!==e_.current.source))return void J(k("studio.liveDataNotice"));if(S&&t.family!==T.family)return void J(k("studio.importFamily"));if(S){if(!S.readOnly)try{S.apply(T,t,F,i)}catch{eC.current={model:t,source:i},J(k("studio.collaborationEditConflict"))}return}if(t===e_.current.model&&i===e_.current.source)return;let s={...e_.current};a&&(es(e=>[...e.slice(-59),s]),ed([])),eL.current++,eU.current=!0,e_.current={model:t,source:i},$(t),O(i),_(!0),J("")},eK=e=>{if(S)return void S.undo[e]();let t="undo"===e?ea:er,i=t.at(-1);if(!i)return;let a={...e_.current};"undo"===e?(es(t.slice(0,-1)),ed(e=>[...e,a])):(ed(t.slice(0,-1)),es(e=>[...e,a])),eB(i.model,i.source,!1)},eX=(0,r.useCallback)(async(t=!1)=>
1{if(S?.readOnly||eH.current||U)return!1;try{await ev.current?.()}catch{return J(k("studio.invalidContent")),!1}if(eH.current||U)return!1;if(!eU.current&&!t)return!0;eH.current=!0,H(!0);let i=eL.current;try{let t=e_.current,a=(0,j.renderStructured)(t.model,t.source,v.title),s=await (0,y.apiFetch)(`${w}/revisions`,{method:"POST",body:JSON.stringify({base_revision:eR.current,title:v.title,content:a,structured:t.model})}),r=await s.json();if(eR.current=r.revision,X(r.revision),S?.snapshot(r.revision),eL.current===i){eU.current=!1,_(!1);try{sessionStorage.removeItem(ej(v.threadId,v.artifactSlug))}catch{}}return v.onSaved?.({revision:r.revision,content:r.content,structured:r.structured,quality:r.quality,artifact_kind:["image","svg"].includes(e.kind)?"html":e.kind}),eL.current===i}catch(t){let e=t?.status;return 409===e||428===e?q(!0):J(k("studio.saveFailed")),!1}finally{eH.current=!1,H(!1)}},[U,L,v,e.kind,k,w,S]);(0,r.useEffect)(()=>{if(!S)return;let{model:e,source:t}=S.value;JSON.stringify(e_.current)!==JSON.stringify({model:e,source:t})&&(e_.current={model:e,source:t},$(e),O(t),eL.current++,eU.current=!0,_(!0)),S.revision&&eR.current!==S.revision&&(eR.current=S.revision,X(S.revision)),S.readOnly&&P("preview")},[S]),(0,r.useEffect)(()=>{let e=()=>{if(eU.current&&!S)try{sessionStorage.setItem(ej(v.threadId,v.artifactSlug),JSON.stringify({...e_.current,baseRevision:eR.current}))}catch{}},t=setTimeout(e,300);return()=>{clearTimeout(t),e()}},[T,F,v.threadId,v.artifactSlug,S]);let eG=(0,r.useRef)(eX);eG.current=eX,(0,r.useEffect)(()=>{if(S||!L||R||U||V||eJ)return;let e=setTimeout(()=>{eG.current()},2500);return()=>clearTimeout(e)},[T,F,L,R,U,V,eJ,S]),(0,r.useEffect)(()=>{let e=e=>{(R||(S?S.pending:L))&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[L,R,S]);let eW={busy:G,upload:async e=>{W(!0);try{let t=new FormData;t.append("file",e);let i=await (0,y.apiFetch)(v.apiPath?`${w}/upload`:`/api/v1/general-chat/threads/${v.threadId}/upload`,{method:"POST",body:t});return String((await i.json()).file_url)}finally{W(!1)}},generate:async(e,t)=>{W(!0);try{let i=await (0,y.apiFetch)(`${w}/images`,{method:"POST",body:JSON.stringify({prompt:e,aspect_ratio:t})});return String((await i.json()).url)}finally{W(!1)}}},eY=ek(T).filter(e=>"string"==typeof e.props.src&&/^https?:\/\//.test(String(e.props.src))).map(e=>({url:String(e.props.src),title:e.label})),eZ=[...v.assets||[],...eY,...C.items.filter(e=>"asset"===e.kind&&e.data.url).map(e=>({url:e.data.url,title:e.title}))].filter((e,t,i)=>i.findIndex(t=>t.url===e.url)===t),eQ=async()=>{try{await ev.current?.()}catch{J(k("studio.invalidContent"))}let e=new Blob([JSON.stringify({...eC.current||e_.current,title:v.title},null,2)],{type:"application/json"}),t=URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download=`${v.artifactSlug}-draft.json`,i.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},e0=(0,r.useCallback)(async t=>{if(!eM.current){eM.current=!0,Q(t),J("");try{await ev.current?.();let{model:i,source:a}=e_.current;if(["mp4","webm","mp3","wav"].includes(t))return void await A.current.start(i,t,E);await (0,em.exportStudioDraft)(t,{title:v.title,artifactSlug:v.artifactSlug,artifactKind:e.kind,content:(0,j.renderStructured)(i,a,v.title),structured:i,transparent:eu}),eh.toast.success(k("paletteOs:session.preview.exportReady",{format:t.toUpperCase()}))}catch(e){console.warn("Studio export failed:",e),J(k("studio.exportFailed")),eh.toast.error(k("paletteOs:session.preview.exportFailed",{format:t.toUpperCase()}))}finally{eM.current=!1,Q(null)}}},[v.title,v.artifactSlug,e.kind,eu,k,E]),e1=(0,em.studioExportFormats)(T.family),e2=v.onExportChange,e5=!!T.deck;(0,r.useEffect)(()=>(e2?.({formats:(0,em.studioExportFormats)(T.family),exporting:Z,disabled:!!eJ||M.pending,transparent:e5?eu:void 0,setTransparent:ep,exportAs:e0}),()=>e2?.(null)),[e2,T.family,e5,Z,eJ,eu,e0,M.pending]);let e4=T.deck,e3="html"===T.sourceFormat,e6=ek(T).filter(e=>(0,f.isPending)(e.props)).length;return(0,i.jsxs)("section",{className:`artifact-studio${eE?" studio-focus":""}${S?.readOnly?" studio-readonly":""}`,"aria-label":k("studio.title"),onKeyDownCapture:e=>{"Escape"===e.key&&eE&&eD(!1),(e.ctrlKey||e.metaKey)&&["z","y"].includes(e.ke
1y.toLowerCase())&&(e.preventDefault(),e.stopPropagation(),eK(e.shiftKey||"y"===e.key.toLowerCase()?"redo":"undo")),(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()&&(e.preventDefault(),eX())},children:[(0,i.jsxs)("header",{className:"studio-header",children:[(0,i.jsxs)("div",{className:"studio-title",children:[(0,i.jsx)("strong",{children:v.title}),(0,i.jsx)("p",{role:"status",children:k(R?"studio.saving":L?S?"studio.unpublished":"studio.unsaved":"studio.saved",{revision:B})})]}),(0,i.jsxs)("div",{className:"studio-actions",children:[!S&&(0,i.jsx)(et,{threadId:v.threadId,prepare:()=>eX()}),(0,i.jsx)("button",{"aria-label":k("studio.undo"),title:k("studio.undo"),disabled:S?S.readOnly||!S.undo.undoStack.length:!ea.length,onClick:()=>eK("undo"),children:(0,i.jsx)(l.default,{size:16})}),(0,i.jsx)("button",{"aria-label":k("studio.redo"),title:k("studio.redo"),disabled:S?S.readOnly||!S.undo.redoStack.length:!er.length,onClick:()=>eK("redo"),children:(0,i.jsx)(o.default,{size:16})}),(0,i.jsxs)("details",{className:"studio-export-menu",children:[(0,i.jsxs)("summary",{children:[(0,i.jsx)(n.Download,{size:16}),k("studio.export")]}),(0,i.jsxs)("div",{children:[T.deck&&(0,i.jsxs)("label",{className:"studio-check",children:[(0,i.jsx)("input",{type:"checkbox",checked:eu,onChange:e=>ep(e.target.checked)}),k("studio.transparentExport")]}),e1.map(e=>(0,i.jsx)("button",{disabled:!!eJ||null!==Z||M.pending,onClick:t=>{t.currentTarget.closest("details")?.removeAttribute("open"),e0(e)},children:Z===e?k("studio.exporting"):e.toUpperCase()},e)),(0,i.jsx)("button",{onClick:eQ,children:k("artifactEditor.downloadDraft")})]})]}),(0,i.jsx)("button",{"aria-label":k(eE?"studio.exitFocus":"studio.focus"),title:k(eE?"studio.exitFocus":"studio.focus"),onClick:()=>eD(!eE),children:eE?(0,i.jsx)(c.default,{size:16}):(0,i.jsx)(d.default,{size:16})}),(0,i.jsx)(ei,{family:T.family,onApply:e=>{eB(e,""),P("edit")},children:(0,i.jsxs)("label",{className:"studio-import",children:[k("studio.restoreDraft"),(0,i.jsx)("input",{className:"rlBare",type:"file",accept:"application/json,.json",onChange:async e=>{let t=e.target.files?.[0];if(t){try{if(t.size>3e6)throw Error("size");let e=JSON.parse(await t.text());if((0,j.validateStructured)(e.model),"string"!=typeof e.source)throw Error("source");eB(e.model,e.source,!0)}catch{J(k("studio.invalidDraft"))}e.target.value=""}}})]})}),(0,i.jsx)("button",{disabled:S?.readOnly||!L||R||U||!!eJ,onClick:()=>void eX(),children:k(S?"studio.saveVersion":"studio.save")}),(0,i.jsx)("button",{className:"studio-primary",disabled:R||U,onClick:async()=>{(S?.readOnly||await eX())&&v.onClose()},children:k("studio.done")})]})]}),e.recovered&&!U&&(0,i.jsx)("p",{className:"studio-notice",role:"status",children:k("studio.recovered")}),U&&(0,i.jsxs)("div",{role:"alert",className:"studio-notice",children:[(0,i.jsx)("p",{children:k("artifactEditor.conflict")}),(0,i.jsx)("button",{onClick:eQ,children:k("artifactEditor.downloadDraft")}),(0,i.jsx)("button",{onClick:()=>{eU.current=!1;try{sessionStorage.removeItem(ej(v.threadId,v.artifactSlug))}catch{}t()},children:k("artifactEditor.reloadLatest")})]}),(V||eJ)&&(0,i.jsxs)("div",{role:"alert",className:"studio-notice",children:[V||k("studio.invalidContent"),(0,i.jsx)("button",{onClick:eQ,children:k("artifactEditor.downloadDraft")})]}),M.job&&(0,i.jsxs)("div",{className:"studio-notice",role:M.error||"failed"===M.job.status?"alert":"status",children:[k(`studio.mediaJob${M.job.status}`),M.job.error&&(0,i.jsx)("span",{children:"storage_limit_exceeded"===M.job.error?k("workspaceSettings:subscription.storageUploadBlocked"):"subscription_expired"===M.job.error?k("workspaceSettings:subscription.expiredToast"):M.job.error}),M.error&&(0,i.jsx)("button",{onClick:M.retry,children:k("studio.retry")}),M.pending&&(0,i.jsx)("button",{onClick:()=>void M.cancel(),children:k("studio.cancelExport")}),M.job.result&&(0,i.jsx)("a",{href:M.job.result.url,target:"_blank",rel:"noopener noreferrer",download:`export.${M.job.result.format}`,children:k("studio.openMediaExport")})]}),e.refreshable&&(0,i.jsx)("p",{className:"studio-notice",children:k("studio.liveDataNotice")}),e3?(0,i.jsx)("p",{className:"studio-notice",children:k("studio.originalDesign")}):!e.structured&&(0,i.jsx)("p",{className:"studio-notice",children:k("studio.importNotice")}),e6>0&&(0,i.jsxs)("p",{className:"studio-notice",role:"status",children:[k("studio.pendingCount",{count:e6})," â ",k("studio.pendingImage")]}),(0,i.jsxs)("nav",{className:"studio-tools","aria-label":k("studio.views"),children:[(0,i.jsx)("div",{className:"studio-seg",children:["edit","preview"].map(e=>(0,i.jsx)("button",{disabled:S?.readOnly&&"edit"===e,"aria-pressed":I===e,onClick:()=>P(e),children:k(`studio.${e}`)},e))}),!e.structured&&!e3&&(0,i.jsxs)("label",{className:"studio-field",children:[k("studio.format"),(0,i.jsx)("select",{value:T.family,onChange:t=>{try{eB((0,j.validateStructured)(eo(t.target.value,F,v.title,e.url)),F,!0)}catch{J(k("studio.invalidContent"))}},children:["document","presentation","website","design"].map(e=>(0,i.jsx)("option",{value:e,children:k(`studio.${e}`)},e))})]})]}),(0,i.jsxs)(p.StudioWorkspaceChrome,{readOnly:S?.readOnly,hiddenTools:"spreadsheet"===T.family?["uploads","brand"]:T.board||T.timeline?["brand"]:[],children:[(0,i.jsx)(p.StudioPanel,{tool:"collaborate",children:S?(0,i.jsx)("p",{children:k("studio.collaborationActive")}
1):(0,i.jsx)(ec,{threadId:v.threadId,slug:v.artifactSlug,prepare:()=>eX(!e.structured)})}),(0,i.jsx)(p.StudioPanel,{tool:"history",children:(0,i.jsx)(en,{path:w,revision:B,onRestore:(e,t)=>{eB(e,t),P("edit")}})}),(0,i.jsx)(p.StudioPanel,{tool:"templates",children:()=>{let t=j.TEMPLATES.filter(e=>e.family===T.family&&("all"===eT||(j.TEMPLATE_CATEGORIES[e.id]||"reports")===eT)).sort((e,t)=>Number("futuristic"===j.TEMPLATE_CATEGORIES[t.id])-Number("futuristic"===j.TEMPLATE_CATEGORIES[e.id])),a="document"===T.family?ef.filter(e=>"all"===e||j.TEMPLATES.some(t=>"document"===t.family&&(j.TEMPLATE_CATEGORIES[t.id]||"reports")===e)):[];return(0,i.jsxs)(i.Fragment,{children:[v.onAskAgent&&"document"===T.family&&(0,i.jsxs)("div",{className:"studio-describe",children:[(0,i.jsx)("strong",{children:k("studio.describeDocument")}),(0,i.jsx)("textarea",{"aria-label":k("studio.describeDocument"),placeholder:k("studio.describePlaceholder"),value:eF,maxLength:600,onChange:e=>ez(e.target.value)}),(0,i.jsxs)("button",{className:"studio-primary",disabled:!eF.trim(),onClick:()=>{v.onAskAgent?.(k("studio.describePrompt",{template:T.templateId,description:eF.trim()})),ez("")},children:[(0,i.jsx)(D.Sparkles,{size:15}),k("studio.generateWithAgent")]})]}),a.length>0&&(0,i.jsx)("div",{className:"studio-chips",children:a.map(e=>(0,i.jsx)("button",{type:"button","aria-pressed":eT===e,onClick:()=>e$(e),children:k(`studio.templateCategories.${e}`)},e))}),!e3&&(0,i.jsx)(N,{library:C,model:T,onApply:e=>{eB(e,""),P("edit")}}),(0,i.jsx)("div",{className:"studio-templates",children:t.map(t=>{let a="";try{a=(0,j.renderStructured)(!e3&&(0,j.hasSkeleton)(t.id)&&"document"===t.family?(0,j.scaffold)(t.id,v.title,e=>k(`studio.skeleton.${e}`)):e3?el(F,t.id):(0,j.applyTemplate)(T,t.id),F,v.title)}catch{}return(0,i.jsxs)("div",{className:"studio-template","data-template":t.id,"aria-current":!e3&&T.templateId===t.id,children:[(0,i.jsx)("div",{className:"studio-template-thumb",ref:ey,"data-family":t.family,children:(0,i.jsx)("iframe",{title:k(`studio.templateNames.${t.name}`),srcDoc:(0,K.prepareArtifactHtml)(a),sandbox:"allow-scripts",tabIndex:-1,loading:"lazy"})}),(0,i.jsx)("strong",{children:k(`studio.templateNames.${t.name}`)}),"futuristic"===j.TEMPLATE_CATEGORIES[t.id]&&(0,i.jsx)("p",{className:"studio-template-description",children:k(`studio.templateDescriptions.${t.name}`)}),(0,i.jsxs)("div",{className:"studio-tools",children:[(0,i.jsx)("button",{disabled:e3&&!!e.refreshable,"aria-pressed":!e3&&T.templateId===t.id,onClick:()=>(e=>{if(e3){try{eP({model:el(F,e),serial:eL.current}),eO.current?.showModal()}catch{J(k("studio.conversionUnsupported"))}return}eB((0,j.applyTemplate)(T,e),F,!0),P("preview")})(t.id),children:k(e3?"studio.previewConversion":"studio.useTemplate")}),!e3&&(0,j.hasSkeleton)(t.id)&&(0,i.jsx)("button",{onClick:()=>{eB((0,j.scaffold)(t.id,v.title,e=>k(`studio.skeleton.${e}`)),F,!0),P("edit")},children:k("studio.startFromTemplate")})]})]},t.id)})})]})}}),!T.timeline&&"spreadsheet"!==T.family&&(0,i.jsx)(z,{library:C,model:T,assets:eZ,images:eW,disabled:!!e.refreshable||!!T.panels||"edit"!==I,onChange:eB}),"preview"===I&&!T.timeline&&(0,i.jsx)("iframe",{className:"studio-preview",title:k("studio.preview"),srcDoc:(0,K.prepareArtifactHtml)(eV),sandbox:"allow-scripts"}),(0,i.jsx)("main",{className:"studio-main",hidden:"edit"!==I&&!T.timeline,children:T.timeline?(0,i.jsx)(r.Suspense,{fallback:(0,i.jsx)(s.PaletteLoader,{label:k("studio.loading")}),children:(0,i.jsx)(ex,{registerCommit:eS,model:T,onChange:eB,readOnly:S?.readOnly,roomId:E,preview:"preview"===I})}):"whiteboard"===T.family?(0,i.jsx)(r.Suspense,{fallback:(0,i.jsx)(s.PaletteLoader,{label:k("studio.loading")}),children:(0,i.jsx)(eg,{images:eW,assets:eZ,model:T,onChange:eB,readOnly:S?.readOnly})}):"spreadsheet"===T.family?(0,i.jsx)(r.Suspense,{fallback:(0,i.jsx)(s.PaletteLoader,{label:k("studio.loading")}),children:(0,i.jsx)(eb,{shared:!!S,registerCommit:eS,model:T,onChange:eB,readOnly:S?.readOnly})}):"document"!==T.family||e3?e4?(0,i.jsx)(Y,{model:T,title:v.title,onChange:eB,images:eW,assets:eZ,zoom:eN,collaboration:S}
1):(0,i.jsx)(ee,{model:T,source:F,title:v.title,onChange:eB,images:eW,assets:eZ,bound:!!(e.refreshable||S?.readOnly)}):(0,i.jsx)(m.DocumentEditor,{model:T,onChange:eB,images:eW,assets:eZ,zoom:eN,collaboration:S})})]}),(0,i.jsxs)("dialog",{ref:eO,className:"studio-import-review","aria-labelledby":"studio-conversion-heading",onClose:()=>eP(null),children:[(0,i.jsxs)("header",{className:"studio-header",children:[(0,i.jsx)("h2",{id:"studio-conversion-heading",children:k("studio.previewConversion")}),(0,i.jsx)("button",{onClick:()=>eO.current?.close(),children:k("studio.cancel")})]}),(0,i.jsx)("p",{className:"studio-notice",children:k("studio.conversionNotice")}),eI&&(0,i.jsx)("iframe",{title:k("studio.importPreview"),srcDoc:(0,K.prepareArtifactHtml)((0,j.renderStructured)(eI.model,"",v.title)),sandbox:"allow-scripts"}),(0,i.jsx)("footer",{className:"studio-footer",children:(0,i.jsx)("button",{disabled:!eI||S?.readOnly,onClick:()=>{if(eI){if(eI.serial!==eL.current){J(k("studio.conversionChanged")),eO.current?.close();return}eB(eI.model,F,!0),P("preview"),eO.current?.close()}},children:k("studio.applyImport")})})]}),(0,i.jsxs)("footer",{className:"studio-statusbar",children:[(0,i.jsx)("span",{children:k(`studio.${T.family}`)}),"edit"===I&&(T.doc||T.deck)&&(0,i.jsxs)("span",{className:"studio-zoom",children:[(0,i.jsx)("button",{"aria-label":k("studio.zoomOut"),disabled:eN<=50,onClick:()=>eA(Math.max(50,eN-10)),children:(0,i.jsx)(h.default,{size:15})}),(0,i.jsxs)("button",{onClick:()=>eA(100),title:k("studio.fitView"),children:[eN,"%"]}),(0,i.jsx)("button",{"aria-label":k("studio.zoomIn"),disabled:eN>=200,onClick:()=>eA(Math.min(200,eN+10)),children:(0,i.jsx)(u.default,{size:15})})]})]})]})}e.s(["ArtifactStudio",0,function(e){let t,s=(0,a.c)(3),r=`${e.threadId}:${e.artifactSlug}`;return s[0]!==e||s[1]!==r?(t=(0,i.jsx)(ev,{...e},r),s[0]=e,s[1]=r,s[2]=t):t=s[2],t}],781623)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.