@engenty/wizards-runtime 0.9.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/apps/runtime/dist/agents/architect.js +4 -2
  2. package/apps/runtime/dist/agents/company.js +1 -1
  3. package/apps/runtime/dist/agents/studio-assistant.js +1 -1
  4. package/apps/runtime/dist/app.js +18 -1
  5. package/apps/runtime/dist/assistant/primer.js +1 -1
  6. package/apps/runtime/dist/auth/index.js +10 -1
  7. package/apps/runtime/dist/authoring/example.js +2 -2
  8. package/apps/runtime/dist/authoring/guide.js +11 -11
  9. package/apps/runtime/dist/credits/estimate.js +5 -5
  10. package/apps/runtime/dist/db/adopt.js +4 -3
  11. package/apps/runtime/dist/db/client.js +9 -1
  12. package/apps/runtime/dist/db/migrations/control/0011_model_classes.sql +11 -0
  13. package/apps/runtime/dist/db/migrations/control/meta/0011_snapshot.json +600 -0
  14. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  15. package/apps/runtime/dist/db/migrations/tenant/0021_model_classes.sql +41 -0
  16. package/apps/runtime/dist/db/migrations/tenant/0022_sync.sql +247 -0
  17. package/apps/runtime/dist/db/migrations/tenant/meta/0021_snapshot.json +3475 -0
  18. package/apps/runtime/dist/db/migrations/tenant/meta/0022_snapshot.json +3792 -0
  19. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
  20. package/apps/runtime/dist/db/schema.js +60 -0
  21. package/apps/runtime/dist/docs/dev/plugins/quick-start.md +2 -2
  22. package/apps/runtime/dist/docs/dev/plugins/server.md +2 -2
  23. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +9 -5
  24. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +2 -2
  25. package/apps/runtime/dist/docs/dev/wizard-format/index.md +14 -8
  26. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +85 -0
  27. package/apps/runtime/dist/docs/user-guide/data.md +4 -4
  28. package/apps/runtime/dist/docs/user-guide/meta.json +1 -0
  29. package/apps/runtime/dist/docs/user-guide/models.md +22 -13
  30. package/apps/runtime/dist/docs/user-guide/steps.md +6 -6
  31. package/apps/runtime/dist/docs/user-guide/test-and-share.md +4 -14
  32. package/apps/runtime/dist/documents/parse.js +1 -1
  33. package/apps/runtime/dist/engine/requirements.js +11 -11
  34. package/apps/runtime/dist/engine/steps.js +4 -4
  35. package/apps/runtime/dist/env.js +4 -4
  36. package/apps/runtime/dist/files/blobs.js +13 -0
  37. package/apps/runtime/dist/film/step.js +1 -1
  38. package/apps/runtime/dist/harness/antigravity.js +3 -3
  39. package/apps/runtime/dist/harness/apple.js +1 -1
  40. package/apps/runtime/dist/harness/claude.js +2 -2
  41. package/apps/runtime/dist/harness/codex.js +3 -3
  42. package/apps/runtime/dist/harness/cursor.js +1 -1
  43. package/apps/runtime/dist/index.js +7 -1
  44. package/apps/runtime/dist/mcp/tools.js +6 -3
  45. package/apps/runtime/dist/models.js +64 -10
  46. package/apps/runtime/dist/plugins/jobs.js +7 -0
  47. package/apps/runtime/dist/plugins/loader.js +1 -1
  48. package/apps/runtime/dist/routes/api.js +107 -0
  49. package/apps/runtime/dist/routes/studio.js +78 -5
  50. package/apps/runtime/dist/services/assistant-chats.js +1 -1
  51. package/apps/runtime/dist/services/brand.js +1 -1
  52. package/apps/runtime/dist/services/cloud.js +39 -5
  53. package/apps/runtime/dist/services/knowledge-model.js +1 -1
  54. package/apps/runtime/dist/services/marketplace.js +3 -1
  55. package/apps/runtime/dist/services/project-files.js +1 -1
  56. package/apps/runtime/dist/services/projects.js +11 -0
  57. package/apps/runtime/dist/services/translations.js +2 -2
  58. package/apps/runtime/dist/services/wizards.js +2 -2
  59. package/apps/runtime/dist/sharing/agent.js +1 -1
  60. package/apps/runtime/dist/sync/apply.js +39 -0
  61. package/apps/runtime/dist/sync/client.js +828 -0
  62. package/apps/runtime/dist/sync/hub.js +324 -0
  63. package/apps/runtime/dist/sync/log.js +74 -0
  64. package/apps/runtime/dist/sync/records.js +943 -0
  65. package/apps/runtime/dist/sync/state.js +17 -0
  66. package/apps/runtime/dist/texts.js +12 -0
  67. package/apps/web/dist/assets/{AboutDialog-B3tljxg5.js → AboutDialog-D1YHT0jc.js} +1 -1
  68. package/apps/web/dist/assets/{ChangelogDialog-DfWTNzyl.js → ChangelogDialog-Bv02g8av.js} +1 -1
  69. package/apps/web/dist/assets/{EditorPage-XDdz2UM4.js → EditorPage-BThoZwqO.js} +4 -4
  70. package/apps/web/dist/assets/{FlowPreview-CKNVCFbp.js → FlowPreview-dc5C92kK.js} +1 -1
  71. package/apps/web/dist/assets/{Harness-BCec49Cq.js → Harness-D0nFOIVx.js} +1 -1
  72. package/apps/web/dist/assets/{Marketplace-BuYeaxK2.js → Marketplace-Cnd8BF3q.js} +2 -2
  73. package/apps/web/dist/assets/{NewWizardChannels-DRNji-bk.js → NewWizardChannels-i62Y_2DZ.js} +1 -1
  74. package/apps/web/dist/assets/{NewWizardPage-4TpgYOaI.js → NewWizardPage-BcpRA1fx.js} +1 -1
  75. package/apps/web/dist/assets/{OnboardingPage-Cf52NOIt.js → OnboardingPage-BcMDEXNq.js} +1 -1
  76. package/apps/web/dist/assets/PreviewPane-GHcVV2Hu.js +4 -0
  77. package/apps/web/dist/assets/{ProjectPage-D6Tah3QK.js → ProjectPage-TDywzUOd.js} +1 -1
  78. package/apps/web/dist/assets/{PublicRunner-Bftc1c4m.js → PublicRunner-B6JINLpR.js} +1 -1
  79. package/apps/web/dist/assets/{ReadOnly-DVQm9IYx.js → ReadOnly-Mv5M2OV9.js} +1 -1
  80. package/apps/web/dist/assets/SettingsPage-B-F1dLgt.js +2 -0
  81. package/apps/web/dist/assets/SetupPage-CVdsdVBW.js +1 -0
  82. package/apps/web/dist/assets/{SharePage-Cn-bqSyr.js → SharePage-CBSRK0wF.js} +1 -1
  83. package/apps/web/dist/assets/changelog-BR1lxaWv.js +1 -0
  84. package/apps/web/dist/assets/{coins-DgDTBbeg.js → coins-BGZKYmu6.js} +1 -1
  85. package/apps/web/dist/assets/index-D3-kv1WF.js +14 -0
  86. package/apps/web/dist/assets/index-DcUL6teA.css +1 -0
  87. package/apps/web/dist/assets/{phone-D1Drdiio.js → phone-BzHhwehj.js} +1 -1
  88. package/apps/web/dist/assets/{runners-CTd0YAiA.js → runners-C1-zIlry.js} +1 -1
  89. package/apps/web/dist/assets/{session-DX2BcTfz.js → session-B_JeZnJ0.js} +1 -1
  90. package/apps/web/dist/assets/{settings-menu-ay9jNbQu.js → settings-menu-BZRGhsIO.js} +1 -1
  91. package/apps/web/dist/assets/theme-HcCfZDzS.js +11 -0
  92. package/apps/web/dist/assets/{ui-CJCF3Mhe.js → ui-BI1RPFWT.js} +26 -26
  93. package/apps/web/dist/assets/{upload-Dj7KPL--.js → upload-CwT8oMz0.js} +1 -1
  94. package/apps/web/dist/assets/{useMutation-CUSQpD-i.js → useMutation-byk81dDj.js} +1 -1
  95. package/apps/web/dist/assets/{volume-2-CcHZOU2m.js → volume-2-B1Pz6Iwt.js} +1 -1
  96. package/apps/web/dist/assets/{wrench-CfJTFnMJ.js → wrench-CvzXRbWN.js} +1 -1
  97. package/apps/web/dist/index.html +8 -8
  98. package/apps/web/dist/mcp/flow.html +56 -56
  99. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +2 -2
  100. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +872 -18
  101. package/node_modules/@engenty/wizards-shared/dist/definition.js +52 -11
  102. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
  103. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
  104. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
  105. package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +37 -0
  106. package/node_modules/@engenty/wizards-shared/dist/providers.js +64 -12
  107. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
  108. package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
  109. package/node_modules/@engenty/wizards-shared/dist/sync-merge.d.ts +55 -0
  110. package/node_modules/@engenty/wizards-shared/dist/sync-merge.js +214 -0
  111. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +166 -0
  112. package/node_modules/@engenty/wizards-shared/dist/sync.js +40 -0
  113. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +14 -0
  114. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +137 -0
  115. package/package.json +1 -1
  116. package/plugin/.claude-plugin/plugin.json +1 -1
  117. package/plugin/plugin.json +1 -1
  118. package/apps/web/dist/assets/PreviewPane-C4yMcZPM.js +0 -4
  119. package/apps/web/dist/assets/SettingsPage-Cd-osLDu.js +0 -2
  120. package/apps/web/dist/assets/SetupPage-Dc8U5k5P.js +0 -1
  121. package/apps/web/dist/assets/changelog-CjSBB-a4.js +0 -1
  122. package/apps/web/dist/assets/index-DS3zUVw_.css +0 -1
  123. package/apps/web/dist/assets/index-Da7hPToW.js +0 -14
  124. package/apps/web/dist/assets/theme-DanjuO1H.js +0 -11
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,A as i,Ai as a,Ar as o,B as s,Bt as c,C as l,Cr as u,D as d,Dr as f,E as p,H as m,Ht as h,I as g,Ir as _,Jr as v,Jt as y,Kt as b,L as x,Lt as S,M as C,Mr as w,N as T,O as E,Or as D,P as O,Pr as ee,Qr as k,Qt as A,R as j,Rt as M,S as te,T as N,U as P,Ut as F,V as ne,Vr as I,Vt as re,W as L,Wr as ie,Wt as R,Xn as z,Xr as B,Xt as V,Yt as H,Zt as U,_ as W,_r as G,ai as ae,b as oe,br as se,d as ce,f as le,ft as ue,g as de,h as K,hr as fe,ii as pe,j as me,jr as he,k as ge,kr as _e,m as ve,ni as ye,on as q,p as J,pr as be,qt as xe,ri as Se,ti as Ce,tn as we,ur as Y,v as Te,w as Ee,x as De,y as X,yr as Oe,z as ke,zt as Ae}from"./ui-CJCF3Mhe.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-BuYeaxK2.js";import{t as Le}from"./useMutation-CUSQpD-i.js";import{F as Re,I as ze,N as Be,S as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at,x as ot,y as st}from"./PreviewPane-C4yMcZPM.js";import{b as ct,f as lt}from"./theme-DanjuO1H.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-DX2BcTfz.js";import{t as ht}from"./phone-D1Drdiio.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-DVQm9IYx.js";import{t as yt}from"./upload-Dj7KPL--.js";import{Dt as bt,K as xt,at as St,bt as Ct,c as wt,d as Tt,f as Et,h as Dt,m as Ot,mt as kt,p as At,pt as jt,q as Mt,s as Nt,tt as Pt,u as Ft,ut as It,v as Lt,wt as Rt,xt as zt,y as Bt,yt as Vt}from"./index-Da7hPToW.js";import{a as Ht,c as Ut,f as Wt,i as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./settings-menu-ay9jNbQu.js";var Qt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Qt.node;var $t=v(Qt),en={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};en.node;var tn=v(en),nn={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};nn.node;var rn=v(nn),an={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};an.node;var on=v(an),sn={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};sn.node;var cn=v(sn),ln={name:`link`,size:24,node:[[`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`}]]};ln.node;var un=v(ln),dn={name:`list`,size:24,node:[[`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`}]]};dn.node;var fn=v(dn),pn={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};pn.node;var mn=v(pn),hn={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};hn.node;var gn=v(hn),Z=e(t(),1),Q=e(n(),1),_n={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function vn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:q(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function yn(e,t){confirm(q(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let i=ke(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:i,alt:``,loading:`lazy`,className:r(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${i}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:i,small:n});let a=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(mn,{className:a}):t.mime===`application/pdf`?(0,Q.jsx)(he,{className:a}):t.mime===`application/json`?(0,Q.jsx)(be,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(o,{className:a}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function xn({src:e,small:t}){let[n,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),i(t)}).catch(()=>i(null))},[e]),(0,Q.jsx)(`div`,{className:r(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Sn=`application/x-wizards-logo`;function Cn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):yn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Sn,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?_n:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(bn,{projectId:e,file:n})}):(0,Q.jsx)(bn,{projectId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(h,{label:q(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(je,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(h,{label:q(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(de,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(vn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(ve,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(Oe,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:i}){let[a,o]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),g=async()=>{l(!0),d(null);try{let r=await t(a.trim());r.file?(n([r.file]),i()):r.candidates?.length?(p(r.candidates),h([r.candidates[0].url])):d(q(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}l(!1)},_=async()=>{l(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}l(!1),e.length&&n(e),e.length===m.length&&i()};return(0,Q.jsx)(c,{open:!0,onClose:i,wide:f?!0:void 0,title:q(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:r(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:_n,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:r(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},t.url)})}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>p(null),children:q(`run.back`)}),(0,Q.jsx)(S,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?q(`project.addMany`,{n:m.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:s,disabled:!a.trim(),children:q(`run.next`)})]})]})})}function Tn(e,t,n){return ae({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>L.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function En(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Dn=e=>[En(e),e.pages?q(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:i}){let o=a(),s=P(e),c=Qe(e),l=ne(e,n),u=s.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,p]=(0,Z.useState)(null);if(!u)return s.isLoading?(0,Q.jsx)(y,{className:`mx-auto text-ink-3`}):null;let m=f??(d?`original`:`text`),g=c.data?.items.find(e=>e.key===`f:${u.id}`),_=ke(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:r(`rounded-full px-3 py-1 text-[0.8125rem] transition`,m===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Dn(u)}),(0,Q.jsx)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{label:q(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(G,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(q(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:g?.categories??[],originLabel:g?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(vn,{file:u,actions:l})}),u.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,Q.jsxs)(M,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[d?v(`original`,q(`project.original`)):null,v(`text`,q(`project.readText`))]}),m===`original`?u.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:_,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:_,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(An,{projectId:e,file:u})]})]})}function An({projectId:e,file:t}){let n=Tn(e,t,On);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(y,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ue,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:q(`project.textCut`,{shown:n.data.text.length.toLocaleString(we),total:n.data.chars.toLocaleString(we)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:q(`project.noText`)})}var jn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),z(e.size)].filter(Boolean).join(` · `);function Nn({projectId:e,file:t,actions:n,onClose:r}){let i=ke(e,t.id);return(0,Q.jsxs)(c,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:_n,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(vn,{file:t,actions:n})})]})}function Pn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(bn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mn(t)})]}),(0,Q.jsx)(vn,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(h,{label:q(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(de,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function Fn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(c,{open:!0,onClose:r,title:q(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:q(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(S,{variant:`danger`,onClick:n,children:q(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(S,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,disabled:!i.trim(),children:q(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:a}){let o=ne(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(r),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=s({assetSections:g},a),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),ee=new Set(g.flatMap(e=>e.assets)),k=g.find(e=>e.id===v)??null,A=k?k.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!ee.has(e.id)),j=D.find(e=>e.id===f),M=u.trim().toLowerCase(),te=M?A.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(M)):A,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),P=async e=>{let t=k?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},F=e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},I=g.length?{options:[{value:``,label:q(`project.assetsGeneral`)},...g.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>g.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,re=[{label:q(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:q(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...g.length<i.logoSections?[{label:q(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],L=g.length||D.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[g.length?(0,Q.jsx)(U,{value:v,onChange:e=>{b(e),d(``)},label:q(`project.assets`),options:[{id:``,label:q(`project.assetsGeneral`)},...g.map(e=>({id:e.id,label:e.title||q(`project.sectionUntitled`)}))]}):null,k&&!n?(0,Q.jsx)(h,{label:q(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(se,{className:`size-4`})}):null]}),A.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Te,{value:u,onChange:d,placeholder:q(`project.assetSearch`)})}),(0,Q.jsx)(h,{label:q(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Ct,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:q(`project.assets`),hint:q(`project.assetsHint`),save:E,tabs:L,action:n?null:(0,Q.jsx)(ce,{entries:re}),children:[(0,Q.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:jn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&P(t)}}),te.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:te,actions:o,moveTo:I,onRemove:F,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:I,onPreview:()=>p(t.id),onRemove:()=>F(t)},t.id))}):A.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.staysLocal`)}):(0,Q.jsxs)(ve,{accept:jn,onFiles:e=>void P(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),q(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:q(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,Q.jsx)(Nn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,Q.jsx)(Fn,{section:x===`current`?k:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&k)_(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=De();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&k?()=>{(!k.assets.length||confirm(q(`project.assetSectionRemoveConfirm`,{name:k.title})))&&(_(e=>e.filter(e=>e.id!==k.id)),b(``),S(null))}:void 0}):null,C?(0,Q.jsx)(wn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,k?.id??null)}}):null]})}var Ln=/^#[0-9a-fA-F]{6}$/;async function Rn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var zn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Bn({projectId:e,gradient:t,isNew:n,brand:i,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[u,f]=(0,Z.useState)(O(t)),[p,m]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!n),T=e=>{l(e),f(O(e)),m(!1)},E=(e,t)=>T({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),D=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));T({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},ee=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:g.trim(),...C?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});T({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),w(!0)}catch(e){x(e.message)}y(!1)};return(0,Q.jsx)(c,{open:!0,onClose:o,wide:!0,title:q(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g.trim()&&!v&&ee()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:g,maxLength:1e3,"aria-label":q(`project.gradientDescribe`),placeholder:q(C?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(S,{type:`submit`,variant:`secondary`,busy:v,disabled:!g.trim(),children:[(0,Q.jsx)(be,{className:`size-4`}),q(C?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??q(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:O(s)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:q(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:q(`project.gradientUse`),onChange:e=>l({...s,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:d.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:q(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":q(`project.gradientAngle`),onChange:e=>T({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(H,{value:Ln.test(e.color)?e.color:`#888888`,onChange:e=>E(t,{color:e.target.value})}),(0,Q.jsx)(F,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Ln.test(n)&&E(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":q(`project.gradientAt`),onChange:e=>E(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(h,{label:q(`project.remove`),disabled:s.stops.length<=2,onClick:()=>T({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.gradientStopAdd`)]}):null,i.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:q(`project.gradientFromBrand`)}),i.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>D(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:`CSS`}),(0,Q.jsx)(F,{value:u,spellCheck:!1,onChange:e=>{f(e.target.value);let t=j(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:q(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:o,children:q(`common.cancel`)}),(0,Q.jsx)(S,{onClick:()=>{a(s),o()},children:q(`settings.save`)})]})]})})}var Vn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Hn=`size-8 bg-card shadow-soft hover:bg-card`;function Un({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(K,{value:e,label:q(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:q(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wn({gradient:e,readOnly:t,onEdit:n,onChange:i,onRemove:a}){let o=O(e),[s,c]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":q(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(h,{label:q(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(_,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),t?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:q(`project.gradientName`),description:e.description,usePlaceholder:q(`project.gradientUse`),readOnly:t,onChange:i})]})}function Gn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kn({projectId:e,pattern:t,fileName:n,readOnly:i,onEdit:a,onChange:o,onRemove:s}){let c=ke(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-label":q(`project.patternEdit`),onClick:a,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gn(c,t.tile)}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(`a`,{href:c,download:n,"aria-label":q(`project.download`),title:q(`project.download`),className:r(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(ee,{className:`size-4`})}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:q(`project.patternUse`),readOnly:i,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:i,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,p]=(0,Z.useState)(t),[m,h]=(0,Z.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:_,wide:!0,title:q(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gn(ke(e,f.file),f.tile),children:(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[a?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(D,{className:`size-4`}),q(`project.patternReplace`)]})}):(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(D,{className:`size-5`}),q(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?i(f.file):q(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:q(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:_,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!f.file||a,onClick:()=>{for(let e of m.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:q(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)([]),h=async()=>{s(!0),u(null);try{let{colors:t}=await L.post(`/api/studio/projects/${e}/colors/scan`,{url:i.trim()});t.length?(f(t),m([])):u(q(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:q(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:r(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>f(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?q(`project.addMany`,{n:p.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorsUrlHint`)})]}),l?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:o,disabled:!i.trim(),children:q(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:a,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:De()}))),[g,_]=(0,Z.useState)(r),[v,y]=(0,Z.useState)(a),[b,x]=(0,Z.useState)(o),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=ne(e,f),D=te(c),[O,ee]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N=s({colors:p.filter(e=>Jn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:g,gradients:v,patterns:b,colorRules:D.rules},d),P=l?g:[],I=P.filter(e=>(e.kind??`colors`)===`colors`),re=e=>I.some(t=>t.id===e.section),L=p.filter(e=>!re(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),B=e=>m(t=>[...t,...e.map(e=>({...e,id:De()}))].slice(0,i.colors)),V=[{value:``,label:q(`project.sectionStandard`)},...I.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],U=(e,t)=>{let n=De();ee(n),_(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},G=e=>({id:De(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&Jn.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&Jn.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),ae=e=>t.files.find(t=>t.id===e)?.name??`pattern`,se=[...p.length<i.colors?[{label:q(`project.colorNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>K()},{label:q(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&g.length<i.logoSections?[{label:q(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>U(`colors`,``)},{label:q(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>U(`gradients`,q(`project.gradientSectionTitle`))},{label:q(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>U(`patterns`,q(`project.patternSectionTitle`))}]:[],...!u||D.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],ue=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(H,{value:Jn.test(e.value)?e.value:`#888888`,onChange:t=>z(e.id,{value:t.target.value})}),(0,Q.jsx)(F,{value:e.name,autoFocus:e.id===k,placeholder:q(`project.colorName`),maxLength:120,onChange:t=>z(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(F,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>z(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===R?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.colorAccent`)})}):f?null:(0,Q.jsx)(h,{label:q(`project.colorFirst`),onClick:()=>m(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(ie,{className:`size-4`})}),f||!I.length?null:(0,Q.jsx)(de,{options:V,value:re(e)?e.section??``:``,onChange:t=>z(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>m(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]},e.id),K=e=>{let t=De();A(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:q(`project.colors`),hint:q(`project.colorsHint`),save:N,locked:f,action:f?null:(0,Q.jsx)(ce,{entries:se}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[L.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:L.map(ue)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.colorsEmpty`)}),P.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),a=v.filter(e=>e.section===t.id),o=b.filter(e=>e.section===t.id),s=n===`gradients`?a.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:t.title,titlePlaceholder:q(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:q(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:q(`project.kindPatterns`)}:{icon:(0,Q.jsx)(jt,{}),label:q(`project.kindColors`)},autoFocus:O===t.id,readOnly:f,onChange:e=>_(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(q(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||q(`project.sectionUntitled`)}))){_(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),y(e=>e.filter(e=>e.section!==t.id));for(let e of o)E.remove(e.file);x(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>C(e),onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>y(t=>t.filter(t=>t.id!==e.id))},e.id)),f||v.length>=i.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>C(G(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(Kn,{projectId:e,pattern:t,fileName:ae(t.file),readOnly:f,onEdit:()=>T(t),onChange:e=>x(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{E.remove(t.file),x(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||b.length>=i.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T({id:De(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ue),f||p.length>=i.colors?null:(0,Q.jsx)(le,{label:q(`project.colorAdd`),onClick:()=>K(t.id)})]})]},t.id)}),u?(0,Q.jsx)(W,{rules:D,placeholder:q(`project.colorRulePlaceholder`),readOnly:f}):null]}),E.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.error}):null,S?(0,Q.jsx)(Bn,{projectId:e,gradient:S,isNew:!v.some(e=>e.id===S.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>C(null),onSave:e=>y(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,w?(0,Q.jsx)(qn,{projectId:e,pattern:w,isNew:!b.some(e=>e.id===w.id),fileName:ae,busy:E.busy,error:E.error,upload:async e=>(await E.upload(`pattern`,[e]))[0]??null,removeFile:e=>void E.remove(e),onClose:()=>T(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,j?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:B}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:f,email:Vt,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let l=Qn[e??t],u=`${q(`project.factType`)}: ${q(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),a(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":i,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:r(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,i?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),i?(0,Q.jsxs)(`div`,{role:`menu`,className:r(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(Fe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=Qn[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),a=(0,Z.useRef)(null),[o,c]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=s(o.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),d=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:q(`project.facts`),hint:q(`project.factsHint`),save:u,locked:n,action:o.length<i.facts&&!n?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=me(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(F,{ref:p(`${e.id}:label`),value:e.label,placeholder:q(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:C(e.label,o.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(V,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:q(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?q(`project.yes`):q(`project.no`)})]}):(0,Q.jsx)(A,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:q(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)($n,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},e.id)})}),o.length<i.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:q(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-3.5`}),` `,q(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[i,a]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),a(!0))},onDragLeave:()=>a(!1),onDrop:t=>{let n=t.dataTransfer.getData(Sn);a(!1),n&&(t.preventDefault(),e(n))},className:r(`-m-2 rounded-xl p-2 transition`,i&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function nr({projectId:e,data:t,readOnly:n,sections:r,rules:a,sectioned:o,ruled:c,save:l}){let u=ne(e,n),[d,f]=(0,Z.useState)(r),p=te(a),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=s({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=o?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=g(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),ee=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},k=C.length?{options:[{value:``,label:q(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,A=(t,n,r)=>(0,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?q(`project.logoAdd`):void 0,onUpload:e=>void ee(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:k,onRemove:e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:q(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:q(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<i.logoSections?[{label:q(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=De();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:q(`project.logos`),hint:q(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(ce,{entries:M}),children:[(0,Q.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ee(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:A(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(tr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:e.title,description:e.description,titlePlaceholder:q(`project.logoSectionTitle`),descriptionPlaceholder:q(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(q(`project.logoSectionRemoveConfirm`,{name:e.title||q(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),A(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(W,{rules:p,placeholder:q(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,Q.jsx)(wn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var rr=e=>URL.canParse(e)?new URL(e).host:e;async function ir(e,t){let n=T({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ar(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function ar(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function or(e,t){let n=e.source;if(!n)return q(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return q(`project.fontSourceFile`,{name:e})}return q(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:i}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=ne(e),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[d,f]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[h,g]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(t.license??``),[C,w]=(0,Z.useState)(!1),T=p.trim(),E=async()=>{v(!0),g({url:T,result:await ir(T,t.family.trim())}),v(!1)},D=l===`file`?d?{file:d}:null:h?.url===T&&h.result===`ok`?{url:T}:null,O=h?.url===T?h.result:null;return(0,Q.jsx)(c,{open:!0,onClose:i,title:q(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontSourceHint`)}),(0,Q.jsx)(b,{value:l,options:[`file`,`url`],label:e=>q(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>f(e.id),className:r(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,d===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&f(n.id)}}),(0,Q.jsxs)(S,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),q(`project.fontSourceUpload`)]}),o.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),E()},children:[(0,Q.jsx)(R,{children:q(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:q(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(S,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:q(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:q(`project.fontCheck.${O}`,{host:rr(T),family:t.family})}):null,O===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:q(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:q(`project.fontLicenseHint`),children:q(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:q(`project.fontLicensePlaceholder`),onChange:e=>x(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:C,onChange:e=>w(e.target.checked)}),q(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(S,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),i()},children:q(`project.fontSourceRemove`)}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!(D&&C),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),i())},children:q(`project.fontSourceSave`)})]})]})})}var cr=new Set;function lr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||cr.has(t))return;cr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${p.join(`,`)}&display=swap`,document.head.append(n)},[e])}var ur=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function dr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var fr=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,pr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function mr({projectId:e,font:t,first:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){lr(t.family);let c=P(e).data?.files??[],[l,u]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:ur(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(K,{value:t.family,label:q(`project.fontFamily`),placeholder:q(`project.fontFamily`),maxLength:80,autoFocus:a,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(K,{value:t.role,label:q(`project.fontRole`),placeholder:q(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:p.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>o({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:ur(t.family),fontWeight:e},className:r(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(K,{value:t.license??``,label:q(`project.fontLicense`),placeholder:q(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),i&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:q(`project.fontUses`)}),N.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):N.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:r(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:[n?(0,Q.jsx)(I,{className:`size-3.5`}):null,q(pr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:or(t,c)}),i||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:q(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:ur(c?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[i?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(K,{value:e.name,label:q(`project.styleName`),placeholder:q(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:i,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":q(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:r(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||q(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":q(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...p,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:q(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:q(`project.styleLine`),label:q(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:q(`project.styleTracking`),label:q(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:q(`project.styleUpper`),"aria-label":q(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:r(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(rn,{className:`size-4`})})]}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gr({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),l(null);try{let{fonts:t}=await L.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(q(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:q(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,Q.jsx)(_r,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?q(`project.addMany`,{n:f.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function _r({font:e,on:t,onToggle:n}){return lr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:r(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:ur(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):q(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:a,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=te(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=s({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:De(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,i.fonts))},x=()=>{let e=De();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<i.fonts?[{label:q(`project.fontNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:q(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<i.textStyles?[{label:q(`project.styleNew`),icon:(0,Q.jsx)(It,{className:`size-4 shrink-0`}),onPick:x}]:[],...!a||m.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:q(`project.typography`),hint:q(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(ce,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(mr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:q(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(hr,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,a?(0,Q.jsx)(W,{rules:m,placeholder:q(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(gr,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function yr({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=s({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(X,{title:q(`project.base`),hint:q(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.title`)}),(0,Q.jsx)(F,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.about`)}),(0,Q.jsx)(A,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.aboutHint`)})]})]})})}function br({project:e,group:t,top:n=!1,children:r}){let i=a(),o=P(e.id),[s,l]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(!1),f=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},p=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),m=pt(),h=dt(),g=o.data??{files:[],embeddings:!0},_=`${e.id}:${s}`,v=e.readOnly,y=t===`knowledge`,b=St(`brandSections`),x=St(`brandRules`),C=St(`typography`);return Mt(v?{}:{title:q(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:q(y?`project.assistantHelloKnowledge`:`project.assistantHello`),about:q(y?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:q(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:q(`assistant.suggest.knowledgeHow`)},{label:q(`assistant.suggest.knowledgeSite`),fill:!0},{label:q(`assistant.suggest.knowledgeCategories`)}]:[{label:q(`assistant.suggest.readSite`),fill:!0},{label:q(`assistant.suggest.missing`)},{label:q(`assistant.suggest.facts`)}],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>l(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,Q.jsx)(vt,{children:gt(e)}):n?(0,Q.jsx)(xt,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:f},`base:${_}`)}),(0,Q.jsx)(J,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>f({facts:e}),readOnly:v},`facts:${_}`)}),(0,Q.jsx)(J,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>f({brand:e})},`logos:${_}`)}),(0,Q.jsx)(J,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>f({brand:e}),readOnly:v},`colors:${_}`)}),C?(0,Q.jsx)(J,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||q(`project.typeSample`),save:e=>f({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,Q.jsx)(J,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>f({brand:e})},`assets:${_}`)})]}):null,r,t===`info`&&m&&!v&&h?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(S,{variant:`danger`,onClick:()=>d(!0),children:q(`settings.delete`)}),(0,Q.jsxs)(c,{open:u,onClose:()=>d(!1),title:q(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:q(`settings.deleteBody`)}),p.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:p.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(!1),children:q(`common.cancel`)}),(0,Q.jsx)(S,{variant:`danger`,busy:p.isPending,onClick:()=>p.mutate(),children:q(`common.delete`)})]})]})]}):null]})}var xr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Sr=`font-mono text-[0.875rem]`,Cr=e=>e.slice(e.indexOf(`.`)+1);function wr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Tr(){let e=q(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(B,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:q(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(B,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:q(`project.facts`)},t):e),` `,q(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:i}){let a=ge.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Cr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:i,"aria-label":q(`page.address`),maxLength:E.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:r(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$,!a&&t&&`text-rose`),children:q(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:i}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:i,maxLength:E.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:i,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:r(`mt-1`,$),children:q(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:i,maxLength:E.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.words`)}),(0,Q.jsx)(A,{value:t.intro??``,disabled:i,minRows:3,maxLength:E.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.lang`)}),(0,Q.jsx)(xe,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:q(e.label)}))}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return q(`page.draftNote`);if(!e.shareEnabled)return q(`page.notSharedNote`);let n=e.description.trim();return t?[n,q(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:i,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:r(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`page.moveUp`)} / ${q(`page.moveDown`)}`,onKeyDown:o.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(_e,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(mt,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:r(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(V,{checked:n,disabled:i||!e.published,label:q(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:i,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:i||a,onClick:o,className:r(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:a?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(i||a)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var jr={desktop:1280,tablet:768,mobile:390},Mr=`wizards.pagePreviewDevice`,Nr=`wizards.pagePreviewHeight`,Pr=360,Fr=e=>e?640:480,Ir=()=>Math.max(Pr,window.innerHeight-140);function Lr(){try{let e=Number(localStorage.getItem(Nr));return e>=Pr?e:null}catch{return null}}function Rr(e){try{e===null?localStorage.removeItem(Nr):localStorage.setItem(Nr,String(Math.round(e)))}catch{}}function zr(){try{let e=localStorage.getItem(Mr);return e&&e in jr?e:`desktop`}catch{return`desktop`}}function Br(e){try{localStorage.setItem(Mr,e)}catch{}}function Vr({url:e,version:t,device:n}){let i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let s=jr[n],[c,l]=(0,Z.useState)(Lr),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=Math.min(c??Fr(a.tall),a.width?Ir():9999),m=e=>{let t=Math.round(Math.min(Ir(),Math.max(Pr,e)));return l(t),t},h=n===`mobile`,g=h?12:0,_=a.width?Math.min(1,(a.width-2*g)/s):1,v=(0,Q.jsxs)(`div`,{className:r(`relative overflow-hidden bg-paper-2`,h?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(s*_),height:p},children:[a.width?(0,Q.jsx)(`iframe`,{title:q(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:r(`absolute top-0 left-0 border-0`,u&&`pointer-events-none`),style:{width:s,height:Math.ceil(p/_),transform:`scale(${_})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":q(`page.resize`),title:q(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}f.current={y:e.clientY,height:p},d(!0)},onPointerMove:e=>{f.current&&m(f.current.height+e.clientY-f.current.y)},onPointerUp:e=>{f.current&&=(Rr(m(f.current.height+e.clientY-f.current.y)),null),d(!1)},onPointerCancel:()=>{f.current=null,d(!1)},onDoubleClick:()=>{l(null),Rr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Rr(m(p+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:i,className:`flex w-full justify-center`,children:h?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:v}):v})}function Hr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Ve(t)})),l=s(o,async e=>{if(!(ge.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=st(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Dr,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Ur({project:e}){let t=a(),n=ft(),i=n.data?.tenant.pagesHost??null,o=n.data?.manageUrl??null,s=e.readOnly,c=e.page,l=!!c?.on,u=ae({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[d,f]=(0,Z.useState)(1),[p,m]=(0,Z.useState)(zr),h=(0,Z.useRef)(c);h.current=c;let g=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),f(e=>e+1)},v=Le({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[y,b]=(0,Z.useState)({state:`idle`,error:null}),{copied:C,copy:w}=wr(),T=u.data??[],E=(c?.wizards??[]).map(e=>T.find(t=>t.id===e)).filter(e=>e!==void 0),D=T.filter(e=>!c?.wizards.includes(e.id)),[O,ee]=(0,Z.useState)(null),k=(e,t)=>{let n=[...c?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),v.mutate({wizards:n})},A=(e,t)=>v.mutate({wizards:t?[...c?.wizards??[],e]:(c?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>g({on:!0,slug:x(j)||`page`,title:j,...st(we===`de`?`de-du`:`en`),wizards:T.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{c?v.mutate({on:e}):e&&te.mutate()},P=v.isPending||te.isPending,F=v.error??te.error;if(!i)return(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsx)(X,{title:q(`space.page`),hint:q(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:q(`page.cloudOnly`)})})});let ne=c?.slug||x(j)||`…`,re=We(i,ne),ie=ot(i,ne,o),R=(0,Q.jsxs)(`span`,{className:r(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[i,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:ne})]}),z=s||!c,B=(0,Q.jsxs)(M,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.previewTitle`)}),l?(0,Q.jsx)(rt,{named:!0,label:q(`editor.device`),value:p,onChange:e=>{m(e),Br(e)},options:[{id:`desktop`,label:q(`editor.deviceDesk`),icon:(0,Q.jsx)(kt,{className:`size-3.5`})},{id:`tablet`,label:q(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:q(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),l?(0,Q.jsx)(Vr,{url:ie,version:d,device:p}):(0,Q.jsx)(`p`,{className:$,children:q(`page.previewOff`)}),l?(0,Q.jsx)(`p`,{className:$,children:q(`page.previewHint`)}):null]}),H=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:q(`share.onPage`,{space:c?.title||j})}),(0,Q.jsx)(`span`,{className:r(`block truncate font-mono`,$),children:re})]}),(0,Q.jsx)(V,{checked:!0,disabled:!0,label:q(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:q(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:q(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:q(`page.intro`)})]}),(0,Q.jsxs)(M,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:r(`size-2 shrink-0 rounded-full`,l?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),R]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>w(ie),children:[C?(0,Q.jsx)(I,{className:`size-3.5`}):(0,Q.jsx)(_,{className:`size-3.5`}),q(C?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(S,{size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>window.open(ie,`_blank`,`noopener`),children:[q(`page.open`),` `,(0,Q.jsx)(bt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:q(`page.sectionPage`),locked:s,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":q(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:q(`page.whoOff`),text:q(`page.whoOffHint`),picked:!l,disabled:s||P,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:q(`page.whoPublic`),text:q(`page.whoPublicHint`),picked:l,disabled:s||P,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:q(`page.whoMembers`),text:q(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),F?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:F.message}):null]})]})}),B,(0,Q.jsx)(J,{id:`page-words`,children:(0,Q.jsx)(X,{title:q(`page.sectionWords`),hint:c?void 0:q(`page.notYet`),save:c?y:void 0,locked:z,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[c?(0,Q.jsx)(Hr,{host:i,page:c,disabled:s,save:g,onState:b},`${e.id}:${c.slug}`):(0,Q.jsx)(Dr,{host:i,disabled:!0,words:{slug:ne,title:j,headline:``,intro:``,voice:we===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:q(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[E.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:z,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>ee(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{O!==null&&k(O,t),ee(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),D.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:z,onToggle:t=>A(e.id,t)},e.id))]}),T.length?null:(0,Q.jsx)(`p`,{className:r(`mt-2`,$),children:q(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:r(`mt-4`,$),children:q(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),H]})}var Wr=`results-search`,Gr={q:``,mode:``,days:0};function Kr(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return ae({queryKey:[`results`,e,i],queryFn:()=>L.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function qr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return Pt({icon:fe,label:q(`space.resultsSearch`),run:()=>{let e=document.getElementById(Wr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(xe,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:q(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(fe,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(F,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Wr,placeholder:q(`space.resultsSearch`),"aria-label":q(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(xe,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:q(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(xe,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:q(`space.resultsAnyTime`)},{value:`1`,label:q(`space.resultsDay`)},{value:`7`,label:q(`space.resultsDays`,{n:7})},{value:`30`,label:q(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Jr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(we,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):q(`space.resultsAll`),hint:q(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(qr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(M,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,q(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:q(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(u,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(re,{children:r.q.trim()||r.mode||r.days?q(`space.resultsNone`):q(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(tt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(lt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Yr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Lt(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xr(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=Lt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Zr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Qr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ht,{icon:e.icon??Me,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Gt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function $r(){let{group:e}=Se(),[t,n]=pe(),i=ye(),a=Ce(),{hash:o}=a,{project:s,loading:c}=ut(),l=Ft(),u=Zt(),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=Et(e)?e:void 0,v=_?void 0:l.spaceParts.find(t=>t.id===e),y=_??v?.id,b=a.state?.parts===!0,x=St(`pages`),S=Ot().filter(e=>x||e.id!==`page`),C=Dt(S,l).map(e=>({...e,to:`/space/${e.id}`})),w={id:`results`,label:q(`space.results`),icon:Rt,to:`/space/results`},T=_===`results`?w:C.find(e=>e.id===y),E=t.get(`show`),D=_===`results`?2:y?E?2:1:0,O=_===`results`?1:u?Math.min(D,1):y&&h!==y&&!b?1:0,ee=Wt(O),A=Wt(D),j=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:m}),[d,u]),M=s?s.brand.name?.trim()||s.name:q(`nav.project`),te=St(`typography`)?[]:[`typography`],N=v?l.spaceMenus[v.id]??[]:[],P=v?[{plugin:null,label:null,sections:N}]:_&&_!==`results`?At(_,l,te):[],F=_?At(_,l).filter(e=>e.plugin):[],ne=Yr([...P,..._===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),I=_===`results`&&E&&E!==`all`?E:null,[L,ie]=(0,Z.useState)(Gr),R=Kr(_===`results`?s?.id:void 0,I,L),z=R.data?.wizards.find(e=>e.id===I)?.title,B=_===`data`&&E&&E!==`all`||_===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,V=B?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=_===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(_===`data`?s?.id:void 0),W=Qe(_===`knowledge`?s?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),ae=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),oe=_===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?ae?.name:W.data?.items.find(e=>e.key===B)?.title:U.data?nt(U.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;Bt([..._===`results`?[]:[{label:q(`nav.project`),to:`/space`}],...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(p??z??oe)?[{label:p??z??oe}]:[]]);let se={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Mt({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:q(`assistant.suggest.dataWhat`)},{label:q(`assistant.suggest.dataWho`)},{label:q(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:q(`assistant.suggest.resultsFailed`)},{label:q(`assistant.suggest.resultsCost`)},{label:q(`assistant.suggest.resultsShare`)}]}:{},...B&&oe?{open:{kind:se[B[0]]??`item`,id:B.slice(2),label:oe}}:I&&z?{open:{kind:`wizard`,id:I,label:z}}:{}});let ce=_===`results`||_===`data`||B?o.slice(1):E||o.slice(1),le=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${ce}`;ce&&le.current!==e&&document.getElementById(ce)&&(le.current=e,requestAnimationFrame(()=>Zr(ce,!1)))},[y,ce,s?.id,l.spaceSections,N.length]),(0,Z.useEffect)(()=>{!u&&(y===`knowledge`||y===`data`)&&Lt().scrollTo({top:0})},[u,y,B]);let ue=Xr();if(!y){let t=o.slice(1),n=t?Tt(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(k,{to:u?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&l.status!==`ready`)return null;if(e!==void 0||!u)return(0,Q.jsx)(k,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(_===`knowledge`&&!E&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let de=e=>{if(u){i({search:`?show=${e}`});return}le.current=`${y}#${e}`,Zr(e,!0),i({search:``,hash:e},{replace:!0})},K=e=>u?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),fe=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(J,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Nt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=u?void 0:ne,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:O===1?T??null:null,onBack:_===`results`?void 0:()=>u?i(`/space`):g(y??null),root:{icon:zt,label:q(`nav.project`),backLabel:q(`nav.wizards`),onBack:()=>i(`/`)}}),(0,Q.jsx)(`div`,{className:r(Ut(ee)),children:O===0?(0,Q.jsx)(Jt,{entries:C,current:u?void 0:T,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:f})},O)]});return(0,Q.jsx)(qt.Provider,{value:j,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:r(`grid gap-6`,_!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[_===`results`?null:(0,Q.jsx)(`aside`,{className:r(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&D===2&&`hidden`,u&&A===`back`&&Ut(`back`)),style:!u&&ue?{maxHeight:ue-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:he}),y?(0,Q.jsxs)(`div`,{className:r(`min-w-0`,u&&D<2&&`hidden`,u&&A===`deeper`&&Ut(`deeper`)),children:[u&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:T?.label??M,onBack:()=>i(`/space/${y}`)})}):null,_===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Ct,label:q(`data.all`),selected:!u&&!B,onPick:()=>K(`all`)})}),U.data?nt(U.data).map(e=>(0,Q.jsx)(Gt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ht,{icon:Ue[e.kind],label:e.title,selected:!u&&e.key===B,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,Q.jsx)(Qr,{groups:F,current:me,onPick:de})]}):_===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Ct,label:q(`know.all`),selected:!(u||B),onPick:()=>K(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:q(`know.categories`),children:W.data.categories.map(e=>(0,Q.jsx)(Ht,{icon:Ye[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(Qr,{groups:F,current:u?void 0:V?.id,onPick:e=>K(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)(Qr,{groups:P,current:me,onPick:de})}),s&&(_===`info`||_===`knowledge`)?(0,Q.jsxs)(br,{project:s,group:_,top:!B||!!V,children:[_===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>K(`all`),onOpen:K},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>K(`all`)},H):(0,Q.jsx)(kn,{projectId:s.id,fileId:H.slice(2),readOnly:s.readOnly,onGone:()=>K(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(Nt,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?ae?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:s.id,category:ae,readOnly:s.readOnly,onOpen:K,onGone:()=>K(`all`)}),ae.type===`choice`?null:(0,Q.jsx)(it,{projectId:s.id,category:ae,categories:W.data.categories,onOpen:K})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:G.data.items.map(e=>(0,Q.jsx)(Ke,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:K},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(J,{id:`documents`,children:(0,Q.jsx)(et,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:K})}):null:null,_===`info`?fe(F):null]},s.id):null,s&&_===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:s},s.id),fe(F)]}):null,s&&v?(0,Q.jsx)(Nt,{of:v,children:(0,Q.jsx)(wt,{part:v.id,children:(0,Q.jsx)(v.component,{})},s.id)}):null,s&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:B.slice(2),onGone:()=>K(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>K(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:K}):null,fe(F)]})}):null,s&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,Q.jsx)(Jr,{data:R.data,wizardId:I,onWizard:e=>K(e??`all`),filter:L,onFilter:ie}):null,R.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,fe(F)]}):null,s||c?null:(0,Q.jsx)(re,{children:q(`settings.noProject`)})]}):null]})})})}export{$r as ProjectPage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,A as i,Ai as a,Ar as o,B as s,Bt as c,C as l,Cr as u,D as d,Dr as f,E as p,H as m,Ht as h,I as g,Ir as _,Jr as v,Jt as y,Kt as b,L as x,Lt as S,M as C,Mr as w,N as T,O as E,Or as D,P as O,Pr as ee,Qr as k,Qt as A,R as j,Rt as M,S as te,T as N,U as P,Ut as F,V as ne,Vr as I,Vt as re,W as L,Wr as ie,Wt as R,Xn as z,Xr as B,Xt as V,Yt as H,Zt as U,_ as W,_r as G,ai as ae,b as oe,br as se,d as ce,f as le,ft as ue,g as de,h as K,hr as fe,ii as pe,j as me,jr as he,k as ge,kr as _e,m as ve,ni as ye,on as q,p as J,pr as be,qt as xe,ri as Se,ti as Ce,tn as we,ur as Y,v as Te,w as Ee,x as De,y as X,yr as Oe,z as ke,zt as Ae}from"./ui-BI1RPFWT.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-Cnd8BF3q.js";import{t as Le}from"./useMutation-byk81dDj.js";import{F as Re,I as ze,N as Be,S as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at,x as ot,y as st}from"./PreviewPane-GHcVV2Hu.js";import{b as ct,f as lt}from"./theme-HcCfZDzS.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-B_JeZnJ0.js";import{t as ht}from"./phone-BzHhwehj.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-Mv5M2OV9.js";import{t as yt}from"./upload-CwT8oMz0.js";import{Ct as bt,Dt as xt,J as St,St as Ct,_t as wt,c as Tt,ct as Et,d as Dt,f as Ot,gt as kt,h as At,it as jt,jt as Mt,m as Nt,p as Pt,pt as Ft,q as It,s as Lt,u as Rt,v as zt,wt as Bt,y as Vt}from"./index-D3-kv1WF.js";import{a as Ht,c as Ut,f as Wt,i as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./settings-menu-BZRGhsIO.js";var Qt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Qt.node;var $t=v(Qt),en={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};en.node;var tn=v(en),nn={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};nn.node;var rn=v(nn),an={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};an.node;var on=v(an),sn={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};sn.node;var cn=v(sn),ln={name:`link`,size:24,node:[[`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`}]]};ln.node;var un=v(ln),dn={name:`list`,size:24,node:[[`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`}]]};dn.node;var fn=v(dn),pn={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};pn.node;var mn=v(pn),hn={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};hn.node;var gn=v(hn),Z=e(t(),1),Q=e(n(),1),_n={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function vn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:q(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function yn(e,t){confirm(q(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let i=ke(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:i,alt:``,loading:`lazy`,className:r(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${i}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:i,small:n});let a=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(mn,{className:a}):t.mime===`application/pdf`?(0,Q.jsx)(he,{className:a}):t.mime===`application/json`?(0,Q.jsx)(be,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(o,{className:a}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function xn({src:e,small:t}){let[n,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),i(t)}).catch(()=>i(null))},[e]),(0,Q.jsx)(`div`,{className:r(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Sn=`application/x-wizards-logo`;function Cn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):yn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Sn,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?_n:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(bn,{projectId:e,file:n})}):(0,Q.jsx)(bn,{projectId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(h,{label:q(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(je,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(h,{label:q(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(de,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(vn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(ve,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(Oe,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:i}){let[a,o]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),g=async()=>{l(!0),d(null);try{let r=await t(a.trim());r.file?(n([r.file]),i()):r.candidates?.length?(p(r.candidates),h([r.candidates[0].url])):d(q(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}l(!1)},_=async()=>{l(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}l(!1),e.length&&n(e),e.length===m.length&&i()};return(0,Q.jsx)(c,{open:!0,onClose:i,wide:f?!0:void 0,title:q(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:r(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:_n,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:r(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},t.url)})}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>p(null),children:q(`run.back`)}),(0,Q.jsx)(S,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?q(`project.addMany`,{n:m.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:s,disabled:!a.trim(),children:q(`run.next`)})]})]})})}function Tn(e,t,n){return ae({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>L.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function En(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Dn=e=>[En(e),e.pages?q(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:i}){let o=a(),s=P(e),c=Qe(e),l=ne(e,n),u=s.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,p]=(0,Z.useState)(null);if(!u)return s.isLoading?(0,Q.jsx)(y,{className:`mx-auto text-ink-3`}):null;let m=f??(d?`original`:`text`),g=c.data?.items.find(e=>e.key===`f:${u.id}`),_=ke(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:r(`rounded-full px-3 py-1 text-[0.8125rem] transition`,m===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Dn(u)}),(0,Q.jsx)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{label:q(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(G,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(q(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:g?.categories??[],originLabel:g?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(vn,{file:u,actions:l})}),u.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,Q.jsxs)(M,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[d?v(`original`,q(`project.original`)):null,v(`text`,q(`project.readText`))]}),m===`original`?u.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:_,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:_,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(An,{projectId:e,file:u})]})]})}function An({projectId:e,file:t}){let n=Tn(e,t,On);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(y,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ue,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:q(`project.textCut`,{shown:n.data.text.length.toLocaleString(we),total:n.data.chars.toLocaleString(we)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:q(`project.noText`)})}var jn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),z(e.size)].filter(Boolean).join(` · `);function Nn({projectId:e,file:t,actions:n,onClose:r}){let i=ke(e,t.id);return(0,Q.jsxs)(c,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:_n,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(vn,{file:t,actions:n})})]})}function Pn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(bn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mn(t)})]}),(0,Q.jsx)(vn,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(h,{label:q(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(de,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function Fn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(c,{open:!0,onClose:r,title:q(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:q(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(S,{variant:`danger`,onClick:n,children:q(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(S,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,disabled:!i.trim(),children:q(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:a}){let o=ne(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(r),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=s({assetSections:g},a),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),ee=new Set(g.flatMap(e=>e.assets)),k=g.find(e=>e.id===v)??null,A=k?k.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!ee.has(e.id)),j=D.find(e=>e.id===f),M=u.trim().toLowerCase(),te=M?A.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(M)):A,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),P=async e=>{let t=k?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},F=e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},I=g.length?{options:[{value:``,label:q(`project.assetsGeneral`)},...g.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>g.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,re=[{label:q(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:q(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...g.length<i.logoSections?[{label:q(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],L=g.length||D.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[g.length?(0,Q.jsx)(U,{value:v,onChange:e=>{b(e),d(``)},label:q(`project.assets`),options:[{id:``,label:q(`project.assetsGeneral`)},...g.map(e=>({id:e.id,label:e.title||q(`project.sectionUntitled`)}))]}):null,k&&!n?(0,Q.jsx)(h,{label:q(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(se,{className:`size-4`})}):null]}),A.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Te,{value:u,onChange:d,placeholder:q(`project.assetSearch`)})}),(0,Q.jsx)(h,{label:q(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(bt,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:q(`project.assets`),hint:q(`project.assetsHint`),save:E,tabs:L,action:n?null:(0,Q.jsx)(ce,{entries:re}),children:[(0,Q.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:jn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&P(t)}}),te.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:te,actions:o,moveTo:I,onRemove:F,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:I,onPreview:()=>p(t.id),onRemove:()=>F(t)},t.id))}):A.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.staysLocal`)}):(0,Q.jsxs)(ve,{accept:jn,onFiles:e=>void P(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),q(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:q(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,Q.jsx)(Nn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,Q.jsx)(Fn,{section:x===`current`?k:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&k)_(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=De();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&k?()=>{(!k.assets.length||confirm(q(`project.assetSectionRemoveConfirm`,{name:k.title})))&&(_(e=>e.filter(e=>e.id!==k.id)),b(``),S(null))}:void 0}):null,C?(0,Q.jsx)(wn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,k?.id??null)}}):null]})}var Ln=/^#[0-9a-fA-F]{6}$/;async function Rn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var zn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Bn({projectId:e,gradient:t,isNew:n,brand:i,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[u,f]=(0,Z.useState)(O(t)),[p,m]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!n),T=e=>{l(e),f(O(e)),m(!1)},E=(e,t)=>T({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),D=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));T({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},ee=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:g.trim(),...C?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});T({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),w(!0)}catch(e){x(e.message)}y(!1)};return(0,Q.jsx)(c,{open:!0,onClose:o,wide:!0,title:q(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g.trim()&&!v&&ee()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:g,maxLength:1e3,"aria-label":q(`project.gradientDescribe`),placeholder:q(C?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(S,{type:`submit`,variant:`secondary`,busy:v,disabled:!g.trim(),children:[(0,Q.jsx)(be,{className:`size-4`}),q(C?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??q(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:O(s)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:q(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:q(`project.gradientUse`),onChange:e=>l({...s,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:d.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:q(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":q(`project.gradientAngle`),onChange:e=>T({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(H,{value:Ln.test(e.color)?e.color:`#888888`,onChange:e=>E(t,{color:e.target.value})}),(0,Q.jsx)(F,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Ln.test(n)&&E(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":q(`project.gradientAt`),onChange:e=>E(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(h,{label:q(`project.remove`),disabled:s.stops.length<=2,onClick:()=>T({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.gradientStopAdd`)]}):null,i.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:q(`project.gradientFromBrand`)}),i.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>D(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:`CSS`}),(0,Q.jsx)(F,{value:u,spellCheck:!1,onChange:e=>{f(e.target.value);let t=j(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:q(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:o,children:q(`common.cancel`)}),(0,Q.jsx)(S,{onClick:()=>{a(s),o()},children:q(`settings.save`)})]})]})})}var Vn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Hn=`size-8 bg-card shadow-soft hover:bg-card`;function Un({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(K,{value:e,label:q(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:q(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wn({gradient:e,readOnly:t,onEdit:n,onChange:i,onRemove:a}){let o=O(e),[s,c]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":q(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(h,{label:q(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(_,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),t?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:q(`project.gradientName`),description:e.description,usePlaceholder:q(`project.gradientUse`),readOnly:t,onChange:i})]})}function Gn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kn({projectId:e,pattern:t,fileName:n,readOnly:i,onEdit:a,onChange:o,onRemove:s}){let c=ke(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-label":q(`project.patternEdit`),onClick:a,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gn(c,t.tile)}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(`a`,{href:c,download:n,"aria-label":q(`project.download`),title:q(`project.download`),className:r(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(ee,{className:`size-4`})}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:q(`project.patternUse`),readOnly:i,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:i,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,p]=(0,Z.useState)(t),[m,h]=(0,Z.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:_,wide:!0,title:q(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gn(ke(e,f.file),f.tile),children:(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[a?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(D,{className:`size-4`}),q(`project.patternReplace`)]})}):(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(D,{className:`size-5`}),q(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?i(f.file):q(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:q(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:_,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!f.file||a,onClick:()=>{for(let e of m.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:q(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)([]),h=async()=>{s(!0),u(null);try{let{colors:t}=await L.post(`/api/studio/projects/${e}/colors/scan`,{url:i.trim()});t.length?(f(t),m([])):u(q(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:q(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:r(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>f(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?q(`project.addMany`,{n:p.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorsUrlHint`)})]}),l?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:o,disabled:!i.trim(),children:q(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:a,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:De()}))),[g,_]=(0,Z.useState)(r),[v,y]=(0,Z.useState)(a),[b,x]=(0,Z.useState)(o),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=ne(e,f),D=te(c),[O,ee]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N=s({colors:p.filter(e=>Jn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:g,gradients:v,patterns:b,colorRules:D.rules},d),P=l?g:[],I=P.filter(e=>(e.kind??`colors`)===`colors`),re=e=>I.some(t=>t.id===e.section),L=p.filter(e=>!re(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),B=e=>m(t=>[...t,...e.map(e=>({...e,id:De()}))].slice(0,i.colors)),V=[{value:``,label:q(`project.sectionStandard`)},...I.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],U=(e,t)=>{let n=De();ee(n),_(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},G=e=>({id:De(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&Jn.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&Jn.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),ae=e=>t.files.find(t=>t.id===e)?.name??`pattern`,se=[...p.length<i.colors?[{label:q(`project.colorNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>K()},{label:q(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&g.length<i.logoSections?[{label:q(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>U(`colors`,``)},{label:q(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>U(`gradients`,q(`project.gradientSectionTitle`))},{label:q(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>U(`patterns`,q(`project.patternSectionTitle`))}]:[],...!u||D.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],ue=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(H,{value:Jn.test(e.value)?e.value:`#888888`,onChange:t=>z(e.id,{value:t.target.value})}),(0,Q.jsx)(F,{value:e.name,autoFocus:e.id===k,placeholder:q(`project.colorName`),maxLength:120,onChange:t=>z(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(F,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>z(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===R?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.colorAccent`)})}):f?null:(0,Q.jsx)(h,{label:q(`project.colorFirst`),onClick:()=>m(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(ie,{className:`size-4`})}),f||!I.length?null:(0,Q.jsx)(de,{options:V,value:re(e)?e.section??``:``,onChange:t=>z(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>m(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]},e.id),K=e=>{let t=De();A(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:q(`project.colors`),hint:q(`project.colorsHint`),save:N,locked:f,action:f?null:(0,Q.jsx)(ce,{entries:se}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[L.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:L.map(ue)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.colorsEmpty`)}),P.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),a=v.filter(e=>e.section===t.id),o=b.filter(e=>e.section===t.id),s=n===`gradients`?a.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:t.title,titlePlaceholder:q(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:q(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:q(`project.kindPatterns`)}:{icon:(0,Q.jsx)(kt,{}),label:q(`project.kindColors`)},autoFocus:O===t.id,readOnly:f,onChange:e=>_(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(q(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||q(`project.sectionUntitled`)}))){_(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),y(e=>e.filter(e=>e.section!==t.id));for(let e of o)E.remove(e.file);x(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>C(e),onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>y(t=>t.filter(t=>t.id!==e.id))},e.id)),f||v.length>=i.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>C(G(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(Kn,{projectId:e,pattern:t,fileName:ae(t.file),readOnly:f,onEdit:()=>T(t),onChange:e=>x(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{E.remove(t.file),x(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||b.length>=i.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T({id:De(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ue),f||p.length>=i.colors?null:(0,Q.jsx)(le,{label:q(`project.colorAdd`),onClick:()=>K(t.id)})]})]},t.id)}),u?(0,Q.jsx)(W,{rules:D,placeholder:q(`project.colorRulePlaceholder`),readOnly:f}):null]}),E.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.error}):null,S?(0,Q.jsx)(Bn,{projectId:e,gradient:S,isNew:!v.some(e=>e.id===S.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>C(null),onSave:e=>y(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,w?(0,Q.jsx)(qn,{projectId:e,pattern:w,isNew:!b.some(e=>e.id===w.id),fileName:ae,busy:E.busy,error:E.error,upload:async e=>(await E.upload(`pattern`,[e]))[0]??null,removeFile:e=>void E.remove(e),onClose:()=>T(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,j?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:B}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:f,email:Ct,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let l=Qn[e??t],u=`${q(`project.factType`)}: ${q(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),a(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":i,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:r(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,i?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),i?(0,Q.jsxs)(`div`,{role:`menu`,className:r(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(Fe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=Qn[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),a=(0,Z.useRef)(null),[o,c]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=s(o.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),d=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:q(`project.facts`),hint:q(`project.factsHint`),save:u,locked:n,action:o.length<i.facts&&!n?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=me(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(F,{ref:p(`${e.id}:label`),value:e.label,placeholder:q(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:C(e.label,o.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(V,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:q(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?q(`project.yes`):q(`project.no`)})]}):(0,Q.jsx)(A,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:q(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)($n,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},e.id)})}),o.length<i.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:q(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-3.5`}),` `,q(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[i,a]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),a(!0))},onDragLeave:()=>a(!1),onDrop:t=>{let n=t.dataTransfer.getData(Sn);a(!1),n&&(t.preventDefault(),e(n))},className:r(`-m-2 rounded-xl p-2 transition`,i&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function nr({projectId:e,data:t,readOnly:n,sections:r,rules:a,sectioned:o,ruled:c,save:l}){let u=ne(e,n),[d,f]=(0,Z.useState)(r),p=te(a),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=s({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=o?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=g(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),ee=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},k=C.length?{options:[{value:``,label:q(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,A=(t,n,r)=>(0,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?q(`project.logoAdd`):void 0,onUpload:e=>void ee(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:k,onRemove:e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:q(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:q(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<i.logoSections?[{label:q(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=De();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:q(`project.logos`),hint:q(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(ce,{entries:M}),children:[(0,Q.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ee(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:A(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(tr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:e.title,description:e.description,titlePlaceholder:q(`project.logoSectionTitle`),descriptionPlaceholder:q(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(q(`project.logoSectionRemoveConfirm`,{name:e.title||q(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),A(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(W,{rules:p,placeholder:q(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,Q.jsx)(wn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var rr=e=>URL.canParse(e)?new URL(e).host:e;async function ir(e,t){let n=T({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ar(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function ar(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function or(e,t){let n=e.source;if(!n)return q(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return q(`project.fontSourceFile`,{name:e})}return q(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:i}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=ne(e),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[d,f]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[h,g]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(t.license??``),[C,w]=(0,Z.useState)(!1),T=p.trim(),E=async()=>{v(!0),g({url:T,result:await ir(T,t.family.trim())}),v(!1)},D=l===`file`?d?{file:d}:null:h?.url===T&&h.result===`ok`?{url:T}:null,O=h?.url===T?h.result:null;return(0,Q.jsx)(c,{open:!0,onClose:i,title:q(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontSourceHint`)}),(0,Q.jsx)(b,{value:l,options:[`file`,`url`],label:e=>q(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>f(e.id),className:r(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,d===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&f(n.id)}}),(0,Q.jsxs)(S,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),q(`project.fontSourceUpload`)]}),o.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),E()},children:[(0,Q.jsx)(R,{children:q(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:q(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(S,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:q(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:q(`project.fontCheck.${O}`,{host:rr(T),family:t.family})}):null,O===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:q(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:q(`project.fontLicenseHint`),children:q(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:q(`project.fontLicensePlaceholder`),onChange:e=>x(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:C,onChange:e=>w(e.target.checked)}),q(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(S,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),i()},children:q(`project.fontSourceRemove`)}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!(D&&C),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),i())},children:q(`project.fontSourceSave`)})]})]})})}var cr=new Set;function lr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||cr.has(t))return;cr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${p.join(`,`)}&display=swap`,document.head.append(n)},[e])}var ur=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function dr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var fr=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,pr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function mr({projectId:e,font:t,first:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){lr(t.family);let c=P(e).data?.files??[],[l,u]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:ur(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(K,{value:t.family,label:q(`project.fontFamily`),placeholder:q(`project.fontFamily`),maxLength:80,autoFocus:a,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(K,{value:t.role,label:q(`project.fontRole`),placeholder:q(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:p.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>o({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:ur(t.family),fontWeight:e},className:r(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(K,{value:t.license??``,label:q(`project.fontLicense`),placeholder:q(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),i&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:q(`project.fontUses`)}),N.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):N.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:r(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:[n?(0,Q.jsx)(I,{className:`size-3.5`}):null,q(pr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:or(t,c)}),i||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:q(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:ur(c?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[i?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(K,{value:e.name,label:q(`project.styleName`),placeholder:q(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:i,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":q(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:r(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||q(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":q(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...p,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:q(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:q(`project.styleLine`),label:q(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:q(`project.styleTracking`),label:q(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:q(`project.styleUpper`),"aria-label":q(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:r(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(rn,{className:`size-4`})})]}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gr({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),l(null);try{let{fonts:t}=await L.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(q(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:q(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,Q.jsx)(_r,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?q(`project.addMany`,{n:f.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function _r({font:e,on:t,onToggle:n}){return lr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:r(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:ur(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):q(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:a,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=te(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=s({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:De(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,i.fonts))},x=()=>{let e=De();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<i.fonts?[{label:q(`project.fontNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:q(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<i.textStyles?[{label:q(`project.styleNew`),icon:(0,Q.jsx)(Ft,{className:`size-4 shrink-0`}),onPick:x}]:[],...!a||m.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:q(`project.typography`),hint:q(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(ce,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(mr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:q(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(hr,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,a?(0,Q.jsx)(W,{rules:m,placeholder:q(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(gr,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function yr({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=s({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(X,{title:q(`project.base`),hint:q(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.title`)}),(0,Q.jsx)(F,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.about`)}),(0,Q.jsx)(A,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.aboutHint`)})]})]})})}function br({project:e,group:t,top:n=!1,children:r}){let i=a(),o=P(e.id),[s,l]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(!1),f=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},p=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),m=pt(),h=dt(),g=o.data??{files:[],embeddings:!0},_=`${e.id}:${s}`,v=e.readOnly,y=t===`knowledge`,b=Et(`brandSections`),x=Et(`brandRules`),C=Et(`typography`);return St(v?{}:{title:q(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:q(y?`project.assistantHelloKnowledge`:`project.assistantHello`),about:q(y?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:q(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:q(`assistant.suggest.knowledgeHow`)},{label:q(`assistant.suggest.knowledgeSite`),fill:!0},{label:q(`assistant.suggest.knowledgeCategories`)}]:[{label:q(`assistant.suggest.readSite`),fill:!0},{label:q(`assistant.suggest.missing`)},{label:q(`assistant.suggest.facts`)}],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>l(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,Q.jsx)(vt,{children:gt(e)}):n?(0,Q.jsx)(It,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:f},`base:${_}`)}),(0,Q.jsx)(J,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>f({facts:e}),readOnly:v},`facts:${_}`)}),(0,Q.jsx)(J,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>f({brand:e})},`logos:${_}`)}),(0,Q.jsx)(J,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>f({brand:e}),readOnly:v},`colors:${_}`)}),C?(0,Q.jsx)(J,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||q(`project.typeSample`),save:e=>f({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,Q.jsx)(J,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>f({brand:e})},`assets:${_}`)})]}):null,r,t===`info`&&m&&!v&&h?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(S,{variant:`danger`,onClick:()=>d(!0),children:q(`settings.delete`)}),(0,Q.jsxs)(c,{open:u,onClose:()=>d(!1),title:q(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:q(`settings.deleteBody`)}),p.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:p.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(!1),children:q(`common.cancel`)}),(0,Q.jsx)(S,{variant:`danger`,busy:p.isPending,onClick:()=>p.mutate(),children:q(`common.delete`)})]})]})]}):null]})}var xr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Sr=`font-mono text-[0.875rem]`,Cr=e=>e.slice(e.indexOf(`.`)+1);function wr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Tr(){let e=q(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(B,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:q(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(B,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:q(`project.facts`)},t):e),` `,q(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:i}){let a=ge.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Cr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:i,"aria-label":q(`page.address`),maxLength:E.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:r(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$,!a&&t&&`text-rose`),children:q(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:i}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:i,maxLength:E.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:i,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:r(`mt-1`,$),children:q(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:i,maxLength:E.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.words`)}),(0,Q.jsx)(A,{value:t.intro??``,disabled:i,minRows:3,maxLength:E.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.lang`)}),(0,Q.jsx)(xe,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:q(e.label)}))}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return q(`page.draftNote`);if(!e.shareEnabled)return q(`page.notSharedNote`);let n=e.description.trim();return t?[n,q(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:i,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:r(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`page.moveUp`)} / ${q(`page.moveDown`)}`,onKeyDown:o.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(_e,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(mt,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:r(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(V,{checked:n,disabled:i||!e.published,label:q(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:i,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:i||a,onClick:o,className:r(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:a?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(i||a)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var jr={desktop:1280,tablet:768,mobile:390},Mr=`wizards.pagePreviewDevice`,Nr=`wizards.pagePreviewHeight`,Pr=360,Fr=e=>e?640:480,Ir=()=>Math.max(Pr,window.innerHeight-140);function Lr(){try{let e=Number(localStorage.getItem(Nr));return e>=Pr?e:null}catch{return null}}function Rr(e){try{e===null?localStorage.removeItem(Nr):localStorage.setItem(Nr,String(Math.round(e)))}catch{}}function zr(){try{let e=localStorage.getItem(Mr);return e&&e in jr?e:`desktop`}catch{return`desktop`}}function Br(e){try{localStorage.setItem(Mr,e)}catch{}}function Vr({url:e,version:t,device:n}){let i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let s=jr[n],[c,l]=(0,Z.useState)(Lr),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=Math.min(c??Fr(a.tall),a.width?Ir():9999),m=e=>{let t=Math.round(Math.min(Ir(),Math.max(Pr,e)));return l(t),t},h=n===`mobile`,g=h?12:0,_=a.width?Math.min(1,(a.width-2*g)/s):1,v=(0,Q.jsxs)(`div`,{className:r(`relative overflow-hidden bg-paper-2`,h?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(s*_),height:p},children:[a.width?(0,Q.jsx)(`iframe`,{title:q(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:r(`absolute top-0 left-0 border-0`,u&&`pointer-events-none`),style:{width:s,height:Math.ceil(p/_),transform:`scale(${_})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":q(`page.resize`),title:q(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}f.current={y:e.clientY,height:p},d(!0)},onPointerMove:e=>{f.current&&m(f.current.height+e.clientY-f.current.y)},onPointerUp:e=>{f.current&&=(Rr(m(f.current.height+e.clientY-f.current.y)),null),d(!1)},onPointerCancel:()=>{f.current=null,d(!1)},onDoubleClick:()=>{l(null),Rr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Rr(m(p+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:i,className:`flex w-full justify-center`,children:h?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:v}):v})}function Hr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Ve(t)})),l=s(o,async e=>{if(!(ge.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=st(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Dr,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Ur({project:e}){let t=a(),n=ft(),i=n.data?.tenant.pagesHost??null,o=n.data?.manageUrl??null,s=e.readOnly,c=e.page,l=!!c?.on,u=ae({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[d,f]=(0,Z.useState)(1),[p,m]=(0,Z.useState)(zr),h=(0,Z.useRef)(c);h.current=c;let g=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),f(e=>e+1)},v=Le({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[y,b]=(0,Z.useState)({state:`idle`,error:null}),{copied:C,copy:w}=wr(),T=u.data??[],E=(c?.wizards??[]).map(e=>T.find(t=>t.id===e)).filter(e=>e!==void 0),D=T.filter(e=>!c?.wizards.includes(e.id)),[O,ee]=(0,Z.useState)(null),k=(e,t)=>{let n=[...c?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),v.mutate({wizards:n})},A=(e,t)=>v.mutate({wizards:t?[...c?.wizards??[],e]:(c?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>g({on:!0,slug:x(j)||`page`,title:j,...st(we===`de`?`de-du`:`en`),wizards:T.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{c?v.mutate({on:e}):e&&te.mutate()},P=v.isPending||te.isPending,F=v.error??te.error;if(!i)return(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsx)(X,{title:q(`space.page`),hint:q(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:q(`page.cloudOnly`)})})});let ne=c?.slug||x(j)||`…`,re=We(i,ne),ie=ot(i,ne,o),R=(0,Q.jsxs)(`span`,{className:r(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[i,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:ne})]}),z=s||!c,B=(0,Q.jsxs)(M,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.previewTitle`)}),l?(0,Q.jsx)(rt,{named:!0,label:q(`editor.device`),value:p,onChange:e=>{m(e),Br(e)},options:[{id:`desktop`,label:q(`editor.deviceDesk`),icon:(0,Q.jsx)(wt,{className:`size-3.5`})},{id:`tablet`,label:q(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:q(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),l?(0,Q.jsx)(Vr,{url:ie,version:d,device:p}):(0,Q.jsx)(`p`,{className:$,children:q(`page.previewOff`)}),l?(0,Q.jsx)(`p`,{className:$,children:q(`page.previewHint`)}):null]}),H=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:q(`share.onPage`,{space:c?.title||j})}),(0,Q.jsx)(`span`,{className:r(`block truncate font-mono`,$),children:re})]}),(0,Q.jsx)(V,{checked:!0,disabled:!0,label:q(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:q(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:q(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:q(`page.intro`)})]}),(0,Q.jsxs)(M,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:r(`size-2 shrink-0 rounded-full`,l?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),R]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>w(ie),children:[C?(0,Q.jsx)(I,{className:`size-3.5`}):(0,Q.jsx)(_,{className:`size-3.5`}),q(C?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(S,{size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>window.open(ie,`_blank`,`noopener`),children:[q(`page.open`),` `,(0,Q.jsx)(Mt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:q(`page.sectionPage`),locked:s,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":q(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:q(`page.whoOff`),text:q(`page.whoOffHint`),picked:!l,disabled:s||P,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:q(`page.whoPublic`),text:q(`page.whoPublicHint`),picked:l,disabled:s||P,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:q(`page.whoMembers`),text:q(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),F?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:F.message}):null]})]})}),B,(0,Q.jsx)(J,{id:`page-words`,children:(0,Q.jsx)(X,{title:q(`page.sectionWords`),hint:c?void 0:q(`page.notYet`),save:c?y:void 0,locked:z,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[c?(0,Q.jsx)(Hr,{host:i,page:c,disabled:s,save:g,onState:b},`${e.id}:${c.slug}`):(0,Q.jsx)(Dr,{host:i,disabled:!0,words:{slug:ne,title:j,headline:``,intro:``,voice:we===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:q(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[E.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:z,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>ee(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{O!==null&&k(O,t),ee(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),D.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:z,onToggle:t=>A(e.id,t)},e.id))]}),T.length?null:(0,Q.jsx)(`p`,{className:r(`mt-2`,$),children:q(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:r(`mt-4`,$),children:q(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),H]})}var Wr=`results-search`,Gr={q:``,mode:``,days:0};function Kr(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return ae({queryKey:[`results`,e,i],queryFn:()=>L.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function qr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return jt({icon:fe,label:q(`space.resultsSearch`),run:()=>{let e=document.getElementById(Wr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(xe,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:q(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(fe,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(F,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Wr,placeholder:q(`space.resultsSearch`),"aria-label":q(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(xe,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:q(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(xe,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:q(`space.resultsAnyTime`)},{value:`1`,label:q(`space.resultsDay`)},{value:`7`,label:q(`space.resultsDays`,{n:7})},{value:`30`,label:q(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Jr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(we,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):q(`space.resultsAll`),hint:q(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(qr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(M,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,q(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:q(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(u,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(re,{children:r.q.trim()||r.mode||r.days?q(`space.resultsNone`):q(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(tt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(lt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Yr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=zt(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xr(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=zt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Zr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Qr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ht,{icon:e.icon??Me,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Gt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function $r(){let{group:e}=Se(),[t,n]=pe(),i=ye(),a=Ce(),{hash:o}=a,{project:s,loading:c}=ut(),l=Rt(),u=Zt(),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=Ot(e)?e:void 0,v=_?void 0:l.spaceParts.find(t=>t.id===e),y=_??v?.id,b=a.state?.parts===!0,x=Et(`pages`),S=Nt().filter(e=>x||e.id!==`page`),C=At(S,l).map(e=>({...e,to:`/space/${e.id}`})),w={id:`results`,label:q(`space.results`),icon:xt,to:`/space/results`},T=_===`results`?w:C.find(e=>e.id===y),E=t.get(`show`),D=_===`results`?2:y?E?2:1:0,O=_===`results`?1:u?Math.min(D,1):y&&h!==y&&!b?1:0,ee=Wt(O),A=Wt(D),j=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:m}),[d,u]),M=s?s.brand.name?.trim()||s.name:q(`nav.project`),te=Et(`typography`)?[]:[`typography`],N=v?l.spaceMenus[v.id]??[]:[],P=v?[{plugin:null,label:null,sections:N}]:_&&_!==`results`?Pt(_,l,te):[],F=_?Pt(_,l).filter(e=>e.plugin):[],ne=Yr([...P,..._===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),I=_===`results`&&E&&E!==`all`?E:null,[L,ie]=(0,Z.useState)(Gr),R=Kr(_===`results`?s?.id:void 0,I,L),z=R.data?.wizards.find(e=>e.id===I)?.title,B=_===`data`&&E&&E!==`all`||_===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,V=B?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=_===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(_===`data`?s?.id:void 0),W=Qe(_===`knowledge`?s?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),ae=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),oe=_===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?ae?.name:W.data?.items.find(e=>e.key===B)?.title:U.data?nt(U.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;Vt([..._===`results`?[]:[{label:q(`nav.project`),to:`/space`}],...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(p??z??oe)?[{label:p??z??oe}]:[]]);let se={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};St({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:q(`assistant.suggest.dataWhat`)},{label:q(`assistant.suggest.dataWho`)},{label:q(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:q(`assistant.suggest.resultsFailed`)},{label:q(`assistant.suggest.resultsCost`)},{label:q(`assistant.suggest.resultsShare`)}]}:{},...B&&oe?{open:{kind:se[B[0]]??`item`,id:B.slice(2),label:oe}}:I&&z?{open:{kind:`wizard`,id:I,label:z}}:{}});let ce=_===`results`||_===`data`||B?o.slice(1):E||o.slice(1),le=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${ce}`;ce&&le.current!==e&&document.getElementById(ce)&&(le.current=e,requestAnimationFrame(()=>Zr(ce,!1)))},[y,ce,s?.id,l.spaceSections,N.length]),(0,Z.useEffect)(()=>{!u&&(y===`knowledge`||y===`data`)&&zt().scrollTo({top:0})},[u,y,B]);let ue=Xr();if(!y){let t=o.slice(1),n=t?Dt(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(k,{to:u?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&l.status!==`ready`)return null;if(e!==void 0||!u)return(0,Q.jsx)(k,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(_===`knowledge`&&!E&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let de=e=>{if(u){i({search:`?show=${e}`});return}le.current=`${y}#${e}`,Zr(e,!0),i({search:``,hash:e},{replace:!0})},K=e=>u?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),fe=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(J,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Lt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=u?void 0:ne,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:O===1?T??null:null,onBack:_===`results`?void 0:()=>u?i(`/space`):g(y??null),root:{icon:Bt,label:q(`nav.project`),backLabel:q(`nav.wizards`),onBack:()=>i(`/`)}}),(0,Q.jsx)(`div`,{className:r(Ut(ee)),children:O===0?(0,Q.jsx)(Jt,{entries:C,current:u?void 0:T,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:f})},O)]});return(0,Q.jsx)(qt.Provider,{value:j,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:r(`grid gap-6`,_!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[_===`results`?null:(0,Q.jsx)(`aside`,{className:r(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&D===2&&`hidden`,u&&A===`back`&&Ut(`back`)),style:!u&&ue?{maxHeight:ue-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:he}),y?(0,Q.jsxs)(`div`,{className:r(`min-w-0`,u&&D<2&&`hidden`,u&&A===`deeper`&&Ut(`deeper`)),children:[u&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:T?.label??M,onBack:()=>i(`/space/${y}`)})}):null,_===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:bt,label:q(`data.all`),selected:!u&&!B,onPick:()=>K(`all`)})}),U.data?nt(U.data).map(e=>(0,Q.jsx)(Gt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ht,{icon:Ue[e.kind],label:e.title,selected:!u&&e.key===B,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,Q.jsx)(Qr,{groups:F,current:me,onPick:de})]}):_===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:bt,label:q(`know.all`),selected:!(u||B),onPick:()=>K(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:q(`know.categories`),children:W.data.categories.map(e=>(0,Q.jsx)(Ht,{icon:Ye[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(Qr,{groups:F,current:u?void 0:V?.id,onPick:e=>K(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)(Qr,{groups:P,current:me,onPick:de})}),s&&(_===`info`||_===`knowledge`)?(0,Q.jsxs)(br,{project:s,group:_,top:!B||!!V,children:[_===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>K(`all`),onOpen:K},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>K(`all`)},H):(0,Q.jsx)(kn,{projectId:s.id,fileId:H.slice(2),readOnly:s.readOnly,onGone:()=>K(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(Lt,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?ae?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:s.id,category:ae,readOnly:s.readOnly,onOpen:K,onGone:()=>K(`all`)}),ae.type===`choice`?null:(0,Q.jsx)(it,{projectId:s.id,category:ae,categories:W.data.categories,onOpen:K})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:G.data.items.map(e=>(0,Q.jsx)(Ke,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:K},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(J,{id:`documents`,children:(0,Q.jsx)(et,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:K})}):null:null,_===`info`?fe(F):null]},s.id):null,s&&_===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:s},s.id),fe(F)]}):null,s&&v?(0,Q.jsx)(Lt,{of:v,children:(0,Q.jsx)(Tt,{part:v.id,children:(0,Q.jsx)(v.component,{})},s.id)}):null,s&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:B.slice(2),onGone:()=>K(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>K(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:K}):null,fe(F)]})}):null,s&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,Q.jsx)(Jr,{data:R.data,wizardId:I,onWizard:e=>K(e??`all`),filter:L,onFilter:ie}):null,R.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,fe(F)]}):null,s||c?null:(0,Q.jsx)(re,{children:q(`settings.noProject`)})]}):null]})})})}export{$r as ProjectPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,$t as i,Gr as a,Ht as o,In as s,J as c,Jr as l,Jt as u,Lt as d,Qr as f,W as p,ai as m,at as h,cn as g,et as _,in as v,it as y,jt as b,ni as x,on as S,ri as ee,sr as C}from"./ui-CJCF3Mhe.js";import{_ as w,b as T,d as E,f as te,g as D,h as O,m as k,n as ne,p as re,v as A,y as j}from"./theme-DanjuO1H.js";import{O as ie,S as M,b as N,x as P}from"./session-DX2BcTfz.js";import{U as F}from"./index-Da7hPToW.js";var I={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};I.node;var ae=l(I),L={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};L.node;var oe=l(L),R=e(t(),1);function se(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=se(),ce=z?new URLSearchParams(window.location.search).get(`page`):null,B=new URLSearchParams(window.location.search).get(`theme`),V=B?`?theme=${encodeURIComponent(B)}`:``,H=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),le=()=>H(`close`);function ue(e){(0,R.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>H(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&H(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var U=e(n(),1),W=`wizards.runner.translate`,G=new Set;function de(){try{return localStorage.getItem(W)===`on`}catch{return!1}}function fe(e){try{localStorage.setItem(W,e?`on`:`off`)}catch{}for(let e of G)e()}function pe(){return(0,R.useSyncExternalStore)(e=>(G.add(e),()=>G.delete(e)),de)}function me(e){let t=pe(),[n]=(0,R.useState)(()=>g()),r=e?.lang??`en`,i=e?.translatable&&n&&n!==r?n:null,a=i&&t?i:r,o=e?.token,c=m({queryKey:[`public-translation`,o,a],enabled:!!(o&&a!==r),queryFn:()=>p.post(`/api/public/wizards/${o}/translation${V}`,{lang:a}),staleTime:1/0,retry:!1}),l=m({queryKey:[`public-texts`,o,a],enabled:!(!o||s(a)),queryFn:()=>p.get(`/api/public/wizards/${o}/texts/${a}`),staleTime:1/0,retry:!1}),u=!s(a),d=a===r||c.data&&(!u||l.data),f=a!==r&&(c.isError||u&&l.isError),h=d&&!f?a:r,_=(0,R.useMemo)(()=>!s(h)&&l.data?.lang===h?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[h,l.data]);if((0,R.useEffect)(()=>{e&&v(h,_)},[e,h,_]),(0,R.useEffect)(()=>()=>v(null),[]),!e)return null;let y=h!==r&&c.data?c.data:null;return{own:r,other:i,shown:h,wizard:y??e,translating:a!==r&&!d&&!f,failed:!!f,translated:!!y,machine:y?.translation?.machine??!1,pick:e=>fe(e!==r)}}function K({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,U.jsx)(F,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function q({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,U.jsx)(`p`,{className:i(`text-ink-3`,n),children:S(`translation.failed`)}):e.translated?(0,U.jsxs)(`p`,{className:i(`text-ink-3`,n),children:[e.machine?(0,U.jsxs)(U.Fragment,{children:[S(`translation.machine`),` · `]}):null,(0,U.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:S(`translation.showOriginal`)})]}):null}function he(e,t){let n=(0,R.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,R.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,p.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ge(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=r(`/api/public/wizards/${e}`),i=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of i)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var J=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Y=J||/Android/.test(navigator.userAgent);function _e(){let[e,t]=(0,R.useState)(()=>window.wizardInstall??null),[n,r]=(0,R.useState)(!1);if((0,R.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||Y&&!e&&!J)return null;let i=/Mac/.test(navigator.platform),a=S(Y?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{Y&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[Y?(0,U.jsx)(oe,{className:`size-4`}):(0,U.jsx)(ae,{className:`size-4`}),S(Y?`install.add`:`install.bookmark`)]}),n?(0,U.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function X({brand:e,toggle:t=!0,start:n}){return(0,U.jsx)(`header`,{className:`safe-top`,children:(0,U.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,U.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,U.jsx)(`img`,{src:r(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,U.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,U.jsx)(`div`,{className:`absolute right-3`,children:(0,U.jsx)(M,{})}):null]})})}function Z({siteKey:e,onToken:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,U.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ve({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||_||z?null:(0,U.jsxs)(`a`,{href:y(`${window.location.origin}${c}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,U.jsx)(T,{className:`size-4`}),` `,S(`install.app`)]})}var ye=e=>`wz.run.${e}`,be=_&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=x(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(()=>{try{return localStorage.getItem(ye(e.token))}catch{return null}})();return{busy:i,error:o,captcha:c,setCaptcha:l,start:async()=>{a(!0),s(null);try{let{runId:i}=await p.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:ce??void 0,lang:n??void 0});try{localStorage.setItem(ye(e.token),i)}catch{}r(`${t}/${i}`,{replace:be})}catch(e){s(e.message),a(!1)}},resume:u?()=>r(`${t}/${u}`):null}}function xe({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=be&&e.available&&!e.turnstileSiteKey,f=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{l&&!f.current&&(f.current=!0,s())},[l]),l&&!r?(0,U.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,U.jsx)(u,{})}):(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,U.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,U.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,U.jsx)(`div`,{className:`mt-3`,children:(0,U.jsx)(q,{page:t})}),e.available?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(d,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),e.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.resume`)}):null,(0,U.jsx)(Se,{wizard:e,current:`steps`}),z||_?null:(0,U.jsx)(_e,{}),(0,U.jsx)(ve,{token:e.token})]}):(0,U.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??S(`run.unavailable`)}),r?(0,U.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,U.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,U.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=j();return(0,U.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,U.jsx)(`span`,{className:i(n?.speaking&&`animate-breathe`),children:(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:38})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,U.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,U.jsx)(q,{page:t,small:!0})]}),e.brand.logoUrl&&z!==`popout`?(0,U.jsx)(`img`,{src:r(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,U.jsx)(K,{page:t,tone:`surface`}),z?null:(0,U.jsx)(M,{}),z===`popout`?(0,U.jsx)(o,{label:S(`common.close`),onClick:le,children:(0,U.jsx)(C,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:S(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??S(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(A(`start`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(D,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),d?(0,U.jsx)(D,{onClick:d,children:S(`run.resume`)}):null,t.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,U.jsxs)(k,{header:r,footer:i,children:[(0,U.jsx)(w,{avatar:t.avatar,costume:t.costume,lines:f}),(0,U.jsx)(O,{})]})}function Te({className:e}){return(0,U.jsx)(`footer`,{className:i(`text-center text-ink-4`,e),children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:r=!1}){let{token:a,runId:o}=ee(),s=x(),l=m({queryKey:[`public`,a,V],queryFn:()=>p.get(`/api/public/wizards/${a}${V}`),retry:(e,t)=>b(t)&&e<3}),g=l.data?.runners??[],v=!l.data||g.some(e=>e.id===`talk`),y=!l.data||g.some(e=>e.id===`video`),C=!l.data||g.some(e=>e.id===`chat`)||n&&v||r&&y,w=g[0]?.id,T=e||z===`popout`||!t&&!o&&C&&(w===`chat`||w===`talk`||w===`video`),D=r&&y||!t&&!e&&!n&&w===`video`,O=!D&&(n&&v||!t&&!e&&w===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(l.data);he(o,A),ne(l.data?.brand.theme),ie(l.data?.avatar),ge(a,l.data?.title),ue(T);let j=A?.wizard.title??l.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{a&&o&&h(`run`,{token:a,runId:o})},[a,o]),l.isLoading)return(0,U.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Q),children:(0,U.jsx)(u,{})});if(e&&l.data&&!C||n&&l.data&&!v||r&&l.data&&!y)return(0,U.jsx)(f,{to:`/w/${a}`,replace:!0});if(!l.data){let e=b(l.error);return(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,U.jsx)(P,{kind:`pebble`,size:80}),(0,U.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:S(e?`common.offline`:`run.notFound`)}),e?(0,U.jsx)(d,{variant:`secondary`,onClick:()=>void l.refetch(),children:S(`common.retry`)}):null]})}let M=A?.wizard??l.data,F=A?.translating?(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,U.jsx)(u,{}),(0,U.jsx)(`p`,{className:`text-[0.875rem]`,children:S(`translation.working`)})]}):null;if(T){let e=(0,U.jsx)(Ce,{wizard:M,page:A}),t=_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,U.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),F??(o?(0,U.jsx)(re,{runId:o,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>s(`/w/${a}/${k}`),header:D||O?void 0:e,footer:t}):(0,U.jsx)(we,{wizard:M,page:A,header:e,footer:t,door:k}))]})}return(0,U.jsxs)(`div`,{className:i(`wizard-page flex flex-col`,Q),children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),z===`inline`||_?null:(0,U.jsx)(X,{brand:l.data.brand,toggle:!z,start:(0,U.jsx)(K,{page:A})}),z===`inline`||_?(0,U.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,U.jsx)(K,{page:A,tone:`surface`})}):null,o&&(A?.translated||A?.failed)?(0,U.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,U.jsx)(q,{page:A})}):null,(0,U.jsx)(`div`,{className:`flex-1`,children:F??(o?(0,U.jsx)(te,{runId:o,onRestart:()=>s(`/w/${a}`)}):(0,U.jsx)(xe,{wizard:M,page:A}))}),_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})]})}export{X as BrandHeader,Ee as PublicRunner};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,$t as i,Gr as a,Ht as o,In as s,J as c,Jr as l,Jt as u,Lt as d,Qr as f,W as p,ai as m,at as h,cn as g,et as _,in as v,it as y,jt as b,ni as x,on as S,ri as ee,sr as C}from"./ui-BI1RPFWT.js";import{_ as w,b as T,d as E,f as te,g as D,h as O,m as k,n as ne,p as re,v as A,y as j}from"./theme-HcCfZDzS.js";import{O as ie,S as M,b as N,x as P}from"./session-B_JeZnJ0.js";import{W as F}from"./index-D3-kv1WF.js";var I={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};I.node;var ae=l(I),L={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};L.node;var oe=l(L),R=e(t(),1);function se(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=se(),ce=z?new URLSearchParams(window.location.search).get(`page`):null,B=new URLSearchParams(window.location.search).get(`theme`),V=B?`?theme=${encodeURIComponent(B)}`:``,H=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),le=()=>H(`close`);function ue(e){(0,R.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>H(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&H(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var U=e(n(),1),W=`wizards.runner.translate`,G=new Set;function de(){try{return localStorage.getItem(W)===`on`}catch{return!1}}function fe(e){try{localStorage.setItem(W,e?`on`:`off`)}catch{}for(let e of G)e()}function pe(){return(0,R.useSyncExternalStore)(e=>(G.add(e),()=>G.delete(e)),de)}function me(e){let t=pe(),[n]=(0,R.useState)(()=>g()),r=e?.lang??`en`,i=e?.translatable&&n&&n!==r?n:null,a=i&&t?i:r,o=e?.token,c=m({queryKey:[`public-translation`,o,a],enabled:!!(o&&a!==r),queryFn:()=>p.post(`/api/public/wizards/${o}/translation${V}`,{lang:a}),staleTime:1/0,retry:!1}),l=m({queryKey:[`public-texts`,o,a],enabled:!(!o||s(a)),queryFn:()=>p.get(`/api/public/wizards/${o}/texts/${a}`),staleTime:1/0,retry:!1}),u=!s(a),d=a===r||c.data&&(!u||l.data),f=a!==r&&(c.isError||u&&l.isError),h=d&&!f?a:r,_=(0,R.useMemo)(()=>!s(h)&&l.data?.lang===h?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[h,l.data]);if((0,R.useEffect)(()=>{e&&v(h,_)},[e,h,_]),(0,R.useEffect)(()=>()=>v(null),[]),!e)return null;let y=h!==r&&c.data?c.data:null;return{own:r,other:i,shown:h,wizard:y??e,translating:a!==r&&!d&&!f,failed:!!f,translated:!!y,machine:y?.translation?.machine??!1,pick:e=>fe(e!==r)}}function K({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,U.jsx)(F,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function q({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,U.jsx)(`p`,{className:i(`text-ink-3`,n),children:S(`translation.failed`)}):e.translated?(0,U.jsxs)(`p`,{className:i(`text-ink-3`,n),children:[e.machine?(0,U.jsxs)(U.Fragment,{children:[S(`translation.machine`),` · `]}):null,(0,U.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:S(`translation.showOriginal`)})]}):null}function he(e,t){let n=(0,R.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,R.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,p.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ge(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=r(`/api/public/wizards/${e}`),i=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of i)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var J=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Y=J||/Android/.test(navigator.userAgent);function _e(){let[e,t]=(0,R.useState)(()=>window.wizardInstall??null),[n,r]=(0,R.useState)(!1);if((0,R.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||Y&&!e&&!J)return null;let i=/Mac/.test(navigator.platform),a=S(Y?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{Y&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[Y?(0,U.jsx)(oe,{className:`size-4`}):(0,U.jsx)(ae,{className:`size-4`}),S(Y?`install.add`:`install.bookmark`)]}),n?(0,U.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function X({brand:e,toggle:t=!0,start:n}){return(0,U.jsx)(`header`,{className:`safe-top`,children:(0,U.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,U.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,U.jsx)(`img`,{src:r(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,U.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,U.jsx)(`div`,{className:`absolute right-3`,children:(0,U.jsx)(M,{})}):null]})})}function Z({siteKey:e,onToken:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,U.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ve({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||_||z?null:(0,U.jsxs)(`a`,{href:y(`${window.location.origin}${c}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,U.jsx)(T,{className:`size-4`}),` `,S(`install.app`)]})}var ye=e=>`wz.run.${e}`,be=_&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=x(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(()=>{try{return localStorage.getItem(ye(e.token))}catch{return null}})();return{busy:i,error:o,captcha:c,setCaptcha:l,start:async()=>{a(!0),s(null);try{let{runId:i}=await p.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:ce??void 0,lang:n??void 0});try{localStorage.setItem(ye(e.token),i)}catch{}r(`${t}/${i}`,{replace:be})}catch(e){s(e.message),a(!1)}},resume:u?()=>r(`${t}/${u}`):null}}function xe({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=be&&e.available&&!e.turnstileSiteKey,f=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{l&&!f.current&&(f.current=!0,s())},[l]),l&&!r?(0,U.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,U.jsx)(u,{})}):(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,U.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,U.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,U.jsx)(`div`,{className:`mt-3`,children:(0,U.jsx)(q,{page:t})}),e.available?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(d,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),e.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.resume`)}):null,(0,U.jsx)(Se,{wizard:e,current:`steps`}),z||_?null:(0,U.jsx)(_e,{}),(0,U.jsx)(ve,{token:e.token})]}):(0,U.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??S(`run.unavailable`)}),r?(0,U.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,U.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,U.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=j();return(0,U.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,U.jsx)(`span`,{className:i(n?.speaking&&`animate-breathe`),children:(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:38})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,U.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,U.jsx)(q,{page:t,small:!0})]}),e.brand.logoUrl&&z!==`popout`?(0,U.jsx)(`img`,{src:r(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,U.jsx)(K,{page:t,tone:`surface`}),z?null:(0,U.jsx)(M,{}),z===`popout`?(0,U.jsx)(o,{label:S(`common.close`),onClick:le,children:(0,U.jsx)(C,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:S(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??S(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(A(`start`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(D,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),d?(0,U.jsx)(D,{onClick:d,children:S(`run.resume`)}):null,t.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,U.jsxs)(k,{header:r,footer:i,children:[(0,U.jsx)(w,{avatar:t.avatar,costume:t.costume,lines:f}),(0,U.jsx)(O,{})]})}function Te({className:e}){return(0,U.jsx)(`footer`,{className:i(`text-center text-ink-4`,e),children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:r=!1}){let{token:a,runId:o}=ee(),s=x(),l=m({queryKey:[`public`,a,V],queryFn:()=>p.get(`/api/public/wizards/${a}${V}`),retry:(e,t)=>b(t)&&e<3}),g=l.data?.runners??[],v=!l.data||g.some(e=>e.id===`talk`),y=!l.data||g.some(e=>e.id===`video`),C=!l.data||g.some(e=>e.id===`chat`)||n&&v||r&&y,w=g[0]?.id,T=e||z===`popout`||!t&&!o&&C&&(w===`chat`||w===`talk`||w===`video`),D=r&&y||!t&&!e&&!n&&w===`video`,O=!D&&(n&&v||!t&&!e&&w===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(l.data);he(o,A),ne(l.data?.brand.theme),ie(l.data?.avatar),ge(a,l.data?.title),ue(T);let j=A?.wizard.title??l.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{a&&o&&h(`run`,{token:a,runId:o})},[a,o]),l.isLoading)return(0,U.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Q),children:(0,U.jsx)(u,{})});if(e&&l.data&&!C||n&&l.data&&!v||r&&l.data&&!y)return(0,U.jsx)(f,{to:`/w/${a}`,replace:!0});if(!l.data){let e=b(l.error);return(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,U.jsx)(P,{kind:`pebble`,size:80}),(0,U.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:S(e?`common.offline`:`run.notFound`)}),e?(0,U.jsx)(d,{variant:`secondary`,onClick:()=>void l.refetch(),children:S(`common.retry`)}):null]})}let M=A?.wizard??l.data,F=A?.translating?(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,U.jsx)(u,{}),(0,U.jsx)(`p`,{className:`text-[0.875rem]`,children:S(`translation.working`)})]}):null;if(T){let e=(0,U.jsx)(Ce,{wizard:M,page:A}),t=_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,U.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),F??(o?(0,U.jsx)(re,{runId:o,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>s(`/w/${a}/${k}`),header:D||O?void 0:e,footer:t}):(0,U.jsx)(we,{wizard:M,page:A,header:e,footer:t,door:k}))]})}return(0,U.jsxs)(`div`,{className:i(`wizard-page flex flex-col`,Q),children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),z===`inline`||_?null:(0,U.jsx)(X,{brand:l.data.brand,toggle:!z,start:(0,U.jsx)(K,{page:A})}),z===`inline`||_?(0,U.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,U.jsx)(K,{page:A,tone:`surface`})}):null,o&&(A?.translated||A?.failed)?(0,U.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,U.jsx)(q,{page:A})}):null,(0,U.jsx)(`div`,{className:`flex-1`,children:F??(o?(0,U.jsx)(te,{runId:o,onRestart:()=>s(`/w/${a}`)}):(0,U.jsx)(xe,{wizard:M,page:A}))}),_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})]})}export{X as BrandHeader,Ee as PublicRunner};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Jr as n,on as r}from"./ui-CJCF3Mhe.js";import{St as i}from"./index-Da7hPToW.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return r(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Jr as n,on as r}from"./ui-BI1RPFWT.js";import{Tt as i}from"./index-D3-kv1WF.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return r(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};