@engenty/wizards-runtime 0.9.5 → 0.9.6

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 (42) hide show
  1. package/apps/web/dist/assets/{AboutDialog-lUBGgvKu.js → AboutDialog-CZr1JFvY.js} +1 -1
  2. package/apps/web/dist/assets/{ChangelogDialog-B2IJbKX8.js → ChangelogDialog-0pKHVdhu.js} +1 -1
  3. package/apps/web/dist/assets/{EditorPage-B1syriTz.js → EditorPage-_qnWDno2.js} +2 -2
  4. package/apps/web/dist/assets/{FlowPreview-BUKI8h6o.js → FlowPreview-BZZvY5U9.js} +1 -1
  5. package/apps/web/dist/assets/{Harness-D35I3Jlp.js → Harness-DPRw6BmX.js} +1 -1
  6. package/apps/web/dist/assets/{Marketplace-C-ft5u_6.js → Marketplace-BwbLRU2n.js} +2 -2
  7. package/apps/web/dist/assets/{NewWizardChannels-PDeL4f5D.js → NewWizardChannels-K5vfNzaC.js} +1 -1
  8. package/apps/web/dist/assets/{NewWizardPage-BHw086HN.js → NewWizardPage-zYwDoQTe.js} +1 -1
  9. package/apps/web/dist/assets/{OnboardingPage-BYa8Xekc.js → OnboardingPage-jFgWaWJV.js} +1 -1
  10. package/apps/web/dist/assets/{PreviewPane-Cuatuhi-.js → PreviewPane-D5Kn9Ila.js} +2 -2
  11. package/apps/web/dist/assets/{ProjectPage-DTbTN9rE.js → ProjectPage-CyeEBVGi.js} +1 -1
  12. package/apps/web/dist/assets/{PublicRunner-BnT-zZrI.js → PublicRunner-_N7DyvWj.js} +1 -1
  13. package/apps/web/dist/assets/{ReadOnly-C5fdw_kg.js → ReadOnly-CQ8lWsnZ.js} +1 -1
  14. package/apps/web/dist/assets/{SettingsPage-Bkd5LuRn.js → SettingsPage-haivwaZK.js} +2 -2
  15. package/apps/web/dist/assets/{SetupPage-CHnbGccO.js → SetupPage-Dy8KeG7z.js} +1 -1
  16. package/apps/web/dist/assets/{SharePage-BiPJsotS.js → SharePage-BXkykFJC.js} +1 -1
  17. package/apps/web/dist/assets/changelog-XRs8voQT.js +1 -0
  18. package/apps/web/dist/assets/{coins-DVGgwSrK.js → coins-Bo9_D-7S.js} +1 -1
  19. package/apps/web/dist/assets/{index-C-u3ZXBZ.js → index-CXA_do-X.js} +5 -5
  20. package/apps/web/dist/assets/index-DG0i3S-z.css +1 -0
  21. package/apps/web/dist/assets/oss-credits-C2JUsf2d.js +1 -0
  22. package/apps/web/dist/assets/{phone-DD2g0U0Q.js → phone-BPybLMSm.js} +1 -1
  23. package/apps/web/dist/assets/preload-helper-DpV6A1kQ.js +1 -0
  24. package/apps/web/dist/assets/{qr-scanner.min-C_UI0gH-.js → qr-scanner.min-BGqShvxG.js} +1 -1
  25. package/apps/web/dist/assets/{runners-D6mK0B73.js → runners-53tvGeez.js} +1 -1
  26. package/apps/web/dist/assets/{session-BHCBxqVb.js → session-DvW7auj-.js} +1 -1
  27. package/apps/web/dist/assets/{settings-menu-DGDn2688.js → settings-menu-tSPDYTfT.js} +1 -1
  28. package/apps/web/dist/assets/{theme-DQ10nO_L.js → theme-CWGl7LyL.js} +1 -1
  29. package/apps/web/dist/assets/{ui-BV4KP5n2.js → ui-Bk08zclS.js} +3 -3
  30. package/apps/web/dist/assets/{upload-uc9uftDy.js → upload-Ct_-rz05.js} +1 -1
  31. package/apps/web/dist/assets/{useMutation-BfQIRblT.js → useMutation-DM9Anfo-.js} +1 -1
  32. package/apps/web/dist/assets/{volume-2-BlaOos9n.js → volume-2-CHuzf68z.js} +1 -1
  33. package/apps/web/dist/assets/{wrench-Cfpkphyw.js → wrench-BAgonupx.js} +1 -1
  34. package/apps/web/dist/index.html +9 -9
  35. package/apps/web/dist/mcp/flow.html +54 -54
  36. package/package.json +3 -3
  37. package/plugin/.claude-plugin/plugin.json +1 -1
  38. package/plugin/plugin.json +1 -1
  39. package/apps/web/dist/assets/changelog-Do_saoEi.js +0 -1
  40. package/apps/web/dist/assets/index-DtjKnB3s.css +0 -1
  41. package/apps/web/dist/assets/oss-credits-D7izqI_0.js +0 -1
  42. package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +0 -1
