@engenty/wizards-runtime 0.20.0 → 0.20.1

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 (29) hide show
  1. package/apps/runtime/dist/cli/main.js +2 -0
  2. package/apps/runtime/dist/docs/user-guide/command-line.md +2 -1
  3. package/apps/web/dist/assets/{AboutDialog-QWzpEK8M.js → AboutDialog-BFi6vOyJ.js} +1 -1
  4. package/apps/web/dist/assets/{CapabilitiesPage-DAr0-gN1.js → CapabilitiesPage-DAX03vkY.js} +1 -1
  5. package/apps/web/dist/assets/{ChangelogDialog-CdHqJV2P.js → ChangelogDialog-CdchxTO8.js} +1 -1
  6. package/apps/web/dist/assets/{ConnectorsSection-BO6jHrYU.js → ConnectorsSection-CNpieoyT.js} +1 -1
  7. package/apps/web/dist/assets/{EditorPage-Bx-fKnsY.js → EditorPage-CxABBMqo.js} +1 -1
  8. package/apps/web/dist/assets/{NewWizardChannels-fveQcQlY.js → NewWizardChannels-0aZoziks.js} +1 -1
  9. package/apps/web/dist/assets/{NewWizardPage-BTX1g2t1.js → NewWizardPage-Bn2BPaUB.js} +1 -1
  10. package/apps/web/dist/assets/{ProtocolSection-YnJcMN9E.js → ProtocolSection-Ce5LBBzL.js} +1 -1
  11. package/apps/web/dist/assets/{ReadOnly-C6qmTD35.js → ReadOnly-BFVaKM3w.js} +1 -1
  12. package/apps/web/dist/assets/{Results-BNuuBiwU.js → Results--mJFsNH2.js} +1 -1
  13. package/apps/web/dist/assets/{RunDrawer-CMgN-XTB.js → RunDrawer-DtbxGBIm.js} +1 -1
  14. package/apps/web/dist/assets/{SettingsPage-CuUB26YJ.js → SettingsPage-Cytcl_9w.js} +2 -2
  15. package/apps/web/dist/assets/{SetupPage-llGzMVeH.js → SetupPage-B5zCrIKT.js} +1 -1
  16. package/apps/web/dist/assets/{SpacePage-Dv6ocsc_.js → SpacePage-Bd5-wBUc.js} +1 -1
  17. package/apps/web/dist/assets/{StudioHome-B0bZRm1L.js → StudioHome-DzVpWMrD.js} +1 -1
  18. package/apps/web/dist/assets/{TableEditor-CfzTLmJF.js → TableEditor-CRhc6jI6.js} +1 -1
  19. package/apps/web/dist/assets/{UpdateCheck-D3QhfI5c.js → UpdateCheck-BEruHgs0.js} +2 -2
  20. package/apps/web/dist/assets/changelog-BgFhbmMa.js +1 -0
  21. package/apps/web/dist/assets/{host-C-AAp8Bz.js → host-B2ZzDrkc.js} +3 -3
  22. package/apps/web/dist/assets/{index-CtE0rJEL.js → index-C1m_S1ls.js} +3 -3
  23. package/apps/web/dist/index.html +4 -4
  24. package/bin/bot.mjs +1120 -0
  25. package/bin/wizards.mjs +6 -0
  26. package/package.json +1 -1
  27. package/plugin/.claude-plugin/plugin.json +1 -1
  28. package/plugin/plugin.json +1 -1
  29. package/apps/web/dist/assets/changelog-Db3nvWao.js +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/viewers-DvA5VsXw.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-Bux-wzFO.js","assets/w3c-keyname-BOAvb0qz.js","assets/jsx-runtime-C3cWAN_r.js","assets/i18n-Dyi0kvaA.js","assets/ui-DSgksc1H.js","assets/marked.esm-BfGIZK7F.js","assets/preload-helper-Cj7BV335.js","assets/code-editor-BLwDuQLI.js","assets/SkillEditor-ARx8QPGp.js","assets/Skills-frfXXEcF.js","assets/useMutation-fT44ij_b.js","assets/plug-CHvl1GhO.js","assets/upload-BZThm-R6.js","assets/code-xml-CdJeig44.js","assets/eye-CG1LzvNI.js","assets/scroll-text-DmK2IucJ.js","assets/session-EIDP3Wzc.js","assets/Bundle-DZyQ1FP7.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{An as t,At as n,Bt as r,Ct as i,D as a,Dt as o,Et as s,Fn as c,Ft as l,It as u,J as d,Kn as f,Lt as p,Mt as m,Nt as h,On as g,Ot as _,Pt as v,Qn as y,Rt as b,St as x,Tn as ee,Tt as te,Ut as ne,Vt as re,Zn as S,_t as ie,a as ae,bt as oe,c as se,cr as C,dt as ce,g as w,gt as le,h as ue,ht as de,jt as fe,kn as pe,kt as me,l as he,m as ge,mt as _e,n as ve,o as ye,pn as be,pt as xe,qn as Se,s as Ce,t as we,tr as Te,u as Ee,vt as De,wt as Oe,xt as ke,yt as Ae,zn as je,zt as Me}from"./host-C-AAp8Bz.js";import{C as Ne,S as T,x as Pe,y as Fe}from"./Marketplace-D3hdvrkz.js";import{n as E,t as Ie}from"./scroll-text-DmK2IucJ.js";import{$ as D,A as Le,B as Re,C as O,D as ze,E as Be,F as Ve,Fn as He,H as k,I as Ue,J as We,K as Ge,L as Ke,Nn as qe,O as Je,On as Ye,P as A,R as j,S as M,Sn as Xe,Sr as Ze,T as N,Tn as Qe,U as $e,Un as et,Wn as tt,X as nt,Xn as rt,Y as P,Z as it,Zn as at,_ as ot,_n as st,a as ct,an as F,b as lt,bn as ut,br as dt,cn as I,dn as L,fn as R,fr as ft,g as z,gn as B,h as V,hn as pt,hr as mt,j as ht,jn as gt,k as _t,kt as H,ln as vt,mn as yt,mr as bt,mt as xt,ni as St,on as U,q as W,qn as Ct,sn as wt,sr as Tt,tr as Et,un as G,v as Dt,vn as Ot,w as kt,x as At,xn as K,xr as jt,y as Mt,yn as Nt,yr as Pt}from"./ui-DSgksc1H.js";import{n as Ft,t as It}from"./jsx-runtime-C3cWAN_r.js";import{Rt as Lt,n as Rt,s as q}from"./i18n-Dyi0kvaA.js";import{d as zt,f as Bt,h as Vt,u as Ht}from"./session-EIDP3Wzc.js";import{a as Ut,c as Wt,f as Gt,i as Kt,l as qt,m as Jt,o as Yt,p as Xt,r as Zt,s as Qt,u as $t}from"./UpdateCheck-D3QhfI5c.js";import{t as en}from"./useMutation-fT44ij_b.js";import{a as tn,c as nn,d as rn,i as J,l as an,o as on,r as Y,s as X,u as sn}from"./marked.esm-BfGIZK7F.js";import{t as cn}from"./eye-CG1LzvNI.js";import{t as ln}from"./preload-helper-Cj7BV335.js";import{a as un,i as dn,n as fn,o as pn,r as mn,t as hn}from"./TableEditor-CfzTLmJF.js";import{t as gn}from"./index-CtE0rJEL.js";import{n as _n,r as vn,t as yn}from"./Results-BNuuBiwU.js";import{c as bn,n as xn,o as Sn}from"./Skills-frfXXEcF.js";import{s as Z,t as Cn}from"./engenty-Cy7MbUxR.js";import{n as wn,r as Tn,t as En}from"./ReadOnly-C6qmTD35.js";import{t as Dn}from"./link-DyYjkzYx.js";import{A as On}from"./floating-ui.dom-S_FT_s1L.js";import{t as kn}from"./upload-BZThm-R6.js";import{t as An}from"./list-checks-D1zkXlZa.js";import{E as jn}from"./theme-B46aPLtX.js";import{t as Mn}from"./phone-CG7Bz_ZL.js";import{n as Nn}from"./volume-2-Br71vpS5.js";var Pn={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Pn.node;var Fn=rn(Pn),In={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};In.node;var Ln=rn(In),Rn={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`}]]};Rn.node;var zn=rn(Rn),Bn={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`}]]};Bn.node;var Vn=rn(Bn),Hn={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`]};Hn.node;var Un=rn(Hn),Q=e(Ft(),1),$=e(It(),1),Wn=e=>[`open-to-clients`,e];function Gn({space:e}){let t=St(),n=Ze({queryKey:[`space-wizards`,e.id],queryFn:()=>D.get(`/api/studio/spaces/${e.id}/wizards`)}),r=Ze({queryKey:Wn(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/open-to-clients`)}),i=en({mutationFn:t=>D.put(`/api/studio/spaces/${e.id}/open-to-clients`,{kind:`wizard`,...t}),onSettled:()=>t.invalidateQueries({queryKey:Wn(e.id)})}),a=(n.data??[]).filter(e=>e.published),o=new Set(r.data?.open.wizard??[]);return(0,$.jsx)(O,{title:q(`clients.wizards`),hint:q(`clients.wizardsHint`),locked:e.readOnly,children:n.isSuccess&&!a.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`clients.noWizards`)}):(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.title}),(0,$.jsx)(Ot,{checked:o.has(e.id),onChange:t=>i.mutate({id:e.id,open:t}),label:e.title})]},e.id))})})}function Kn({spaceId:e,kind:t,id:n}){let r=St(),i=Ze({queryKey:Wn(e),queryFn:()=>D.get(`/api/studio/spaces/${e}/open-to-clients`)}),a=en({mutationFn:r=>D.put(`/api/studio/spaces/${e}/open-to-clients`,{kind:t,id:n,open:r}),onSettled:()=>r.invalidateQueries({queryKey:Wn(e)})}),o=i.data?.open[t].includes(n)??!1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-ink/5 px-4 py-2.5`,children:[(0,$.jsx)(ee,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-[0.875rem]`,children:q(`clients.openTitle`)}),(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:q(o?`clients.openOn`:`clients.openOff`)})]}),(0,$.jsx)(Ot,{checked:o,disabled:!i.isSuccess||a.isPending,onChange:e=>a.mutate(e),label:q(`clients.openTitle`)})]})}function qn({databaseId:e,people:t}){let n=Ze({queryKey:[`wizard-database`,e],queryFn:()=>D.get(`/api/studio/databases/${e}`)}),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(0),s=n.data?.tables??[],c=r??s[0]?.name??null,l=Ze({queryKey:[`wizard-database`,e,c,a],queryFn:()=>D.get(`/api/studio/databases/${e}/tables/${encodeURIComponent(c??``)}?offset=${a}`),enabled:!!c});if(!n.data)return n.error?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:n.error.message}):(0,$.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,$.jsx)(B,{className:`text-ink-3`})});let u=l.data;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:q(`data.database.title`,{wizard:n.data.title})}),(0,$.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[q(`data.database.hint`),` `,t?q(`data.database.people`,{n:t}):``]})]}),s.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,$.jsx)(`div`,{className:`min-w-48`,children:(0,$.jsx)(pt,{value:c??``,onChange:e=>{i(e),o(0)},options:s.map(e=>({value:e.name,label:`${e.name} · ${q(`data.rows`,{n:e.rows})}`}))})}),c?(0,$.jsx)(`a`,{href:xt(`/api/studio/databases/${e}/tables/${encodeURIComponent(c)}/csv`),download:!0,children:(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,children:[(0,$.jsx)(at,{className:`size-4`}),` `,q(`data.database.csv`)]})}):null]}),(0,$.jsx)(U,{className:`overflow-hidden`,children:u?.rows.length?(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-left text-[0.8125rem]`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-border-soft border-b`,children:u.columns.map(e=>(0,$.jsx)(`th`,{className:`px-3 py-2 font-medium text-ink-3`,children:e},e))})}),(0,$.jsx)(`tbody`,{children:u.rows.map((e,t)=>(0,$.jsx)(`tr`,{className:`border-border-soft border-b last:border-b-0`,children:u.columns.map(t=>(0,$.jsx)(`td`,{className:`max-w-80 truncate px-3 py-2 tabular-nums`,children:e[t]===null||e[t]===void 0?``:String(e[t])},t))},t))})]})}):(0,$.jsx)(vt,{children:l.isPending?q(`common.loading`):q(`data.database.noRows`)})}),u&&u.total>u.rows.length?(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{children:q(`data.database.range`,{from:u.offset+1,to:u.offset+u.rows.length,total:u.total})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,size:`sm`,disabled:u.offset===0,onClick:()=>o(Math.max(0,u.offset-u.rows.length)),children:q(`data.database.previous`)}),(0,$.jsx)(F,{variant:`ghost`,size:`sm`,disabled:u.offset+u.rows.length>=u.total,onClick:()=>o(u.offset+u.rows.length),children:q(`data.database.next`)})]})]}):null]}):(0,$.jsx)(U,{children:(0,$.jsx)(vt,{children:q(`data.database.noTables`)})})]})}var Jn={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Yn({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.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,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:q(o?`space.describing`:`space.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`})}async function Xn(e,t){await ct(q(`space.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Zn({spaceId:e,file:t,small:n}){let r=$e(e,t.id);if(t.thumb&&(t.kind===`asset`||t.kind===`document`))return(0,$.jsx)(`img`,{src:Ge(e,t.id),alt:``,loading:`lazy`,className:`size-full object-cover object-top`});if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:K(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(Qn,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(rt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(X,{className:i}):t.mime===`application/json`?(0,$.jsx)(Ye,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(zn,{className:i}):(0,$.jsx)(Ct,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function Qn({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.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,$.jsx)(`div`,{className:K(`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 $n=`application/x-wizards-logo`;function er({spaceId: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):Xn(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData($n,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,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(wt,{tone:`ember`,children:q(`space.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Jn:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${q(`space.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(Zn,{spaceId:e,file:n})}):(0,$.jsx)(Zn,{spaceId:e,file:n}),(0,$.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,$.jsx)(G,{label:q(`space.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(cn,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(G,{label:q(`space.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(T,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(lt,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(Yn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(Dt,{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,$.jsx)(B,{className:`size-5`}):(0,$.jsx)(J,{className:`size-5`}),a]}):null]})}function tr({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(q(e===`logo`?`space.logoNoneFound`:`space.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,$.jsx)(I,{open:!0,onClose:r,wide:u?!0:void 0,title:q(u?e===`logo`?`space.logoFound`:`space.assetFound`:e===`logo`?`space.logoFromUrl`:`space.assetFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(e===`logo`?`space.logoFoundHint`:`space.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:K(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Jn,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:K(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(sn,{className:`size-3.5`})}):null]},t.url)})}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>d(null),children:q(`run.back`)}),(0,$.jsx)(F,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?q(`space.addMany`,{n:f.length}):q(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.logoUrl`)}),(0,$.jsx)(L,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(e===`logo`?`space.logoUrlHint`:`space.assetUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,busy:o,disabled:!i.trim(),children:q(`run.next`)})]})]})})}var nr=(0,Q.lazy)(()=>ln(()=>import(`./viewers-DvA5VsXw.js`).then(e=>({default:e.Viewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function rr(e,t,n){return Ze({queryKey:[`space-file-text`,t.id,t.chars,n],queryFn:()=>D.get(`/api/studio/spaces/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function ir(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var ar=e=>[ir(e),e.pages?q(`space.pages`,{n:e.pages}):null,Lt(e.size)].filter(Boolean).join(` · `),or=2e5;function sr({spaceId:e,fileId:t,readOnly:n,onGone:r,page:i}){let a=St(),s=nt(e),c=o(e),l=We(e,n),u=s.data?.files.find(e=>e.id===t),d=Fe(`knowledgeTree`),f=u?ke(u.mime,u.name):null,p=u?d?f!==null:u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[m,h]=(0,Q.useState)(null);if(!u)return s.isLoading?(0,$.jsx)(B,{className:`mx-auto text-ink-3`}):null;let g=m??(p?`original`:`text`),_=c.data?.items.find(e=>e.key===`f:${u.id}`),v=$e(e,u.id),y=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":g===e,onClick:()=>h(e),className:K(`rounded-full px-3 py-1 text-[0.8125rem] transition`,g===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:ar(u)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":q(`space.openOriginal`),title:q(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(nn,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:q(`space.reindex`),onClick:async()=>{await l.reindex(u.id),await a.invalidateQueries({queryKey:it.knowledge(e)})},children:(0,$.jsx)(qe,{className:`size-4`})}),(0,$.jsx)(G,{label:q(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{await ct(q(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await a.invalidateQueries({queryKey:it.knowledge(e)}),r())},children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(Oe,{spaceId:e,itemKey:`f:${u.id}`,has:_?.categories??[],originLabel:_?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Yn,{file:u,actions:l})}),u.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,$.jsxs)(U,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[p?y(`original`,q(`space.original`)):null,y(`text`,q(`space.readText`))]}),g===`original`&&d&&f?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(B,{})}),children:(0,$.jsx)(nr,{kind:f,url:v,name:u.name,page:i})}):g===`original`?u.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(cr,{spaceId:e,file:u})]})]})}function cr({spaceId:e,file:t}){let n=rr(e,t,or);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(B,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(H,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:q(`space.textCut`,{shown:n.data.text.length.toLocaleString(Rt),total:n.data.chars.toLocaleString(Rt)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:q(`space.noText`)})}var lr=8;function ur({tab:e,onTab:t}){let n=(n,r)=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:K(`flex-1 rounded-md px-2 py-1 text-[0.8125rem] transition`,e===n?`bg-card font-medium text-ink shadow-soft`:`text-ink-2 hover:text-ink`),children:r});return(0,$.jsxs)(`div`,{role:`tablist`,className:`mb-2 flex gap-0.5 rounded-lg bg-paper-2 p-0.5`,children:[n(`folders`,q(`know.tabFolders`)),n(`categories`,q(`know.tabCategories`))]})}function dr({categories:e,picked:t,pickedCategory:n,readOnly:r,onPick:i,onNew:a}){let{filter:o}=Xt(),[s,c]=(0,Q.useState)(()=>new Set);(0,Q.useEffect)(()=>{n&&c(e=>e.has(n)?e:new Set([...e,n]))},[n]);let l=e=>c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(!e.length)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-1`,children:[(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:q(`know.categoriesEmpty`)}),r?null:(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,className:`self-start`,onClick:a,children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`know.category`)]})]});let d=e=>K(`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-2 text-left text-[0.875rem]`,e?`font-medium text-ink`:`text-ink-2 group-hover/row:text-ink`),f=o?e.filter(e=>e.name.toLowerCase().includes(o)||e.values.some(e=>e.value.toLowerCase().includes(o))):e;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:f.map(e=>{let r=u[e.type],a=o?e.values.filter(e=>e.value.toLowerCase().includes(o)):e.values,c=s.has(e.id)||!!(o&&a.length),f=t===`c:${e.id}`||!c&&n===e.id&&t!==null;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:K(`group/row flex items-center rounded-lg transition`,f?`bg-paper-2`:`hover:bg-accent`),children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:a.length?0:-1,"aria-label":q(c?`know.collapse`:`know.expand`),"aria-expanded":a.length?c:void 0,onClick:()=>a.length&&l(e.id),className:K(`grid size-6 shrink-0 place-items-center rounded-md text-ink-4`,a.length?`hover:text-ink`:`invisible`),children:(0,$.jsx)(Et,{className:K(`size-3.5 transition-transform`,c&&`rotate-90`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),"aria-current":f?`page`:void 0,className:d(f),children:[(0,$.jsx)(r,{className:K(`size-4 shrink-0`,f?`text-ember-strong`:`text-ink-3`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.proposed?(0,$.jsx)(wt,{tone:`ember`,children:q(`know.proposed`)}):(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})]}),c&&a.length?(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5 pt-0.5`,children:[a.slice(0,o?void 0:lr).map(e=>{let n=t===`v:${e.id}`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),"aria-current":n?`page`:void 0,className:K(`flex w-full items-center gap-2 rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.875rem] transition`,n?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.value}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})},e.id)}),!o&&a.length>lr?(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),className:`w-full rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:q(`know.moreValues`,{n:a.length-lr})})}):null]}):null]},e.id)})}),r?null:(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`mt-2 flex items-center gap-2 rounded-lg px-1 py-1.5 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center`,children:(0,$.jsx)(J,{className:`size-4`})}),q(`know.category`)]})]})}function fr({onEdit:e,onDelete:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null);w(i,n,()=>r(!1));let a=`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink`,o=e=>()=>{r(!1),e()};return(0,$.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,$.jsx)(G,{label:q(`know.more`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`size-8`,children:(0,$.jsx)(E,{className:`size-4`})}),n?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,onClick:o(e),children:[(0,$.jsx)(He,{className:`size-4 shrink-0`}),` `,q(`know.edit`)]}),(0,$.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:K(a,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:o(t),children:[(0,$.jsx)(Y,{className:`size-4 shrink-0`}),` `,q(`know.deleteCategory`)]})]}):null]})}function pr({eyebrow:e,title:n,line:r,action:i}){return(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(t,{className:`size-3.5`}),` `,e]}),(0,$.jsx)(`h2`,{className:`mt-0.5 font-display font-semibold text-lg leading-tight`,children:n}),r?(0,$.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3`,children:r}):null]}),i?(0,$.jsx)(`div`,{className:`shrink-0`,children:i}):null]})}function mr({spaceId:e,data:t,category:n,readOnly:i,onOpen:a,onGone:o}){let s=St(),[c,l]=(0,Q.useState)(!1),d=en({mutationFn:e=>e(),onSuccess:()=>s.invalidateQueries({queryKey:it.knowledge(e)})}),f=u[n.type];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(pr,{eyebrow:q(`know.type.${n.type}`),title:n.name,line:[r(n.count),n.unit,n.hint].filter(Boolean).join(` · `),action:i?null:(0,$.jsx)(fr,{onEdit:()=>l(!0),onDelete:async()=>await ct(q(`know.confirmCategory`,{name:n.name}))&&d.mutate(async()=>{await D.del(`/api/studio/categories/${n.id}`),o()})})}),n.proposed&&!i?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl bg-ember-tint px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:q(`know.proposedHint`)}),(0,$.jsx)(F,{size:`sm`,variant:`secondary`,onClick:()=>d.mutate(()=>D.del(`/api/studio/categories/${n.id}`)),children:q(`know.dismiss`)}),(0,$.jsx)(F,{size:`sm`,onClick:()=>d.mutate(()=>D.patch(`/api/studio/categories/${n.id}`,{proposed:!1})),children:q(`know.accept`)})]}):null,n.type===`choice`?(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.values.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(`v:${e.id}`),className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3.5 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(f,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e.value})]}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[r(e.count),e.summary?q(`know.summary`):``].filter(Boolean).join(` · `)})]},e.id))}):(0,$.jsx)(x,{spaceId:e,category:n,categories:t.categories,onOpen:a}),d.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,$.jsx)(I,{open:c,onClose:()=>l(!1),wide:!0,children:(0,$.jsx)(p,{spaceId:e,category:n,readOnly:i,onOpen:e=>{l(!1),a(e)},onGone:()=>{l(!1),o()}})})]})}function hr({data:e,value:t,readOnly:n,onOpen:i}){let a=t.rows.reduce((e,t)=>e+t.count,0);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(pr,{eyebrow:t.category.name,title:t.value,line:[r(t.items.length),...t.rows.map(e=>q(`know.tocRows`,{n:e.count,table:e.title}))].filter(Boolean).join(` · `)}),(0,$.jsx)(Me,{value:t,readOnly:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.items.length?(0,$.jsx)(_,{items:t.items,categories:e.categories.filter(e=>e.id!==t.category.id),onOpen:i}):null,a?t.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId)):null]})})]})}var gr={info:`bg-cobalt-tint`,brand:`bg-violet-500/10`,knowledge:`bg-moss-tint`,data:`bg-amber-tint`,page:`bg-ember-tint`},_r=`var(--color-paper)`,vr=`var(--color-paper-3)`,yr={fill:`#000`,opacity:.12};function br({kind:e,x:t,y:n,size:r=92}){let i=r/120;return(0,$.jsx)(`g`,{transform:`translate(${t-60*i} ${n-106*i})`,children:(0,$.jsx)(Cn,{kind:e,size:r})})}function xr({cx:e,cy:t,rx:n}){return(0,$.jsx)(`ellipse`,{cx:e,cy:t,rx:n,ry:5,...yr})}function Sr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:196,cy:142,rx:48}),(0,$.jsx)(`path`,{d:`M180 30 L196 54 L212 30`,fill:`none`,stroke:Z.ember,strokeWidth:6,strokeLinecap:`round`}),(0,$.jsxs)(`g`,{transform:`rotate(6 196 96)`,children:[(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:92,rx:14,fill:_r}),(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:24,rx:14,fill:Z.ember}),(0,$.jsx)(`rect`,{x:150,y:62,width:92,height:12,fill:Z.ember}),(0,$.jsx)(`rect`,{x:188,y:44,width:16,height:12,rx:4,fill:Z.slate}),(0,$.jsx)(`circle`,{cx:174,cy:98,r:14,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:176,cy:96,r:4.5,fill:`#fff`}),(0,$.jsx)(`circle`,{cx:177,cy:96,r:2.2,fill:`#1d1b19`}),(0,$.jsx)(`rect`,{x:196,y:88,width:34,height:8,rx:4,fill:Z.slate}),(0,$.jsx)(`rect`,{x:196,y:102,width:24,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:162,y:122,width:68,height:6,rx:3,fill:vr})]}),(0,$.jsx)(br,{kind:`round`,x:98,y:144,size:124})]})}function Cr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:200,cy:142,rx:56}),(0,$.jsx)(`path`,{d:`M150 98c0-30 26-52 58-52s50 18 50 40c0 14-10 20-22 18-10-2-16 4-14 14 3 14-6 24-24 24-28 0-48-18-48-44z`,fill:_r}),(0,$.jsx)(`circle`,{cx:180,cy:78,r:10,fill:Z.rose}),(0,$.jsx)(`circle`,{cx:208,cy:64,r:10,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:234,cy:76,r:9,fill:Z.moss}),(0,$.jsx)(`circle`,{cx:172,cy:108,r:10,fill:Z.cobalt}),(0,$.jsx)(`circle`,{cx:204,cy:124,r:6,fill:`var(--color-paper-2)`}),(0,$.jsxs)(`g`,{transform:`rotate(-38 236 112)`,children:[(0,$.jsx)(`rect`,{x:230,y:64,width:12,height:62,rx:6,fill:Z.slate}),(0,$.jsx)(`rect`,{x:229,y:58,width:14,height:12,rx:3,fill:`#c9c3bb`}),(0,$.jsx)(`path`,{d:`M230 58c0-14 6-22 6-22s6 8 6 22z`,fill:Z.violet})]}),(0,$.jsx)(br,{kind:`tower`,x:100,y:144,size:124})]})}function wr(){let e=(e,t,n,r=0)=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:128+r,y:e,width:t,height:20,rx:4,fill:n}),(0,$.jsx)(`rect`,{x:128+r+t-18,y:e+4,width:14,height:12,rx:2,fill:_r,opacity:.9})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:190,cy:142,rx:68}),e(120,124,Z.cobalt),e(100,112,Z.rose,8),e(80,118,Z.amber,2),(0,$.jsx)(br,{kind:`dome`,x:188,y:84,size:100}),(0,$.jsxs)(`g`,{transform:`rotate(-8 82 66)`,children:[(0,$.jsx)(`path`,{d:`M50 62c12-8 24-8 32 0v34c-8-8-20-8-32 0z`,fill:_r}),(0,$.jsx)(`path`,{d:`M114 62c-12-8-24-8-32 0v34c8-8 20-8 32 0z`,fill:_r}),(0,$.jsx)(`path`,{d:`M82 62v34`,stroke:vr,strokeWidth:2}),(0,$.jsx)(`rect`,{x:56,y:70,width:18,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:56,y:78,width:14,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:90,y:70,width:18,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:90,y:78,width:12,height:4,rx:2,fill:vr})]}),(0,$.jsx)(`circle`,{cx:46,cy:40,r:4,fill:Z.moss,opacity:.6}),(0,$.jsx)(`circle`,{cx:120,cy:34,r:3,fill:Z.amber,opacity:.7})]})}function Tr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:200,cy:142,rx:58}),(0,$.jsx)(`rect`,{x:158,y:50,width:52,height:40,rx:6,fill:_r,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:176,y:44,width:52,height:44,rx:6,fill:_r,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:168,y:56,width:22,height:6,rx:3,fill:Z.teal,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:186,y:52,width:26,height:6,rx:3,fill:Z.violet,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:68,rx:12,fill:Z.amber}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:14,rx:7,fill:`#000`,opacity:.08}),(0,$.jsx)(`rect`,{x:184,y:104,width:32,height:10,rx:5,fill:`#000`,opacity:.14}),(0,$.jsxs)(`g`,{transform:`rotate(-14 112 40)`,children:[(0,$.jsx)(`rect`,{x:94,y:26,width:40,height:28,rx:5,fill:_r}),(0,$.jsx)(`rect`,{x:100,y:34,width:22,height:5,rx:2.5,fill:Z.ember}),(0,$.jsx)(`rect`,{x:100,y:43,width:14,height:4,rx:2,fill:vr})]}),(0,$.jsx)(br,{kind:`bean`,x:90,y:144,size:120})]})}function Er(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:196,cy:142,rx:60}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:106,rx:14,fill:_r}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:20,rx:10,fill:`var(--color-paper-2)`}),(0,$.jsx)(`circle`,{cx:150,cy:40,r:3.5,fill:Z.rose}),(0,$.jsx)(`circle`,{cx:161,cy:40,r:3.5,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:172,cy:40,r:3.5,fill:Z.moss}),(0,$.jsx)(`rect`,{x:150,y:62,width:56,height:10,rx:5,fill:Z.ember}),(0,$.jsx)(`rect`,{x:150,y:80,width:70,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:150,y:92,width:48,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:150,y:108,width:40,height:14,rx:7,fill:Z.cobalt}),(0,$.jsx)(`circle`,{cx:232,cy:102,r:16,fill:Z.teal,opacity:.85}),(0,$.jsx)(br,{kind:`sprout`,x:96,y:144,size:120})]})}var Dr={info:Sr,brand:Cr,knowledge:wr,data:Tr,page:Er};function Or({id:e,icon:t,className:n}){let r=Dr[e];return(0,$.jsx)(`span`,{"aria-hidden":!0,className:K(`relative block h-36 overflow-hidden`,gr[e]??`bg-paper-2`,n),children:r?(0,$.jsx)(`svg`,{viewBox:`20 10 280 140`,className:`absolute inset-0 h-full w-full`,preserveAspectRatio:`xMidYMax meet`,overflow:`visible`,children:(0,$.jsx)(r,{})}):(0,$.jsx)(`span`,{className:`absolute inset-0 grid place-items-center text-ink-3`,children:(0,$.jsx)(`span`,{className:`grid size-16 place-items-center rounded-2xl bg-paper shadow-soft`,children:(0,$.jsx)(t,{className:`size-8`})})})})}var kr={info:`space.teaser.info`,brand:`space.teaser.brand`,knowledge:`space.teaser.knowledge`,data:`space.teaser.data`,page:`space.teaser.page`};function Ar({space:e,parts:t}){let n=dt(),r=nt(e.id),i=o(e.id),a=un(e.id);ne({title:q(`space.overviewAssistantTitle`),hello:q(`space.overviewAssistantHello`),suggestions:[{label:q(`assistant.suggest.missing`)},{label:q(`assistant.suggest.readSite`),fill:!0}]});let s=r.data?.files.filter(e=>e.kind===`logo`)??[],c=s.length,l=e.brand.colors?.length??0,u=i.data?.items.length??0,f=i.data?.categories.length??0,p=a.data?.tables.length??0,m=a.data?.pages.length??0,h=t=>{let n=(...e)=>e.filter(Boolean).join(` · `);switch(t){case`info`:{let t=!!e.brand.name?.trim();return{text:n(!t&&q(`space.status.noTitle`),e.facts.length>0&&q(`space.status.facts`,{n:e.facts.length}))||q(`space.status.empty`),filled:t}}case`brand`:return r.isPending?null:{text:n(c>0&&q(`space.status.logos`,{n:c}),l>0&&q(`space.status.colors`,{n:l}))||q(`space.status.empty`),filled:c+l>0};case`knowledge`:return i.isPending?null:{text:n(u>0&&q(`space.status.entries`,{n:u}),f>0&&q(`space.status.categories`,{n:f}))||q(`space.status.empty`),filled:u>0};case`data`:return a.isPending?null:{text:n(p>0&&q(`space.status.tables`,{n:p}),m>0&&q(`space.pages`,{n:m}))||q(`space.status.empty`),filled:p+m>0};default:return null}},g=t=>{let n=`flex min-w-0 items-center gap-2 text-[0.8125rem] text-ink-2`;switch(t){case`info`:return e.brand.name?.trim()||e.facts.length?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.brand.name?.trim()?(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.name}):null,e.facts.slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-ink-3`,children:e.label}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.value})]},e.key))]}):null;case`brand`:return c+l||e.brand.tagline?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.brand.brandName||e.brand.tagline?(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.brandName||e.brand.name}),e.brand.tagline?(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-3 italic`,children:e.brand.tagline}):null]}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[s.slice(0,3).map(t=>(0,$.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center overflow-hidden rounded-lg bg-paper ring-1 ring-border-soft`,children:(0,$.jsx)(Zn,{spaceId:e.id,file:t,small:!0})},t.id)),(0,$.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:(e.brand.colors??[]).slice(0,8).map(e=>(0,$.jsx)(`span`,{title:`${e.name} ${e.value}`,className:`size-5 rounded-full ring-1 ring-border-soft`,style:{background:e.value}},`${e.name}${e.value}`))})]})]}):null;case`knowledge`:return u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i.data?.items.slice(0,3).map(e=>{let t=e.kind===`page`?X:e.kind===`table`?Qe:on;return(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.key)}),f?(0,$.jsx)(`span`,{className:`mt-1 flex flex-wrap gap-1`,children:i.data?.categories.slice(0,4).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-paper-2 px-2 py-0.5 text-[0.75rem] text-ink-3`,children:e.name},e.id))}):null]}):null;case`data`:return p+m?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:[...(a.data?.tables??[]).map(e=>({key:`t:${e.id}`,title:e.title,rows:e.rows,Icon:Qe})),...(a.data?.pages??[]).map(e=>({key:`p:${e.id}`,title:e.title,rows:null,Icon:X}))].slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(e.Icon,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.rows===null?null:(0,$.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:e.rows})]},e.key))}):null;default:return null}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(d,{}),(0,$.jsx)(O,{title:q(`nav.sources`),hint:q(`space.overviewHint`),plain:!0,children:(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:t.map(e=>{let t=h(e.id),r=kr[e.id];return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.to),className:`group flex min-w-0 flex-col overflow-hidden rounded-2xl bg-card text-left shadow-soft ring-1 ring-border-soft transition hover:-translate-y-0.5 hover:ring-border motion-reduce:transition-none motion-reduce:hover:translate-y-0`,children:[(0,$.jsx)(Or,{id:e.id,icon:e.icon}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-2 p-4`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1.0625rem]`,children:e.label}),(0,$.jsx)(Et,{className:`size-4 text-ink-4 transition group-hover:translate-x-0.5 group-hover:text-ink-3`})]}),r?(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:q(r)}):null,g(e.id)?(0,$.jsx)(`span`,{className:`block rounded-lg bg-paper-2/50 p-3`,children:g(e.id)}):null,t?(0,$.jsx)(`span`,{className:`mt-auto pt-1`,children:(0,$.jsx)(wt,{tone:t.filled?`live`:`warn`,children:t.text})}):null]})]},e.id)})})})]})}var jr=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mr=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),Lt(e.size)].filter(Boolean).join(` · `);function Nr({spaceId:e,file:t,actions:n,onClose:r}){let i=$e(e,t.id);return(0,$.jsxs)(I,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mr(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":q(`space.openOriginal`),title:q(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(nn,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Jn,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Yn,{file:t,actions:n})})]})}function Pr({spaceId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${q(`space.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(Zn,{spaceId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.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,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mr(t)})]}),(0,$.jsx)(Yn,{file:t,actions:n})]}),(0,$.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,$.jsx)(G,{label:q(`space.preview`),onClick:i,children:(0,$.jsx)(cn,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(lt,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]})}function Fr({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(I,{open:!0,onClose:r,title:q(e?`space.assetSectionRename`:`space.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.assetSectionName`)}),(0,$.jsx)(L,{autoFocus:!0,value:i,maxLength:80,placeholder:q(`space.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(F,{variant:`danger`,onClick:n,children:q(`space.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(F,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,disabled:!i.trim(),children:q(e?`settings.save`:`space.add`)})]})]})})}function Ir({spaceId:e,data:t,readOnly:n,sections:r,save:i}){let a=We(e,n),[o,s]=P(`assets`,`cards`),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(r),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),ee=W({assetSections:p},i),te=t.files.filter(e=>e.kind===`asset`),ne=new Map(te.map(e=>[e.id,e])),re=new Set(p.flatMap(e=>e.assets)),S=p.find(e=>e.id===h)??null,ie=S?S.assets.map(e=>ne.get(e)).filter(e=>!!e):te.filter(e=>!re.has(e.id)),ae=te.find(e=>e.id===u),oe=c.trim().toLowerCase(),se=oe?ie.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(oe)):ie,C=(e,t)=>m(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ce=async e=>{let t=S?.id??null;for(let n of await a.upload(`asset`,e))C(n.id,t)},w=async e=>{await ct(q(`space.removeConfirm`,{name:e.name}))&&(a.remove(e.id),C(e.id,null))},le=p.length?{options:[{value:``,label:q(`space.assetsGeneral`)},...p.map(e=>({value:e.id,label:e.title||q(`space.sectionUntitled`)}))],current:e=>p.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>C(e.id,t||null)}:void 0,ue=[{label:q(`space.assetUpload`),icon:(0,$.jsx)(kn,{className:`size-4 shrink-0`}),onPick:()=>x.current?.click()},{label:q(`space.assetFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>b(!0)},...p.length<A.logoSections?[{label:q(`space.assetSectionAdd`),icon:(0,$.jsx)(Te,{className:`size-4 shrink-0`}),onPick:()=>v(`new`)}]:[]],de=p.length||te.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[p.length?(0,$.jsx)(Nt,{value:h,onChange:e=>{g(e),l(``)},label:q(`space.assets`),options:[{id:``,label:q(`space.assetsGeneral`)},...p.map(e=>({id:e.id,label:e.title||q(`space.sectionUntitled`)}))]}):null,S&&!n?(0,$.jsx)(G,{label:q(`space.assetSectionRename`),onClick:()=>v(`current`),children:(0,$.jsx)(He,{className:`size-4`})}):null]}),ie.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(M,{value:c,onChange:l,placeholder:q(`space.assetSearch`)})}),(0,$.jsx)(G,{label:q(o===`list`?`space.viewCards`:`space.viewList`),onClick:s,children:o===`list`?(0,$.jsx)(f,{className:`size-4`}):(0,$.jsx)(On,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(O,{title:q(`space.assets`),hint:q(`space.assetsHint`),save:ee,tabs:de,action:n?null:(0,$.jsx)(V,{entries:ue}),children:[(0,$.jsx)(`input`,{ref:x,type:`file`,multiple:!0,accept:jr,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ce(t)}}),se.length?o===`cards`?(0,$.jsx)(er,{spaceId:e,kind:`asset`,files:se,actions:a,moveTo:le,onRemove:w,onPreview:e=>d(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:se.map(t=>(0,$.jsx)(Pr,{spaceId:e,file:t,actions:a,moveTo:le,onPreview:()=>d(t.id),onRemove:()=>w(t)},t.id))}):ie.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`space.staysLocal`)}):(0,$.jsxs)(Dt,{accept:jr,onFiles:e=>void ce(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(B,{className:`size-4`}):(0,$.jsx)(kn,{className:`size-4`}),q(`space.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:q(`space.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,ae?(0,$.jsx)(Nr,{spaceId:e,file:ae,actions:a,onClose:()=>d(null)}):null,_?(0,$.jsx)(Fr,{section:_===`current`?S:null,onClose:()=>v(null),onSave:e=>{if(_===`current`&&S)m(t=>t.map(t=>t.id===S.id?{...t,title:e}:t));else{let t=N();m(n=>[...n,{id:t,title:e,assets:[]}]),g(t)}},onRemove:_===`current`&&S?async()=>{(!S.assets.length||await ct(q(`space.assetSectionRemoveConfirm`,{name:S.title})))&&(m(e=>e.filter(e=>e.id!==S.id)),g(``),v(null))}:void 0}):null,y?(0,$.jsx)(tr,{kind:`asset`,onClose:()=>b(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)C(t.id,S?.id??null)}}):null]})}var Lr=/^#[0-9a-fA-F]{6}$/;async function Rr(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 zr={linear:`space.gradientLinear`,radial:`space.gradientRadial`,conic:`space.gradientConic`};function Br({spaceId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(j(t)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!n),b=e=>{s(e),l(j(e)),d(!1)},x=(e,t)=>b({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),ee=e=>{let t=[...o.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));b({...o,stops:[...o.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},te=async()=>{h(!0),_(null);try{let{gradient:t}=await D.post(`/api/studio/spaces/${e}/gradients/describe`,{text:f.trim(),...v?{gradient:{name:o.name,type:o.type,angle:o.angle,stops:o.stops}}:{}});b({...o,...t,name:o.name.trim()?o.name:t.name}),p(``),y(!0)}catch(e){_(e.message)}h(!1)};return(0,$.jsx)(I,{open:!0,onClose:a,wide:!0,title:q(n?`space.gradientNew`:`space.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f.trim()&&!m&&te()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{"data-autofocus":n||void 0,value:f,maxLength:1e3,"aria-label":q(`space.gradientDescribe`),placeholder:q(v?`space.gradientDescribeChange`:`space.gradientDescribeNew`),onChange:e=>p(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(F,{type:`submit`,variant:`secondary`,busy:m,disabled:!f.trim(),children:[(0,$.jsx)(Ye,{className:`size-4`}),q(v?`space.gradientDescribeApply`:`space.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,g?`text-rose`:`text-ink-3`),children:g??q(`space.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:j(o)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.gradientName`)}),(0,$.jsx)(L,{value:o.name,maxLength:80,placeholder:q(`space.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.fillUseLabel`)}),(0,$.jsx)(L,{value:o.description??``,maxLength:400,placeholder:q(`space.gradientUse`),onChange:e=>s({...o,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:ht.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>b({...o,type:e}),className:K(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,o.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(zr[e])},e))})]}),o.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(R,{children:q(`space.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:o.angle,"aria-label":q(`space.gradientAngle`),onChange:e=>b({...o,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(o.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(st,{value:Lr.test(e.color)?e.color:`#888888`,onChange:e=>x(t,{color:e.target.value})}),(0,$.jsx)(L,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Lr.test(n)&&x(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":q(`space.gradientAt`),onChange:e=>x(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(G,{label:q(`space.remove`),disabled:o.stops.length<=2,onClick:()=>b({...o,stops:o.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>ee(),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.gradientStopAdd`)]}):null,r.length&&o.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:q(`space.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>ee(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:`CSS`}),(0,$.jsx)(L,{value:c,spellCheck:!1,onChange:e=>{l(e.target.value);let t=k(e.target.value);d(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,u?`text-rose`:`text-ink-3`),children:q(u?`space.gradientCssError`:`space.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:a,children:q(`common.cancel`)}),(0,$.jsx)(F,{onClick:()=>{i(o),a()},children:q(`settings.save`)})]})]})})}var Vr=`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`,Hr=`size-8 bg-card shadow-soft hover:bg-card`;function Ur({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(Mt,{value:e,label:q(`space.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(Mt,{value:n??``,label:q(`space.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wr({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=j(e),[o,s]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":q(`space.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:Vr,children:[(0,$.jsx)(G,{label:q(o?`space.gradientCopied`:`space.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Hr,children:(0,$.jsx)(an,{className:`size-4`})}),(0,$.jsx)(G,{label:q(`space.download`),onClick:()=>void Rr(e,e.name),className:Hr,children:(0,$.jsx)(at,{className:`size-4`})}),t?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:i,className:K(Hr,`hover:text-rose`),children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(Ur,{name:e.name,namePlaceholder:q(`space.gradientName`),description:e.description,usePlaceholder:q(`space.gradientUse`),readOnly:t,onChange:r})]})}function Gr(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kr({spaceId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=$e(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":q(`space.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gr(s,t.tile)}),(0,$.jsxs)(`div`,{className:Vr,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":q(`space.download`),title:q(`space.download`),className:K(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hr),children:(0,$.jsx)(at,{className:`size-4`})}),r?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:o,className:K(Hr,`hover:text-rose`),children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(Ur,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:q(`space.patternUse`),readOnly:r,onChange:a})]})}function qr({spaceId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Q.useState)(t),[f,p]=(0,Q.useState)([]),m=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},h=()=>{for(let e of f)s(e);l()};return(0,$.jsx)(I,{open:!0,onClose:h,wide:!0,title:q(n?`space.patternNew`:`space.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gr($e(e,u.file),u.tile),children:(0,$.jsxs)(Dt,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(B,{className:`size-4`}):(0,$.jsx)(tn,{className:`size-4`}),q(`space.patternReplace`)]})}):(0,$.jsxs)(Dt,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(B,{className:`size-5`}):(0,$.jsx)(tn,{className:`size-5`}),q(`space.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.patternName`)}),(0,$.jsx)(L,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):q(`space.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.fillUseLabel`)}),(0,$.jsx)(L,{value:u.description??``,maxLength:400,placeholder:q(`space.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.patternShow`)}),(0,$.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,$.jsx)(`button`,{type:`button`,"aria-pressed":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:K(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(e?`space.patternTile`:`space.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:h,children:q(`common.cancel`)}),(0,$.jsx)(F,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:q(n?`space.add`:`settings.save`)})]})]})})}var Jr=/^#[0-9a-fA-F]{6}$/;function Yr({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await D.post(`/api/studio/spaces/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(q(`space.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(I,{open:!0,onClose:n,wide:l?!0:void 0,title:q(l?`space.colorsFound`:`space.colorsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`space.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:K(`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,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(sn,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:q(`run.back`)}),(0,$.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?q(`space.addMany`,{n:d.length}):q(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.logoUrl`)}),(0,$.jsx)(L,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.colorsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function Xr({spaceId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,save:s,readOnly:c}){let[l,u]=(0,Q.useState)(()=>n.map(e=>({...e,id:N()}))),[d,f]=(0,Q.useState)(r),[p,m]=(0,Q.useState)(i),[h,g]=(0,Q.useState)(a),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),x=We(e,c),ee=Be(o),[te,ne]=(0,Q.useState)(null),[re,S]=(0,Q.useState)(null),[ie,ae]=(0,Q.useState)(!1),oe=W({colors:l.filter(e=>Jr.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:d,gradients:p,patterns:h,colorRules:ee.rules},s),se=d.filter(e=>(e.kind??`colors`)===`colors`),C=e=>se.some(t=>t.id===e.section),ce=l.filter(e=>!C(e)),w=(ce[0]??l[0])?.id,le=(e,t)=>u(n=>n.map(n=>n.id===e?{...n,...t}:n)),ue=e=>u(t=>[...t,...e.map(e=>({...e,id:N()}))].slice(0,A.colors)),de=[{value:``,label:q(`space.sectionStandard`)},...se.map(e=>({value:e.id,label:e.title||q(`space.sectionUntitled`)}))],fe=(e,t)=>{let n=N();ne(n),f(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},pe=e=>({id:N(),name:``,section:e,type:`linear`,angle:90,stops:[{color:l[0]?.value&&Jr.test(l[0].value)?l[0].value:`#4b73ff`,at:0},{color:l[1]?.value&&Jr.test(l[1].value)?l[1].value:`#ff6d1b`,at:100}]}),me=e=>t.files.find(t=>t.id===e)?.name??`pattern`,he=[...l.length<A.colors?[{label:q(`space.colorNew`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>_e()},{label:q(`space.colorsFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>ae(!0)}]:[],...d.length<A.logoSections?[{label:q(`space.colorSectionAdd`),icon:(0,$.jsx)(Te,{className:`size-4 shrink-0`}),onPick:()=>fe(`colors`,``)},{label:q(`space.gradientSectionAdd`),icon:(0,$.jsx)(Ln,{className:`size-4 shrink-0`}),onPick:()=>fe(`gradients`,q(`space.gradientSectionTitle`))},{label:q(`space.patternSectionAdd`),icon:(0,$.jsx)(Un,{className:`size-4 shrink-0`}),onPick:()=>fe(`patterns`,q(`space.patternSectionTitle`))}]:[],...ee.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>ee.add()}]],ge=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(st,{value:Jr.test(e.value)?e.value:`#888888`,onChange:t=>le(e.id,{value:t.target.value})}),(0,$.jsx)(L,{value:e.name,autoFocus:e.id===re,placeholder:q(`space.colorName`),maxLength:120,onChange:t=>le(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(L,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>le(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===w?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(wt,{tone:`ember`,children:q(`space.colorAccent`)})}):c?null:(0,$.jsx)(G,{label:q(`space.colorFirst`),onClick:()=>u(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,$.jsx)(Tt,{className:`size-4`})}),c||!se.length?null:(0,$.jsx)(lt,{options:de,value:C(e)?e.section??``:``,onChange:t=>le(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),c?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>u(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,$.jsx)(Y,{className:`size-4`})})]})]},e.id),_e=e=>{let t=N();S(t),u(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(O,{title:q(`space.colors`),hint:q(`space.colorsHint`),save:oe,locked:c,action:c?null:(0,$.jsx)(V,{entries:he}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[ce.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:ce.map(ge)}),c?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.colorUse`)})]}):l.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`space.colorsEmpty`)}),d.map(t=>{let n=t.kind??`colors`,r=l.filter(e=>e.section===t.id),i=p.filter(e=>e.section===t.id),a=h.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(kt,{title:t.title,titlePlaceholder:q(n===`gradients`?`space.gradientSectionTitlePlaceholder`:n===`patterns`?`space.patternSectionTitlePlaceholder`:`space.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Ln,{}),label:q(`space.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Un,{}),label:q(`space.kindPatterns`)}:{icon:(0,$.jsx)(je,{}),label:q(`space.kindColors`)},autoFocus:te===t.id,readOnly:c,onChange:e=>f(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:async()=>{if(!o||await ct(q(n===`colors`?`space.colorSectionRemoveConfirm`:`space.fillSectionRemoveConfirm`,{name:t.title||q(`space.sectionUntitled`)}))){f(e=>e.filter(e=>e.id!==t.id)),u(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),m(e=>e.filter(e=>e.section!==t.id));for(let e of a)x.remove(e.file);g(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(Wr,{gradient:e,readOnly:c,onEdit:()=>v(e),onChange:t=>m(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>m(t=>t.filter(t=>t.id!==e.id))},e.id)),c||p.length>=A.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(pe(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,$.jsx)(J,{className:`size-5`}),q(`space.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(Kr,{spaceId:e,pattern:t,fileName:me(t.file),readOnly:c,onEdit:()=>b(t),onChange:e=>g(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{x.remove(t.file),g(e=>e.filter(e=>e.id!==t.id))}},t.id)),c||h.length>=A.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b({id:N(),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,$.jsx)(J,{className:`size-5`}),q(`space.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ge),c||l.length>=A.colors?null:(0,$.jsx)(z,{label:q(`space.colorAdd`),onClick:()=>_e(t.id)})]})]},t.id)}),(0,$.jsx)(At,{rules:ee,placeholder:q(`space.colorRulePlaceholder`),readOnly:c})]}),x.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:x.error}):null,_?(0,$.jsx)(Br,{spaceId:e,gradient:_,isNew:!p.some(e=>e.id===_.id),brand:l.filter(e=>Jr.test(e.value)),onClose:()=>v(null),onSave:e=>m(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,y?(0,$.jsx)(qr,{spaceId:e,pattern:y,isNew:!h.some(e=>e.id===y.id),fileName:me,busy:x.busy,error:x.error,upload:async e=>(await x.upload(`pattern`,[e]))[0]??null,removeFile:e=>void x.remove(e),onClose:()=>b(null),onSave:e=>g(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,ie?(0,$.jsx)(Yr,{spaceId:e,onClose:()=>ae(!1),onAdd:ue}):null]})}var Zr=e=>/^(ja|yes|true)$/i.test(e.trim()),Qr={text:Pe,longtext:Tn,number:y,date:C,url:et,email:jn,phone:Mn,boolean:g};function $r({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=Qr[e??t],l=`${q(`space.factType`)}: ${q(`space.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:K(`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,$.jsx)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:K(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,$.jsx)(Xe,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:q(`space.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:q(`space.type.${t}`)}),(0,$.jsx)(sn,{className:K(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Je.map(t=>{let n=Qr[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:q(`space.type.${t}`)}),(0,$.jsx)(sn,{className:K(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function ei({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=W(a.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),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=ze.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(O,{title:q(`space.facts`),hint:q(`space.factsHint`),save:s,locked:n,action:a.length<A.facts&&!n?(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ve(e.value),r=e.type??t;return(0,$.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,$.jsx)(L,{ref:u(`${e.id}:label`),value:e.label,placeholder:q(`space.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:Ue(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(Ot,{checked:Zr(e.value),label:e.label,onChange:t=>c(e.id,{value:q(t?`space.yes`:`space.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zr(e.value)?q(`space.yes`):q(`space.no`)})]}):(0,$.jsx)(ut,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:q(`space.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)($r,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]},e.id)})}),a.length<A.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e,label:q(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(J,{className:`size-3.5`}),` `,q(`fact.${e}`)]},e))]}):null]})}var ti=[{label:`Website`,placeholder:`https://…`},{label:`LinkedIn`,placeholder:`linkedin.com/company/…`},{label:`Instagram`,placeholder:`instagram.com/…`},{label:`Facebook`,placeholder:`facebook.com/…`},{label:`YouTube`,placeholder:`youtube.com/@…`},{label:`TikTok`,placeholder:`tiktok.com/@…`},{label:`X`,placeholder:`x.com/…`}],ni=e=>e===`Website`?Nn:ti.some(t=>t.label===e)?Fn:et;function ri({links:e,readOnly:t,save:n}){let[r,i]=(0,Q.useState)(e),a=(0,Q.useRef)(null),o=W(r.map(e=>({...e,label:e.label.trim(),url:e.url.trim()})).filter(e=>e.url),n),s=(e,t)=>i(n=>n.map(n=>n.id===e?{...n,...t}:n)),c=e=>{let t=N();a.current=`${t}:${e?`url`:`label`}`,i(n=>[...n,{id:t,label:e,url:``}])},l=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},u=ti.filter(e=>!r.some(t=>t.label===e.label)),d=r.length>=A.links,f=[...u.map(e=>{let t=ni(e.label);return{label:e.label,icon:(0,$.jsx)(t,{className:`size-4 shrink-0`}),onPick:()=>c(e.label)}}),{label:q(`space.links.own`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>c(``)}];return(0,$.jsxs)(O,{title:q(`space.links`),hint:q(`space.linksHint`),save:o,locked:t,action:t||d?null:(0,$.jsx)(V,{entries:f}),children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>{let n=ni(e.label);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:grid-cols-[auto_minmax(0,2fr)_minmax(0,3fr)_auto]`,children:[(0,$.jsx)(`span`,{className:`grid size-11 place-items-center text-ink-3`,children:(0,$.jsx)(n,{className:`size-4`})}),(0,$.jsx)(L,{ref:l(`${e.id}:label`),value:e.label,maxLength:80,readOnly:t,placeholder:q(`space.links.label`),onChange:t=>s(e.id,{label:t.target.value}),className:`max-sm:col-span-1 max-sm:font-medium`}),(0,$.jsx)(L,{ref:l(`${e.id}:url`),value:e.url,maxLength:600,readOnly:t,inputMode:`url`,placeholder:ti.find(t=>t.label===e.label)?.placeholder??`https://…`,onChange:t=>s(e.id,{url:t.target.value}),className:`max-sm:col-span-2 max-sm:col-start-2 max-sm:row-start-2`}),t?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>i(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose max-sm:col-start-3 max-sm:row-start-1`,children:(0,$.jsx)(Y,{className:`size-4`})})]},e.id)})}),t||d?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${r.length?`mt-4`:``}`,children:[(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>c(``),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.links.own`)]}),u.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(e.label),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,$.jsx)(J,{className:`size-3.5`}),` `,e.label]},e.label))]})]})}function ii({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData($n);i(!1),n&&(t.preventDefault(),e(n))},className:K(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function ai({spaceId:e,data:t,readOnly:n,sections:r,rules:i,save:a}){let o=We(e,n),[s,c]=(0,Q.useState)(r),l=Be(i),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),h=W({logoSections:s,logoRules:l.rules},a),g=t.files.filter(e=>e.kind===`logo`),_=new Map(g.map(e=>[e.id,e])),v=new Set(s.flatMap(e=>e.logos)),y=g.filter(e=>!v.has(e.id)),b=Re(g,s)?.id,x=(e,t)=>c(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),ee=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),te=async(e,t)=>{let n=await o.upload(`logo`,e);for(let e of n)x(e.id,t)},ne=s.length?{options:[{value:``,label:q(`space.sectionStandard`)},...s.map(e=>({value:e.id,label:e.title||q(`space.sectionUntitled`)}))],current:e=>s.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>x(e.id,t||null)}:void 0,re=(t,n,r)=>(0,$.jsx)(er,{spaceId:e,kind:`logo`,files:t,actions:o,accept:`image/*`,addLabel:r?q(`space.logoAdd`):void 0,onUpload:e=>void te(e,n),mainId:b,onMakeMain:e=>{x(e.id,null),o.order(`logo`,[e.id,...g.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ne,onRemove:async e=>{await ct(q(`space.removeConfirm`,{name:e.name}))&&(o.remove(e.id),x(e.id,null))}}),S=n?void 0:e=>t=>x(t,e),ie=[{label:q(`space.logoUpload`),icon:(0,$.jsx)(kn,{className:`size-4 shrink-0`}),onPick:()=>m.current?.click()},{label:q(`space.logoFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>p(!0)},...s.length<A.logoSections?[{label:q(`space.logoSectionAdd`),icon:(0,$.jsx)(Te,{className:`size-4 shrink-0`}),onPick:()=>{let e=N();d(e),c(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...l.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>l.add()}]];return(0,$.jsxs)(O,{title:q(`space.logos`),hint:q(`space.logosHint`),save:h,action:n?null:(0,$.jsx)(V,{entries:ie}),children:[(0,$.jsx)(`input`,{ref:m,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&&te(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(ii,{onLogo:S?.(null),children:re(y,null,!0)}),s.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(ii,{onLogo:S?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(kt,{title:e.title,description:e.description,titlePlaceholder:q(`space.logoSectionTitle`),descriptionPlaceholder:q(`space.logoSectionUse`),autoFocus:u===e.id,readOnly:n,onChange:t=>ee(e.id,t),onRemove:async()=>{(!e.logos.length||await ct(q(`space.logoSectionRemoveConfirm`,{name:e.title||q(`space.sectionUntitled`)})))&&c(t=>t.filter(t=>t.id!==e.id))}}),re(e.logos.map(e=>_.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),(0,$.jsx)(At,{rules:l,placeholder:q(`space.logoRulePlaceholder`),readOnly:n})]}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,f?(0,$.jsx)(tr,{kind:`logo`,onClose:()=>p(!1),fetchUrl:e=>o.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)x(t.id,null)}}):null]})}var oi=e=>URL.canParse(e)?new URL(e).host:e;async function si(e,t){let n=Ke({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ci(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 ci(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 li(e,t){let n=e.source;if(!n)return q(`space.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return q(`space.fontSourceFile`,{name:e})}return q(`space.fontSourceUrl`,{host:oi(n.url)})}function ui({spaceId:e,font:t,onSave:n,onClose:r}){let i=(nt(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=We(e),o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(t.source&&`url`in t.source?`url`:`file`),[l,u]=(0,Q.useState)(t.source&&`file`in t.source?t.source.file:``),[d,f]=(0,Q.useState)(t.source&&`url`in t.source?t.source.url:``),[p,m]=(0,Q.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(t.license??``),[y,b]=(0,Q.useState)(!1),x=d.trim(),ee=async()=>{g(!0),m({url:x,result:await si(x,t.family.trim())}),g(!1)},te=s===`file`?l?{file:l}:null:p?.url===x&&p.result===`ok`?{url:x}:null,ne=p?.url===x?p.result:null;return(0,$.jsx)(I,{open:!0,onClose:r,title:q(`space.fontSourceTitle`,{family:t.family}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`space.fontSourceHint`)}),(0,$.jsx)(yt,{value:s,options:[`file`,`url`],label:e=>q(`space.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.fontSourceFiles`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>u(e.id),className:K(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,l===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,$.jsx)(`input`,{ref:o,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await a.upload(`asset`,t);n&&u(n.id)}}),(0,$.jsxs)(F,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,$.jsx)(kn,{className:`size-4`}),q(`space.fontSourceUpload`)]}),a.error?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:a.error}):null]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ee()},children:[(0,$.jsx)(R,{children:q(`space.fontSourceUrlLabel`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{value:d,inputMode:`url`,placeholder:q(`space.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,$.jsx)(F,{type:`submit`,variant:`ghost`,busy:h,disabled:!x.startsWith(`https://`),children:q(`space.fontSourceCheck`)})]}),ne?(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.875rem]`,ne===`ok`?`text-ink-3`:`text-rose`),children:q(`space.fontCheck.${ne}`,{host:oi(x),family:t.family})}):null,ne===`ok`?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:q(`space.fontPrivacy`,{host:oi(x)})}):null]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{hint:q(`space.fontLicenseHint`),children:q(`space.fontLicense`)}),(0,$.jsx)(L,{value:_,maxLength:200,placeholder:q(`space.fontLicensePlaceholder`),onChange:e=>v(e.target.value)}),(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:y,onChange:e=>b(e.target.checked)}),q(`space.fontLicenseConfirm`,{family:t.family})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,$.jsx)(F,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:q(`space.fontSourceRemove`)}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,$.jsx)(F,{disabled:!(te&&y),onClick:()=>{te&&(n({source:te,license:_.trim()||void 0}),r())},children:q(`space.fontSourceSave`)})]})]})})}var di=new Set;function fi(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||di.has(t))return;di.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${Le.join(`,`)}&display=swap`,document.head.append(n)},[e])}var pi=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function mi({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.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 hi=`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`,gi={web:`space.fontUseWeb`,documents:`space.fontUseDocuments`,print:`space.fontUsePrint`,images:`space.fontUseImages`,video:`space.fontUseVideo`};function _i({spaceId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){fi(t.family);let s=nt(e).data?.files??[],[c,l]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.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:pi(t.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Mt,{value:t.family,label:q(`space.fontFamily`),placeholder:q(`space.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(Mt,{value:t.role,label:q(`space.fontRole`),placeholder:q(n?`space.fontRoleFirst`:`space.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Le.map(e=>{let n=t.weights.includes(e);return(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:pi(t.family),fontWeight:e},className:K(`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,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,$.jsx)(Mt,{value:t.license??``,label:q(`space.fontLicense`),placeholder:q(`space.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:q(`space.fontUses`)}),_t.map(e=>{let n=!!t.uses?.includes(e);return(0,$.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):_t.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:K(`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,$.jsx)(sn,{className:`size-3.5`}):null,q(gi[e])]},e)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:li(t,s)}),r||!t.family.trim()?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:q(t.source?`space.fontSourceChange`:`space.fontSourceSet`)})]}),c?(0,$.jsx)(ui,{spaceId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:o,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,$.jsx)(Y,{className:`size-4`})})]})}function vi({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:pi(s?.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,$.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,$.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(Mt,{value:e.name,label:q(`space.styleName`),placeholder:q(`space.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":q(`space.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:K(hi,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||q(`space.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":q(`space.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:hi,children:[...new Set([...Le,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(mi,{unit:`px`,label:q(`space.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(mi,{unit:q(`space.styleLine`),label:q(`space.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(mi,{unit:q(`space.styleTracking`),label:q(`space.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:q(`space.styleUpper`),"aria-label":q(`space.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:K(`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,$.jsx)(Vn,{className:`size-4`})})]}),r?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]})}function yi({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await D.post(`/api/studio/spaces/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(q(`space.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(I,{open:!0,onClose:n,wide:l?!0:void 0,title:q(l?`space.fontsFound`:`space.fontsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`space.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(bi,{font:e,on:d.includes(e.family),onToggle:()=>f(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:q(`run.back`)}),(0,$.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?q(`space.addMany`,{n:d.length}):q(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.logoUrl`)}),(0,$.jsx)(L,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.fontsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function bi({font:e,on:t,onToggle:n}){return fi(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:K(`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,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:pi(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):q(`space.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(sn,{className:`size-3.5`})}):null]})}function xi({spaceId:e,fonts:t,styles:n,rules:r,sample:i,save:a,readOnly:o}){let[s,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=Be(r),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=W({fonts:s,textStyles:u,typeRules:f.rules},a),v=(e,t=!1)=>{let n=e.map(e=>({id:N(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,A.fonts))},y=()=>{let e=N();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},b=[...s.length<A.fonts?[{label:q(`space.fontNew`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>v([{family:``,weights:[400,700]}],!0)},{label:q(`space.fontsFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<A.textStyles?[{label:q(`space.styleNew`),icon:(0,$.jsx)(c,{className:`size-4 shrink-0`}),onPick:y}]:[],...f.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(O,{title:q(`space.typography`),hint:q(`space.typographyHint`),save:_,action:o?null:(0,$.jsx)(V,{entries:b}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[s.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:s.map((t,n)=>(0,$.jsx)(_i,{spaceId:e,font:t,first:n===0,readOnly:o,autoFocus:p===t.id,onChange:e=>l(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>l(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`space.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`space.styles`)}),o?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:q(`space.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(vi,{style:e,fonts:s,sample:i,readOnly:o,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,(0,$.jsx)(At,{rules:f,placeholder:q(`space.typeRulePlaceholder`),readOnly:o})]}),h?(0,$.jsx)(yi,{spaceId:e,onClose:()=>g(!1),onAdd:e=>v(e)}):null]})}var Si=[{title:`space.voice.tone`,hint:`space.voice.toneHint`},{title:`space.voice.audience`,hint:`space.voice.audienceHint`},{title:`space.voice.positioning`,hint:`space.voice.positioningHint`},{title:`space.voice.values`,hint:`space.voice.valuesHint`}];function Ci({blocks:e,rules:t,readOnly:n,save:r}){let[i,a]=(0,Q.useState)(e),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),u=Be(t),d=W({voice:i,voiceRules:u.rules},r),f=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),p=i.length>=A.voiceBlocks,m=e=>{let t=N();(e?l:s)(t),a(n=>[...n,{id:t,title:e,text:``}])},h=Si.filter(e=>!i.some(t=>t.title===q(e.title))),g=e=>Si.find(t=>q(t.title)===e)?.hint,_=[...p?[]:[...h.map(e=>({label:q(e.title),icon:(0,$.jsx)(pe,{className:`size-4 shrink-0`}),onPick:()=>m(q(e.title))})),{label:q(`space.voice.own`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>m(``)}],...u.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>u.add()}]];return(0,$.jsx)(O,{title:q(`space.voice`),hint:q(`space.voiceHint`),save:d,locked:n,action:n||!_.length?null:(0,$.jsx)(V,{entries:_}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[i.length?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:i.map(e=>{let t=g(e.title);return(0,$.jsxs)(`div`,{className:`group/row grid gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[n?(0,$.jsx)(`p`,{className:`min-w-0 flex-1 font-medium text-[0.9375rem]`,children:e.title}):(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(Mt,{value:e.title,label:q(`space.voice.title`),placeholder:q(`space.voice.title`),maxLength:80,autoFocus:o===e.id,onChange:t=>f(e.id,{title:t}),className:`font-medium text-[0.9375rem]`})}),n?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:async()=>{(!e.text.trim()||await ct(q(`space.voice.removeConfirm`,{name:e.title||q(`space.sectionUntitled`)})))&&a(t=>t.filter(t=>t.id!==e.id))},className:`-mt-1 size-8 shrink-0 rounded-lg opacity-0 transition hover:text-rose focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-100`,children:(0,$.jsx)(Y,{className:`size-4`})})]}),n?(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.9375rem] text-ink-2 leading-relaxed sm:pt-2`,children:e.text}):(0,$.jsx)(ut,{ref:t=>{t&&c===e.id&&(l(null),t.focus())},rows:2,minRows:2,maxRows:14,maxLength:A.voiceText,value:e.text,placeholder:q(t||`space.voice.textPlaceholder`),onChange:t=>f(e.id,{text:t.target.value})})]},e.id)})}):null,n||p?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>m(``),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.voice.own`)]}),h.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(q(e.title)),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,$.jsx)(J,{className:`size-3.5`}),` `,q(e.title)]},e.title))]}),(0,$.jsx)(At,{rules:u,placeholder:q(`space.voice.rulePlaceholder`),readOnly:n})]})})}function wi({spaceId:e,logo:t}){let n=q(t?`space.logoPeek`:`space.logoPeekAdd`);return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(R,{children:q(`space.logo`)}),(0,$.jsx)(ft,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:K(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,$.jsx)(Zn,{spaceId:e,file:t,small:!0}):(0,$.jsx)(tt,{className:`size-5`})})]})}function Ti({space:e,save:t}){let n=Vt().data,r=zt(),i=Fe(`capabilities`)&&r&&n?.mode===`managed`,[a,o]=(0,Q.useState)(e.membersStudio);return i?(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-border-soft border-t pt-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:q(`space.membersStudio`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:q(`space.membersStudioHint`)})]}),(0,$.jsx)(Ot,{checked:a,disabled:e.readOnly,label:q(`space.membersStudio`),onChange:e=>{o(e),t({membersStudio:e}).catch(()=>o(!e))}})]}):null}function Ei({space:e,organization:t,save:n}){let r=zt(),[i,a]=(0,Q.useState)(!1),o=e.brandFrom===`root`;return(0,$.jsxs)(`section`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 rounded-xl bg-card p-4 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-[0.75rem] text-ink-3`,children:q(`space.brandFrom`)}),(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem] text-ink`,children:o?q(`space.brandFromRoot`,{organization:t}):q(`space.brandFromOwn`)}),(0,$.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:q(o?`space.brandFromRootHint`:`space.brandFromOwnHint`,{organization:t})})]}),r&&!e.readOnly?(0,$.jsx)(F,{variant:`secondary`,busy:i,onClick:async()=>{a(!0);try{await n({brandFrom:o?`own`:`root`})}finally{a(!1)}},children:o?q(`space.brandUseOwn`):q(`space.brandUseRoot`,{organization:t})}):null]})}function Di({space:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.brandName??``),[i,a]=(0,Q.useState)(e.brand.tagline??``),o=W({brandName:n.trim(),tagline:i.trim()},e=>t({brand:e}));return(0,$.jsx)(O,{title:q(`space.identity`),hint:q(`space.identityHint`),save:o,locked:e.readOnly,children:(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[{id:`brand-name`,label:q(`space.brandName`),hint:q(`space.brandNameHint`),field:(0,$.jsx)(L,{id:`brand-name`,value:n,maxLength:120,placeholder:e.brand.name??``,onChange:e=>r(e.target.value)})},{id:`brand-tagline`,label:q(`space.tagline`),hint:q(`space.taglineHint`),field:(0,$.jsx)(L,{id:`brand-tagline`,value:i,maxLength:200,onChange:e=>a(e.target.value)})}].map(e=>(0,$.jsxs)(`div`,{className:`grid items-start gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:e.id,className:`font-medium text-[0.9375rem]`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.hint})]}),e.field]},e.id))})})}function Oi({space:e,logo:t,save:n}){let[r,i]=(0,Q.useState)(e.brand.name??``),[a,o]=(0,Q.useState)(e.brand.about??``),s=W({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,$.jsx)(O,{title:q(`space.base`),hint:q(`space.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(R,{children:q(`space.title`)}),(0,$.jsx)(L,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.titleHint`)})]}),(0,$.jsx)(wi,{spaceId:e.id,logo:t})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.about`)}),(0,$.jsx)(ut,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.aboutHint`)})]}),(0,$.jsx)(Ti,{space:e,save:n})]})})}function ki({space:e,group:t,top:n=!1,children:r}){let i=St(),a=nt(e.id),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(!1),u=async t=>{await D.patch(`/api/studio/spaces/${e.id}`,t),await i.invalidateQueries({queryKey:it.spaces()})},f=en({mutationFn:()=>D.del(`/api/studio/spaces/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:it.spaces()})}),p=Bt(),m=zt(),h=a.data??{files:[],embeddings:!0},g=`${e.id}:${o}`,_=e.readOnly,v=t===`knowledge`,y=Vt().data,b=Fe(`orgSpaces`)&&!!e.parentId&&e.kind!==`client`&&(t===`info`||t===`brand`),x=b&&e.brandFrom===`root`;return ne(_?{}:{title:q(v?`space.assistantTitleKnowledge`:`space.assistantTitle`),hello:q(v?`space.assistantHelloKnowledge`:`space.assistantHello`),about:q(v?`space.assistantAboutKnowledge`:`space.assistantAbout`),placeholder:q(v?`space.assistantComposerKnowledge`:`space.assistantComposer`),suggestions:v?[{label:q(`assistant.suggest.knowledgeHow`)},{label:q(`assistant.suggest.knowledgeSite`),fill:!0},{label:q(`assistant.suggest.knowledgeCategories`)}]:[{label:q(`assistant.suggest.readSite`),fill:!0},{label:q(`assistant.suggest.missing`)},...t===`info`?[{label:q(`assistant.suggest.facts`)}]:[]],summary:v?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${h.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[_?(0,$.jsx)(En,{children:wn(e)}):n?(0,$.jsx)(d,{}):null,b&&y?(0,$.jsx)(Ei,{space:e,organization:y.tenant.name||q(`nav.space`),save:u},`from:${e.brandFrom}`):null,t===`info`&&x?(0,$.jsx)(Ti,{space:e,save:u}):null,t===`info`&&!x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{id:`base`,children:(0,$.jsx)(Oi,{space:e,logo:Re(h.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:u},`base:${g}`)}),(0,$.jsx)(ot,{id:`facts`,children:(0,$.jsx)(ei,{facts:e.facts,save:e=>u({facts:e}),readOnly:_},`facts:${g}`)}),(0,$.jsx)(ot,{id:`links`,children:(0,$.jsx)(ri,{links:e.brand.links??[],save:e=>u({brand:{links:e}}),readOnly:_},`links:${g}`)})]}):null,t===`brand`&&!x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{id:`identity`,children:(0,$.jsx)(Di,{space:e,save:u},`identity:${g}`)}),(0,$.jsx)(ot,{id:`logos`,children:(0,$.jsx)(ai,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],save:e=>u({brand:e})},`logos:${g}`)}),(0,$.jsx)(ot,{id:`colors`,children:(0,$.jsx)(Xr,{spaceId:e.id,data:h,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],save:e=>u({brand:e}),readOnly:_},`colors:${g}`)}),(0,$.jsx)(ot,{id:`typography`,children:(0,$.jsx)(xi,{spaceId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],sample:e.brand.name||q(`space.typeSample`),save:e=>u({brand:e}),readOnly:_},`typography:${g}`)}),(0,$.jsx)(ot,{id:`assets`,children:(0,$.jsx)(Ir,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${g}`)}),(0,$.jsx)(ot,{id:`voice`,children:(0,$.jsx)(Ci,{blocks:e.brand.voice??[],rules:e.brand.voiceRules??[],save:e=>u({brand:e}),readOnly:_},`voice:${g}`)})]}):null,r,t===`info`&&p&&!_&&m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(F,{variant:`danger`,onClick:()=>l(!0),children:q(`settings.delete`)}),(0,$.jsxs)(I,{open:c,onClose:()=>l(!1),title:q(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:q(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>l(!1),children:q(`common.cancel`)}),(0,$.jsx)(F,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:q(`common.delete`)})]})]})]}):null]})}var Ai=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function ji(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=ge(),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 Mi(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=ge(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Ni(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Pi({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Qt,{icon:e.icon??Ne,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Yt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},e.plugin??`own`)})}var Fi=(0,Q.lazy)(()=>ln(()=>import(`./SkillEditor-ARx8QPGp.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([10,1,6,4,5,7,8,11,12,13,14,15,16,17,18,9,2,3,19])));function Ii({place:e}){let{group:t}=jt(),[r,c]=bt(),d=dt(),g=Pt(),{hash:_}=g,{space:y,loading:ee}=Ht(),C=ae(),w=Gt(),[pe,Te]=(0,Q.useState)(null),[Oe,ke]=(0,Q.useState)(null),[je,Ne]=(0,Q.useState)(null),T=e??(Ce(t)&&t!==`skills`?t:void 0),Pe=T?void 0:C.spaceParts.find(e=>e.id===t),E=T??Pe?.id,D=g.state?.parts===!0,Le=Fe(`pages`),Re=Fe(`skills`),ze=zt(),Be=Fe(`clientSpaces`),Ve=Fe(`orgSpaces`),He=Be&&Ve&&ze&&!!y?.root,k=Fe(`knowledgeTree`),Ue=Vt().data?.mode===`local`,We=Fe(`dateien`)&&(Ue||C.mountKinds.length>0),Ge=se().filter(e=>(Le||e.id!==`page`)&&(He||e.id!==`clients`)&&(We||e.id!==`files`)),Ke=Ee(Ge,C).map(e=>({...e,to:`/space/${e.id}`})),qe=Ke,Je={id:`results`,label:q(`space.results`),icon:S,to:`/space/results`},Ye={id:`skills`,label:q(`space.skills`),icon:Ie,to:`/skills`},A=T===`results`||T===`skills`,j=T===`results`?Je:T===`skills`?Ye:qe.find(e=>e.id===E),M=r.get(`show`),[Xe,Ze]=(0,Q.useState)(``),N=(0,Q.useRef)(null),Qe=Xe.trim().toLowerCase(),$e=(0,Q.useMemo)(()=>({slot:pe,narrow:w,setDetail:ke,filter:Qe}),[pe,w,Qe]),et=Vt().data,tt=y?y.brand.name?.trim()||(et?a(et,y):y.name):q(`nav.space`),nt=Pe?C.spaceMenus[Pe.id]??[]:[],rt=Pe?[{plugin:null,label:null,sections:nt}]:T&&T!==`results`?he(T,C):[],P=T?he(T,C).filter(e=>e.plugin):[],it=ji([...rt,...T===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),at=(0,Q.useRef)(null),[st,ct]=Bi(),F=T===`results`&&M&&M!==`all`?M:null,[lt,ut]=(0,Q.useState)(yn),I=vn(T===`results`?y?.id:void 0,F,lt),L=I.data?.wizards.find(e=>e.id===F)?.title,[R,ft]=(M??``).split(`#`),z=T===`data`&&R&&R!==`all`||T===`knowledge`&&R&&/^[ptfcvsq]:/.test(R)?R:null,B=z?.startsWith(`s:`)?C.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=T===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,pt=T===`skills`&&M?.startsWith(`k:`)?M:null,ht=bn(T===`skills`&&Re?y?.id:void 0),_t=un(T===`data`?y?.id:void 0),H=o(T===`knowledge`?y?.id:void 0),yt=de(T===`knowledge`&&k?y?.id:void 0),[xt,St]=(0,Q.useState)(null);m.clear(),h.clear();for(let e of yt.sources)e.folderId&&(m.set(e.folderId,yt.iconOf(e)),h.set(e.folderId,e.id));let U=re(z?.startsWith(`v:`)?z.slice(2):``),W=H.data?.items.find(e=>e.key===V),[Ct,wt]=(0,Q.useState)(null),[Tt,Et]=(0,Q.useState)(null),[G,Dt]=(0,Q.useState)(void 0),Ot=l(y?.id),kt=H.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):U.data?.category.id)),[At,Mt]=(0,Q.useState)(`folders`),[Nt,Ft]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{z&&/^[cv]:/.test(z)?Mt(`categories`):z&&/^[ptf]:/.test(z)&&Mt(`folders`)},[z]);let It=P.length>0||T===`files`||T===`knowledge`&&!!(H.data?.categories.length||k&&H.data?.items.length)||T===`data`&&!!(_t.data&&dn(_t.data).some(e=>e.items.length)),Lt=!!T&&!A&&(T!==`data`&&T!==`knowledge`&&T!==`files`||!It),Rt=T===`results`?2:E?M||Lt?2:1:M===`overview`?2:0,Bt=A?1:w?Math.min(Rt,1):E&&!Lt&&je!==E&&!D?1:0,Xt=Jt(Bt),en=Jt(Rt);(0,Q.useEffect)(()=>{Ne(null),Ze(``)},[E]),(0,Q.useEffect)(()=>{if(w||Bt!==1)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`&&N.current&&(e.preventDefault(),N.current.focus(),N.current.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,Bt]);let tn=T===`skills`?ht.data?.skills.find(e=>`k:${e.id}`===pt)?.name:T===`knowledge`?B?B.label():z?.startsWith(`v:`)?U.data&&`${U.data.category.name}: ${U.data.value}`:z?.startsWith(`c:`)?kt?.name:H.data?.items.find(e=>e.key===z)?.title:_t.data?dn(_t.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;ue([...A?[]:[{label:q(`nav.sources`),to:`/space`}],...E?[]:[{label:q(`space.overview`)}],...j?[{label:j.label,to:j.to}]:[],...k&&W&&H.data?fe(H.data.items,W).map(e=>({label:e.title,to:`/space/knowledge?show=${e.key}`})):[],...j&&(Oe??L??tn)?[{label:Oe??L??tn}]:[]]);let nn={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};ne({...T===`data`||T===`results`?{compact:!0}:{},...T===`data`?{suggestions:[{label:q(`assistant.suggest.dataWhat`)},{label:q(`assistant.suggest.dataWho`)},{label:q(`assistant.suggest.dataEdit`)}]}:T===`results`?{suggestions:[{label:q(`assistant.suggest.resultsFailed`)},{label:q(`assistant.suggest.resultsCost`)},{label:q(`assistant.suggest.resultsShare`)}]}:{},...z&&tn?{open:{kind:nn[z[0]]??`item`,id:z.slice(2),label:tn}}:F&&L?{open:{kind:`wizard`,id:F,label:L}}:{}});let rn=T===`results`||T===`data`||z?_.slice(1):M||_.slice(1),J=(0,Q.useRef)(``);(0,Q.useEffect)(()=>{let e=`${E}#${rn}`;rn&&J.current!==e&&document.getElementById(rn)&&(J.current=e,requestAnimationFrame(()=>Ni(rn,!1)))},[E,rn,y?.id,C.spaceSections,nt.length]),(0,Q.useEffect)(()=>{w||E!==`knowledge`&&E!==`data`&&E!==`skills`||ge().scrollTo({top:0})},[w,E,z,pt]);let an=Mi();if(t===`skills`)return(0,$.jsx)(mt,{to:{pathname:`/skills`,search:g.search,hash:_},replace:!0});if(!E){let e=_.slice(1),n=e?ye(e,C):null;if(n===`knowledge`&&C.spaceSections.some(t=>t.id===e))return(0,$.jsx)(mt,{to:`/space/knowledge?show=s:${e}`,replace:!0});if(n)return(0,$.jsx)(mt,{to:w?`/space/${n}?show=${e}`:{pathname:`/space/${n}`,hash:e},replace:!0});if((e||t)&&C.status!==`ready`)return null;if(t!==void 0)return(0,$.jsx)(mt,{to:`/space`,replace:!0})}let on=T===`info`?M??_.slice(1):``;if(on&&ye(on,C)===`brand`)return(0,$.jsx)(mt,{to:w?`/space/brand?show=${on}`:{pathname:`/space/brand`,hash:on},replace:!0});if(T===`skills`&&!Re)return(0,$.jsx)(mt,{to:`/`,replace:!0});if(T===`knowledge`&&!M&&C.spaceSections.some(e=>e.id===_.slice(1)))return(0,$.jsx)(mt,{to:`/space/knowledge?show=s:${_.slice(1)}`,replace:!0});let Y=e=>{w?d({search:`?show=${e}`}):(J.current=`${E}#${e}`,Ni(e,!0),d({search:``,hash:e},{replace:!0}))},X=e=>{e!==M&&(w?c({show:e}):c(e===`all`?{}:{show:e},{replace:T!==`knowledge`}))},sn=e=>e.flatMap(e=>e.sections).map(e=>C.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(ot,{id:e.id,children:(0,$.jsx)(O,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(we,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),cn=e=>e.flatMap(e=>e.sections).map(e=>C.spaceSections.find(t=>t.id===e.id)).map(e=>e?.status?(0,$.jsx)(we,{of:e,children:(0,$.jsx)(e.status,{})},e.serial):null),ln=w?void 0:it,Z=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kt,{title:tt,open:Bt===1?j??null:null,onBack:A?void 0:()=>w?d(`/space`):Ne(E??null),root:{icon:Se,label:q(`nav.sources`),onOpen:()=>d(w?`/space?show=overview`:`/space`),current:!E}}),w||A?(0,$.jsx)(`div`,{className:K($t(Xt)),children:Bt===0?(0,$.jsx)(Ut,{entries:qe,current:void 0,onPick:()=>Ne(null)}):(0,$.jsx)(`div`,{ref:Te})},Bt):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ut,{entries:qe,current:Bt===0?j:void 0,hide:Bt===1?j?.id:void 0,onPick:()=>{Ne(null),Lt&&j&&(d(j.to),ge().scrollTo({top:0,behavior:`smooth`}))}}),Bt===1?(0,$.jsxs)(`div`,{className:`fade-in-0 slide-in-from-top-1 animate-in duration-200`,children:[(0,$.jsx)(`div`,{className:`mx-2 my-3 h-px bg-border-soft`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(gt,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,$.jsx)(`input`,{ref:N,type:`search`,value:Xe,onChange:e=>Ze(e.target.value),onKeyDown:e=>e.key===`Escape`&&Ze(``),"aria-label":q(`space.menuSearch`),placeholder:q(`space.menuSearch`),className:`h-8 w-full rounded-lg border border-input bg-card pr-14 pl-9 text-[0.8125rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),(0,$.jsx)(`kbd`,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 rounded border border-border-soft px-1 font-sans text-[0.6875rem] text-ink-4`,children:Ai?`⌘F`:`Ctrl F`})]}),(0,$.jsx)(`div`,{ref:Te})]},E):null]})]});return(0,$.jsx)(Wt.Provider,{value:$e,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{ref:at,className:K(`grid gap-6`,T!==`results`&&`md:grid-cols-[var(--menu-w,10.5rem)_minmax(0,1fr)] md:gap-5 lg:grid-cols-[var(--menu-w,15rem)_minmax(0,1fr)] lg:gap-10`),style:st?{"--menu-w":`${st}px`}:void 0,children:[T===`results`?null:(0,$.jsxs)(`div`,{className:`relative min-w-0`,style:!w&&an?{minHeight:an-48}:void 0,children:[(0,$.jsx)(`aside`,{className:K(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,w&&Rt===2&&`hidden`,w&&en===`back`&&$t(`back`)),style:!w&&an?{maxHeight:an-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:Z}),w?null:(0,$.jsx)(Vi,{grid:at,onWidth:ct})]}),E?(0,$.jsxs)(`div`,{className:K(`min-w-0`,w&&Rt<2&&`hidden`,w&&en===`deeper`&&$t(`deeper`)),children:[w&&T!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Zt,{label:j?.label??tt,onBack:()=>d(j?.to??`/space/${E}`)})}):null,T===`data`?(0,$.jsxs)(qt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Qt,{icon:f,label:q(`data.all`),selected:!w&&!z,onPick:()=>X(`all`)})}),_t.data?dn(_t.data).map(e=>(0,$.jsx)(Yt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Qt,{icon:fn[e.kind],label:e.title,selected:!w&&e.key===z,onPick:()=>X(e.key)},e.key))},e.key)):null,(0,$.jsx)(Pi,{groups:P,current:ln,onPick:Y})]}):T===`knowledge`?(0,$.jsxs)(qt,{children:[k&&H.data?(0,$.jsx)(ur,{tab:At,onTab:Mt}):null,k&&H.data&&At===`categories`?(0,$.jsx)(dr,{categories:H.data.categories,picked:w?null:z,pickedCategory:U.data?.category.id??null,readOnly:!!y?.readOnly,onPick:X,onNew:()=>Ft(!0)}):k&&H.data?(0,$.jsx)(me,{spaceId:y.id,items:H.data.items,picked:w?null:V,all:!(w||z),readOnly:!!y?.readOnly,onPick:X,onMove:Ot,onNewFolder:Dt,onMoveTo:Et}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Qt,{icon:f,label:q(`know.all`),selected:!(w||z),onPick:()=>X(`all`)})}),H.data?.categories.length&&!k?(0,$.jsx)(Yt,{label:q(`know.categories`),children:H.data.categories.map(e=>(0,$.jsx)(Qt,{icon:u[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!w&&(z===`c:${e.id}`||U.data?.category.id===e.id),onPick:()=>X(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Pi,{groups:P,current:w?void 0:B?.id,onPick:e=>X(`s:${e}`)})]}):T===`files`&&y?(0,$.jsx)(qt,{children:(0,$.jsx)(Ae,{spaceId:y.id,admin:ze})}):T===`skills`?(0,$.jsxs)(qt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Qt,{icon:f,label:q(`skills.all`),selected:!(w||pt),onPick:()=>X(`all`)}),ht.data?.skills.map(e=>(0,$.jsx)(Qt,{icon:xn[e.mode],label:e.name,selected:!w&&pt===`k:${e.id}`,onPick:()=>X(`k:${e.id}`)},e.id))]}),(0,$.jsx)(Pi,{groups:P,current:ln,onPick:Y})]}):(0,$.jsx)(qt,{children:(0,$.jsx)(Pi,{groups:rt,current:ln,onPick:Y})}),y&&(T===`info`||T===`brand`||T===`knowledge`)?(0,$.jsxs)(ki,{space:y,group:T,top:!z||!!B,children:[T===`knowledge`&&ze?(0,$.jsx)(be,{spaceId:y.id,folder:r.has(`audience`)&&W?.kind===`page`?{id:W.id,title:W.title}:null,onClose:()=>c(M?{show:M}:{},{replace:!0})}):null,T===`knowledge`&&V&&He?(0,$.jsx)(Kn,{spaceId:y.id,kind:V.startsWith(`p:`)?`page`:V.startsWith(`t:`)?`table`:`document`,id:V.slice(2)}):null,T===`knowledge`?V?k&&H.data&&W&&v(W)&&Ct!==V?(0,$.jsx)(le,{spaceId:y.id,data:H.data,folder:W,readOnly:y.readOnly,onOpen:X,onWrite:e=>{wt(e),X(e)},onGone:()=>X(W.parentId?`p:${W.parentId}`:`all`),kinds:yt.kinds,source:yt.ofFolder(W.id)??(W.kept?void 0:yt.sources.find(e=>W.origin===`source:${e.id}`)),status:yt.ofFolder(W.id)?(0,$.jsx)(_e,{spaceId:y.id,sources:yt.sources,only:yt.ofFolder(W.id)?.id}):null},V):V.startsWith(`p:`)?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(pn,{pageId:V.slice(2),onGone:()=>X(`all`),onOpen:X}),k&&H.data&&W?(0,$.jsx)(De,{data:H.data,page:W,onOpen:X}):null]},V):V.startsWith(`t:`)?(0,$.jsx)(hn,{tableId:V.slice(2),onGone:()=>X(`all`)},V):(0,$.jsx)(sr,{spaceId:y.id,fileId:V.slice(2),page:Number(ft)||void 0,readOnly:y.readOnly,onGone:()=>X(`all`)},V):k&&z?.startsWith(`q:`)?(0,$.jsx)(xe,{spaceId:y.id,sourceId:z.slice(2),readOnly:y.readOnly,onOpen:X,onGone:()=>X(`all`)},z):H.data?B?(0,$.jsx)(O,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(we,{of:B,children:(0,$.jsx)(B.component,{})})},z):k&&z?.startsWith(`c:`)?kt?(0,$.jsx)(mr,{spaceId:y.id,data:H.data,category:kt,readOnly:y.readOnly,onOpen:X,onGone:()=>X(`all`)},z):null:k&&z?.startsWith(`v:`)?U.data?(0,$.jsx)(hr,{data:H.data,value:U.data,readOnly:y.readOnly,onOpen:X},z):null:z?.startsWith(`c:`)?kt?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(p,{spaceId:y.id,category:kt,readOnly:y.readOnly,onOpen:X,onGone:()=>X(`all`)}),kt.type===`choice`?null:(0,$.jsx)(x,{spaceId:y.id,category:kt,categories:H.data.categories,onOpen:X})]},z):null:z?.startsWith(`v:`)?U.data?(0,$.jsx)(Me,{value:U.data,readOnly:y.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[U.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:U.data.items.map(e=>(0,$.jsx)(i,{item:e,categories:H.data.categories.filter(e=>e.id!==U.data?.category.id),onOpen:X},e.key))}):null,U.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>X(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(ot,{id:`documents`,children:k?(0,$.jsx)(ie,{spaceId:y.id,data:H.data,readOnly:y.readOnly,onOpen:X,onWrite:e=>{wt(e),X(e)},status:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_e,{spaceId:y.id,sources:yt.sources,onOpen:X}),cn(P)]}),kinds:yt.kinds,adds:C.spaceSections.filter(e=>(e.group??`knowledge`)===`knowledge`&&e.add).map(e=>({id:e.id,label:e.add?.label()??e.label(),hint:e.add?.hint?.(),icon:e.add?.icon??e.icon}))}):(0,$.jsx)(te,{spaceId:y.id,data:H.data,readOnly:y.readOnly,onOpen:X,status:cn(P)})}):null:null,T===`info`||T===`brand`?sn(P):null]},y.id):null,y&&T===`knowledge`&&k&&H.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{spaceId:y.id,kind:xt?.kind??null,parentId:xt?.parentId??null,onClose:()=>St(null),onOpen:X}),(0,$.jsx)(n,{item:Tt,items:H.data.items,onClose:()=>Et(null),onMove:Ot}),(0,$.jsx)(b,{spaceId:y.id,open:Nt,onClose:()=>Ft(!1),onMade:e=>{Ft(!1),X(`c:${e}`)}}),(0,$.jsx)(s,{kind:G===void 0?null:`folder`,spaceId:y.id,parentId:G,onClose:()=>Dt(void 0),onMade:e=>{Dt(void 0),X(e)}})]}):null,y&&T===`clients`&&He?(0,$.jsx)(ot,{id:`clients`,children:(0,$.jsx)(Gn,{space:y})}):null,y&&T===`skills`&&Re?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:pt?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Fi,{skillId:pt.slice(2),onGone:()=>X(`all`),onOpen:X},pt)}):ht.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Sn,{spaceId:y.id,data:ht.data,onOpen:X}),sn(P)]}):ht.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:ht.error.message}):null}):null,y&&T===`page`&&Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(gn,{space:y},y.id),sn(P)]}):null,y&&Pe?(0,$.jsx)(we,{of:Pe,children:(0,$.jsx)(ve,{part:Pe.id,children:(0,$.jsx)(Pe.component,{})},y.id)}):null,y&&T===`files`&&We?(0,$.jsx)(oe,{spaceId:y.id,admin:ze},y.id):null,y&&T===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(hn,{tableId:z.slice(2),onGone:()=>X(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(pn,{pageId:z.slice(2),onGone:()=>X(`all`)},z):z?.startsWith(`d:`)?(0,$.jsx)(qn,{databaseId:z.slice(2),people:_t.data?.databases?.find(e=>`d:${e.id}`===z)?.people??0},z):(0,$.jsxs)($.Fragment,{children:[_t.data?(0,$.jsx)(mn,{spaceId:y.id,data:_t.data,readOnly:y.readOnly,onOpen:X}):null,sn(P)]})}):null,y&&T===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[I.data?(0,$.jsx)(_n,{data:I.data,wizardId:F,onWizard:e=>X(e??`all`),filter:lt,onFilter:ut}):null,I.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:I.error.message}):null,sn(P)]}):null,y||ee?null:(0,$.jsx)(vt,{children:q(`settings.noSpace`)})]}):y&&(!w||M===`overview`)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[w?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Zt,{label:q(`nav.sources`),onBack:()=>d(`/space`)})}):null,(0,$.jsx)(Ar,{space:y,parts:Ke})]}):null]})})})}var Li=`space.menuWidth`,Ri=160,zi=480;function Bi(){let[e,t]=(0,Q.useState)(()=>{try{let e=Number(localStorage.getItem(Li));return e>=Ri&&e<=zi?e:null}catch{return null}});return[e,e=>{t(e);try{e===null?localStorage.removeItem(Li):localStorage.setItem(Li,String(e))}catch{}}]}function Vi({grid:e,onWidth:t}){let[n,r]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{"aria-hidden":!0,onDoubleClick:()=>{e.current?.style.removeProperty(`--menu-w`),t(null)},onPointerDown:n=>{let i=n.currentTarget.parentElement,a=e.current;if(!(i&&a)||n.button!==0)return;n.preventDefault();let o=n.clientX,s=i.getBoundingClientRect().width,c=s;r(!0);let l=e=>{c=Math.round(Math.min(zi,Math.max(Ri,s+e.clientX-o))),a.style.setProperty(`--menu-w`,`${c}px`)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),r(!1),c!==s&&t(c)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},className:`group/resize -right-4 lg:-right-6 absolute inset-y-0 z-10 hidden w-3 cursor-col-resize touch-none md:block`,children:[(0,$.jsx)(`span`,{className:K(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`)}),(0,$.jsxs)(`span`,{className:K(`group/grip sticky top-[calc(50vh-1.5rem)] mx-auto flex h-12 w-3 items-center justify-center transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`),children:[(0,$.jsx)(`span`,{className:K(`block h-10 w-1 rounded-full transition-colors`,n?`bg-ink-2`:`bg-ink-4 group-hover/grip:bg-ink-2`)}),(0,$.jsx)(`span`,{className:K(`pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[0.75rem] text-paper opacity-0 shadow-overlay transition-opacity`,!n&&`group-hover/grip:opacity-100 group-hover/grip:delay-300`),children:q(`space.menuWidth`)})]})]})}export{Ii as SpacePage};
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{An as t,At as n,Bt as r,Ct as i,D as a,Dt as o,Et as s,Fn as c,Ft as l,It as u,J as d,Kn as f,Lt as p,Mt as m,Nt as h,On as g,Ot as _,Pt as v,Qn as y,Rt as b,St as x,Tn as ee,Tt as te,Ut as ne,Vt as re,Zn as S,_t as ie,a as ae,bt as oe,c as se,cr as C,dt as ce,g as w,gt as le,h as ue,ht as de,jt as fe,kn as pe,kt as me,l as he,m as ge,mt as _e,n as ve,o as ye,pn as be,pt as xe,qn as Se,s as Ce,t as we,tr as Te,u as Ee,vt as De,wt as Oe,xt as ke,yt as Ae,zn as je,zt as Me}from"./host-B2ZzDrkc.js";import{C as Ne,S as T,x as Pe,y as Fe}from"./Marketplace-D3hdvrkz.js";import{n as E,t as Ie}from"./scroll-text-DmK2IucJ.js";import{$ as D,A as Le,B as Re,C as O,D as ze,E as Be,F as Ve,Fn as He,H as k,I as Ue,J as We,K as Ge,L as Ke,Nn as qe,O as Je,On as Ye,P as A,R as j,S as M,Sn as Xe,Sr as Ze,T as N,Tn as Qe,U as $e,Un as et,Wn as tt,X as nt,Xn as rt,Y as P,Z as it,Zn as at,_ as ot,_n as st,a as ct,an as F,b as lt,bn as ut,br as dt,cn as I,dn as L,fn as R,fr as ft,g as z,gn as B,h as V,hn as pt,hr as mt,j as ht,jn as gt,k as _t,kt as H,ln as vt,mn as yt,mr as bt,mt as xt,ni as St,on as U,q as W,qn as Ct,sn as wt,sr as Tt,tr as Et,un as G,v as Dt,vn as Ot,w as kt,x as At,xn as K,xr as jt,y as Mt,yn as Nt,yr as Pt}from"./ui-DSgksc1H.js";import{n as Ft,t as It}from"./jsx-runtime-C3cWAN_r.js";import{Rt as Lt,n as Rt,s as q}from"./i18n-Dyi0kvaA.js";import{d as zt,f as Bt,h as Vt,u as Ht}from"./session-EIDP3Wzc.js";import{a as Ut,c as Wt,f as Gt,i as Kt,l as qt,m as Jt,o as Yt,p as Xt,r as Zt,s as Qt,u as $t}from"./UpdateCheck-BEruHgs0.js";import{t as en}from"./useMutation-fT44ij_b.js";import{a as tn,c as nn,d as rn,i as J,l as an,o as on,r as Y,s as X,u as sn}from"./marked.esm-BfGIZK7F.js";import{t as cn}from"./eye-CG1LzvNI.js";import{t as ln}from"./preload-helper-Cj7BV335.js";import{a as un,i as dn,n as fn,o as pn,r as mn,t as hn}from"./TableEditor-CRhc6jI6.js";import{t as gn}from"./index-C1m_S1ls.js";import{n as _n,r as vn,t as yn}from"./Results--mJFsNH2.js";import{c as bn,n as xn,o as Sn}from"./Skills-frfXXEcF.js";import{s as Z,t as Cn}from"./engenty-Cy7MbUxR.js";import{n as wn,r as Tn,t as En}from"./ReadOnly-BFVaKM3w.js";import{t as Dn}from"./link-DyYjkzYx.js";import{A as On}from"./floating-ui.dom-S_FT_s1L.js";import{t as kn}from"./upload-BZThm-R6.js";import{t as An}from"./list-checks-D1zkXlZa.js";import{E as jn}from"./theme-B46aPLtX.js";import{t as Mn}from"./phone-CG7Bz_ZL.js";import{n as Nn}from"./volume-2-Br71vpS5.js";var Pn={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Pn.node;var Fn=rn(Pn),In={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};In.node;var Ln=rn(In),Rn={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`}]]};Rn.node;var zn=rn(Rn),Bn={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`}]]};Bn.node;var Vn=rn(Bn),Hn={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`]};Hn.node;var Un=rn(Hn),Q=e(Ft(),1),$=e(It(),1),Wn=e=>[`open-to-clients`,e];function Gn({space:e}){let t=St(),n=Ze({queryKey:[`space-wizards`,e.id],queryFn:()=>D.get(`/api/studio/spaces/${e.id}/wizards`)}),r=Ze({queryKey:Wn(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/open-to-clients`)}),i=en({mutationFn:t=>D.put(`/api/studio/spaces/${e.id}/open-to-clients`,{kind:`wizard`,...t}),onSettled:()=>t.invalidateQueries({queryKey:Wn(e.id)})}),a=(n.data??[]).filter(e=>e.published),o=new Set(r.data?.open.wizard??[]);return(0,$.jsx)(O,{title:q(`clients.wizards`),hint:q(`clients.wizardsHint`),locked:e.readOnly,children:n.isSuccess&&!a.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`clients.noWizards`)}):(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.title}),(0,$.jsx)(Ot,{checked:o.has(e.id),onChange:t=>i.mutate({id:e.id,open:t}),label:e.title})]},e.id))})})}function Kn({spaceId:e,kind:t,id:n}){let r=St(),i=Ze({queryKey:Wn(e),queryFn:()=>D.get(`/api/studio/spaces/${e}/open-to-clients`)}),a=en({mutationFn:r=>D.put(`/api/studio/spaces/${e}/open-to-clients`,{kind:t,id:n,open:r}),onSettled:()=>r.invalidateQueries({queryKey:Wn(e)})}),o=i.data?.open[t].includes(n)??!1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-ink/5 px-4 py-2.5`,children:[(0,$.jsx)(ee,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-[0.875rem]`,children:q(`clients.openTitle`)}),(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:q(o?`clients.openOn`:`clients.openOff`)})]}),(0,$.jsx)(Ot,{checked:o,disabled:!i.isSuccess||a.isPending,onChange:e=>a.mutate(e),label:q(`clients.openTitle`)})]})}function qn({databaseId:e,people:t}){let n=Ze({queryKey:[`wizard-database`,e],queryFn:()=>D.get(`/api/studio/databases/${e}`)}),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(0),s=n.data?.tables??[],c=r??s[0]?.name??null,l=Ze({queryKey:[`wizard-database`,e,c,a],queryFn:()=>D.get(`/api/studio/databases/${e}/tables/${encodeURIComponent(c??``)}?offset=${a}`),enabled:!!c});if(!n.data)return n.error?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:n.error.message}):(0,$.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,$.jsx)(B,{className:`text-ink-3`})});let u=l.data;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:q(`data.database.title`,{wizard:n.data.title})}),(0,$.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[q(`data.database.hint`),` `,t?q(`data.database.people`,{n:t}):``]})]}),s.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,$.jsx)(`div`,{className:`min-w-48`,children:(0,$.jsx)(pt,{value:c??``,onChange:e=>{i(e),o(0)},options:s.map(e=>({value:e.name,label:`${e.name} · ${q(`data.rows`,{n:e.rows})}`}))})}),c?(0,$.jsx)(`a`,{href:xt(`/api/studio/databases/${e}/tables/${encodeURIComponent(c)}/csv`),download:!0,children:(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,children:[(0,$.jsx)(at,{className:`size-4`}),` `,q(`data.database.csv`)]})}):null]}),(0,$.jsx)(U,{className:`overflow-hidden`,children:u?.rows.length?(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-left text-[0.8125rem]`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-border-soft border-b`,children:u.columns.map(e=>(0,$.jsx)(`th`,{className:`px-3 py-2 font-medium text-ink-3`,children:e},e))})}),(0,$.jsx)(`tbody`,{children:u.rows.map((e,t)=>(0,$.jsx)(`tr`,{className:`border-border-soft border-b last:border-b-0`,children:u.columns.map(t=>(0,$.jsx)(`td`,{className:`max-w-80 truncate px-3 py-2 tabular-nums`,children:e[t]===null||e[t]===void 0?``:String(e[t])},t))},t))})]})}):(0,$.jsx)(vt,{children:l.isPending?q(`common.loading`):q(`data.database.noRows`)})}),u&&u.total>u.rows.length?(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{children:q(`data.database.range`,{from:u.offset+1,to:u.offset+u.rows.length,total:u.total})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,size:`sm`,disabled:u.offset===0,onClick:()=>o(Math.max(0,u.offset-u.rows.length)),children:q(`data.database.previous`)}),(0,$.jsx)(F,{variant:`ghost`,size:`sm`,disabled:u.offset+u.rows.length>=u.total,onClick:()=>o(u.offset+u.rows.length),children:q(`data.database.next`)})]})]}):null]}):(0,$.jsx)(U,{children:(0,$.jsx)(vt,{children:q(`data.database.noTables`)})})]})}var Jn={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Yn({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.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,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:q(o?`space.describing`:`space.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`})}async function Xn(e,t){await ct(q(`space.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Zn({spaceId:e,file:t,small:n}){let r=$e(e,t.id);if(t.thumb&&(t.kind===`asset`||t.kind===`document`))return(0,$.jsx)(`img`,{src:Ge(e,t.id),alt:``,loading:`lazy`,className:`size-full object-cover object-top`});if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:K(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(Qn,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(rt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(X,{className:i}):t.mime===`application/json`?(0,$.jsx)(Ye,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(zn,{className:i}):(0,$.jsx)(Ct,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function Qn({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.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,$.jsx)(`div`,{className:K(`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 $n=`application/x-wizards-logo`;function er({spaceId: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):Xn(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData($n,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,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(wt,{tone:`ember`,children:q(`space.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Jn:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${q(`space.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(Zn,{spaceId:e,file:n})}):(0,$.jsx)(Zn,{spaceId:e,file:n}),(0,$.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,$.jsx)(G,{label:q(`space.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(cn,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(G,{label:q(`space.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(T,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(lt,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(Yn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(Dt,{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,$.jsx)(B,{className:`size-5`}):(0,$.jsx)(J,{className:`size-5`}),a]}):null]})}function tr({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(q(e===`logo`?`space.logoNoneFound`:`space.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,$.jsx)(I,{open:!0,onClose:r,wide:u?!0:void 0,title:q(u?e===`logo`?`space.logoFound`:`space.assetFound`:e===`logo`?`space.logoFromUrl`:`space.assetFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(e===`logo`?`space.logoFoundHint`:`space.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:K(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Jn,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:K(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(sn,{className:`size-3.5`})}):null]},t.url)})}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>d(null),children:q(`run.back`)}),(0,$.jsx)(F,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?q(`space.addMany`,{n:f.length}):q(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.logoUrl`)}),(0,$.jsx)(L,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(e===`logo`?`space.logoUrlHint`:`space.assetUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,busy:o,disabled:!i.trim(),children:q(`run.next`)})]})]})})}var nr=(0,Q.lazy)(()=>ln(()=>import(`./viewers-DvA5VsXw.js`).then(e=>({default:e.Viewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function rr(e,t,n){return Ze({queryKey:[`space-file-text`,t.id,t.chars,n],queryFn:()=>D.get(`/api/studio/spaces/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function ir(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var ar=e=>[ir(e),e.pages?q(`space.pages`,{n:e.pages}):null,Lt(e.size)].filter(Boolean).join(` · `),or=2e5;function sr({spaceId:e,fileId:t,readOnly:n,onGone:r,page:i}){let a=St(),s=nt(e),c=o(e),l=We(e,n),u=s.data?.files.find(e=>e.id===t),d=Fe(`knowledgeTree`),f=u?ke(u.mime,u.name):null,p=u?d?f!==null:u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[m,h]=(0,Q.useState)(null);if(!u)return s.isLoading?(0,$.jsx)(B,{className:`mx-auto text-ink-3`}):null;let g=m??(p?`original`:`text`),_=c.data?.items.find(e=>e.key===`f:${u.id}`),v=$e(e,u.id),y=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":g===e,onClick:()=>h(e),className:K(`rounded-full px-3 py-1 text-[0.8125rem] transition`,g===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:ar(u)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":q(`space.openOriginal`),title:q(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(nn,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:q(`space.reindex`),onClick:async()=>{await l.reindex(u.id),await a.invalidateQueries({queryKey:it.knowledge(e)})},children:(0,$.jsx)(qe,{className:`size-4`})}),(0,$.jsx)(G,{label:q(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{await ct(q(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await a.invalidateQueries({queryKey:it.knowledge(e)}),r())},children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(Oe,{spaceId:e,itemKey:`f:${u.id}`,has:_?.categories??[],originLabel:_?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Yn,{file:u,actions:l})}),u.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,$.jsxs)(U,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[p?y(`original`,q(`space.original`)):null,y(`text`,q(`space.readText`))]}),g===`original`&&d&&f?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(B,{})}),children:(0,$.jsx)(nr,{kind:f,url:v,name:u.name,page:i})}):g===`original`?u.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(cr,{spaceId:e,file:u})]})]})}function cr({spaceId:e,file:t}){let n=rr(e,t,or);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(B,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(H,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:q(`space.textCut`,{shown:n.data.text.length.toLocaleString(Rt),total:n.data.chars.toLocaleString(Rt)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:q(`space.noText`)})}var lr=8;function ur({tab:e,onTab:t}){let n=(n,r)=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:K(`flex-1 rounded-md px-2 py-1 text-[0.8125rem] transition`,e===n?`bg-card font-medium text-ink shadow-soft`:`text-ink-2 hover:text-ink`),children:r});return(0,$.jsxs)(`div`,{role:`tablist`,className:`mb-2 flex gap-0.5 rounded-lg bg-paper-2 p-0.5`,children:[n(`folders`,q(`know.tabFolders`)),n(`categories`,q(`know.tabCategories`))]})}function dr({categories:e,picked:t,pickedCategory:n,readOnly:r,onPick:i,onNew:a}){let{filter:o}=Xt(),[s,c]=(0,Q.useState)(()=>new Set);(0,Q.useEffect)(()=>{n&&c(e=>e.has(n)?e:new Set([...e,n]))},[n]);let l=e=>c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(!e.length)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-1`,children:[(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:q(`know.categoriesEmpty`)}),r?null:(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,className:`self-start`,onClick:a,children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`know.category`)]})]});let d=e=>K(`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-2 text-left text-[0.875rem]`,e?`font-medium text-ink`:`text-ink-2 group-hover/row:text-ink`),f=o?e.filter(e=>e.name.toLowerCase().includes(o)||e.values.some(e=>e.value.toLowerCase().includes(o))):e;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:f.map(e=>{let r=u[e.type],a=o?e.values.filter(e=>e.value.toLowerCase().includes(o)):e.values,c=s.has(e.id)||!!(o&&a.length),f=t===`c:${e.id}`||!c&&n===e.id&&t!==null;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:K(`group/row flex items-center rounded-lg transition`,f?`bg-paper-2`:`hover:bg-accent`),children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:a.length?0:-1,"aria-label":q(c?`know.collapse`:`know.expand`),"aria-expanded":a.length?c:void 0,onClick:()=>a.length&&l(e.id),className:K(`grid size-6 shrink-0 place-items-center rounded-md text-ink-4`,a.length?`hover:text-ink`:`invisible`),children:(0,$.jsx)(Et,{className:K(`size-3.5 transition-transform`,c&&`rotate-90`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),"aria-current":f?`page`:void 0,className:d(f),children:[(0,$.jsx)(r,{className:K(`size-4 shrink-0`,f?`text-ember-strong`:`text-ink-3`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.proposed?(0,$.jsx)(wt,{tone:`ember`,children:q(`know.proposed`)}):(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})]}),c&&a.length?(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5 pt-0.5`,children:[a.slice(0,o?void 0:lr).map(e=>{let n=t===`v:${e.id}`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),"aria-current":n?`page`:void 0,className:K(`flex w-full items-center gap-2 rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.875rem] transition`,n?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.value}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})},e.id)}),!o&&a.length>lr?(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),className:`w-full rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:q(`know.moreValues`,{n:a.length-lr})})}):null]}):null]},e.id)})}),r?null:(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`mt-2 flex items-center gap-2 rounded-lg px-1 py-1.5 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center`,children:(0,$.jsx)(J,{className:`size-4`})}),q(`know.category`)]})]})}function fr({onEdit:e,onDelete:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null);w(i,n,()=>r(!1));let a=`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink`,o=e=>()=>{r(!1),e()};return(0,$.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,$.jsx)(G,{label:q(`know.more`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`size-8`,children:(0,$.jsx)(E,{className:`size-4`})}),n?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,onClick:o(e),children:[(0,$.jsx)(He,{className:`size-4 shrink-0`}),` `,q(`know.edit`)]}),(0,$.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:K(a,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:o(t),children:[(0,$.jsx)(Y,{className:`size-4 shrink-0`}),` `,q(`know.deleteCategory`)]})]}):null]})}function pr({eyebrow:e,title:n,line:r,action:i}){return(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(t,{className:`size-3.5`}),` `,e]}),(0,$.jsx)(`h2`,{className:`mt-0.5 font-display font-semibold text-lg leading-tight`,children:n}),r?(0,$.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3`,children:r}):null]}),i?(0,$.jsx)(`div`,{className:`shrink-0`,children:i}):null]})}function mr({spaceId:e,data:t,category:n,readOnly:i,onOpen:a,onGone:o}){let s=St(),[c,l]=(0,Q.useState)(!1),d=en({mutationFn:e=>e(),onSuccess:()=>s.invalidateQueries({queryKey:it.knowledge(e)})}),f=u[n.type];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(pr,{eyebrow:q(`know.type.${n.type}`),title:n.name,line:[r(n.count),n.unit,n.hint].filter(Boolean).join(` · `),action:i?null:(0,$.jsx)(fr,{onEdit:()=>l(!0),onDelete:async()=>await ct(q(`know.confirmCategory`,{name:n.name}))&&d.mutate(async()=>{await D.del(`/api/studio/categories/${n.id}`),o()})})}),n.proposed&&!i?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl bg-ember-tint px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:q(`know.proposedHint`)}),(0,$.jsx)(F,{size:`sm`,variant:`secondary`,onClick:()=>d.mutate(()=>D.del(`/api/studio/categories/${n.id}`)),children:q(`know.dismiss`)}),(0,$.jsx)(F,{size:`sm`,onClick:()=>d.mutate(()=>D.patch(`/api/studio/categories/${n.id}`,{proposed:!1})),children:q(`know.accept`)})]}):null,n.type===`choice`?(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.values.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(`v:${e.id}`),className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3.5 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(f,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e.value})]}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[r(e.count),e.summary?q(`know.summary`):``].filter(Boolean).join(` · `)})]},e.id))}):(0,$.jsx)(x,{spaceId:e,category:n,categories:t.categories,onOpen:a}),d.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,$.jsx)(I,{open:c,onClose:()=>l(!1),wide:!0,children:(0,$.jsx)(p,{spaceId:e,category:n,readOnly:i,onOpen:e=>{l(!1),a(e)},onGone:()=>{l(!1),o()}})})]})}function hr({data:e,value:t,readOnly:n,onOpen:i}){let a=t.rows.reduce((e,t)=>e+t.count,0);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(pr,{eyebrow:t.category.name,title:t.value,line:[r(t.items.length),...t.rows.map(e=>q(`know.tocRows`,{n:e.count,table:e.title}))].filter(Boolean).join(` · `)}),(0,$.jsx)(Me,{value:t,readOnly:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.items.length?(0,$.jsx)(_,{items:t.items,categories:e.categories.filter(e=>e.id!==t.category.id),onOpen:i}):null,a?t.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId)):null]})})]})}var gr={info:`bg-cobalt-tint`,brand:`bg-violet-500/10`,knowledge:`bg-moss-tint`,data:`bg-amber-tint`,page:`bg-ember-tint`},_r=`var(--color-paper)`,vr=`var(--color-paper-3)`,yr={fill:`#000`,opacity:.12};function br({kind:e,x:t,y:n,size:r=92}){let i=r/120;return(0,$.jsx)(`g`,{transform:`translate(${t-60*i} ${n-106*i})`,children:(0,$.jsx)(Cn,{kind:e,size:r})})}function xr({cx:e,cy:t,rx:n}){return(0,$.jsx)(`ellipse`,{cx:e,cy:t,rx:n,ry:5,...yr})}function Sr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:196,cy:142,rx:48}),(0,$.jsx)(`path`,{d:`M180 30 L196 54 L212 30`,fill:`none`,stroke:Z.ember,strokeWidth:6,strokeLinecap:`round`}),(0,$.jsxs)(`g`,{transform:`rotate(6 196 96)`,children:[(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:92,rx:14,fill:_r}),(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:24,rx:14,fill:Z.ember}),(0,$.jsx)(`rect`,{x:150,y:62,width:92,height:12,fill:Z.ember}),(0,$.jsx)(`rect`,{x:188,y:44,width:16,height:12,rx:4,fill:Z.slate}),(0,$.jsx)(`circle`,{cx:174,cy:98,r:14,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:176,cy:96,r:4.5,fill:`#fff`}),(0,$.jsx)(`circle`,{cx:177,cy:96,r:2.2,fill:`#1d1b19`}),(0,$.jsx)(`rect`,{x:196,y:88,width:34,height:8,rx:4,fill:Z.slate}),(0,$.jsx)(`rect`,{x:196,y:102,width:24,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:162,y:122,width:68,height:6,rx:3,fill:vr})]}),(0,$.jsx)(br,{kind:`round`,x:98,y:144,size:124})]})}function Cr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:200,cy:142,rx:56}),(0,$.jsx)(`path`,{d:`M150 98c0-30 26-52 58-52s50 18 50 40c0 14-10 20-22 18-10-2-16 4-14 14 3 14-6 24-24 24-28 0-48-18-48-44z`,fill:_r}),(0,$.jsx)(`circle`,{cx:180,cy:78,r:10,fill:Z.rose}),(0,$.jsx)(`circle`,{cx:208,cy:64,r:10,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:234,cy:76,r:9,fill:Z.moss}),(0,$.jsx)(`circle`,{cx:172,cy:108,r:10,fill:Z.cobalt}),(0,$.jsx)(`circle`,{cx:204,cy:124,r:6,fill:`var(--color-paper-2)`}),(0,$.jsxs)(`g`,{transform:`rotate(-38 236 112)`,children:[(0,$.jsx)(`rect`,{x:230,y:64,width:12,height:62,rx:6,fill:Z.slate}),(0,$.jsx)(`rect`,{x:229,y:58,width:14,height:12,rx:3,fill:`#c9c3bb`}),(0,$.jsx)(`path`,{d:`M230 58c0-14 6-22 6-22s6 8 6 22z`,fill:Z.violet})]}),(0,$.jsx)(br,{kind:`tower`,x:100,y:144,size:124})]})}function wr(){let e=(e,t,n,r=0)=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:128+r,y:e,width:t,height:20,rx:4,fill:n}),(0,$.jsx)(`rect`,{x:128+r+t-18,y:e+4,width:14,height:12,rx:2,fill:_r,opacity:.9})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:190,cy:142,rx:68}),e(120,124,Z.cobalt),e(100,112,Z.rose,8),e(80,118,Z.amber,2),(0,$.jsx)(br,{kind:`dome`,x:188,y:84,size:100}),(0,$.jsxs)(`g`,{transform:`rotate(-8 82 66)`,children:[(0,$.jsx)(`path`,{d:`M50 62c12-8 24-8 32 0v34c-8-8-20-8-32 0z`,fill:_r}),(0,$.jsx)(`path`,{d:`M114 62c-12-8-24-8-32 0v34c8-8 20-8 32 0z`,fill:_r}),(0,$.jsx)(`path`,{d:`M82 62v34`,stroke:vr,strokeWidth:2}),(0,$.jsx)(`rect`,{x:56,y:70,width:18,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:56,y:78,width:14,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:90,y:70,width:18,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:90,y:78,width:12,height:4,rx:2,fill:vr})]}),(0,$.jsx)(`circle`,{cx:46,cy:40,r:4,fill:Z.moss,opacity:.6}),(0,$.jsx)(`circle`,{cx:120,cy:34,r:3,fill:Z.amber,opacity:.7})]})}function Tr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:200,cy:142,rx:58}),(0,$.jsx)(`rect`,{x:158,y:50,width:52,height:40,rx:6,fill:_r,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:176,y:44,width:52,height:44,rx:6,fill:_r,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:168,y:56,width:22,height:6,rx:3,fill:Z.teal,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:186,y:52,width:26,height:6,rx:3,fill:Z.violet,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:68,rx:12,fill:Z.amber}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:14,rx:7,fill:`#000`,opacity:.08}),(0,$.jsx)(`rect`,{x:184,y:104,width:32,height:10,rx:5,fill:`#000`,opacity:.14}),(0,$.jsxs)(`g`,{transform:`rotate(-14 112 40)`,children:[(0,$.jsx)(`rect`,{x:94,y:26,width:40,height:28,rx:5,fill:_r}),(0,$.jsx)(`rect`,{x:100,y:34,width:22,height:5,rx:2.5,fill:Z.ember}),(0,$.jsx)(`rect`,{x:100,y:43,width:14,height:4,rx:2,fill:vr})]}),(0,$.jsx)(br,{kind:`bean`,x:90,y:144,size:120})]})}function Er(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:196,cy:142,rx:60}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:106,rx:14,fill:_r}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:20,rx:10,fill:`var(--color-paper-2)`}),(0,$.jsx)(`circle`,{cx:150,cy:40,r:3.5,fill:Z.rose}),(0,$.jsx)(`circle`,{cx:161,cy:40,r:3.5,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:172,cy:40,r:3.5,fill:Z.moss}),(0,$.jsx)(`rect`,{x:150,y:62,width:56,height:10,rx:5,fill:Z.ember}),(0,$.jsx)(`rect`,{x:150,y:80,width:70,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:150,y:92,width:48,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:150,y:108,width:40,height:14,rx:7,fill:Z.cobalt}),(0,$.jsx)(`circle`,{cx:232,cy:102,r:16,fill:Z.teal,opacity:.85}),(0,$.jsx)(br,{kind:`sprout`,x:96,y:144,size:120})]})}var Dr={info:Sr,brand:Cr,knowledge:wr,data:Tr,page:Er};function Or({id:e,icon:t,className:n}){let r=Dr[e];return(0,$.jsx)(`span`,{"aria-hidden":!0,className:K(`relative block h-36 overflow-hidden`,gr[e]??`bg-paper-2`,n),children:r?(0,$.jsx)(`svg`,{viewBox:`20 10 280 140`,className:`absolute inset-0 h-full w-full`,preserveAspectRatio:`xMidYMax meet`,overflow:`visible`,children:(0,$.jsx)(r,{})}):(0,$.jsx)(`span`,{className:`absolute inset-0 grid place-items-center text-ink-3`,children:(0,$.jsx)(`span`,{className:`grid size-16 place-items-center rounded-2xl bg-paper shadow-soft`,children:(0,$.jsx)(t,{className:`size-8`})})})})}var kr={info:`space.teaser.info`,brand:`space.teaser.brand`,knowledge:`space.teaser.knowledge`,data:`space.teaser.data`,page:`space.teaser.page`};function Ar({space:e,parts:t}){let n=dt(),r=nt(e.id),i=o(e.id),a=un(e.id);ne({title:q(`space.overviewAssistantTitle`),hello:q(`space.overviewAssistantHello`),suggestions:[{label:q(`assistant.suggest.missing`)},{label:q(`assistant.suggest.readSite`),fill:!0}]});let s=r.data?.files.filter(e=>e.kind===`logo`)??[],c=s.length,l=e.brand.colors?.length??0,u=i.data?.items.length??0,f=i.data?.categories.length??0,p=a.data?.tables.length??0,m=a.data?.pages.length??0,h=t=>{let n=(...e)=>e.filter(Boolean).join(` · `);switch(t){case`info`:{let t=!!e.brand.name?.trim();return{text:n(!t&&q(`space.status.noTitle`),e.facts.length>0&&q(`space.status.facts`,{n:e.facts.length}))||q(`space.status.empty`),filled:t}}case`brand`:return r.isPending?null:{text:n(c>0&&q(`space.status.logos`,{n:c}),l>0&&q(`space.status.colors`,{n:l}))||q(`space.status.empty`),filled:c+l>0};case`knowledge`:return i.isPending?null:{text:n(u>0&&q(`space.status.entries`,{n:u}),f>0&&q(`space.status.categories`,{n:f}))||q(`space.status.empty`),filled:u>0};case`data`:return a.isPending?null:{text:n(p>0&&q(`space.status.tables`,{n:p}),m>0&&q(`space.pages`,{n:m}))||q(`space.status.empty`),filled:p+m>0};default:return null}},g=t=>{let n=`flex min-w-0 items-center gap-2 text-[0.8125rem] text-ink-2`;switch(t){case`info`:return e.brand.name?.trim()||e.facts.length?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.brand.name?.trim()?(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.name}):null,e.facts.slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-ink-3`,children:e.label}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.value})]},e.key))]}):null;case`brand`:return c+l||e.brand.tagline?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.brand.brandName||e.brand.tagline?(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.brandName||e.brand.name}),e.brand.tagline?(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-3 italic`,children:e.brand.tagline}):null]}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[s.slice(0,3).map(t=>(0,$.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center overflow-hidden rounded-lg bg-paper ring-1 ring-border-soft`,children:(0,$.jsx)(Zn,{spaceId:e.id,file:t,small:!0})},t.id)),(0,$.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:(e.brand.colors??[]).slice(0,8).map(e=>(0,$.jsx)(`span`,{title:`${e.name} ${e.value}`,className:`size-5 rounded-full ring-1 ring-border-soft`,style:{background:e.value}},`${e.name}${e.value}`))})]})]}):null;case`knowledge`:return u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i.data?.items.slice(0,3).map(e=>{let t=e.kind===`page`?X:e.kind===`table`?Qe:on;return(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.key)}),f?(0,$.jsx)(`span`,{className:`mt-1 flex flex-wrap gap-1`,children:i.data?.categories.slice(0,4).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-paper-2 px-2 py-0.5 text-[0.75rem] text-ink-3`,children:e.name},e.id))}):null]}):null;case`data`:return p+m?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:[...(a.data?.tables??[]).map(e=>({key:`t:${e.id}`,title:e.title,rows:e.rows,Icon:Qe})),...(a.data?.pages??[]).map(e=>({key:`p:${e.id}`,title:e.title,rows:null,Icon:X}))].slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(e.Icon,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.rows===null?null:(0,$.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:e.rows})]},e.key))}):null;default:return null}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(d,{}),(0,$.jsx)(O,{title:q(`nav.sources`),hint:q(`space.overviewHint`),plain:!0,children:(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:t.map(e=>{let t=h(e.id),r=kr[e.id];return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.to),className:`group flex min-w-0 flex-col overflow-hidden rounded-2xl bg-card text-left shadow-soft ring-1 ring-border-soft transition hover:-translate-y-0.5 hover:ring-border motion-reduce:transition-none motion-reduce:hover:translate-y-0`,children:[(0,$.jsx)(Or,{id:e.id,icon:e.icon}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-2 p-4`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1.0625rem]`,children:e.label}),(0,$.jsx)(Et,{className:`size-4 text-ink-4 transition group-hover:translate-x-0.5 group-hover:text-ink-3`})]}),r?(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:q(r)}):null,g(e.id)?(0,$.jsx)(`span`,{className:`block rounded-lg bg-paper-2/50 p-3`,children:g(e.id)}):null,t?(0,$.jsx)(`span`,{className:`mt-auto pt-1`,children:(0,$.jsx)(wt,{tone:t.filled?`live`:`warn`,children:t.text})}):null]})]},e.id)})})})]})}var jr=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mr=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),Lt(e.size)].filter(Boolean).join(` · `);function Nr({spaceId:e,file:t,actions:n,onClose:r}){let i=$e(e,t.id);return(0,$.jsxs)(I,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mr(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":q(`space.openOriginal`),title:q(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(nn,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Jn,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Yn,{file:t,actions:n})})]})}function Pr({spaceId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${q(`space.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(Zn,{spaceId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.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,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mr(t)})]}),(0,$.jsx)(Yn,{file:t,actions:n})]}),(0,$.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,$.jsx)(G,{label:q(`space.preview`),onClick:i,children:(0,$.jsx)(cn,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(lt,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]})}function Fr({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(I,{open:!0,onClose:r,title:q(e?`space.assetSectionRename`:`space.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.assetSectionName`)}),(0,$.jsx)(L,{autoFocus:!0,value:i,maxLength:80,placeholder:q(`space.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(F,{variant:`danger`,onClick:n,children:q(`space.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(F,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,disabled:!i.trim(),children:q(e?`settings.save`:`space.add`)})]})]})})}function Ir({spaceId:e,data:t,readOnly:n,sections:r,save:i}){let a=We(e,n),[o,s]=P(`assets`,`cards`),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(r),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),ee=W({assetSections:p},i),te=t.files.filter(e=>e.kind===`asset`),ne=new Map(te.map(e=>[e.id,e])),re=new Set(p.flatMap(e=>e.assets)),S=p.find(e=>e.id===h)??null,ie=S?S.assets.map(e=>ne.get(e)).filter(e=>!!e):te.filter(e=>!re.has(e.id)),ae=te.find(e=>e.id===u),oe=c.trim().toLowerCase(),se=oe?ie.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(oe)):ie,C=(e,t)=>m(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ce=async e=>{let t=S?.id??null;for(let n of await a.upload(`asset`,e))C(n.id,t)},w=async e=>{await ct(q(`space.removeConfirm`,{name:e.name}))&&(a.remove(e.id),C(e.id,null))},le=p.length?{options:[{value:``,label:q(`space.assetsGeneral`)},...p.map(e=>({value:e.id,label:e.title||q(`space.sectionUntitled`)}))],current:e=>p.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>C(e.id,t||null)}:void 0,ue=[{label:q(`space.assetUpload`),icon:(0,$.jsx)(kn,{className:`size-4 shrink-0`}),onPick:()=>x.current?.click()},{label:q(`space.assetFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>b(!0)},...p.length<A.logoSections?[{label:q(`space.assetSectionAdd`),icon:(0,$.jsx)(Te,{className:`size-4 shrink-0`}),onPick:()=>v(`new`)}]:[]],de=p.length||te.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[p.length?(0,$.jsx)(Nt,{value:h,onChange:e=>{g(e),l(``)},label:q(`space.assets`),options:[{id:``,label:q(`space.assetsGeneral`)},...p.map(e=>({id:e.id,label:e.title||q(`space.sectionUntitled`)}))]}):null,S&&!n?(0,$.jsx)(G,{label:q(`space.assetSectionRename`),onClick:()=>v(`current`),children:(0,$.jsx)(He,{className:`size-4`})}):null]}),ie.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(M,{value:c,onChange:l,placeholder:q(`space.assetSearch`)})}),(0,$.jsx)(G,{label:q(o===`list`?`space.viewCards`:`space.viewList`),onClick:s,children:o===`list`?(0,$.jsx)(f,{className:`size-4`}):(0,$.jsx)(On,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(O,{title:q(`space.assets`),hint:q(`space.assetsHint`),save:ee,tabs:de,action:n?null:(0,$.jsx)(V,{entries:ue}),children:[(0,$.jsx)(`input`,{ref:x,type:`file`,multiple:!0,accept:jr,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ce(t)}}),se.length?o===`cards`?(0,$.jsx)(er,{spaceId:e,kind:`asset`,files:se,actions:a,moveTo:le,onRemove:w,onPreview:e=>d(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:se.map(t=>(0,$.jsx)(Pr,{spaceId:e,file:t,actions:a,moveTo:le,onPreview:()=>d(t.id),onRemove:()=>w(t)},t.id))}):ie.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`space.staysLocal`)}):(0,$.jsxs)(Dt,{accept:jr,onFiles:e=>void ce(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(B,{className:`size-4`}):(0,$.jsx)(kn,{className:`size-4`}),q(`space.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:q(`space.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,ae?(0,$.jsx)(Nr,{spaceId:e,file:ae,actions:a,onClose:()=>d(null)}):null,_?(0,$.jsx)(Fr,{section:_===`current`?S:null,onClose:()=>v(null),onSave:e=>{if(_===`current`&&S)m(t=>t.map(t=>t.id===S.id?{...t,title:e}:t));else{let t=N();m(n=>[...n,{id:t,title:e,assets:[]}]),g(t)}},onRemove:_===`current`&&S?async()=>{(!S.assets.length||await ct(q(`space.assetSectionRemoveConfirm`,{name:S.title})))&&(m(e=>e.filter(e=>e.id!==S.id)),g(``),v(null))}:void 0}):null,y?(0,$.jsx)(tr,{kind:`asset`,onClose:()=>b(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)C(t.id,S?.id??null)}}):null]})}var Lr=/^#[0-9a-fA-F]{6}$/;async function Rr(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 zr={linear:`space.gradientLinear`,radial:`space.gradientRadial`,conic:`space.gradientConic`};function Br({spaceId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(j(t)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!n),b=e=>{s(e),l(j(e)),d(!1)},x=(e,t)=>b({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),ee=e=>{let t=[...o.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));b({...o,stops:[...o.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},te=async()=>{h(!0),_(null);try{let{gradient:t}=await D.post(`/api/studio/spaces/${e}/gradients/describe`,{text:f.trim(),...v?{gradient:{name:o.name,type:o.type,angle:o.angle,stops:o.stops}}:{}});b({...o,...t,name:o.name.trim()?o.name:t.name}),p(``),y(!0)}catch(e){_(e.message)}h(!1)};return(0,$.jsx)(I,{open:!0,onClose:a,wide:!0,title:q(n?`space.gradientNew`:`space.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f.trim()&&!m&&te()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{"data-autofocus":n||void 0,value:f,maxLength:1e3,"aria-label":q(`space.gradientDescribe`),placeholder:q(v?`space.gradientDescribeChange`:`space.gradientDescribeNew`),onChange:e=>p(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(F,{type:`submit`,variant:`secondary`,busy:m,disabled:!f.trim(),children:[(0,$.jsx)(Ye,{className:`size-4`}),q(v?`space.gradientDescribeApply`:`space.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,g?`text-rose`:`text-ink-3`),children:g??q(`space.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:j(o)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.gradientName`)}),(0,$.jsx)(L,{value:o.name,maxLength:80,placeholder:q(`space.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.fillUseLabel`)}),(0,$.jsx)(L,{value:o.description??``,maxLength:400,placeholder:q(`space.gradientUse`),onChange:e=>s({...o,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:ht.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>b({...o,type:e}),className:K(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,o.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(zr[e])},e))})]}),o.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(R,{children:q(`space.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:o.angle,"aria-label":q(`space.gradientAngle`),onChange:e=>b({...o,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(o.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(st,{value:Lr.test(e.color)?e.color:`#888888`,onChange:e=>x(t,{color:e.target.value})}),(0,$.jsx)(L,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Lr.test(n)&&x(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":q(`space.gradientAt`),onChange:e=>x(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(G,{label:q(`space.remove`),disabled:o.stops.length<=2,onClick:()=>b({...o,stops:o.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>ee(),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.gradientStopAdd`)]}):null,r.length&&o.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:q(`space.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>ee(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:`CSS`}),(0,$.jsx)(L,{value:c,spellCheck:!1,onChange:e=>{l(e.target.value);let t=k(e.target.value);d(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,u?`text-rose`:`text-ink-3`),children:q(u?`space.gradientCssError`:`space.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:a,children:q(`common.cancel`)}),(0,$.jsx)(F,{onClick:()=>{i(o),a()},children:q(`settings.save`)})]})]})})}var Vr=`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`,Hr=`size-8 bg-card shadow-soft hover:bg-card`;function Ur({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(Mt,{value:e,label:q(`space.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(Mt,{value:n??``,label:q(`space.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wr({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=j(e),[o,s]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":q(`space.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:Vr,children:[(0,$.jsx)(G,{label:q(o?`space.gradientCopied`:`space.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Hr,children:(0,$.jsx)(an,{className:`size-4`})}),(0,$.jsx)(G,{label:q(`space.download`),onClick:()=>void Rr(e,e.name),className:Hr,children:(0,$.jsx)(at,{className:`size-4`})}),t?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:i,className:K(Hr,`hover:text-rose`),children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(Ur,{name:e.name,namePlaceholder:q(`space.gradientName`),description:e.description,usePlaceholder:q(`space.gradientUse`),readOnly:t,onChange:r})]})}function Gr(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kr({spaceId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=$e(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":q(`space.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gr(s,t.tile)}),(0,$.jsxs)(`div`,{className:Vr,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":q(`space.download`),title:q(`space.download`),className:K(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hr),children:(0,$.jsx)(at,{className:`size-4`})}),r?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:o,className:K(Hr,`hover:text-rose`),children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(Ur,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:q(`space.patternUse`),readOnly:r,onChange:a})]})}function qr({spaceId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Q.useState)(t),[f,p]=(0,Q.useState)([]),m=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},h=()=>{for(let e of f)s(e);l()};return(0,$.jsx)(I,{open:!0,onClose:h,wide:!0,title:q(n?`space.patternNew`:`space.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gr($e(e,u.file),u.tile),children:(0,$.jsxs)(Dt,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(B,{className:`size-4`}):(0,$.jsx)(tn,{className:`size-4`}),q(`space.patternReplace`)]})}):(0,$.jsxs)(Dt,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(B,{className:`size-5`}):(0,$.jsx)(tn,{className:`size-5`}),q(`space.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.patternName`)}),(0,$.jsx)(L,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):q(`space.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.fillUseLabel`)}),(0,$.jsx)(L,{value:u.description??``,maxLength:400,placeholder:q(`space.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.patternShow`)}),(0,$.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,$.jsx)(`button`,{type:`button`,"aria-pressed":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:K(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(e?`space.patternTile`:`space.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:h,children:q(`common.cancel`)}),(0,$.jsx)(F,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:q(n?`space.add`:`settings.save`)})]})]})})}var Jr=/^#[0-9a-fA-F]{6}$/;function Yr({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await D.post(`/api/studio/spaces/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(q(`space.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(I,{open:!0,onClose:n,wide:l?!0:void 0,title:q(l?`space.colorsFound`:`space.colorsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`space.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:K(`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,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(sn,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:q(`run.back`)}),(0,$.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?q(`space.addMany`,{n:d.length}):q(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.logoUrl`)}),(0,$.jsx)(L,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.colorsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function Xr({spaceId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,save:s,readOnly:c}){let[l,u]=(0,Q.useState)(()=>n.map(e=>({...e,id:N()}))),[d,f]=(0,Q.useState)(r),[p,m]=(0,Q.useState)(i),[h,g]=(0,Q.useState)(a),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),x=We(e,c),ee=Be(o),[te,ne]=(0,Q.useState)(null),[re,S]=(0,Q.useState)(null),[ie,ae]=(0,Q.useState)(!1),oe=W({colors:l.filter(e=>Jr.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:d,gradients:p,patterns:h,colorRules:ee.rules},s),se=d.filter(e=>(e.kind??`colors`)===`colors`),C=e=>se.some(t=>t.id===e.section),ce=l.filter(e=>!C(e)),w=(ce[0]??l[0])?.id,le=(e,t)=>u(n=>n.map(n=>n.id===e?{...n,...t}:n)),ue=e=>u(t=>[...t,...e.map(e=>({...e,id:N()}))].slice(0,A.colors)),de=[{value:``,label:q(`space.sectionStandard`)},...se.map(e=>({value:e.id,label:e.title||q(`space.sectionUntitled`)}))],fe=(e,t)=>{let n=N();ne(n),f(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},pe=e=>({id:N(),name:``,section:e,type:`linear`,angle:90,stops:[{color:l[0]?.value&&Jr.test(l[0].value)?l[0].value:`#4b73ff`,at:0},{color:l[1]?.value&&Jr.test(l[1].value)?l[1].value:`#ff6d1b`,at:100}]}),me=e=>t.files.find(t=>t.id===e)?.name??`pattern`,he=[...l.length<A.colors?[{label:q(`space.colorNew`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>_e()},{label:q(`space.colorsFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>ae(!0)}]:[],...d.length<A.logoSections?[{label:q(`space.colorSectionAdd`),icon:(0,$.jsx)(Te,{className:`size-4 shrink-0`}),onPick:()=>fe(`colors`,``)},{label:q(`space.gradientSectionAdd`),icon:(0,$.jsx)(Ln,{className:`size-4 shrink-0`}),onPick:()=>fe(`gradients`,q(`space.gradientSectionTitle`))},{label:q(`space.patternSectionAdd`),icon:(0,$.jsx)(Un,{className:`size-4 shrink-0`}),onPick:()=>fe(`patterns`,q(`space.patternSectionTitle`))}]:[],...ee.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>ee.add()}]],ge=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(st,{value:Jr.test(e.value)?e.value:`#888888`,onChange:t=>le(e.id,{value:t.target.value})}),(0,$.jsx)(L,{value:e.name,autoFocus:e.id===re,placeholder:q(`space.colorName`),maxLength:120,onChange:t=>le(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(L,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>le(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===w?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(wt,{tone:`ember`,children:q(`space.colorAccent`)})}):c?null:(0,$.jsx)(G,{label:q(`space.colorFirst`),onClick:()=>u(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,$.jsx)(Tt,{className:`size-4`})}),c||!se.length?null:(0,$.jsx)(lt,{options:de,value:C(e)?e.section??``:``,onChange:t=>le(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),c?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>u(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,$.jsx)(Y,{className:`size-4`})})]})]},e.id),_e=e=>{let t=N();S(t),u(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(O,{title:q(`space.colors`),hint:q(`space.colorsHint`),save:oe,locked:c,action:c?null:(0,$.jsx)(V,{entries:he}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[ce.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:ce.map(ge)}),c?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.colorUse`)})]}):l.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`space.colorsEmpty`)}),d.map(t=>{let n=t.kind??`colors`,r=l.filter(e=>e.section===t.id),i=p.filter(e=>e.section===t.id),a=h.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(kt,{title:t.title,titlePlaceholder:q(n===`gradients`?`space.gradientSectionTitlePlaceholder`:n===`patterns`?`space.patternSectionTitlePlaceholder`:`space.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Ln,{}),label:q(`space.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Un,{}),label:q(`space.kindPatterns`)}:{icon:(0,$.jsx)(je,{}),label:q(`space.kindColors`)},autoFocus:te===t.id,readOnly:c,onChange:e=>f(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:async()=>{if(!o||await ct(q(n===`colors`?`space.colorSectionRemoveConfirm`:`space.fillSectionRemoveConfirm`,{name:t.title||q(`space.sectionUntitled`)}))){f(e=>e.filter(e=>e.id!==t.id)),u(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),m(e=>e.filter(e=>e.section!==t.id));for(let e of a)x.remove(e.file);g(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(Wr,{gradient:e,readOnly:c,onEdit:()=>v(e),onChange:t=>m(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>m(t=>t.filter(t=>t.id!==e.id))},e.id)),c||p.length>=A.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(pe(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,$.jsx)(J,{className:`size-5`}),q(`space.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(Kr,{spaceId:e,pattern:t,fileName:me(t.file),readOnly:c,onEdit:()=>b(t),onChange:e=>g(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{x.remove(t.file),g(e=>e.filter(e=>e.id!==t.id))}},t.id)),c||h.length>=A.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b({id:N(),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,$.jsx)(J,{className:`size-5`}),q(`space.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ge),c||l.length>=A.colors?null:(0,$.jsx)(z,{label:q(`space.colorAdd`),onClick:()=>_e(t.id)})]})]},t.id)}),(0,$.jsx)(At,{rules:ee,placeholder:q(`space.colorRulePlaceholder`),readOnly:c})]}),x.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:x.error}):null,_?(0,$.jsx)(Br,{spaceId:e,gradient:_,isNew:!p.some(e=>e.id===_.id),brand:l.filter(e=>Jr.test(e.value)),onClose:()=>v(null),onSave:e=>m(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,y?(0,$.jsx)(qr,{spaceId:e,pattern:y,isNew:!h.some(e=>e.id===y.id),fileName:me,busy:x.busy,error:x.error,upload:async e=>(await x.upload(`pattern`,[e]))[0]??null,removeFile:e=>void x.remove(e),onClose:()=>b(null),onSave:e=>g(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,ie?(0,$.jsx)(Yr,{spaceId:e,onClose:()=>ae(!1),onAdd:ue}):null]})}var Zr=e=>/^(ja|yes|true)$/i.test(e.trim()),Qr={text:Pe,longtext:Tn,number:y,date:C,url:et,email:jn,phone:Mn,boolean:g};function $r({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=Qr[e??t],l=`${q(`space.factType`)}: ${q(`space.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:K(`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,$.jsx)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:K(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,$.jsx)(Xe,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:q(`space.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:q(`space.type.${t}`)}),(0,$.jsx)(sn,{className:K(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Je.map(t=>{let n=Qr[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:q(`space.type.${t}`)}),(0,$.jsx)(sn,{className:K(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function ei({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=W(a.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),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=ze.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(O,{title:q(`space.facts`),hint:q(`space.factsHint`),save:s,locked:n,action:a.length<A.facts&&!n?(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ve(e.value),r=e.type??t;return(0,$.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,$.jsx)(L,{ref:u(`${e.id}:label`),value:e.label,placeholder:q(`space.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:Ue(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(Ot,{checked:Zr(e.value),label:e.label,onChange:t=>c(e.id,{value:q(t?`space.yes`:`space.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zr(e.value)?q(`space.yes`):q(`space.no`)})]}):(0,$.jsx)(ut,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:q(`space.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)($r,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]},e.id)})}),a.length<A.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e,label:q(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(J,{className:`size-3.5`}),` `,q(`fact.${e}`)]},e))]}):null]})}var ti=[{label:`Website`,placeholder:`https://…`},{label:`LinkedIn`,placeholder:`linkedin.com/company/…`},{label:`Instagram`,placeholder:`instagram.com/…`},{label:`Facebook`,placeholder:`facebook.com/…`},{label:`YouTube`,placeholder:`youtube.com/@…`},{label:`TikTok`,placeholder:`tiktok.com/@…`},{label:`X`,placeholder:`x.com/…`}],ni=e=>e===`Website`?Nn:ti.some(t=>t.label===e)?Fn:et;function ri({links:e,readOnly:t,save:n}){let[r,i]=(0,Q.useState)(e),a=(0,Q.useRef)(null),o=W(r.map(e=>({...e,label:e.label.trim(),url:e.url.trim()})).filter(e=>e.url),n),s=(e,t)=>i(n=>n.map(n=>n.id===e?{...n,...t}:n)),c=e=>{let t=N();a.current=`${t}:${e?`url`:`label`}`,i(n=>[...n,{id:t,label:e,url:``}])},l=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},u=ti.filter(e=>!r.some(t=>t.label===e.label)),d=r.length>=A.links,f=[...u.map(e=>{let t=ni(e.label);return{label:e.label,icon:(0,$.jsx)(t,{className:`size-4 shrink-0`}),onPick:()=>c(e.label)}}),{label:q(`space.links.own`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>c(``)}];return(0,$.jsxs)(O,{title:q(`space.links`),hint:q(`space.linksHint`),save:o,locked:t,action:t||d?null:(0,$.jsx)(V,{entries:f}),children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>{let n=ni(e.label);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:grid-cols-[auto_minmax(0,2fr)_minmax(0,3fr)_auto]`,children:[(0,$.jsx)(`span`,{className:`grid size-11 place-items-center text-ink-3`,children:(0,$.jsx)(n,{className:`size-4`})}),(0,$.jsx)(L,{ref:l(`${e.id}:label`),value:e.label,maxLength:80,readOnly:t,placeholder:q(`space.links.label`),onChange:t=>s(e.id,{label:t.target.value}),className:`max-sm:col-span-1 max-sm:font-medium`}),(0,$.jsx)(L,{ref:l(`${e.id}:url`),value:e.url,maxLength:600,readOnly:t,inputMode:`url`,placeholder:ti.find(t=>t.label===e.label)?.placeholder??`https://…`,onChange:t=>s(e.id,{url:t.target.value}),className:`max-sm:col-span-2 max-sm:col-start-2 max-sm:row-start-2`}),t?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:()=>i(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose max-sm:col-start-3 max-sm:row-start-1`,children:(0,$.jsx)(Y,{className:`size-4`})})]},e.id)})}),t||d?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${r.length?`mt-4`:``}`,children:[(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>c(``),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.links.own`)]}),u.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(e.label),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,$.jsx)(J,{className:`size-3.5`}),` `,e.label]},e.label))]})]})}function ii({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData($n);i(!1),n&&(t.preventDefault(),e(n))},className:K(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function ai({spaceId:e,data:t,readOnly:n,sections:r,rules:i,save:a}){let o=We(e,n),[s,c]=(0,Q.useState)(r),l=Be(i),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),h=W({logoSections:s,logoRules:l.rules},a),g=t.files.filter(e=>e.kind===`logo`),_=new Map(g.map(e=>[e.id,e])),v=new Set(s.flatMap(e=>e.logos)),y=g.filter(e=>!v.has(e.id)),b=Re(g,s)?.id,x=(e,t)=>c(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),ee=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),te=async(e,t)=>{let n=await o.upload(`logo`,e);for(let e of n)x(e.id,t)},ne=s.length?{options:[{value:``,label:q(`space.sectionStandard`)},...s.map(e=>({value:e.id,label:e.title||q(`space.sectionUntitled`)}))],current:e=>s.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>x(e.id,t||null)}:void 0,re=(t,n,r)=>(0,$.jsx)(er,{spaceId:e,kind:`logo`,files:t,actions:o,accept:`image/*`,addLabel:r?q(`space.logoAdd`):void 0,onUpload:e=>void te(e,n),mainId:b,onMakeMain:e=>{x(e.id,null),o.order(`logo`,[e.id,...g.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ne,onRemove:async e=>{await ct(q(`space.removeConfirm`,{name:e.name}))&&(o.remove(e.id),x(e.id,null))}}),S=n?void 0:e=>t=>x(t,e),ie=[{label:q(`space.logoUpload`),icon:(0,$.jsx)(kn,{className:`size-4 shrink-0`}),onPick:()=>m.current?.click()},{label:q(`space.logoFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>p(!0)},...s.length<A.logoSections?[{label:q(`space.logoSectionAdd`),icon:(0,$.jsx)(Te,{className:`size-4 shrink-0`}),onPick:()=>{let e=N();d(e),c(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...l.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>l.add()}]];return(0,$.jsxs)(O,{title:q(`space.logos`),hint:q(`space.logosHint`),save:h,action:n?null:(0,$.jsx)(V,{entries:ie}),children:[(0,$.jsx)(`input`,{ref:m,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&&te(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(ii,{onLogo:S?.(null),children:re(y,null,!0)}),s.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(ii,{onLogo:S?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(kt,{title:e.title,description:e.description,titlePlaceholder:q(`space.logoSectionTitle`),descriptionPlaceholder:q(`space.logoSectionUse`),autoFocus:u===e.id,readOnly:n,onChange:t=>ee(e.id,t),onRemove:async()=>{(!e.logos.length||await ct(q(`space.logoSectionRemoveConfirm`,{name:e.title||q(`space.sectionUntitled`)})))&&c(t=>t.filter(t=>t.id!==e.id))}}),re(e.logos.map(e=>_.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),(0,$.jsx)(At,{rules:l,placeholder:q(`space.logoRulePlaceholder`),readOnly:n})]}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,f?(0,$.jsx)(tr,{kind:`logo`,onClose:()=>p(!1),fetchUrl:e=>o.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)x(t.id,null)}}):null]})}var oi=e=>URL.canParse(e)?new URL(e).host:e;async function si(e,t){let n=Ke({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ci(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 ci(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 li(e,t){let n=e.source;if(!n)return q(`space.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return q(`space.fontSourceFile`,{name:e})}return q(`space.fontSourceUrl`,{host:oi(n.url)})}function ui({spaceId:e,font:t,onSave:n,onClose:r}){let i=(nt(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=We(e),o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(t.source&&`url`in t.source?`url`:`file`),[l,u]=(0,Q.useState)(t.source&&`file`in t.source?t.source.file:``),[d,f]=(0,Q.useState)(t.source&&`url`in t.source?t.source.url:``),[p,m]=(0,Q.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(t.license??``),[y,b]=(0,Q.useState)(!1),x=d.trim(),ee=async()=>{g(!0),m({url:x,result:await si(x,t.family.trim())}),g(!1)},te=s===`file`?l?{file:l}:null:p?.url===x&&p.result===`ok`?{url:x}:null,ne=p?.url===x?p.result:null;return(0,$.jsx)(I,{open:!0,onClose:r,title:q(`space.fontSourceTitle`,{family:t.family}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`space.fontSourceHint`)}),(0,$.jsx)(yt,{value:s,options:[`file`,`url`],label:e=>q(`space.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.fontSourceFiles`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>u(e.id),className:K(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,l===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,$.jsx)(`input`,{ref:o,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await a.upload(`asset`,t);n&&u(n.id)}}),(0,$.jsxs)(F,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,$.jsx)(kn,{className:`size-4`}),q(`space.fontSourceUpload`)]}),a.error?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:a.error}):null]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ee()},children:[(0,$.jsx)(R,{children:q(`space.fontSourceUrlLabel`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{value:d,inputMode:`url`,placeholder:q(`space.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,$.jsx)(F,{type:`submit`,variant:`ghost`,busy:h,disabled:!x.startsWith(`https://`),children:q(`space.fontSourceCheck`)})]}),ne?(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.875rem]`,ne===`ok`?`text-ink-3`:`text-rose`),children:q(`space.fontCheck.${ne}`,{host:oi(x),family:t.family})}):null,ne===`ok`?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:q(`space.fontPrivacy`,{host:oi(x)})}):null]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{hint:q(`space.fontLicenseHint`),children:q(`space.fontLicense`)}),(0,$.jsx)(L,{value:_,maxLength:200,placeholder:q(`space.fontLicensePlaceholder`),onChange:e=>v(e.target.value)}),(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:y,onChange:e=>b(e.target.checked)}),q(`space.fontLicenseConfirm`,{family:t.family})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,$.jsx)(F,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:q(`space.fontSourceRemove`)}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,$.jsx)(F,{disabled:!(te&&y),onClick:()=>{te&&(n({source:te,license:_.trim()||void 0}),r())},children:q(`space.fontSourceSave`)})]})]})})}var di=new Set;function fi(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||di.has(t))return;di.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${Le.join(`,`)}&display=swap`,document.head.append(n)},[e])}var pi=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function mi({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.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 hi=`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`,gi={web:`space.fontUseWeb`,documents:`space.fontUseDocuments`,print:`space.fontUsePrint`,images:`space.fontUseImages`,video:`space.fontUseVideo`};function _i({spaceId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){fi(t.family);let s=nt(e).data?.files??[],[c,l]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.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:pi(t.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Mt,{value:t.family,label:q(`space.fontFamily`),placeholder:q(`space.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(Mt,{value:t.role,label:q(`space.fontRole`),placeholder:q(n?`space.fontRoleFirst`:`space.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Le.map(e=>{let n=t.weights.includes(e);return(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:pi(t.family),fontWeight:e},className:K(`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,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,$.jsx)(Mt,{value:t.license??``,label:q(`space.fontLicense`),placeholder:q(`space.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:q(`space.fontUses`)}),_t.map(e=>{let n=!!t.uses?.includes(e);return(0,$.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):_t.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:K(`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,$.jsx)(sn,{className:`size-3.5`}):null,q(gi[e])]},e)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:li(t,s)}),r||!t.family.trim()?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:q(t.source?`space.fontSourceChange`:`space.fontSourceSet`)})]}),c?(0,$.jsx)(ui,{spaceId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:o,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,$.jsx)(Y,{className:`size-4`})})]})}function vi({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:pi(s?.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,$.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,$.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(Mt,{value:e.name,label:q(`space.styleName`),placeholder:q(`space.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":q(`space.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:K(hi,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||q(`space.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":q(`space.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:hi,children:[...new Set([...Le,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(mi,{unit:`px`,label:q(`space.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(mi,{unit:q(`space.styleLine`),label:q(`space.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(mi,{unit:q(`space.styleTracking`),label:q(`space.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:q(`space.styleUpper`),"aria-label":q(`space.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:K(`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,$.jsx)(Vn,{className:`size-4`})})]}),r?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]})}function yi({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await D.post(`/api/studio/spaces/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(q(`space.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(I,{open:!0,onClose:n,wide:l?!0:void 0,title:q(l?`space.fontsFound`:`space.fontsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`space.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(bi,{font:e,on:d.includes(e.family),onToggle:()=>f(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:q(`run.back`)}),(0,$.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?q(`space.addMany`,{n:d.length}):q(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.logoUrl`)}),(0,$.jsx)(L,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.fontsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,$.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function bi({font:e,on:t,onToggle:n}){return fi(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:K(`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,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:pi(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):q(`space.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(sn,{className:`size-3.5`})}):null]})}function xi({spaceId:e,fonts:t,styles:n,rules:r,sample:i,save:a,readOnly:o}){let[s,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=Be(r),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=W({fonts:s,textStyles:u,typeRules:f.rules},a),v=(e,t=!1)=>{let n=e.map(e=>({id:N(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,A.fonts))},y=()=>{let e=N();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},b=[...s.length<A.fonts?[{label:q(`space.fontNew`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>v([{family:``,weights:[400,700]}],!0)},{label:q(`space.fontsFromUrl`),icon:(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<A.textStyles?[{label:q(`space.styleNew`),icon:(0,$.jsx)(c,{className:`size-4 shrink-0`}),onPick:y}]:[],...f.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(O,{title:q(`space.typography`),hint:q(`space.typographyHint`),save:_,action:o?null:(0,$.jsx)(V,{entries:b}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[s.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:s.map((t,n)=>(0,$.jsx)(_i,{spaceId:e,font:t,first:n===0,readOnly:o,autoFocus:p===t.id,onChange:e=>l(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>l(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`space.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`space.styles`)}),o?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:q(`space.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(vi,{style:e,fonts:s,sample:i,readOnly:o,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,(0,$.jsx)(At,{rules:f,placeholder:q(`space.typeRulePlaceholder`),readOnly:o})]}),h?(0,$.jsx)(yi,{spaceId:e,onClose:()=>g(!1),onAdd:e=>v(e)}):null]})}var Si=[{title:`space.voice.tone`,hint:`space.voice.toneHint`},{title:`space.voice.audience`,hint:`space.voice.audienceHint`},{title:`space.voice.positioning`,hint:`space.voice.positioningHint`},{title:`space.voice.values`,hint:`space.voice.valuesHint`}];function Ci({blocks:e,rules:t,readOnly:n,save:r}){let[i,a]=(0,Q.useState)(e),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),u=Be(t),d=W({voice:i,voiceRules:u.rules},r),f=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),p=i.length>=A.voiceBlocks,m=e=>{let t=N();(e?l:s)(t),a(n=>[...n,{id:t,title:e,text:``}])},h=Si.filter(e=>!i.some(t=>t.title===q(e.title))),g=e=>Si.find(t=>q(t.title)===e)?.hint,_=[...p?[]:[...h.map(e=>({label:q(e.title),icon:(0,$.jsx)(pe,{className:`size-4 shrink-0`}),onPick:()=>m(q(e.title))})),{label:q(`space.voice.own`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>m(``)}],...u.full?[]:[{label:q(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>u.add()}]];return(0,$.jsx)(O,{title:q(`space.voice`),hint:q(`space.voiceHint`),save:d,locked:n,action:n||!_.length?null:(0,$.jsx)(V,{entries:_}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[i.length?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:i.map(e=>{let t=g(e.title);return(0,$.jsxs)(`div`,{className:`group/row grid gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[n?(0,$.jsx)(`p`,{className:`min-w-0 flex-1 font-medium text-[0.9375rem]`,children:e.title}):(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(Mt,{value:e.title,label:q(`space.voice.title`),placeholder:q(`space.voice.title`),maxLength:80,autoFocus:o===e.id,onChange:t=>f(e.id,{title:t}),className:`font-medium text-[0.9375rem]`})}),n?null:(0,$.jsx)(G,{label:q(`space.remove`),onClick:async()=>{(!e.text.trim()||await ct(q(`space.voice.removeConfirm`,{name:e.title||q(`space.sectionUntitled`)})))&&a(t=>t.filter(t=>t.id!==e.id))},className:`-mt-1 size-8 shrink-0 rounded-lg opacity-0 transition hover:text-rose focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-100`,children:(0,$.jsx)(Y,{className:`size-4`})})]}),n?(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.9375rem] text-ink-2 leading-relaxed sm:pt-2`,children:e.text}):(0,$.jsx)(ut,{ref:t=>{t&&c===e.id&&(l(null),t.focus())},rows:2,minRows:2,maxRows:14,maxLength:A.voiceText,value:e.text,placeholder:q(t||`space.voice.textPlaceholder`),onChange:t=>f(e.id,{text:t.target.value})})]},e.id)})}):null,n||p?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>m(``),children:[(0,$.jsx)(J,{className:`size-4`}),` `,q(`space.voice.own`)]}),h.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(q(e.title)),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,$.jsx)(J,{className:`size-3.5`}),` `,q(e.title)]},e.title))]}),(0,$.jsx)(At,{rules:u,placeholder:q(`space.voice.rulePlaceholder`),readOnly:n})]})})}function wi({spaceId:e,logo:t}){let n=q(t?`space.logoPeek`:`space.logoPeekAdd`);return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(R,{children:q(`space.logo`)}),(0,$.jsx)(ft,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:K(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,$.jsx)(Zn,{spaceId:e,file:t,small:!0}):(0,$.jsx)(tt,{className:`size-5`})})]})}function Ti({space:e,save:t}){let n=Vt().data,r=zt(),i=Fe(`capabilities`)&&r&&n?.mode===`managed`,[a,o]=(0,Q.useState)(e.membersStudio);return i?(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-border-soft border-t pt-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:q(`space.membersStudio`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:q(`space.membersStudioHint`)})]}),(0,$.jsx)(Ot,{checked:a,disabled:e.readOnly,label:q(`space.membersStudio`),onChange:e=>{o(e),t({membersStudio:e}).catch(()=>o(!e))}})]}):null}function Ei({space:e,organization:t,save:n}){let r=zt(),[i,a]=(0,Q.useState)(!1),o=e.brandFrom===`root`;return(0,$.jsxs)(`section`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 rounded-xl bg-card p-4 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-[0.75rem] text-ink-3`,children:q(`space.brandFrom`)}),(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem] text-ink`,children:o?q(`space.brandFromRoot`,{organization:t}):q(`space.brandFromOwn`)}),(0,$.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:q(o?`space.brandFromRootHint`:`space.brandFromOwnHint`,{organization:t})})]}),r&&!e.readOnly?(0,$.jsx)(F,{variant:`secondary`,busy:i,onClick:async()=>{a(!0);try{await n({brandFrom:o?`own`:`root`})}finally{a(!1)}},children:o?q(`space.brandUseOwn`):q(`space.brandUseRoot`,{organization:t})}):null]})}function Di({space:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.brandName??``),[i,a]=(0,Q.useState)(e.brand.tagline??``),o=W({brandName:n.trim(),tagline:i.trim()},e=>t({brand:e}));return(0,$.jsx)(O,{title:q(`space.identity`),hint:q(`space.identityHint`),save:o,locked:e.readOnly,children:(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[{id:`brand-name`,label:q(`space.brandName`),hint:q(`space.brandNameHint`),field:(0,$.jsx)(L,{id:`brand-name`,value:n,maxLength:120,placeholder:e.brand.name??``,onChange:e=>r(e.target.value)})},{id:`brand-tagline`,label:q(`space.tagline`),hint:q(`space.taglineHint`),field:(0,$.jsx)(L,{id:`brand-tagline`,value:i,maxLength:200,onChange:e=>a(e.target.value)})}].map(e=>(0,$.jsxs)(`div`,{className:`grid items-start gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:e.id,className:`font-medium text-[0.9375rem]`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.hint})]}),e.field]},e.id))})})}function Oi({space:e,logo:t,save:n}){let[r,i]=(0,Q.useState)(e.brand.name??``),[a,o]=(0,Q.useState)(e.brand.about??``),s=W({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,$.jsx)(O,{title:q(`space.base`),hint:q(`space.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(R,{children:q(`space.title`)}),(0,$.jsx)(L,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.titleHint`)})]}),(0,$.jsx)(wi,{spaceId:e.id,logo:t})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{children:q(`space.about`)}),(0,$.jsx)(ut,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`space.aboutHint`)})]}),(0,$.jsx)(Ti,{space:e,save:n})]})})}function ki({space:e,group:t,top:n=!1,children:r}){let i=St(),a=nt(e.id),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(!1),u=async t=>{await D.patch(`/api/studio/spaces/${e.id}`,t),await i.invalidateQueries({queryKey:it.spaces()})},f=en({mutationFn:()=>D.del(`/api/studio/spaces/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:it.spaces()})}),p=Bt(),m=zt(),h=a.data??{files:[],embeddings:!0},g=`${e.id}:${o}`,_=e.readOnly,v=t===`knowledge`,y=Vt().data,b=Fe(`orgSpaces`)&&!!e.parentId&&e.kind!==`client`&&(t===`info`||t===`brand`),x=b&&e.brandFrom===`root`;return ne(_?{}:{title:q(v?`space.assistantTitleKnowledge`:`space.assistantTitle`),hello:q(v?`space.assistantHelloKnowledge`:`space.assistantHello`),about:q(v?`space.assistantAboutKnowledge`:`space.assistantAbout`),placeholder:q(v?`space.assistantComposerKnowledge`:`space.assistantComposer`),suggestions:v?[{label:q(`assistant.suggest.knowledgeHow`)},{label:q(`assistant.suggest.knowledgeSite`),fill:!0},{label:q(`assistant.suggest.knowledgeCategories`)}]:[{label:q(`assistant.suggest.readSite`),fill:!0},{label:q(`assistant.suggest.missing`)},...t===`info`?[{label:q(`assistant.suggest.facts`)}]:[]],summary:v?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${h.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[_?(0,$.jsx)(En,{children:wn(e)}):n?(0,$.jsx)(d,{}):null,b&&y?(0,$.jsx)(Ei,{space:e,organization:y.tenant.name||q(`nav.space`),save:u},`from:${e.brandFrom}`):null,t===`info`&&x?(0,$.jsx)(Ti,{space:e,save:u}):null,t===`info`&&!x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{id:`base`,children:(0,$.jsx)(Oi,{space:e,logo:Re(h.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:u},`base:${g}`)}),(0,$.jsx)(ot,{id:`facts`,children:(0,$.jsx)(ei,{facts:e.facts,save:e=>u({facts:e}),readOnly:_},`facts:${g}`)}),(0,$.jsx)(ot,{id:`links`,children:(0,$.jsx)(ri,{links:e.brand.links??[],save:e=>u({brand:{links:e}}),readOnly:_},`links:${g}`)})]}):null,t===`brand`&&!x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{id:`identity`,children:(0,$.jsx)(Di,{space:e,save:u},`identity:${g}`)}),(0,$.jsx)(ot,{id:`logos`,children:(0,$.jsx)(ai,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],save:e=>u({brand:e})},`logos:${g}`)}),(0,$.jsx)(ot,{id:`colors`,children:(0,$.jsx)(Xr,{spaceId:e.id,data:h,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],save:e=>u({brand:e}),readOnly:_},`colors:${g}`)}),(0,$.jsx)(ot,{id:`typography`,children:(0,$.jsx)(xi,{spaceId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],sample:e.brand.name||q(`space.typeSample`),save:e=>u({brand:e}),readOnly:_},`typography:${g}`)}),(0,$.jsx)(ot,{id:`assets`,children:(0,$.jsx)(Ir,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${g}`)}),(0,$.jsx)(ot,{id:`voice`,children:(0,$.jsx)(Ci,{blocks:e.brand.voice??[],rules:e.brand.voiceRules??[],save:e=>u({brand:e}),readOnly:_},`voice:${g}`)})]}):null,r,t===`info`&&p&&!_&&m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(F,{variant:`danger`,onClick:()=>l(!0),children:q(`settings.delete`)}),(0,$.jsxs)(I,{open:c,onClose:()=>l(!1),title:q(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:q(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>l(!1),children:q(`common.cancel`)}),(0,$.jsx)(F,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:q(`common.delete`)})]})]})]}):null]})}var Ai=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function ji(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=ge(),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 Mi(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=ge(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Ni(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Pi({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Qt,{icon:e.icon??Ne,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Yt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},e.plugin??`own`)})}var Fi=(0,Q.lazy)(()=>ln(()=>import(`./SkillEditor-ARx8QPGp.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([10,1,6,4,5,7,8,11,12,13,14,15,16,17,18,9,2,3,19])));function Ii({place:e}){let{group:t}=jt(),[r,c]=bt(),d=dt(),g=Pt(),{hash:_}=g,{space:y,loading:ee}=Ht(),C=ae(),w=Gt(),[pe,Te]=(0,Q.useState)(null),[Oe,ke]=(0,Q.useState)(null),[je,Ne]=(0,Q.useState)(null),T=e??(Ce(t)&&t!==`skills`?t:void 0),Pe=T?void 0:C.spaceParts.find(e=>e.id===t),E=T??Pe?.id,D=g.state?.parts===!0,Le=Fe(`pages`),Re=Fe(`skills`),ze=zt(),Be=Fe(`clientSpaces`),Ve=Fe(`orgSpaces`),He=Be&&Ve&&ze&&!!y?.root,k=Fe(`knowledgeTree`),Ue=Vt().data?.mode===`local`,We=Fe(`dateien`)&&(Ue||C.mountKinds.length>0),Ge=se().filter(e=>(Le||e.id!==`page`)&&(He||e.id!==`clients`)&&(We||e.id!==`files`)),Ke=Ee(Ge,C).map(e=>({...e,to:`/space/${e.id}`})),qe=Ke,Je={id:`results`,label:q(`space.results`),icon:S,to:`/space/results`},Ye={id:`skills`,label:q(`space.skills`),icon:Ie,to:`/skills`},A=T===`results`||T===`skills`,j=T===`results`?Je:T===`skills`?Ye:qe.find(e=>e.id===E),M=r.get(`show`),[Xe,Ze]=(0,Q.useState)(``),N=(0,Q.useRef)(null),Qe=Xe.trim().toLowerCase(),$e=(0,Q.useMemo)(()=>({slot:pe,narrow:w,setDetail:ke,filter:Qe}),[pe,w,Qe]),et=Vt().data,tt=y?y.brand.name?.trim()||(et?a(et,y):y.name):q(`nav.space`),nt=Pe?C.spaceMenus[Pe.id]??[]:[],rt=Pe?[{plugin:null,label:null,sections:nt}]:T&&T!==`results`?he(T,C):[],P=T?he(T,C).filter(e=>e.plugin):[],it=ji([...rt,...T===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),at=(0,Q.useRef)(null),[st,ct]=Bi(),F=T===`results`&&M&&M!==`all`?M:null,[lt,ut]=(0,Q.useState)(yn),I=vn(T===`results`?y?.id:void 0,F,lt),L=I.data?.wizards.find(e=>e.id===F)?.title,[R,ft]=(M??``).split(`#`),z=T===`data`&&R&&R!==`all`||T===`knowledge`&&R&&/^[ptfcvsq]:/.test(R)?R:null,B=z?.startsWith(`s:`)?C.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=T===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,pt=T===`skills`&&M?.startsWith(`k:`)?M:null,ht=bn(T===`skills`&&Re?y?.id:void 0),_t=un(T===`data`?y?.id:void 0),H=o(T===`knowledge`?y?.id:void 0),yt=de(T===`knowledge`&&k?y?.id:void 0),[xt,St]=(0,Q.useState)(null);m.clear(),h.clear();for(let e of yt.sources)e.folderId&&(m.set(e.folderId,yt.iconOf(e)),h.set(e.folderId,e.id));let U=re(z?.startsWith(`v:`)?z.slice(2):``),W=H.data?.items.find(e=>e.key===V),[Ct,wt]=(0,Q.useState)(null),[Tt,Et]=(0,Q.useState)(null),[G,Dt]=(0,Q.useState)(void 0),Ot=l(y?.id),kt=H.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):U.data?.category.id)),[At,Mt]=(0,Q.useState)(`folders`),[Nt,Ft]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{z&&/^[cv]:/.test(z)?Mt(`categories`):z&&/^[ptf]:/.test(z)&&Mt(`folders`)},[z]);let It=P.length>0||T===`files`||T===`knowledge`&&!!(H.data?.categories.length||k&&H.data?.items.length)||T===`data`&&!!(_t.data&&dn(_t.data).some(e=>e.items.length)),Lt=!!T&&!A&&(T!==`data`&&T!==`knowledge`&&T!==`files`||!It),Rt=T===`results`?2:E?M||Lt?2:1:M===`overview`?2:0,Bt=A?1:w?Math.min(Rt,1):E&&!Lt&&je!==E&&!D?1:0,Xt=Jt(Bt),en=Jt(Rt);(0,Q.useEffect)(()=>{Ne(null),Ze(``)},[E]),(0,Q.useEffect)(()=>{if(w||Bt!==1)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`&&N.current&&(e.preventDefault(),N.current.focus(),N.current.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,Bt]);let tn=T===`skills`?ht.data?.skills.find(e=>`k:${e.id}`===pt)?.name:T===`knowledge`?B?B.label():z?.startsWith(`v:`)?U.data&&`${U.data.category.name}: ${U.data.value}`:z?.startsWith(`c:`)?kt?.name:H.data?.items.find(e=>e.key===z)?.title:_t.data?dn(_t.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;ue([...A?[]:[{label:q(`nav.sources`),to:`/space`}],...E?[]:[{label:q(`space.overview`)}],...j?[{label:j.label,to:j.to}]:[],...k&&W&&H.data?fe(H.data.items,W).map(e=>({label:e.title,to:`/space/knowledge?show=${e.key}`})):[],...j&&(Oe??L??tn)?[{label:Oe??L??tn}]:[]]);let nn={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};ne({...T===`data`||T===`results`?{compact:!0}:{},...T===`data`?{suggestions:[{label:q(`assistant.suggest.dataWhat`)},{label:q(`assistant.suggest.dataWho`)},{label:q(`assistant.suggest.dataEdit`)}]}:T===`results`?{suggestions:[{label:q(`assistant.suggest.resultsFailed`)},{label:q(`assistant.suggest.resultsCost`)},{label:q(`assistant.suggest.resultsShare`)}]}:{},...z&&tn?{open:{kind:nn[z[0]]??`item`,id:z.slice(2),label:tn}}:F&&L?{open:{kind:`wizard`,id:F,label:L}}:{}});let rn=T===`results`||T===`data`||z?_.slice(1):M||_.slice(1),J=(0,Q.useRef)(``);(0,Q.useEffect)(()=>{let e=`${E}#${rn}`;rn&&J.current!==e&&document.getElementById(rn)&&(J.current=e,requestAnimationFrame(()=>Ni(rn,!1)))},[E,rn,y?.id,C.spaceSections,nt.length]),(0,Q.useEffect)(()=>{w||E!==`knowledge`&&E!==`data`&&E!==`skills`||ge().scrollTo({top:0})},[w,E,z,pt]);let an=Mi();if(t===`skills`)return(0,$.jsx)(mt,{to:{pathname:`/skills`,search:g.search,hash:_},replace:!0});if(!E){let e=_.slice(1),n=e?ye(e,C):null;if(n===`knowledge`&&C.spaceSections.some(t=>t.id===e))return(0,$.jsx)(mt,{to:`/space/knowledge?show=s:${e}`,replace:!0});if(n)return(0,$.jsx)(mt,{to:w?`/space/${n}?show=${e}`:{pathname:`/space/${n}`,hash:e},replace:!0});if((e||t)&&C.status!==`ready`)return null;if(t!==void 0)return(0,$.jsx)(mt,{to:`/space`,replace:!0})}let on=T===`info`?M??_.slice(1):``;if(on&&ye(on,C)===`brand`)return(0,$.jsx)(mt,{to:w?`/space/brand?show=${on}`:{pathname:`/space/brand`,hash:on},replace:!0});if(T===`skills`&&!Re)return(0,$.jsx)(mt,{to:`/`,replace:!0});if(T===`knowledge`&&!M&&C.spaceSections.some(e=>e.id===_.slice(1)))return(0,$.jsx)(mt,{to:`/space/knowledge?show=s:${_.slice(1)}`,replace:!0});let Y=e=>{w?d({search:`?show=${e}`}):(J.current=`${E}#${e}`,Ni(e,!0),d({search:``,hash:e},{replace:!0}))},X=e=>{e!==M&&(w?c({show:e}):c(e===`all`?{}:{show:e},{replace:T!==`knowledge`}))},sn=e=>e.flatMap(e=>e.sections).map(e=>C.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(ot,{id:e.id,children:(0,$.jsx)(O,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(we,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),cn=e=>e.flatMap(e=>e.sections).map(e=>C.spaceSections.find(t=>t.id===e.id)).map(e=>e?.status?(0,$.jsx)(we,{of:e,children:(0,$.jsx)(e.status,{})},e.serial):null),ln=w?void 0:it,Z=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kt,{title:tt,open:Bt===1?j??null:null,onBack:A?void 0:()=>w?d(`/space`):Ne(E??null),root:{icon:Se,label:q(`nav.sources`),onOpen:()=>d(w?`/space?show=overview`:`/space`),current:!E}}),w||A?(0,$.jsx)(`div`,{className:K($t(Xt)),children:Bt===0?(0,$.jsx)(Ut,{entries:qe,current:void 0,onPick:()=>Ne(null)}):(0,$.jsx)(`div`,{ref:Te})},Bt):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ut,{entries:qe,current:Bt===0?j:void 0,hide:Bt===1?j?.id:void 0,onPick:()=>{Ne(null),Lt&&j&&(d(j.to),ge().scrollTo({top:0,behavior:`smooth`}))}}),Bt===1?(0,$.jsxs)(`div`,{className:`fade-in-0 slide-in-from-top-1 animate-in duration-200`,children:[(0,$.jsx)(`div`,{className:`mx-2 my-3 h-px bg-border-soft`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(gt,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,$.jsx)(`input`,{ref:N,type:`search`,value:Xe,onChange:e=>Ze(e.target.value),onKeyDown:e=>e.key===`Escape`&&Ze(``),"aria-label":q(`space.menuSearch`),placeholder:q(`space.menuSearch`),className:`h-8 w-full rounded-lg border border-input bg-card pr-14 pl-9 text-[0.8125rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),(0,$.jsx)(`kbd`,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 rounded border border-border-soft px-1 font-sans text-[0.6875rem] text-ink-4`,children:Ai?`⌘F`:`Ctrl F`})]}),(0,$.jsx)(`div`,{ref:Te})]},E):null]})]});return(0,$.jsx)(Wt.Provider,{value:$e,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{ref:at,className:K(`grid gap-6`,T!==`results`&&`md:grid-cols-[var(--menu-w,10.5rem)_minmax(0,1fr)] md:gap-5 lg:grid-cols-[var(--menu-w,15rem)_minmax(0,1fr)] lg:gap-10`),style:st?{"--menu-w":`${st}px`}:void 0,children:[T===`results`?null:(0,$.jsxs)(`div`,{className:`relative min-w-0`,style:!w&&an?{minHeight:an-48}:void 0,children:[(0,$.jsx)(`aside`,{className:K(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,w&&Rt===2&&`hidden`,w&&en===`back`&&$t(`back`)),style:!w&&an?{maxHeight:an-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:Z}),w?null:(0,$.jsx)(Vi,{grid:at,onWidth:ct})]}),E?(0,$.jsxs)(`div`,{className:K(`min-w-0`,w&&Rt<2&&`hidden`,w&&en===`deeper`&&$t(`deeper`)),children:[w&&T!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Zt,{label:j?.label??tt,onBack:()=>d(j?.to??`/space/${E}`)})}):null,T===`data`?(0,$.jsxs)(qt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Qt,{icon:f,label:q(`data.all`),selected:!w&&!z,onPick:()=>X(`all`)})}),_t.data?dn(_t.data).map(e=>(0,$.jsx)(Yt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Qt,{icon:fn[e.kind],label:e.title,selected:!w&&e.key===z,onPick:()=>X(e.key)},e.key))},e.key)):null,(0,$.jsx)(Pi,{groups:P,current:ln,onPick:Y})]}):T===`knowledge`?(0,$.jsxs)(qt,{children:[k&&H.data?(0,$.jsx)(ur,{tab:At,onTab:Mt}):null,k&&H.data&&At===`categories`?(0,$.jsx)(dr,{categories:H.data.categories,picked:w?null:z,pickedCategory:U.data?.category.id??null,readOnly:!!y?.readOnly,onPick:X,onNew:()=>Ft(!0)}):k&&H.data?(0,$.jsx)(me,{spaceId:y.id,items:H.data.items,picked:w?null:V,all:!(w||z),readOnly:!!y?.readOnly,onPick:X,onMove:Ot,onNewFolder:Dt,onMoveTo:Et}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Qt,{icon:f,label:q(`know.all`),selected:!(w||z),onPick:()=>X(`all`)})}),H.data?.categories.length&&!k?(0,$.jsx)(Yt,{label:q(`know.categories`),children:H.data.categories.map(e=>(0,$.jsx)(Qt,{icon:u[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!w&&(z===`c:${e.id}`||U.data?.category.id===e.id),onPick:()=>X(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Pi,{groups:P,current:w?void 0:B?.id,onPick:e=>X(`s:${e}`)})]}):T===`files`&&y?(0,$.jsx)(qt,{children:(0,$.jsx)(Ae,{spaceId:y.id,admin:ze})}):T===`skills`?(0,$.jsxs)(qt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Qt,{icon:f,label:q(`skills.all`),selected:!(w||pt),onPick:()=>X(`all`)}),ht.data?.skills.map(e=>(0,$.jsx)(Qt,{icon:xn[e.mode],label:e.name,selected:!w&&pt===`k:${e.id}`,onPick:()=>X(`k:${e.id}`)},e.id))]}),(0,$.jsx)(Pi,{groups:P,current:ln,onPick:Y})]}):(0,$.jsx)(qt,{children:(0,$.jsx)(Pi,{groups:rt,current:ln,onPick:Y})}),y&&(T===`info`||T===`brand`||T===`knowledge`)?(0,$.jsxs)(ki,{space:y,group:T,top:!z||!!B,children:[T===`knowledge`&&ze?(0,$.jsx)(be,{spaceId:y.id,folder:r.has(`audience`)&&W?.kind===`page`?{id:W.id,title:W.title}:null,onClose:()=>c(M?{show:M}:{},{replace:!0})}):null,T===`knowledge`&&V&&He?(0,$.jsx)(Kn,{spaceId:y.id,kind:V.startsWith(`p:`)?`page`:V.startsWith(`t:`)?`table`:`document`,id:V.slice(2)}):null,T===`knowledge`?V?k&&H.data&&W&&v(W)&&Ct!==V?(0,$.jsx)(le,{spaceId:y.id,data:H.data,folder:W,readOnly:y.readOnly,onOpen:X,onWrite:e=>{wt(e),X(e)},onGone:()=>X(W.parentId?`p:${W.parentId}`:`all`),kinds:yt.kinds,source:yt.ofFolder(W.id)??(W.kept?void 0:yt.sources.find(e=>W.origin===`source:${e.id}`)),status:yt.ofFolder(W.id)?(0,$.jsx)(_e,{spaceId:y.id,sources:yt.sources,only:yt.ofFolder(W.id)?.id}):null},V):V.startsWith(`p:`)?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(pn,{pageId:V.slice(2),onGone:()=>X(`all`),onOpen:X}),k&&H.data&&W?(0,$.jsx)(De,{data:H.data,page:W,onOpen:X}):null]},V):V.startsWith(`t:`)?(0,$.jsx)(hn,{tableId:V.slice(2),onGone:()=>X(`all`)},V):(0,$.jsx)(sr,{spaceId:y.id,fileId:V.slice(2),page:Number(ft)||void 0,readOnly:y.readOnly,onGone:()=>X(`all`)},V):k&&z?.startsWith(`q:`)?(0,$.jsx)(xe,{spaceId:y.id,sourceId:z.slice(2),readOnly:y.readOnly,onOpen:X,onGone:()=>X(`all`)},z):H.data?B?(0,$.jsx)(O,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(we,{of:B,children:(0,$.jsx)(B.component,{})})},z):k&&z?.startsWith(`c:`)?kt?(0,$.jsx)(mr,{spaceId:y.id,data:H.data,category:kt,readOnly:y.readOnly,onOpen:X,onGone:()=>X(`all`)},z):null:k&&z?.startsWith(`v:`)?U.data?(0,$.jsx)(hr,{data:H.data,value:U.data,readOnly:y.readOnly,onOpen:X},z):null:z?.startsWith(`c:`)?kt?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(p,{spaceId:y.id,category:kt,readOnly:y.readOnly,onOpen:X,onGone:()=>X(`all`)}),kt.type===`choice`?null:(0,$.jsx)(x,{spaceId:y.id,category:kt,categories:H.data.categories,onOpen:X})]},z):null:z?.startsWith(`v:`)?U.data?(0,$.jsx)(Me,{value:U.data,readOnly:y.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[U.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:U.data.items.map(e=>(0,$.jsx)(i,{item:e,categories:H.data.categories.filter(e=>e.id!==U.data?.category.id),onOpen:X},e.key))}):null,U.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>X(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(ot,{id:`documents`,children:k?(0,$.jsx)(ie,{spaceId:y.id,data:H.data,readOnly:y.readOnly,onOpen:X,onWrite:e=>{wt(e),X(e)},status:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_e,{spaceId:y.id,sources:yt.sources,onOpen:X}),cn(P)]}),kinds:yt.kinds,adds:C.spaceSections.filter(e=>(e.group??`knowledge`)===`knowledge`&&e.add).map(e=>({id:e.id,label:e.add?.label()??e.label(),hint:e.add?.hint?.(),icon:e.add?.icon??e.icon}))}):(0,$.jsx)(te,{spaceId:y.id,data:H.data,readOnly:y.readOnly,onOpen:X,status:cn(P)})}):null:null,T===`info`||T===`brand`?sn(P):null]},y.id):null,y&&T===`knowledge`&&k&&H.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{spaceId:y.id,kind:xt?.kind??null,parentId:xt?.parentId??null,onClose:()=>St(null),onOpen:X}),(0,$.jsx)(n,{item:Tt,items:H.data.items,onClose:()=>Et(null),onMove:Ot}),(0,$.jsx)(b,{spaceId:y.id,open:Nt,onClose:()=>Ft(!1),onMade:e=>{Ft(!1),X(`c:${e}`)}}),(0,$.jsx)(s,{kind:G===void 0?null:`folder`,spaceId:y.id,parentId:G,onClose:()=>Dt(void 0),onMade:e=>{Dt(void 0),X(e)}})]}):null,y&&T===`clients`&&He?(0,$.jsx)(ot,{id:`clients`,children:(0,$.jsx)(Gn,{space:y})}):null,y&&T===`skills`&&Re?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:pt?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Fi,{skillId:pt.slice(2),onGone:()=>X(`all`),onOpen:X},pt)}):ht.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Sn,{spaceId:y.id,data:ht.data,onOpen:X}),sn(P)]}):ht.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:ht.error.message}):null}):null,y&&T===`page`&&Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(gn,{space:y},y.id),sn(P)]}):null,y&&Pe?(0,$.jsx)(we,{of:Pe,children:(0,$.jsx)(ve,{part:Pe.id,children:(0,$.jsx)(Pe.component,{})},y.id)}):null,y&&T===`files`&&We?(0,$.jsx)(oe,{spaceId:y.id,admin:ze},y.id):null,y&&T===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(hn,{tableId:z.slice(2),onGone:()=>X(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(pn,{pageId:z.slice(2),onGone:()=>X(`all`)},z):z?.startsWith(`d:`)?(0,$.jsx)(qn,{databaseId:z.slice(2),people:_t.data?.databases?.find(e=>`d:${e.id}`===z)?.people??0},z):(0,$.jsxs)($.Fragment,{children:[_t.data?(0,$.jsx)(mn,{spaceId:y.id,data:_t.data,readOnly:y.readOnly,onOpen:X}):null,sn(P)]})}):null,y&&T===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[I.data?(0,$.jsx)(_n,{data:I.data,wizardId:F,onWizard:e=>X(e??`all`),filter:lt,onFilter:ut}):null,I.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:I.error.message}):null,sn(P)]}):null,y||ee?null:(0,$.jsx)(vt,{children:q(`settings.noSpace`)})]}):y&&(!w||M===`overview`)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[w?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Zt,{label:q(`nav.sources`),onBack:()=>d(`/space`)})}):null,(0,$.jsx)(Ar,{space:y,parts:Ke})]}):null]})})})}var Li=`space.menuWidth`,Ri=160,zi=480;function Bi(){let[e,t]=(0,Q.useState)(()=>{try{let e=Number(localStorage.getItem(Li));return e>=Ri&&e<=zi?e:null}catch{return null}});return[e,e=>{t(e);try{e===null?localStorage.removeItem(Li):localStorage.setItem(Li,String(e))}catch{}}]}function Vi({grid:e,onWidth:t}){let[n,r]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{"aria-hidden":!0,onDoubleClick:()=>{e.current?.style.removeProperty(`--menu-w`),t(null)},onPointerDown:n=>{let i=n.currentTarget.parentElement,a=e.current;if(!(i&&a)||n.button!==0)return;n.preventDefault();let o=n.clientX,s=i.getBoundingClientRect().width,c=s;r(!0);let l=e=>{c=Math.round(Math.min(zi,Math.max(Ri,s+e.clientX-o))),a.style.setProperty(`--menu-w`,`${c}px`)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),r(!1),c!==s&&t(c)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},className:`group/resize -right-4 lg:-right-6 absolute inset-y-0 z-10 hidden w-3 cursor-col-resize touch-none md:block`,children:[(0,$.jsx)(`span`,{className:K(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`)}),(0,$.jsxs)(`span`,{className:K(`group/grip sticky top-[calc(50vh-1.5rem)] mx-auto flex h-12 w-3 items-center justify-center transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`),children:[(0,$.jsx)(`span`,{className:K(`block h-10 w-1 rounded-full transition-colors`,n?`bg-ink-2`:`bg-ink-4 group-hover/grip:bg-ink-2`)}),(0,$.jsx)(`span`,{className:K(`pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[0.75rem] text-paper opacity-0 shadow-overlay transition-opacity`,!n&&`group-hover/grip:opacity-100 group-hover/grip:delay-300`),children:q(`space.menuWidth`)})]})]})}export{Ii as SpacePage};