@@ -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{$r as r,$t as i,A as a,Ar as o,B as s,Bt as c,C as l,D as u,Dr as d,E as f,Er as p,H as m,Hr as h,Ht as g,I as _,Jr as v,Jt as y,Kr as b,Kt as x,L as S,Lt as C,M as w,Mr as T,N as E,O as D,Oi as O,Or as k,P as A,Pr as ee,Qt as j,R as te,Rt as M,S as N,T as ne,Tr as re,U as P,Ut as F,V as I,Vt as ie,W as L,Wt as R,Xn as z,Xr as ae,Xt as oe,Yt as B,Zt as V,_ as H,_r as U,b as W,cr as G,d as se,dr as ce,ei as le,f as ue,ft as de,g as fe,h as K,hr as q,j as pe,k as me,kr as he,m as ge,ni as _e,on as J,p as Y,pr as ve,qt as ye,ri as be,ti as xe,tn as Se,v as Ce,vr as we,w as Te,x as Ee,xr as De,y as X,z as Oe,zr as ke,zt as Ae}from"./ui-BV4KP5n2.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-C-ft5u_6.js";import{t as Le}from"./useMutation-BfQIRblT.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-Cuatuhi-.js";import{b as ct,f as lt}from"./theme-DQ10nO_L.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-BHCBxqVb.js";import{t as ht}from"./phone-DD2g0U0Q.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-C5fdw_kg.js";import{t as yt}from"./upload-uc9uftDy.js";import{Ct as bt,Et as xt,K as St,b as Ct,bt as wt,c as Tt,d as Et,et as Dt,f as Ot,ft as kt,h as At,it as jt,lt as Mt,m as Nt,p as Pt,pt as Ft,s as It,u as Lt,v as Rt,vt as zt,y as Bt,yt as Vt}from"./index-C-u3ZXBZ.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-DGDn2688.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=b(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=b(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=b(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=b(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=b(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=b(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=b(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=b(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=b(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:J(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(J(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let r=Oe(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:i(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:r,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)(ce,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(k,{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,r]=(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),r(t)}).catch(()=>r(null))},[e]),(0,Q.jsx)(`div`,{className:i(`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:J(`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":`${J(`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)(g,{label:J(`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)(g,{label:J(`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)(fe,{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)(g,{label:J(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(G,{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)(ge,{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)(U,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){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 i=await t(a.trim());i.file?(n([i.file]),r()):i.candidates?.length?(p(i.candidates),h([i.candidates[0].url])):d(J(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&&r()};return(0,Q.jsx)(c,{open:!0,onClose:r,wide:f?!0:void 0,title:J(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:J(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:i(`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:i(`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)(ke,{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)(C,{variant:`ghost`,onClick:()=>p(null),children:J(`run.back`)}),(0,Q.jsx)(C,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?J(`project.addMany`,{n:m.length}):J(`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:J(`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:J(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)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:s,disabled:!a.trim(),children:J(`run.next`)})]})]})})}function Tn(e,t,n){return be({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?J(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:r}){let a=O(),s=P(e),c=Qe(e),l=I(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`),h=c.data?.items.find(e=>e.key===`f:${u.id}`),_=Oe(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:i(`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":J(`project.openOriginal`),title:J(`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)(o,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{label:J(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(q,{className:`size-4`})}),(0,Q.jsx)(g,{label:J(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(J(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:h?.categories??[],originLabel:h?.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`,J(`project.original`)):null,v(`text`,J(`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)(de,{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:J(`project.textCut`,{shown:n.data.text.length.toLocaleString(Se),total:n.data.chars.toLocaleString(Se)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:J(`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=Oe(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":J(`project.openOriginal`),title:J(`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)(o,{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":`${J(`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)(g,{label:J(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(fe,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(G,{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:J(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:J(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:J(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(C,{variant:`danger`,onClick:n,children:J(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,disabled:!i.trim(),children:J(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:i}){let o=I(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[h,_]=(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:h},i),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),k=new Set(h.flatMap(e=>e.assets)),A=h.find(e=>e.id===v)??null,ee=A?A.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!k.has(e.id)),j=D.find(e=>e.id===f),te=u.trim().toLowerCase(),M=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ne=async e=>{let t=A?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},re=e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},P=h.length?{options:[{value:``,label:J(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,F=[{label:J(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:J(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...h.length<a.logoSections?[{label:J(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],ie=h.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:[h.length?(0,Q.jsx)(V,{value:v,onChange:e=>{b(e),d(``)},label:J(`project.assets`),options:[{id:``,label:J(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||J(`project.sectionUntitled`)}))]}):null,A&&!n?(0,Q.jsx)(g,{label:J(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(we,{className:`size-4`})}):null]}),ee.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Ce,{value:u,onChange:d,placeholder:J(`project.assetSearch`)})}),(0,Q.jsx)(g,{label:J(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Vt,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:J(`project.assets`),hint:J(`project.assetsHint`),save:E,tabs:ie,action:n?null:(0,Q.jsx)(se,{entries:F}),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&&ne(t)}}),M.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:M,actions:o,moveTo:P,onRemove:re,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:M.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:P,onPreview:()=>p(t.id),onRemove:()=>re(t)},t.id))}):ee.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.staysLocal`)}):(0,Q.jsxs)(ge,{accept:jn,onFiles:e=>void ne(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),J(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:J(`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`?A:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&A)_(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=Ee();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&A?()=>{(!A.assets.length||confirm(J(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(_(e=>e.filter(e=>e.id!==A.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,A?.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:r,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[d,f]=(0,Z.useState)(A(t)),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(!n),T=e=>{l(e),f(A(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}]})},O=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:h.trim(),...S?{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:J(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(),h.trim()&&!v&&O()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:h,maxLength:1e3,"aria-label":J(`project.gradientDescribe`),placeholder:J(S?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(C,{type:`submit`,variant:`secondary`,busy:v,disabled:!h.trim(),children:[(0,Q.jsx)(ce,{className:`size-4`}),J(S?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??J(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:A(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:J(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:J(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:J(`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:J(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:u.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:i(`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:J(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:J(`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":J(`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:J(`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)(B,{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":J(`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)(g,{label:J(`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)(G,{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)(C,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.gradientStopAdd`)]}):null,r.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:J(`project.gradientFromBrand`)}),r.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:d,spellCheck:!1,onChange:e=>{f(e.target.value);let t=te(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:J(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:o,children:J(`common.cancel`)}),(0,Q.jsx)(C,{onClick:()=>{a(s),o()},children:J(`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:J(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:J(`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:r,onRemove:a}){let o=A(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":J(`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)(g,{label:J(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),(0,Q.jsx)(g,{label:J(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(T,{className:`size-4`})}),t?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:a,className:i(Hn,`hover:text-rose`),children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:J(`project.gradientName`),description:e.description,usePlaceholder:J(`project.gradientUse`),readOnly:t,onChange:r})]})}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:r,onEdit:a,onChange:o,onRemove:s}){let c=Oe(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:r,"aria-label":J(`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":J(`project.download`),title:J(`project.download`),className:i(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(T,{className:`size-4`})}),r?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:s,className:i(Hn,`hover:text-rose`),children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:J(`project.patternUse`),readOnly:r,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:r,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,m]=(0,Z.useState)(t),[h,g]=(0,Z.useState)([]),_=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(g(e=>[...e,n.id]),m(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},v=()=>{for(let e of h)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:v,wide:!0,title:J(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(Oe(e,f.file),f.tile),children:(0,Q.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void _(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)(p,{className:`size-4`}),J(`project.patternReplace`)]})}):(0,Q.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void _(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(p,{className:`size-5`}),J(`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:J(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):J(`project.patternNamePlaceholder`),onChange:e=>m({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:J(`project.patternUse`),onChange:e=>m({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`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:()=>m({...f,tile:e||void 0}),className:i(`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:J(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)(C,{variant:`ghost`,onClick:v,children:J(`common.cancel`)}),(0,Q.jsx)(C,{disabled:!f.file||a,onClick:()=>{for(let e of h.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:J(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[r,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:r.trim()});t.length?(f(t),m([])):u(J(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:J(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:J(`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:i(`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)(ke,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>f(null),children:J(`run.back`)}),(0,Q.jsx)(C,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?J(`project.addMany`,{n:p.length}):J(`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:J(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,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:J(`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)(C,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:o,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:Ee()}))),[_,v]=(0,Z.useState)(r),[y,b]=(0,Z.useState)(i),[x,S]=(0,Z.useState)(o),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=I(e,f),O=N(c),[k,A]=(0,Z.useState)(null),[ee,j]=(0,Z.useState)(null),[te,M]=(0,Z.useState)(!1),ne=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:_,gradients:y,patterns:x,colorRules:O.rules},d),re=l?_:[],P=re.filter(e=>(e.kind??`colors`)===`colors`),ie=e=>P.some(t=>t.id===e.section),L=p.filter(e=>!ie(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),ae=e=>m(t=>[...t,...e.map(e=>({...e,id:Ee()}))].slice(0,a.colors)),oe=[{value:``,label:J(`project.sectionStandard`)},...P.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],V=(e,t)=>{let n=Ee();A(n),v(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},ce=e=>({id:Ee(),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}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,de=[...p.length<a.colors?[{label:J(`project.colorNew`),icon:(0,Q.jsx)(U,{className:`size-4 shrink-0`}),onPick:()=>q()},{label:J(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&_.length<a.logoSections?[{label:J(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>V(`colors`,``)},{label:J(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>V(`gradients`,J(`project.gradientSectionTitle`))},{label:J(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>V(`patterns`,J(`project.patternSectionTitle`))}]:[],...!u||O.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>O.add()}]],K=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(B,{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===ee,placeholder:J(`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:J(`project.colorAccent`)})}):f?null:(0,Q.jsx)(g,{label:J(`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)(h,{className:`size-4`})}),f||!P.length?null:(0,Q.jsx)(fe,{options:oe,value:ie(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)(g,{label:J(`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)(G,{className:`size-4`})})]})]},e.id),q=e=>{let t=Ee();j(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:J(`project.colors`),hint:J(`project.colorsHint`),save:ne,locked:f,action:f?null:(0,Q.jsx)(se,{entries:de}),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(K)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.colorsEmpty`)}),re.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),i=y.filter(e=>e.section===t.id),o=x.filter(e=>e.section===t.id),s=n===`gradients`?i.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(W,{title:t.title,titlePlaceholder:J(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:J(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:J(`project.kindPatterns`)}:{icon:(0,Q.jsx)(kt,{}),label:J(`project.kindColors`)},autoFocus:k===t.id,readOnly:f,onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(J(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||J(`project.sectionUntitled`)}))){v(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),b(e=>e.filter(e=>e.section!==t.id));for(let e of o)D.remove(e.file);S(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:[i.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>w(e),onChange:t=>b(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>b(t=>t.filter(t=>t.id!==e.id))},e.id)),f||y.length>=a.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(ce(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)(U,{className:`size-5`}),J(`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:le(t.file),readOnly:f,onEdit:()=>E(t),onChange:e=>S(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{D.remove(t.file),S(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||x.length>=a.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E({id:Ee(),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)(U,{className:`size-5`}),J(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(K),f||p.length>=a.colors?null:(0,Q.jsx)(ue,{label:J(`project.colorAdd`),onClick:()=>q(t.id)})]})]},t.id)}),u?(0,Q.jsx)(H,{rules:O,placeholder:J(`project.colorRulePlaceholder`),readOnly:f}):null]}),D.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:D.error}):null,C?(0,Q.jsx)(Bn,{projectId:e,gradient:C,isNew:!y.some(e=>e.id===C.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>w(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,T?(0,Q.jsx)(qn,{projectId:e,pattern:T,isNew:!x.some(e=>e.id===T.id),fileName:le,busy:D.busy,error:D.error,upload:async e=>(await D.upload(`pattern`,[e]))[0]??null,removeFile:e=>void D.remove(e),onClose:()=>E(null),onSave:e=>S(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,te?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:ae}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:re,email:zt,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[r,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)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)}},[r]);let l=Qn[e??t],u=`${J(`project.factType`)}: ${J(`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":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:i(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:i(`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:J(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:J(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:i(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Te.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:J(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:i(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(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 a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:J(`project.facts`),hint:J(`project.factsHint`),save:u,locked:n,action:o.length<a.facts&&!n?(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=pe(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:J(`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:w(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)(oe,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:J(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?J(`project.yes`):J(`project.no`)})]}):(0,Q.jsx)(j,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:J(`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)(g,{label:J(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]},e.id)})}),o.length<a.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:J(`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)(U,{className:`size-3.5`}),` `,J(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[r,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:i(`-m-2 rounded-xl p-2 transition`,r&&`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:i,sectioned:o,ruled:c,save:l}){let u=I(e,n),[d,f]=(0,Z.useState)(r),p=N(i),[m,h]=(0,Z.useState)(null),[g,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=_(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)),k=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},A=C.length?{options:[{value:``,label:J(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,ee=(t,n,r)=>(0,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?J(`project.logoAdd`):void 0,onUpload:e=>void k(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:A,onRemove:e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),te=[{label:J(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:J(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<a.logoSections?[{label:J(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=Ee();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:J(`project.logos`),hint:J(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(se,{entries:te}),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&&k(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:ee(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)(W,{title:e.title,description:e.description,titlePlaceholder:J(`project.logoSectionTitle`),descriptionPlaceholder:J(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(J(`project.logoSectionRemoveConfirm`,{name:e.title||J(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),ee(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(H,{rules:p,placeholder:J(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,g?(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=E({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 J(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return J(`project.fontSourceFile`,{name:e})}return J(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:r}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=I(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,b]=(0,Z.useState)(t.license??``),[S,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:r,title:J(`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:J(`project.fontSourceHint`)}),(0,Q.jsx)(x,{value:l,options:[`file`,`url`],label:e=>J(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`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:i(`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)(C,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),J(`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:J(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:J(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(C,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:J(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:J(`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:J(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:J(`project.fontLicenseHint`),children:J(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:J(`project.fontLicensePlaceholder`),onChange:e=>b(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:S,onChange:e=>w(e.target.checked)}),J(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(C,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:J(`project.fontSourceRemove`)}):null,(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{disabled:!(D&&S),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),r())},children:J(`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)}:${f.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:r,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`})]}),r?(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:J(`project.fontFamily`),placeholder:J(`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:J(`project.fontRole`),placeholder:J(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:f.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"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:i(`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`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?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:J(`project.fontLicense`),placeholder:J(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!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:J(`project.fontUses`)}),ne.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):ne.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:i(`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`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(ke,{className:`size-3.5`}):null,J(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)}),r||!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:J(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,r?null:(0,Q.jsx)(g,{label:J(`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)(G,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:r,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:[r?(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:J(`project.styleName`),placeholder:J(`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:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":J(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:i(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||J(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":J(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...f,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:J(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:J(`project.styleLine`),label:J(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:J(`project.styleTracking`),label:J(`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:J(`project.styleUpper`),"aria-label":J(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:i(`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`})})]}),r?null:(0,Q.jsx)(g,{label:J(`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)(G,{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(J(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:J(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:J(`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)(C,{variant:`ghost`,onClick:()=>d(null),children:J(`run.back`)}),(0,Q.jsx)(C,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?J(`project.addMany`,{n:f.length}):J(`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:J(`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:J(`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)(C,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`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:i(`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(` · `):J(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(ke,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=N(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:Ee(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,a.fonts))},x=()=>{let e=Ee();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<a.fonts?[{label:J(`project.fontNew`),icon:(0,Q.jsx)(U,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:J(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<a.textStyles?[{label:J(`project.styleNew`),icon:(0,Q.jsx)(Mt,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||m.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:J(`project.typography`),hint:J(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(se,{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:J(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:J(`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,i?(0,Q.jsx)(H,{rules:m,placeholder:J(`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:J(`project.base`),hint:J(`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:J(`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:J(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.about`)}),(0,Q.jsx)(j,{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:J(`project.aboutHint`)})]})]})})}function br({project:e,group:t,children:n}){let r=O(),i=P(e.id),[a,o]=(0,Z.useState)(0),[s,l]=(0,Z.useState)(!1),u=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},d=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),f=pt(),p=dt(),m=i.data??{files:[],embeddings:!0},h=`${e.id}:${a}`,g=e.readOnly,_=t===`knowledge`,v=jt(`brandSections`),y=jt(`brandRules`),b=jt(`typography`);return St(g?{}:{title:J(_?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:J(_?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:J(_?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:_?[{label:J(`assistant.suggest.knowledgeHow`)},{label:J(`assistant.suggest.knowledgeSite`),fill:!0},{label:J(`assistant.suggest.knowledgeCategories`)}]:[{label:J(`assistant.suggest.readSite`),fill:!0},{label:J(`assistant.suggest.missing`)},{label:J(`assistant.suggest.facts`)}],summary:_?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${m.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>o(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[g?(0,Q.jsx)(vt,{children:gt(e)}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:u},`base:${h}`)}),(0,Q.jsx)(Y,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>u({facts:e}),readOnly:g},`facts:${h}`)}),(0,Q.jsx)(Y,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:m,readOnly:g,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:v,ruled:y,save:e=>u({brand:e})},`logos:${h}`)}),(0,Q.jsx)(Y,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:m,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:v,ruled:y,save:e=>u({brand:e}),readOnly:g},`colors:${h}`)}),b?(0,Q.jsx)(Y,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:y,sample:e.brand.name||J(`project.typeSample`),save:e=>u({brand:e}),readOnly:g},`typography:${h}`)}):null,(0,Q.jsx)(Y,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:m,readOnly:g,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${h}`)})]}):null,n,t===`info`&&f&&!g&&p?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(C,{variant:`danger`,onClick:()=>l(!0),children:J(`settings.delete`)}),(0,Q.jsxs)(c,{open:s,onClose:()=>l(!1),title:J(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:J(`settings.deleteBody`)}),d.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>l(!1),children:J(`common.cancel`)}),(0,Q.jsx)(C,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:J(`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=J(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(v,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:J(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(v,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:J(`project.facts`)},t):e),` `,J(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:r}){let a=me.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:r,"aria-label":J(`page.address`),maxLength:D.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:i(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$,!a&&t&&`text-rose`),children:J(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:r}){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:J(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:r,maxLength:D.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$),children:J(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:i(`mt-1`,$),children:J(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:J(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:r,maxLength:D.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:J(`page.words`)}),(0,Q.jsx)(j,{value:t.intro??``,disabled:r,minRows:3,maxLength:D.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.lang`)}),(0,Q.jsx)(ye,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:J(e.label)}))}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$),children:J(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return J(`page.draftNote`);if(!e.shareEnabled)return J(`page.notSharedNote`);let n=e.description.trim();return t?[n,J(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:r,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:i(`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":`${J(`page.moveUp`)} / ${J(`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)(d,{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:i(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(oe,{checked:n,disabled:r||!e.published,label:J(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:r,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||a,onClick:o,className:i(`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`,(r||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 r=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.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:i(`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:J(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:i(`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":J(`page.resize`),title:J(`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:r,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(!(me.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=O(),n=ft(),r=n.data?.tenant.pagesHost??null,a=n.data?.manageUrl??null,o=e.readOnly,s=e.page,c=!!s?.on,l=be({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[u,d]=(0,Z.useState)(1),[f,p]=(0,Z.useState)(zr),m=(0,Z.useRef)(s);m.current=s;let h=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),d(e=>e+1)},g=Le({mutationFn:e=>{let t=m.current;return t?h({...t,...e}):Promise.resolve()}}),[_,v]=(0,Z.useState)({state:`idle`,error:null}),{copied:y,copy:b}=wr(),x=l.data??[],w=(s?.wizards??[]).map(e=>x.find(t=>t.id===e)).filter(e=>e!==void 0),T=x.filter(e=>!s?.wizards.includes(e.id)),[E,D]=(0,Z.useState)(null),k=(e,t)=>{let n=[...s?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),g.mutate({wizards:n})},A=(e,t)=>g.mutate({wizards:t?[...s?.wizards??[],e]:(s?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>h({on:!0,slug:S(j)||`page`,title:j,...st(Se===`de`?`de-du`:`en`),wizards:x.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{s?g.mutate({on:e}):e&&te.mutate()},ne=g.isPending||te.isPending,re=g.error??te.error;if(!r)return(0,Q.jsx)(Y,{id:`page`,children:(0,Q.jsx)(X,{title:J(`space.page`),hint:J(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:J(`page.cloudOnly`)})})});let P=s?.slug||S(j)||`…`,F=We(r,P),I=ot(r,P,a),ie=(0,Q.jsxs)(`span`,{className:i(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:P})]}),R=o||!s,z=(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:J(`page.previewTitle`)}),c?(0,Q.jsx)(rt,{named:!0,label:J(`editor.device`),value:f,onChange:e=>{p(e),Br(e)},options:[{id:`desktop`,label:J(`editor.deviceDesk`),icon:(0,Q.jsx)(Ft,{className:`size-3.5`})},{id:`tablet`,label:J(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:J(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),c?(0,Q.jsx)(Vr,{url:I,version:u,device:f}):(0,Q.jsx)(`p`,{className:$,children:J(`page.previewOff`)}),c?(0,Q.jsx)(`p`,{className:$,children:J(`page.previewHint`)}):null]}),ae=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:J(`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:J(`share.onPage`,{space:s?.title||j})}),(0,Q.jsx)(`span`,{className:i(`block truncate font-mono`,$),children:F})]}),(0,Q.jsx)(oe,{checked:!0,disabled:!0,label:J(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:J(`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)(Y,{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:J(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:J(`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:i(`size-2 shrink-0 rounded-full`,c?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ie]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!c,onClick:()=>b(I),children:[y?(0,Q.jsx)(ke,{className:`size-3.5`}):(0,Q.jsx)(ee,{className:`size-3.5`}),J(y?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(C,{size:`sm`,className:`max-sm:flex-1`,disabled:!c,onClick:()=>window.open(I,`_blank`,`noopener`),children:[J(`page.open`),` `,(0,Q.jsx)(xt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:J(`page.sectionPage`),locked:o,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":J(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:J(`page.whoOff`),text:J(`page.whoOffHint`),picked:!c,disabled:o||ne,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:J(`page.whoPublic`),text:J(`page.whoPublicHint`),picked:c,disabled:o||ne,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:J(`page.whoMembers`),text:J(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),re?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:re.message}):null]})]})}),z,(0,Q.jsx)(Y,{id:`page-words`,children:(0,Q.jsx)(X,{title:J(`page.sectionWords`),hint:s?void 0:J(`page.notYet`),save:s?_:void 0,locked:R,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[s?(0,Q.jsx)(Hr,{host:r,page:s,disabled:o,save:h,onState:v},`${e.id}:${s.slug}`):(0,Q.jsx)(Dr,{host:r,disabled:!0,words:{slug:P,title:j,headline:``,intro:``,voice:Se===`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:J(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:J(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[w.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:R,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>D(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{E!==null&&k(E,t),D(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),T.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:R,onToggle:t=>A(e.id,t)},e.id))]}),x.length?null:(0,Q.jsx)(`p`,{className:i(`mt-2`,$),children:J(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:i(`mt-4`,$),children:J(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),ae]})}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 be({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 Dt({icon:ve,label:J(`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)(ye,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:J(`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)(ve,{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:J(`space.resultsSearch`),"aria-label":J(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(ye,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:J(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(ye,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:J(`space.resultsAnyTime`)},{value:`1`,label:J(`space.resultsDay`)},{value:`7`,label:J(`space.resultsDays`,{n:7})},{value:`30`,label:J(`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(Se,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):J(`space.resultsAll`),hint:J(`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))} · `,J(`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:J(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(De,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:J(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(ie,{children:r.q.trim()||r.mode||r.days?J(`space.resultsNone`):J(`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:J(`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({project:e,save:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.name),o=Le({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{label:J(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,Q.jsx)(we,{className:`size-4`})}),(0,Q.jsx)(c,{open:n,onClose:()=>r(!1),title:J(`project.rename`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,Q.jsx)(F,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>r(!1),children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:J(`settings.save`)})]})]})})]})}function Xr({project:e}){let t=O();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Ct,{}),e.readOnly?null:(0,Q.jsx)(Yr,{project:e,save:async n=>{await L.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Zr(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=Rt(),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 Qr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function $r({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 ei(){let{group:e}=xe(),[t,n]=_e(),a=le(),o=r(),{hash:s}=o,{project:c,loading:l}=ut(),u=pt(),d=Lt(),f=Zt(),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=Ot(e)?e:void 0,b=y?void 0:d.spaceParts.find(t=>t.id===e),x=y??b?.id,S=o.state?.parts===!0,C=jt(`pages`),w=Nt().filter(e=>C||e.id!==`page`),T=At(w,d).map(e=>({...e,to:`/space/${e.id}`})),E={id:`results`,label:J(`space.results`),icon:bt,to:`/space/results`},D=y===`results`?E:T.find(e=>e.id===x),O=t.get(`show`),k=y===`results`?2:x?O?2:1:0,A=y===`results`?1:f?Math.min(k,1):x&&_!==x&&!S?1:0,ee=Wt(A),j=Wt(k),te=(0,Z.useMemo)(()=>({slot:p,narrow:f,setDetail:g}),[p,f]),M=c?c.brand.name?.trim()||c.name:J(`nav.project`),N=jt(`typography`)?[]:[`typography`],ne=b?d.spaceMenus[b.id]??[]:[],re=b?[{plugin:null,label:null,sections:ne}]:y&&y!==`results`?Pt(y,d,N):[],P=y?Pt(y,d).filter(e=>e.plugin):[],F=Zr([...re,...y===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),I=y===`results`&&O&&O!==`all`?O:null,[L,R]=(0,Z.useState)(Gr),z=Kr(y===`results`?c?.id:void 0,I,L),oe=z.data?.wizards.find(e=>e.id===I)?.title,B=y===`data`&&O&&O!==`all`||y===`knowledge`&&O&&/^[ptfcvs]:/.test(O)?O:null,V=B?.startsWith(`s:`)?d.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=y===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(y===`data`?c?.id:void 0),W=Qe(y===`knowledge`?c?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),se=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),ce=y===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?se?.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([...y===`results`?[]:[{label:J(`nav.project`),to:`/space`}],...D?[{label:D.label,to:`/space/${D.id}`}]:[],...D&&(h??oe??ce)?[{label:h??oe??ce}]:[]]);let ue={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};St({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:J(`assistant.suggest.dataWhat`)},{label:J(`assistant.suggest.dataWho`)},{label:J(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:J(`assistant.suggest.resultsFailed`)},{label:J(`assistant.suggest.resultsCost`)},{label:J(`assistant.suggest.resultsShare`)}]}:{},...B&&ce?{open:{kind:ue[B[0]]??`item`,id:B.slice(2),label:ce}}:I&&oe?{open:{kind:`wizard`,id:I,label:oe}}:{}});let de=y===`results`||y===`data`||B?s.slice(1):O||s.slice(1),fe=(0,Z.useRef)(``);if((0,Z.useEffect)(()=>{let e=`${x}#${de}`;de&&fe.current!==e&&document.getElementById(de)&&(fe.current=e,requestAnimationFrame(()=>Qr(de,!1)))},[x,de,c?.id,d.spaceSections,ne.length]),!x){let t=s.slice(1),n=t?Et(t,d):null;if(n===`knowledge`&&d.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(ae,{to:f?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&d.status!==`ready`)return null;if(e!==void 0||!f)return(0,Q.jsx)(ae,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!O&&d.spaceSections.some(e=>e.id===s.slice(1)))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${s.slice(1)}`,replace:!0});let K=e=>{if(f){a({search:`?show=${e}`});return}fe.current=`${x}#${e}`,Qr(e,!0),a({search:``,hash:e},{replace:!0})},q=e=>f?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),pe=e=>e.flatMap(e=>e.sections).map(e=>d.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(Y,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(It,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=f?void 0:F,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:A===1?D??null:null,onBack:y===`results`?void 0:()=>f?a(`/space`):v(x??null),root:{icon:wt,label:J(`nav.project`),backLabel:J(`nav.wizards`),onBack:()=>a(`/`)}}),(0,Q.jsx)(`div`,{className:i(Ut(ee)),children:A===0?(0,Q.jsx)(Jt,{entries:T,current:f?void 0:D,onPick:()=>v(null)}):(0,Q.jsx)(`div`,{ref:m})},A)]});return(0,Q.jsx)(qt.Provider,{value:te,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:i(`grid gap-6`,y!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[y===`results`?null:(0,Q.jsx)(`aside`,{className:i(`min-w-0 md:sticky md:top-6 md:self-start`,f&&k===2&&`hidden`,f&&j===`back`&&Ut(`back`)),children:he}),x?(0,Q.jsxs)(`div`,{className:i(`min-w-0`,f&&k<2&&`hidden`,f&&j===`deeper`&&Ut(`deeper`)),children:[f&&y!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:D?.label??M,onBack:()=>a(`/space/${x}`)})}):null,u&&c?(0,Q.jsx)(`div`,{className:`mb-6`,children:(0,Q.jsx)(Xr,{project:c})}):null,y===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Vt,label:J(`data.all`),selected:!f&&!B,onPick:()=>q(`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:!f&&e.key===B,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,Q.jsx)($r,{groups:P,current:me,onPick:K})]}):y===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Vt,label:J(`know.all`),selected:!(f||B),onPick:()=>q(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:J(`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:!f&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($r,{groups:P,current:f?void 0:V?.id,onPick:e=>q(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)($r,{groups:re,current:me,onPick:K})}),c&&(y===`info`||y===`knowledge`)?(0,Q.jsxs)(br,{project:c,group:y,children:[y===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>q(`all`),onOpen:q},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>q(`all`)},H):(0,Q.jsx)(kn,{projectId:c.id,fileId:H.slice(2),readOnly:c.readOnly,onGone:()=>q(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(It,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?se?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:c.id,category:se,readOnly:c.readOnly,onOpen:q,onGone:()=>q(`all`)}),se.type===`choice`?null:(0,Q.jsx)(it,{projectId:c.id,category:se,categories:W.data.categories,onOpen:q})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:c.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:q},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:J(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(Y,{id:`documents`,children:(0,Q.jsx)(et,{projectId:c.id,data:W.data,readOnly:c.readOnly,onOpen:q})}):null:null,y===`info`?pe(P):null]},c.id):null,c&&y===`page`&&C?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:c},c.id),pe(P)]}):null,c&&b?(0,Q.jsx)(It,{of:b,children:(0,Q.jsx)(Tt,{part:b.id,children:(0,Q.jsx)(b.component,{})},c.id)}):null,c&&y===`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:()=>q(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>q(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:c.id,data:U.data,readOnly:c.readOnly,onOpen:q}):null,pe(P)]})}):null,c&&y===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[z.data?(0,Q.jsx)(Jr,{data:z.data,wizardId:I,onWizard:e=>q(e??`all`),filter:L,onFilter:R}):null,z.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:z.error.message}):null,pe(P)]}):null,c||l?null:(0,Q.jsx)(ie,{children:J(`settings.noProject`)})]}):null]})})})}export{ei 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{$r as r,$t as i,A as a,Ar as o,B as s,Bt as c,C as l,D as u,Dr as d,E as f,Er as p,H as m,Hr as h,Ht as g,I as _,Jr as v,Jt as y,Kr as b,Kt as x,L as S,Lt as C,M as w,Mr as T,N as E,O as D,Oi as O,Or as k,P as A,Pr as ee,Qt as j,R as te,Rt as M,S as N,T as ne,Tr as re,U as P,Ut as F,V as I,Vt as ie,W as L,Wt as R,Xn as z,Xr as ae,Xt as oe,Yt as B,Zt as V,_ as H,_r as U,b as W,cr as G,d as se,dr as ce,ei as le,f as ue,ft as de,g as fe,h as K,hr as q,j as pe,k as me,kr as he,m as ge,ni as _e,on as J,p as Y,pr as ve,qt as ye,ri as be,ti as xe,tn as Se,v as Ce,vr as we,w as Te,x as Ee,xr as De,y as X,z as Oe,zr as ke,zt as Ae}from"./ui-Bk08zclS.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-BwbLRU2n.js";import{t as Le}from"./useMutation-DM9Anfo-.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-D5Kn9Ila.js";import{b as ct,f as lt}from"./theme-CWGl7LyL.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-DvW7auj-.js";import{t as ht}from"./phone-BPybLMSm.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-CQ8lWsnZ.js";import{t as yt}from"./upload-Ct_-rz05.js";import{Ct as bt,Et as xt,K as St,b as Ct,bt as wt,c as Tt,d as Et,et as Dt,f as Ot,ft as kt,h as At,it as jt,lt as Mt,m as Nt,p as Pt,pt as Ft,s as It,u as Lt,v as Rt,vt as zt,y as Bt,yt as Vt}from"./index-CXA_do-X.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-tSPDYTfT.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=b(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=b(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=b(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=b(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=b(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=b(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=b(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=b(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=b(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:J(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(J(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let r=Oe(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:i(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:r,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)(ce,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(k,{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,r]=(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),r(t)}).catch(()=>r(null))},[e]),(0,Q.jsx)(`div`,{className:i(`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:J(`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":`${J(`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)(g,{label:J(`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)(g,{label:J(`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)(fe,{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)(g,{label:J(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(G,{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)(ge,{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)(U,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){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 i=await t(a.trim());i.file?(n([i.file]),r()):i.candidates?.length?(p(i.candidates),h([i.candidates[0].url])):d(J(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&&r()};return(0,Q.jsx)(c,{open:!0,onClose:r,wide:f?!0:void 0,title:J(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:J(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:i(`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:i(`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)(ke,{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)(C,{variant:`ghost`,onClick:()=>p(null),children:J(`run.back`)}),(0,Q.jsx)(C,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?J(`project.addMany`,{n:m.length}):J(`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:J(`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:J(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)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:s,disabled:!a.trim(),children:J(`run.next`)})]})]})})}function Tn(e,t,n){return be({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?J(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:r}){let a=O(),s=P(e),c=Qe(e),l=I(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`),h=c.data?.items.find(e=>e.key===`f:${u.id}`),_=Oe(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:i(`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":J(`project.openOriginal`),title:J(`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)(o,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{label:J(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(q,{className:`size-4`})}),(0,Q.jsx)(g,{label:J(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(J(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:h?.categories??[],originLabel:h?.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`,J(`project.original`)):null,v(`text`,J(`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)(de,{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:J(`project.textCut`,{shown:n.data.text.length.toLocaleString(Se),total:n.data.chars.toLocaleString(Se)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:J(`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=Oe(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":J(`project.openOriginal`),title:J(`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)(o,{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":`${J(`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)(g,{label:J(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(fe,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(G,{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:J(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:J(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:J(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(C,{variant:`danger`,onClick:n,children:J(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,disabled:!i.trim(),children:J(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:i}){let o=I(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[h,_]=(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:h},i),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),k=new Set(h.flatMap(e=>e.assets)),A=h.find(e=>e.id===v)??null,ee=A?A.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!k.has(e.id)),j=D.find(e=>e.id===f),te=u.trim().toLowerCase(),M=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ne=async e=>{let t=A?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},re=e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},P=h.length?{options:[{value:``,label:J(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,F=[{label:J(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:J(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...h.length<a.logoSections?[{label:J(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],ie=h.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:[h.length?(0,Q.jsx)(V,{value:v,onChange:e=>{b(e),d(``)},label:J(`project.assets`),options:[{id:``,label:J(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||J(`project.sectionUntitled`)}))]}):null,A&&!n?(0,Q.jsx)(g,{label:J(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(we,{className:`size-4`})}):null]}),ee.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Ce,{value:u,onChange:d,placeholder:J(`project.assetSearch`)})}),(0,Q.jsx)(g,{label:J(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Vt,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:J(`project.assets`),hint:J(`project.assetsHint`),save:E,tabs:ie,action:n?null:(0,Q.jsx)(se,{entries:F}),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&&ne(t)}}),M.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:M,actions:o,moveTo:P,onRemove:re,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:M.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:P,onPreview:()=>p(t.id),onRemove:()=>re(t)},t.id))}):ee.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.staysLocal`)}):(0,Q.jsxs)(ge,{accept:jn,onFiles:e=>void ne(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),J(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:J(`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`?A:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&A)_(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=Ee();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&A?()=>{(!A.assets.length||confirm(J(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(_(e=>e.filter(e=>e.id!==A.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,A?.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:r,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[d,f]=(0,Z.useState)(A(t)),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(!n),T=e=>{l(e),f(A(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}]})},O=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:h.trim(),...S?{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:J(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(),h.trim()&&!v&&O()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:h,maxLength:1e3,"aria-label":J(`project.gradientDescribe`),placeholder:J(S?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(C,{type:`submit`,variant:`secondary`,busy:v,disabled:!h.trim(),children:[(0,Q.jsx)(ce,{className:`size-4`}),J(S?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??J(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:A(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:J(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:J(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:J(`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:J(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:u.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:i(`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:J(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:J(`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":J(`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:J(`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)(B,{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":J(`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)(g,{label:J(`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)(G,{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)(C,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.gradientStopAdd`)]}):null,r.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:J(`project.gradientFromBrand`)}),r.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:d,spellCheck:!1,onChange:e=>{f(e.target.value);let t=te(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:J(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:o,children:J(`common.cancel`)}),(0,Q.jsx)(C,{onClick:()=>{a(s),o()},children:J(`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:J(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:J(`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:r,onRemove:a}){let o=A(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":J(`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)(g,{label:J(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),(0,Q.jsx)(g,{label:J(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(T,{className:`size-4`})}),t?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:a,className:i(Hn,`hover:text-rose`),children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:J(`project.gradientName`),description:e.description,usePlaceholder:J(`project.gradientUse`),readOnly:t,onChange:r})]})}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:r,onEdit:a,onChange:o,onRemove:s}){let c=Oe(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:r,"aria-label":J(`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":J(`project.download`),title:J(`project.download`),className:i(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(T,{className:`size-4`})}),r?null:(0,Q.jsx)(g,{label:J(`project.remove`),onClick:s,className:i(Hn,`hover:text-rose`),children:(0,Q.jsx)(G,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:J(`project.patternUse`),readOnly:r,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:r,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,m]=(0,Z.useState)(t),[h,g]=(0,Z.useState)([]),_=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(g(e=>[...e,n.id]),m(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},v=()=>{for(let e of h)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:v,wide:!0,title:J(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(Oe(e,f.file),f.tile),children:(0,Q.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void _(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)(p,{className:`size-4`}),J(`project.patternReplace`)]})}):(0,Q.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void _(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(p,{className:`size-5`}),J(`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:J(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):J(`project.patternNamePlaceholder`),onChange:e=>m({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:J(`project.patternUse`),onChange:e=>m({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`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:()=>m({...f,tile:e||void 0}),className:i(`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:J(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)(C,{variant:`ghost`,onClick:v,children:J(`common.cancel`)}),(0,Q.jsx)(C,{disabled:!f.file||a,onClick:()=>{for(let e of h.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:J(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[r,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:r.trim()});t.length?(f(t),m([])):u(J(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:J(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:J(`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:i(`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)(ke,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>f(null),children:J(`run.back`)}),(0,Q.jsx)(C,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?J(`project.addMany`,{n:p.length}):J(`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:J(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,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:J(`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)(C,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:o,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:Ee()}))),[_,v]=(0,Z.useState)(r),[y,b]=(0,Z.useState)(i),[x,S]=(0,Z.useState)(o),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=I(e,f),O=N(c),[k,A]=(0,Z.useState)(null),[ee,j]=(0,Z.useState)(null),[te,M]=(0,Z.useState)(!1),ne=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:_,gradients:y,patterns:x,colorRules:O.rules},d),re=l?_:[],P=re.filter(e=>(e.kind??`colors`)===`colors`),ie=e=>P.some(t=>t.id===e.section),L=p.filter(e=>!ie(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),ae=e=>m(t=>[...t,...e.map(e=>({...e,id:Ee()}))].slice(0,a.colors)),oe=[{value:``,label:J(`project.sectionStandard`)},...P.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],V=(e,t)=>{let n=Ee();A(n),v(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},ce=e=>({id:Ee(),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}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,de=[...p.length<a.colors?[{label:J(`project.colorNew`),icon:(0,Q.jsx)(U,{className:`size-4 shrink-0`}),onPick:()=>q()},{label:J(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&_.length<a.logoSections?[{label:J(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>V(`colors`,``)},{label:J(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>V(`gradients`,J(`project.gradientSectionTitle`))},{label:J(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>V(`patterns`,J(`project.patternSectionTitle`))}]:[],...!u||O.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>O.add()}]],K=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(B,{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===ee,placeholder:J(`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:J(`project.colorAccent`)})}):f?null:(0,Q.jsx)(g,{label:J(`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)(h,{className:`size-4`})}),f||!P.length?null:(0,Q.jsx)(fe,{options:oe,value:ie(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)(g,{label:J(`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)(G,{className:`size-4`})})]})]},e.id),q=e=>{let t=Ee();j(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:J(`project.colors`),hint:J(`project.colorsHint`),save:ne,locked:f,action:f?null:(0,Q.jsx)(se,{entries:de}),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(K)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`project.colorsEmpty`)}),re.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),i=y.filter(e=>e.section===t.id),o=x.filter(e=>e.section===t.id),s=n===`gradients`?i.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(W,{title:t.title,titlePlaceholder:J(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:J(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:J(`project.kindPatterns`)}:{icon:(0,Q.jsx)(kt,{}),label:J(`project.kindColors`)},autoFocus:k===t.id,readOnly:f,onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(J(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||J(`project.sectionUntitled`)}))){v(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),b(e=>e.filter(e=>e.section!==t.id));for(let e of o)D.remove(e.file);S(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:[i.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>w(e),onChange:t=>b(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>b(t=>t.filter(t=>t.id!==e.id))},e.id)),f||y.length>=a.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(ce(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)(U,{className:`size-5`}),J(`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:le(t.file),readOnly:f,onEdit:()=>E(t),onChange:e=>S(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{D.remove(t.file),S(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||x.length>=a.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E({id:Ee(),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)(U,{className:`size-5`}),J(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(K),f||p.length>=a.colors?null:(0,Q.jsx)(ue,{label:J(`project.colorAdd`),onClick:()=>q(t.id)})]})]},t.id)}),u?(0,Q.jsx)(H,{rules:O,placeholder:J(`project.colorRulePlaceholder`),readOnly:f}):null]}),D.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:D.error}):null,C?(0,Q.jsx)(Bn,{projectId:e,gradient:C,isNew:!y.some(e=>e.id===C.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>w(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,T?(0,Q.jsx)(qn,{projectId:e,pattern:T,isNew:!x.some(e=>e.id===T.id),fileName:le,busy:D.busy,error:D.error,upload:async e=>(await D.upload(`pattern`,[e]))[0]??null,removeFile:e=>void D.remove(e),onClose:()=>E(null),onSave:e=>S(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,te?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:ae}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:re,email:zt,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[r,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)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)}},[r]);let l=Qn[e??t],u=`${J(`project.factType`)}: ${J(`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":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:i(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:i(`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:J(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:J(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:i(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Te.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:J(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:i(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(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 a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:J(`project.facts`),hint:J(`project.factsHint`),save:u,locked:n,action:o.length<a.facts&&!n?(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=pe(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:J(`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:w(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)(oe,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:J(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?J(`project.yes`):J(`project.no`)})]}):(0,Q.jsx)(j,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:J(`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)(g,{label:J(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(G,{className:`size-4`})})]},e.id)})}),o.length<a.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(U,{className:`size-4`}),` `,J(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:J(`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)(U,{className:`size-3.5`}),` `,J(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[r,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:i(`-m-2 rounded-xl p-2 transition`,r&&`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:i,sectioned:o,ruled:c,save:l}){let u=I(e,n),[d,f]=(0,Z.useState)(r),p=N(i),[m,h]=(0,Z.useState)(null),[g,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=_(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)),k=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},A=C.length?{options:[{value:``,label:J(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||J(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,ee=(t,n,r)=>(0,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?J(`project.logoAdd`):void 0,onUpload:e=>void k(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:A,onRemove:e=>{confirm(J(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),te=[{label:J(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:J(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<a.logoSections?[{label:J(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=Ee();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:J(`project.logos`),hint:J(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(se,{entries:te}),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&&k(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:ee(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)(W,{title:e.title,description:e.description,titlePlaceholder:J(`project.logoSectionTitle`),descriptionPlaceholder:J(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(J(`project.logoSectionRemoveConfirm`,{name:e.title||J(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),ee(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(H,{rules:p,placeholder:J(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,g?(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=E({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 J(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return J(`project.fontSourceFile`,{name:e})}return J(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:r}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=I(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,b]=(0,Z.useState)(t.license??``),[S,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:r,title:J(`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:J(`project.fontSourceHint`)}),(0,Q.jsx)(x,{value:l,options:[`file`,`url`],label:e=>J(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`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:i(`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)(C,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),J(`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:J(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:J(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(C,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:J(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:i(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:J(`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:J(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:J(`project.fontLicenseHint`),children:J(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:J(`project.fontLicensePlaceholder`),onChange:e=>b(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:S,onChange:e=>w(e.target.checked)}),J(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(C,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:J(`project.fontSourceRemove`)}):null,(0,Q.jsx)(C,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,Q.jsx)(C,{disabled:!(D&&S),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),r())},children:J(`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)}:${f.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:r,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`})]}),r?(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:J(`project.fontFamily`),placeholder:J(`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:J(`project.fontRole`),placeholder:J(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:f.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"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:i(`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`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?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:J(`project.fontLicense`),placeholder:J(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!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:J(`project.fontUses`)}),ne.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):ne.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:i(`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`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(ke,{className:`size-3.5`}):null,J(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)}),r||!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:J(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,r?null:(0,Q.jsx)(g,{label:J(`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)(G,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:r,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:[r?(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:J(`project.styleName`),placeholder:J(`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:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":J(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:i(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||J(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":J(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...f,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:J(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:J(`project.styleLine`),label:J(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:J(`project.styleTracking`),label:J(`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:J(`project.styleUpper`),"aria-label":J(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:i(`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`})})]}),r?null:(0,Q.jsx)(g,{label:J(`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)(G,{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(J(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:J(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:J(`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)(C,{variant:`ghost`,onClick:()=>d(null),children:J(`run.back`)}),(0,Q.jsx)(C,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?J(`project.addMany`,{n:f.length}):J(`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:J(`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:J(`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)(C,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`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:i(`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(` · `):J(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(ke,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=N(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:Ee(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,a.fonts))},x=()=>{let e=Ee();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<a.fonts?[{label:J(`project.fontNew`),icon:(0,Q.jsx)(U,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:J(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<a.textStyles?[{label:J(`project.styleNew`),icon:(0,Q.jsx)(Mt,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||m.full?[]:[{label:J(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:J(`project.typography`),hint:J(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(se,{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:J(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:J(`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,i?(0,Q.jsx)(H,{rules:m,placeholder:J(`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:J(`project.base`),hint:J(`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:J(`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:J(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:J(`project.about`)}),(0,Q.jsx)(j,{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:J(`project.aboutHint`)})]})]})})}function br({project:e,group:t,children:n}){let r=O(),i=P(e.id),[a,o]=(0,Z.useState)(0),[s,l]=(0,Z.useState)(!1),u=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},d=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),f=pt(),p=dt(),m=i.data??{files:[],embeddings:!0},h=`${e.id}:${a}`,g=e.readOnly,_=t===`knowledge`,v=jt(`brandSections`),y=jt(`brandRules`),b=jt(`typography`);return St(g?{}:{title:J(_?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:J(_?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:J(_?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:_?[{label:J(`assistant.suggest.knowledgeHow`)},{label:J(`assistant.suggest.knowledgeSite`),fill:!0},{label:J(`assistant.suggest.knowledgeCategories`)}]:[{label:J(`assistant.suggest.readSite`),fill:!0},{label:J(`assistant.suggest.missing`)},{label:J(`assistant.suggest.facts`)}],summary:_?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${m.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>o(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[g?(0,Q.jsx)(vt,{children:gt(e)}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:u},`base:${h}`)}),(0,Q.jsx)(Y,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>u({facts:e}),readOnly:g},`facts:${h}`)}),(0,Q.jsx)(Y,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:m,readOnly:g,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:v,ruled:y,save:e=>u({brand:e})},`logos:${h}`)}),(0,Q.jsx)(Y,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:m,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:v,ruled:y,save:e=>u({brand:e}),readOnly:g},`colors:${h}`)}),b?(0,Q.jsx)(Y,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:y,sample:e.brand.name||J(`project.typeSample`),save:e=>u({brand:e}),readOnly:g},`typography:${h}`)}):null,(0,Q.jsx)(Y,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:m,readOnly:g,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${h}`)})]}):null,n,t===`info`&&f&&!g&&p?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(C,{variant:`danger`,onClick:()=>l(!0),children:J(`settings.delete`)}),(0,Q.jsxs)(c,{open:s,onClose:()=>l(!1),title:J(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:J(`settings.deleteBody`)}),d.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>l(!1),children:J(`common.cancel`)}),(0,Q.jsx)(C,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:J(`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=J(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(v,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:J(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(v,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:J(`project.facts`)},t):e),` `,J(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:r}){let a=me.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:r,"aria-label":J(`page.address`),maxLength:D.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:i(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$,!a&&t&&`text-rose`),children:J(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:r}){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:J(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:r,maxLength:D.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$),children:J(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:i(`mt-1`,$),children:J(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:J(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:r,maxLength:D.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:J(`page.words`)}),(0,Q.jsx)(j,{value:t.intro??``,disabled:r,minRows:3,maxLength:D.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:J(`page.lang`)}),(0,Q.jsx)(ye,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:J(e.label)}))}),(0,Q.jsx)(`p`,{className:i(`mt-1.5`,$),children:J(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return J(`page.draftNote`);if(!e.shareEnabled)return J(`page.notSharedNote`);let n=e.description.trim();return t?[n,J(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:r,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:i(`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":`${J(`page.moveUp`)} / ${J(`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)(d,{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:i(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(oe,{checked:n,disabled:r||!e.published,label:J(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:r,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||a,onClick:o,className:i(`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`,(r||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 r=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.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:i(`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:J(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:i(`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":J(`page.resize`),title:J(`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:r,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(!(me.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=O(),n=ft(),r=n.data?.tenant.pagesHost??null,a=n.data?.manageUrl??null,o=e.readOnly,s=e.page,c=!!s?.on,l=be({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[u,d]=(0,Z.useState)(1),[f,p]=(0,Z.useState)(zr),m=(0,Z.useRef)(s);m.current=s;let h=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),d(e=>e+1)},g=Le({mutationFn:e=>{let t=m.current;return t?h({...t,...e}):Promise.resolve()}}),[_,v]=(0,Z.useState)({state:`idle`,error:null}),{copied:y,copy:b}=wr(),x=l.data??[],w=(s?.wizards??[]).map(e=>x.find(t=>t.id===e)).filter(e=>e!==void 0),T=x.filter(e=>!s?.wizards.includes(e.id)),[E,D]=(0,Z.useState)(null),k=(e,t)=>{let n=[...s?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),g.mutate({wizards:n})},A=(e,t)=>g.mutate({wizards:t?[...s?.wizards??[],e]:(s?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>h({on:!0,slug:S(j)||`page`,title:j,...st(Se===`de`?`de-du`:`en`),wizards:x.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{s?g.mutate({on:e}):e&&te.mutate()},ne=g.isPending||te.isPending,re=g.error??te.error;if(!r)return(0,Q.jsx)(Y,{id:`page`,children:(0,Q.jsx)(X,{title:J(`space.page`),hint:J(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:J(`page.cloudOnly`)})})});let P=s?.slug||S(j)||`…`,F=We(r,P),I=ot(r,P,a),ie=(0,Q.jsxs)(`span`,{className:i(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:P})]}),R=o||!s,z=(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:J(`page.previewTitle`)}),c?(0,Q.jsx)(rt,{named:!0,label:J(`editor.device`),value:f,onChange:e=>{p(e),Br(e)},options:[{id:`desktop`,label:J(`editor.deviceDesk`),icon:(0,Q.jsx)(Ft,{className:`size-3.5`})},{id:`tablet`,label:J(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:J(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),c?(0,Q.jsx)(Vr,{url:I,version:u,device:f}):(0,Q.jsx)(`p`,{className:$,children:J(`page.previewOff`)}),c?(0,Q.jsx)(`p`,{className:$,children:J(`page.previewHint`)}):null]}),ae=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:J(`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:J(`share.onPage`,{space:s?.title||j})}),(0,Q.jsx)(`span`,{className:i(`block truncate font-mono`,$),children:F})]}),(0,Q.jsx)(oe,{checked:!0,disabled:!0,label:J(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:J(`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)(Y,{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:J(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:J(`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:i(`size-2 shrink-0 rounded-full`,c?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ie]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(C,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!c,onClick:()=>b(I),children:[y?(0,Q.jsx)(ke,{className:`size-3.5`}):(0,Q.jsx)(ee,{className:`size-3.5`}),J(y?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(C,{size:`sm`,className:`max-sm:flex-1`,disabled:!c,onClick:()=>window.open(I,`_blank`,`noopener`),children:[J(`page.open`),` `,(0,Q.jsx)(xt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:J(`page.sectionPage`),locked:o,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":J(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:J(`page.whoOff`),text:J(`page.whoOffHint`),picked:!c,disabled:o||ne,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:J(`page.whoPublic`),text:J(`page.whoPublicHint`),picked:c,disabled:o||ne,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:J(`page.whoMembers`),text:J(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),re?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:re.message}):null]})]})}),z,(0,Q.jsx)(Y,{id:`page-words`,children:(0,Q.jsx)(X,{title:J(`page.sectionWords`),hint:s?void 0:J(`page.notYet`),save:s?_:void 0,locked:R,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[s?(0,Q.jsx)(Hr,{host:r,page:s,disabled:o,save:h,onState:v},`${e.id}:${s.slug}`):(0,Q.jsx)(Dr,{host:r,disabled:!0,words:{slug:P,title:j,headline:``,intro:``,voice:Se===`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:J(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:J(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[w.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:R,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>D(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{E!==null&&k(E,t),D(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),T.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:R,onToggle:t=>A(e.id,t)},e.id))]}),x.length?null:(0,Q.jsx)(`p`,{className:i(`mt-2`,$),children:J(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:i(`mt-4`,$),children:J(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),ae]})}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 be({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 Dt({icon:ve,label:J(`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)(ye,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:J(`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)(ve,{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:J(`space.resultsSearch`),"aria-label":J(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(ye,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:J(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(ye,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:J(`space.resultsAnyTime`)},{value:`1`,label:J(`space.resultsDay`)},{value:`7`,label:J(`space.resultsDays`,{n:7})},{value:`30`,label:J(`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(Se,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):J(`space.resultsAll`),hint:J(`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))} · `,J(`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:J(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(De,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:J(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(ie,{children:r.q.trim()||r.mode||r.days?J(`space.resultsNone`):J(`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:J(`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({project:e,save:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.name),o=Le({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{label:J(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,Q.jsx)(we,{className:`size-4`})}),(0,Q.jsx)(c,{open:n,onClose:()=>r(!1),title:J(`project.rename`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,Q.jsx)(F,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,onClick:()=>r(!1),children:J(`common.cancel`)}),(0,Q.jsx)(C,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:J(`settings.save`)})]})]})})]})}function Xr({project:e}){let t=O();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Ct,{}),e.readOnly?null:(0,Q.jsx)(Yr,{project:e,save:async n=>{await L.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Zr(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=Rt(),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 Qr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function $r({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 ei(){let{group:e}=xe(),[t,n]=_e(),a=le(),o=r(),{hash:s}=o,{project:c,loading:l}=ut(),u=pt(),d=Lt(),f=Zt(),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=Ot(e)?e:void 0,b=y?void 0:d.spaceParts.find(t=>t.id===e),x=y??b?.id,S=o.state?.parts===!0,C=jt(`pages`),w=Nt().filter(e=>C||e.id!==`page`),T=At(w,d).map(e=>({...e,to:`/space/${e.id}`})),E={id:`results`,label:J(`space.results`),icon:bt,to:`/space/results`},D=y===`results`?E:T.find(e=>e.id===x),O=t.get(`show`),k=y===`results`?2:x?O?2:1:0,A=y===`results`?1:f?Math.min(k,1):x&&_!==x&&!S?1:0,ee=Wt(A),j=Wt(k),te=(0,Z.useMemo)(()=>({slot:p,narrow:f,setDetail:g}),[p,f]),M=c?c.brand.name?.trim()||c.name:J(`nav.project`),N=jt(`typography`)?[]:[`typography`],ne=b?d.spaceMenus[b.id]??[]:[],re=b?[{plugin:null,label:null,sections:ne}]:y&&y!==`results`?Pt(y,d,N):[],P=y?Pt(y,d).filter(e=>e.plugin):[],F=Zr([...re,...y===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),I=y===`results`&&O&&O!==`all`?O:null,[L,R]=(0,Z.useState)(Gr),z=Kr(y===`results`?c?.id:void 0,I,L),oe=z.data?.wizards.find(e=>e.id===I)?.title,B=y===`data`&&O&&O!==`all`||y===`knowledge`&&O&&/^[ptfcvs]:/.test(O)?O:null,V=B?.startsWith(`s:`)?d.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=y===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(y===`data`?c?.id:void 0),W=Qe(y===`knowledge`?c?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),se=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),ce=y===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?se?.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([...y===`results`?[]:[{label:J(`nav.project`),to:`/space`}],...D?[{label:D.label,to:`/space/${D.id}`}]:[],...D&&(h??oe??ce)?[{label:h??oe??ce}]:[]]);let ue={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};St({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:J(`assistant.suggest.dataWhat`)},{label:J(`assistant.suggest.dataWho`)},{label:J(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:J(`assistant.suggest.resultsFailed`)},{label:J(`assistant.suggest.resultsCost`)},{label:J(`assistant.suggest.resultsShare`)}]}:{},...B&&ce?{open:{kind:ue[B[0]]??`item`,id:B.slice(2),label:ce}}:I&&oe?{open:{kind:`wizard`,id:I,label:oe}}:{}});let de=y===`results`||y===`data`||B?s.slice(1):O||s.slice(1),fe=(0,Z.useRef)(``);if((0,Z.useEffect)(()=>{let e=`${x}#${de}`;de&&fe.current!==e&&document.getElementById(de)&&(fe.current=e,requestAnimationFrame(()=>Qr(de,!1)))},[x,de,c?.id,d.spaceSections,ne.length]),!x){let t=s.slice(1),n=t?Et(t,d):null;if(n===`knowledge`&&d.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(ae,{to:f?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&d.status!==`ready`)return null;if(e!==void 0||!f)return(0,Q.jsx)(ae,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!O&&d.spaceSections.some(e=>e.id===s.slice(1)))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${s.slice(1)}`,replace:!0});let K=e=>{if(f){a({search:`?show=${e}`});return}fe.current=`${x}#${e}`,Qr(e,!0),a({search:``,hash:e},{replace:!0})},q=e=>f?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),pe=e=>e.flatMap(e=>e.sections).map(e=>d.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(Y,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(It,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=f?void 0:F,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:A===1?D??null:null,onBack:y===`results`?void 0:()=>f?a(`/space`):v(x??null),root:{icon:wt,label:J(`nav.project`),backLabel:J(`nav.wizards`),onBack:()=>a(`/`)}}),(0,Q.jsx)(`div`,{className:i(Ut(ee)),children:A===0?(0,Q.jsx)(Jt,{entries:T,current:f?void 0:D,onPick:()=>v(null)}):(0,Q.jsx)(`div`,{ref:m})},A)]});return(0,Q.jsx)(qt.Provider,{value:te,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:i(`grid gap-6`,y!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[y===`results`?null:(0,Q.jsx)(`aside`,{className:i(`min-w-0 md:sticky md:top-6 md:self-start`,f&&k===2&&`hidden`,f&&j===`back`&&Ut(`back`)),children:he}),x?(0,Q.jsxs)(`div`,{className:i(`min-w-0`,f&&k<2&&`hidden`,f&&j===`deeper`&&Ut(`deeper`)),children:[f&&y!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:D?.label??M,onBack:()=>a(`/space/${x}`)})}):null,u&&c?(0,Q.jsx)(`div`,{className:`mb-6`,children:(0,Q.jsx)(Xr,{project:c})}):null,y===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Vt,label:J(`data.all`),selected:!f&&!B,onPick:()=>q(`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:!f&&e.key===B,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,Q.jsx)($r,{groups:P,current:me,onPick:K})]}):y===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Vt,label:J(`know.all`),selected:!(f||B),onPick:()=>q(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:J(`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:!f&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($r,{groups:P,current:f?void 0:V?.id,onPick:e=>q(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)($r,{groups:re,current:me,onPick:K})}),c&&(y===`info`||y===`knowledge`)?(0,Q.jsxs)(br,{project:c,group:y,children:[y===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>q(`all`),onOpen:q},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>q(`all`)},H):(0,Q.jsx)(kn,{projectId:c.id,fileId:H.slice(2),readOnly:c.readOnly,onGone:()=>q(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(It,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?se?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:c.id,category:se,readOnly:c.readOnly,onOpen:q,onGone:()=>q(`all`)}),se.type===`choice`?null:(0,Q.jsx)(it,{projectId:c.id,category:se,categories:W.data.categories,onOpen:q})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:c.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:q},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:J(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(Y,{id:`documents`,children:(0,Q.jsx)(et,{projectId:c.id,data:W.data,readOnly:c.readOnly,onOpen:q})}):null:null,y===`info`?pe(P):null]},c.id):null,c&&y===`page`&&C?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:c},c.id),pe(P)]}):null,c&&b?(0,Q.jsx)(It,{of:b,children:(0,Q.jsx)(Tt,{part:b.id,children:(0,Q.jsx)(b.component,{})},c.id)}):null,c&&y===`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:()=>q(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>q(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:c.id,data:U.data,readOnly:c.readOnly,onOpen:q}):null,pe(P)]})}):null,c&&y===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[z.data?(0,Q.jsx)(Jr,{data:z.data,wizardId:I,onWizard:e=>q(e??`all`),filter:L,onFilter:R}):null,z.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:z.error.message}):null,pe(P)]}):null,c||l?null:(0,Q.jsx)(ie,{children:J(`settings.noProject`)})]}):null]})})})}export{ei 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,Ht as a,In as o,J as s,Jt as c,Kr as l,Lt as u,Ur as d,W as f,Xr as p,ar as m,at as h,cn as g,ei as _,et as v,in as y,it as b,jt as x,on as S,ri as C,ti as ee}from"./ui-BV4KP5n2.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-DQ10nO_L.js";import{O as ie,S as M,b as N,x as P}from"./session-BHCBxqVb.js";import{U as F}from"./index-C-u3ZXBZ.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,s=e?.token,c=C({queryKey:[`public-translation`,s,a],enabled:!!(s&&a!==r),queryFn:()=>f.post(`/api/public/wizards/${s}/translation${V}`,{lang:a}),staleTime:1/0,retry:!1}),l=C({queryKey:[`public-texts`,s,a],enabled:!(!s||o(a)),queryFn:()=>f.get(`/api/public/wizards/${s}/texts/${a}`),staleTime:1/0,retry:!1}),u=!o(a),d=a===r||c.data&&(!u||l.data),p=a!==r&&(c.isError||u&&l.isError),m=d&&!p?a:r,h=(0,R.useMemo)(()=>!o(m)&&l.data?.lang===m?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[m,l.data]);if((0,R.useEffect)(()=>{e&&y(m,h)},[e,m,h]),(0,R.useEffect)(()=>()=>y(null),[]),!e)return null;let _=m!==r&&c.data?c.data:null;return{own:r,other:i,shown:m,wizard:_??e,translating:a!==r&&!d&&!p,failed:!!p,translated:!!_,machine:_?.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,f.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)||v||z?null:(0,U.jsxs)(`a`,{href:b(`${window.location.origin}${s}/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=v&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=_(),[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 f.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:a,start:o,resume:s}=$(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,o())},[l]),l&&!r?(0,U.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,U.jsx)(c,{})}):(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)(u,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:o,children:[S(`run.start`),` `,(0,U.jsx)(d,{className:`size-4`})]}),e.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:a}):null,s?(0,U.jsx)(`button`,{type:`button`,onClick:s,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||v?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)(a,{label:S(`common.close`),onClick:le,children:(0,U.jsx)(m,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(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`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(A(`start`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(D,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[S(`run.start`),` `,(0,U.jsx)(d,{className:`size-4`})]}),u?(0,U.jsx)(D,{onClick:u,children:S(`run.resume`)}):null,t.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:c}):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:`${s}/`,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(),l=_(),d=C({queryKey:[`public`,a,V],queryFn:()=>f.get(`/api/public/wizards/${a}${V}`),retry:(e,t)=>x(t)&&e<3}),m=d.data?.runners??[],g=!d.data||m.some(e=>e.id===`talk`),y=!d.data||m.some(e=>e.id===`video`),b=!d.data||m.some(e=>e.id===`chat`)||n&&g||r&&y,w=m[0]?.id,T=e||z===`popout`||!t&&!o&&b&&(w===`chat`||w===`talk`||w===`video`),D=r&&y||!t&&!e&&!n&&w===`video`,O=!D&&(n&&g||!t&&!e&&w===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(d.data);he(o,A),ne(d.data?.brand.theme),ie(d.data?.avatar),ge(a,d.data?.title),ue(T);let j=A?.wizard.title??d.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{a&&o&&h(`run`,{token:a,runId:o})},[a,o]),d.isLoading)return(0,U.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Q),children:(0,U.jsx)(c,{})});if(e&&d.data&&!b||n&&d.data&&!g||r&&d.data&&!y)return(0,U.jsx)(p,{to:`/w/${a}`,replace:!0});if(!d.data){let e=x(d.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)(u,{variant:`secondary`,onClick:()=>void d.refetch(),children:S(`common.retry`)}):null]})}let M=A?.wizard??d.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)(c,{}),(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=v?(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:d.data.brand.theme.effects}),F??(o?(0,U.jsx)(re,{runId:o,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>l(`/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:d.data.brand.theme.effects}),z===`inline`||v?null:(0,U.jsx)(X,{brand:d.data.brand,toggle:!z,start:(0,U.jsx)(K,{page:A})}),z===`inline`||v?(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:()=>l(`/w/${a}`)}):(0,U.jsx)(xe,{wizard:M,page:A}))}),v?(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:`${s}/`,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,Ht as a,In as o,J as s,Jt as c,Kr as l,Lt as u,Ur as d,W as f,Xr as p,ar as m,at as h,cn as g,ei as _,et as v,in as y,it as b,jt as x,on as S,ri as C,ti as ee}from"./ui-Bk08zclS.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-CWGl7LyL.js";import{O as ie,S as M,b as N,x as P}from"./session-DvW7auj-.js";import{U as F}from"./index-CXA_do-X.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,s=e?.token,c=C({queryKey:[`public-translation`,s,a],enabled:!!(s&&a!==r),queryFn:()=>f.post(`/api/public/wizards/${s}/translation${V}`,{lang:a}),staleTime:1/0,retry:!1}),l=C({queryKey:[`public-texts`,s,a],enabled:!(!s||o(a)),queryFn:()=>f.get(`/api/public/wizards/${s}/texts/${a}`),staleTime:1/0,retry:!1}),u=!o(a),d=a===r||c.data&&(!u||l.data),p=a!==r&&(c.isError||u&&l.isError),m=d&&!p?a:r,h=(0,R.useMemo)(()=>!o(m)&&l.data?.lang===m?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[m,l.data]);if((0,R.useEffect)(()=>{e&&y(m,h)},[e,m,h]),(0,R.useEffect)(()=>()=>y(null),[]),!e)return null;let _=m!==r&&c.data?c.data:null;return{own:r,other:i,shown:m,wizard:_??e,translating:a!==r&&!d&&!p,failed:!!p,translated:!!_,machine:_?.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,f.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)||v||z?null:(0,U.jsxs)(`a`,{href:b(`${window.location.origin}${s}/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=v&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=_(),[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 f.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:a,start:o,resume:s}=$(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,o())},[l]),l&&!r?(0,U.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,U.jsx)(c,{})}):(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)(u,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:o,children:[S(`run.start`),` `,(0,U.jsx)(d,{className:`size-4`})]}),e.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:a}):null,s?(0,U.jsx)(`button`,{type:`button`,onClick:s,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||v?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)(a,{label:S(`common.close`),onClick:le,children:(0,U.jsx)(m,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(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`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(A(`start`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(D,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[S(`run.start`),` `,(0,U.jsx)(d,{className:`size-4`})]}),u?(0,U.jsx)(D,{onClick:u,children:S(`run.resume`)}):null,t.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:c}):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:`${s}/`,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(),l=_(),d=C({queryKey:[`public`,a,V],queryFn:()=>f.get(`/api/public/wizards/${a}${V}`),retry:(e,t)=>x(t)&&e<3}),m=d.data?.runners??[],g=!d.data||m.some(e=>e.id===`talk`),y=!d.data||m.some(e=>e.id===`video`),b=!d.data||m.some(e=>e.id===`chat`)||n&&g||r&&y,w=m[0]?.id,T=e||z===`popout`||!t&&!o&&b&&(w===`chat`||w===`talk`||w===`video`),D=r&&y||!t&&!e&&!n&&w===`video`,O=!D&&(n&&g||!t&&!e&&w===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(d.data);he(o,A),ne(d.data?.brand.theme),ie(d.data?.avatar),ge(a,d.data?.title),ue(T);let j=A?.wizard.title??d.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{a&&o&&h(`run`,{token:a,runId:o})},[a,o]),d.isLoading)return(0,U.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Q),children:(0,U.jsx)(c,{})});if(e&&d.data&&!b||n&&d.data&&!g||r&&d.data&&!y)return(0,U.jsx)(p,{to:`/w/${a}`,replace:!0});if(!d.data){let e=x(d.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)(u,{variant:`secondary`,onClick:()=>void d.refetch(),children:S(`common.retry`)}):null]})}let M=A?.wizard??d.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)(c,{}),(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=v?(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:d.data.brand.theme.effects}),F??(o?(0,U.jsx)(re,{runId:o,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>l(`/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:d.data.brand.theme.effects}),z===`inline`||v?null:(0,U.jsx)(X,{brand:d.data.brand,toggle:!z,start:(0,U.jsx)(K,{page:A})}),z===`inline`||v?(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:()=>l(`/w/${a}`)}):(0,U.jsx)(xe,{wizard:M,page:A}))}),v?(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:`${s}/`,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{Kr as n,on as r}from"./ui-BV4KP5n2.js";import{xt as i}from"./index-C-u3ZXBZ.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{Kr as n,on as r}from"./ui-Bk08zclS.js";import{xt as i}from"./index-CXA_do-X.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};