@engenty/wizards-runtime 0.9.8 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/app.js +18 -1
- package/apps/runtime/dist/auth/index.js +10 -1
- package/apps/runtime/dist/db/client.js +9 -1
- package/apps/runtime/dist/db/migrations/tenant/0022_sync.sql +247 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0022_snapshot.json +3792 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +60 -0
- package/apps/runtime/dist/docs/user-guide/cloud-sync.md +85 -0
- package/apps/runtime/dist/docs/user-guide/data.md +4 -4
- package/apps/runtime/dist/docs/user-guide/meta.json +1 -0
- package/apps/runtime/dist/docs/user-guide/test-and-share.md +4 -14
- package/apps/runtime/dist/files/blobs.js +13 -0
- package/apps/runtime/dist/index.js +7 -1
- package/apps/runtime/dist/plugins/jobs.js +7 -0
- package/apps/runtime/dist/routes/api.js +107 -0
- package/apps/runtime/dist/routes/studio.js +62 -0
- package/apps/runtime/dist/services/cloud.js +39 -5
- package/apps/runtime/dist/services/projects.js +11 -0
- package/apps/runtime/dist/sync/apply.js +39 -0
- package/apps/runtime/dist/sync/client.js +828 -0
- package/apps/runtime/dist/sync/hub.js +324 -0
- package/apps/runtime/dist/sync/log.js +74 -0
- package/apps/runtime/dist/sync/records.js +943 -0
- package/apps/runtime/dist/sync/state.js +17 -0
- package/apps/web/dist/assets/{AboutDialog-B_Ixp_Tb.js → AboutDialog-D1YHT0jc.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-BpEIbAZ8.js → ChangelogDialog-Bv02g8av.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-CKHY4hn4.js → EditorPage-BThoZwqO.js} +4 -4
- package/apps/web/dist/assets/{FlowPreview-APXdRflR.js → FlowPreview-dc5C92kK.js} +1 -1
- package/apps/web/dist/assets/{Harness-BsGXMlLg.js → Harness-D0nFOIVx.js} +1 -1
- package/apps/web/dist/assets/{Marketplace-Dr-Qnb-F.js → Marketplace-Cnd8BF3q.js} +2 -2
- package/apps/web/dist/assets/{NewWizardChannels-0JrRdUFd.js → NewWizardChannels-i62Y_2DZ.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-9igFL5O8.js → NewWizardPage-BcpRA1fx.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-BcK9FUnU.js → OnboardingPage-BcMDEXNq.js} +1 -1
- package/apps/web/dist/assets/PreviewPane-GHcVV2Hu.js +4 -0
- package/apps/web/dist/assets/ProjectPage-TDywzUOd.js +1 -0
- package/apps/web/dist/assets/{PublicRunner-CZR1ziQ4.js → PublicRunner-B6JINLpR.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-BraZbEG_.js → ReadOnly-Mv5M2OV9.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-B-F1dLgt.js +2 -0
- package/apps/web/dist/assets/{SetupPage-CvkE2aKx.js → SetupPage-CVdsdVBW.js} +1 -1
- package/apps/web/dist/assets/{SharePage-Dk7zC5Zo.js → SharePage-CBSRK0wF.js} +1 -1
- package/apps/web/dist/assets/changelog-BR1lxaWv.js +1 -0
- package/apps/web/dist/assets/{coins-391m1e4_.js → coins-BGZKYmu6.js} +1 -1
- package/apps/web/dist/assets/index-D3-kv1WF.js +14 -0
- package/apps/web/dist/assets/{phone-DvgrtyNO.js → phone-BzHhwehj.js} +1 -1
- package/apps/web/dist/assets/{runners-4OBelIgF.js → runners-C1-zIlry.js} +1 -1
- package/apps/web/dist/assets/{session-DvnGHbDz.js → session-B_JeZnJ0.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-xK9A-gaP.js → settings-menu-BZRGhsIO.js} +1 -1
- package/apps/web/dist/assets/{theme-D3yDT4QT.js → theme-HcCfZDzS.js} +2 -2
- package/apps/web/dist/assets/{ui-BVQk2DtW.js → ui-BI1RPFWT.js} +1 -1
- package/apps/web/dist/assets/{upload-BgXbzG6C.js → upload-CwT8oMz0.js} +1 -1
- package/apps/web/dist/assets/{useMutation-DkwSQWoD.js → useMutation-byk81dDj.js} +1 -1
- package/apps/web/dist/assets/{volume-2-DHGoe3Cg.js → volume-2-B1Pz6Iwt.js} +1 -1
- package/apps/web/dist/assets/{wrench-Cf_aE3O0.js → wrench-CvzXRbWN.js} +1 -1
- package/apps/web/dist/index.html +7 -7
- package/apps/web/dist/mcp/flow.html +1 -1
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
- package/node_modules/@engenty/wizards-shared/dist/sync-merge.d.ts +55 -0
- package/node_modules/@engenty/wizards-shared/dist/sync-merge.js +214 -0
- package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +166 -0
- package/node_modules/@engenty/wizards-shared/dist/sync.js +40 -0
- package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +14 -0
- package/node_modules/@engenty/wizards-shared/dist/text-merge.js +137 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/PreviewPane-X4LBqA0D.js +0 -4
- package/apps/web/dist/assets/ProjectPage-CG0i-KhR.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Bw4tdoV7.js +0 -2
- package/apps/web/dist/assets/changelog-DDXnAaHm.js +0 -1
- package/apps/web/dist/assets/index-BTUtot4r.js +0 -14
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Ai as i,At as a,B as o,Bn as s,Br as c,Bt as l,Cr as u,Dr as d,Er as f,Ht as p,In as m,Jn as h,Jr as g,Jt as _,Kr as v,Kt as y,Lt as b,Qt as x,Rr as S,Rt as C,Ut as w,V as T,Vr as E,Vt as D,W as O,Wt as k,Xt as A,Yn as ee,_r as te,ai as j,bi as ne,br as re,dn as ie,ft as M,gr as ae,jr as N,lr as P,m as oe,mr as se,ni as ce,on as F,ot as le,qt as I,sr as L,tn as R,ur as z,ut as ue,v as B,y as V,yr as H,z as U,zn as de,zt as W}from"./ui-BI1RPFWT.js";import{S as fe,h as G,m as pe}from"./Marketplace-Cnd8BF3q.js";import{t as K}from"./useMutation-byk81dDj.js";import{i as me}from"./volume-2-B1Pz6Iwt.js";import{b as he,d as ge,f as _e,p as ve,r as ye,t as be}from"./theme-HcCfZDzS.js";import{M as xe,j as Se,x as Ce}from"./session-B_JeZnJ0.js";import{t as q}from"./upload-CwT8oMz0.js";import{Z as J,_t as we,a as Te,i as Ee,it as De,mt as Oe,n as ke,o as Ae,r as je,ut as Me}from"./index-D3-kv1WF.js";import{t as Ne}from"./runners-C1-zIlry.js";var Pe={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};Pe.node;var Fe=g(Pe),Ie={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};Ie.node;var Le=g(Ie),Re={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};Re.node;var ze=g(Re),Be={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};Be.node;var Ve=g(Be),He={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};He.node;var Ue=g(He),We={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};We.node;var Ge=g(We),Ke={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};Ke.node;var qe=g(Ke),Je={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};Je.node;var Ye=g(Je),Xe={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Xe.node;var Y=g(Xe),Ze={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};Ze.node;var Qe=g(Ze),$e={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};$e.node;var et=g($e),tt={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};tt.node;var nt=g(tt),X=e(n(),1),Z=e(t(),1);function rt(e){return j({queryKey:[`share-targets`,e,R],queryFn:()=>O.get(`/api/studio/wizards/${e}/share-targets?lang=${R}`),enabled:!!e,staleTime:6e4})}var it=(0,Z.createContext)(null);function at(e){return e.share?e.share.length?`own`:`off`:`default`}var ot=e=>e.byDefault&&e.usable;function st(e,t){let n=at(e),r=e.share??[],i=new Map,a=e=>{let t=i.get(e)??0;return i.set(e,t+1),`${e}#${t}`},o=e=>({key:a(e.id),target:e.id,info:e,index:null,option:null,on:!1,name:e.name});if(n==="default")return{mode:n,rows:t.filter(ot).map(e=>({...o(e),on:!0})),unset:t.filter(e=>e.byDefault&&!e.usable)};let s=r.map((e,n)=>{let r=t.find(t=>t.id===e.target);return{key:a(e.target),target:e.target,info:r,index:n,option:e,on:!0,name:e.label||r?.name||e.target}}),c=new Set(r.map(e=>e.target));return s.push(...t.filter(e=>ot(e)&&!c.has(e.id)).map(o)),{mode:n,rows:s,unset:t.filter(e=>e.byDefault&&!e.usable&&!c.has(e.id))}}function ct(e,t){let n=t.filter(e=>e.on&&e.info?.usable);return{visitors:n.filter(t=>!(e==="default"&&t.info?.agent)),onlyYou:e==="default"?n.filter(e=>e.info?.agent):[],broken:t.filter(e=>e.on&&!e.info?.usable)}}function lt(e){return e.filter(e=>ot(e)&&!e.agent).map(e=>({target:e.id}))}function ut(e,t){let n=at(e);return n===`own`?e.share??[]:n==="default"?lt(t):[]}function dt(e,t,n,r){let i=ut(e,t);return r?[...i,{target:n.target}]:n.index===null?i.filter(e=>e.target!==n.target):i.filter((e,t)=>t!==n.index)}function ft(e,t,n,r){let i=ut(e,t),a=n.index??i.findIndex(e=>e.target===n.target);return a===-1?[...i,r]:i.map((e,t)=>t===a?r:e)}function pt(e,t,n){return[...ut(e,t),{target:n}]}function mt(e,t){let n=new Set(e.map(e=>e.target));return t.filter(e=>e.usable&&!e.byDefault&&!n.has(e.id))}function ht(e,t){let n=e.steps.slice(0,e.steps.indexOf(t));return[...n.flatMap(e=>e.type===`page`?e.fields.filter(e=>e.kind!==`image`&&e.kind!==`file`&&e.kind!==`signature`).map(e=>({ref:e.id,label:e.label})):[]),...n.flatMap(e=>e.type===`agent`&&e.output.format!==`json`?[{ref:`steps.${e.id}`,label:e.title}]:[]),{ref:`brand.name`,label:F(`shareEditor.brandName`)}]}function gt(e){return new Intl.ListFormat(R===`en`?`en-GB`:R,{style:`long`,type:`conjunction`}).format(e)}var _t=(e,t)=>`${e}/${t}`;function vt(e,t,n){if(e.endsWith(`.localhost`)){let r=n&&URL.canParse(n)?new URL(n).port:``;return`http://${e}${r?`:${r}`:``}/${t}`}return`https://${e}/${t}`}var yt=e=>e.lang===`en`?`en`:e.form===`sie`?`de-sie`:`de-du`;function bt(e){return e===`en`?{lang:`en`}:{lang:`de`,form:e===`de-sie`?`sie`:`du`}}var Q={choice:Qe,date:Fe,number:ze,text:pe,boolean:et},xt=e=>[`knowledge`,e];function St(e){return e===1?F(`know.item`):F(`know.items`,{n:e})}function $(e,t){if(e.type===`boolean`||typeof t==`boolean`)return F(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(R,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(R)}${e.unit?` ${e.unit}`:``}`:String(t)}function Ct(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>$(e,t)).join(`, `)]:[]}).join(` · `)}function wt({trigger:e,open:t,onOpen:n,children:r}){let i=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,X.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,X.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function Tt({category:e,current:t,onSave:n}){let[r,i]=(0,Z.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,X.jsx)(y,{multi:!0,value:a,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!a.includes(e)).slice(0,1))}):null,(0,X.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,X.jsx)(w,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:F(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,X.jsx)(p,{label:F(`know.addValue`),type:`submit`,children:(0,X.jsx)(H,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,X.jsx)(y,{value:t[0]===!0?F(`know.yes`):t[0]===!1?F(`know.no`):``,options:[F(`know.yes`),F(`know.no`)],onChange:e=>n([e===F(`know.yes`)])}):(0,X.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,X.jsx)(w,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,X.jsx)(b,{type:`submit`,size:`sm`,children:`OK`})]})}function Et({projectId:e,itemKey:t,has:n,categories:r,readOnly:a}){let o=i(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(n);(0,Z.useEffect)(()=>u(n),[n]);let d=K({mutationFn:({categoryId:n,next:r})=>O.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>o.invalidateQueries({queryKey:xt(e)})}),f=r.filter(e=>!(e.proposed||e.tableId)),m=(e,t)=>{u(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),d.mutate({categoryId:e.id,next:t}),c(null)},h=f.filter(e=>l.some(t=>t.categoryId===e.id)),g=f.filter(e=>!l.some(t=>t.categoryId===e.id));return f.length?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[h.map(e=>{let t=l.find(t=>t.categoryId===e.id),n=Q[e.type],r=(0,X.jsxs)(`button`,{type:`button`,disabled:a,title:`${e.name} · ${F(`know.by.${t.by}`)}`,onClick:()=>c(s===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,X.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,X.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,X.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>$(e,t)).join(`, `)})]},e.id);return a?(0,X.jsx)(`span`,{children:r},e.id):(0,X.jsxs)(wt,{trigger:r,open:s===e.id,onOpen:t=>c(t?e.id:null),children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,X.jsx)(p,{label:F(`know.remove`),onClick:()=>m(e,[]),className:`size-7`,children:(0,X.jsx)(L,{className:`size-3.5`})})]}),(0,X.jsx)(Tt,{category:e,current:t.values,onSave:t=>m(e,t)})]},e.id)}),a||!g.length?null:(0,X.jsx)(wt,{open:s===`+`,onOpen:e=>c(e?`+`:null),trigger:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(s===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,X.jsx)(H,{className:`size-3.5`}),` `,F(`know.category`)]}),children:(0,X.jsx)(Dt,{categories:g,onSave:m})})]}):null}function Dt({categories:e,onSave:t}){let[n,r]=(0,Z.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,X.jsx)(I,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,X.jsx)(Tt,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function Ot({projectId:e,open:t,onClose:n,onMade:r}){let a=i(),[o,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(`choice`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),[y,S]=(0,Z.useState)(``),C=K({mutationFn:()=>O.post(`/api/studio/projects/${e}/categories`,{name:o.trim(),type:c,unit:c===`number`&&d.trim()||null,multiple:c===`choice`&&p,ordered:c===`choice`&&h,hint:y.trim()||null,values:c===`choice`?_.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:xt(e)}),s(``),v(``),S(``),r(t)}});return(0,X.jsx)(l,{open:t,onClose:n,title:F(`know.newCategory`),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&C.mutate()},children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`know.name`)}),(0,X.jsx)(w,{"data-autofocus":!0,value:o,maxLength:80,onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`know.type`)}),(0,X.jsx)(I,{value:c,onChange:e=>u(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:F(`know.type.${e}`)}))})]}),c===`number`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{hint:F(`know.unitHint`),children:F(`know.unit`)}),(0,X.jsx)(w,{value:d,maxLength:20,onChange:e=>f(e.target.value)})]}):null,c===`choice`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{hint:F(`know.valuesHint`),children:F(`know.values`)}),(0,X.jsx)(x,{minRows:3,value:_,onChange:e=>v(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[F(`know.multiple`),(0,X.jsx)(A,{checked:p,onChange:m})]}),(0,X.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[F(`know.ordered`),(0,X.jsx)(A,{checked:h,onChange:g})]})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{hint:F(`know.hintFieldHint`),children:F(`know.hintField`)}),(0,X.jsx)(w,{value:y,maxLength:120,onChange:e=>S(e.target.value)})]}),C.error?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:C.error.message}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(b,{variant:`ghost`,onClick:n,children:F(`common.cancel`)}),(0,X.jsx)(b,{type:`submit`,busy:C.isPending,disabled:!o.trim(),children:F(`know.create`)})]})]})})}function kt({projectId:e,category:t,readOnly:n,onOpen:r,onGone:a}){let o=i(),s=()=>o.invalidateQueries({queryKey:xt(e)}),[c,l]=(0,Z.useState)(``),u=K({mutationFn:e=>e(),onSuccess:s}),d=Q[t.type],f=new Map(t.values.map(e=>[e.id,e]));return(0,X.jsxs)(V,{title:t.name,hint:[F(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,X.jsx)(p,{label:F(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(F(`know.confirmCategory`,{name:t.name}))&&u.mutate(async()=>{await O.del(`/api/studio/categories/${t.id}`),a()}),children:(0,X.jsx)(z,{className:`size-4`})}),children:[t.proposed&&!n?(0,X.jsxs)(C,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,X.jsx)(W,{tone:`ember`,children:F(`know.proposed`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:F(`know.proposedHint`)}),(0,X.jsx)(b,{size:`sm`,onClick:()=>u.mutate(()=>O.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:F(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=f.get(e),i=f.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,X.jsxs)(C,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,X.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:F(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,X.jsx)(b,{size:`sm`,variant:`secondary`,busy:u.isPending,onClick:()=>u.mutate(()=>O.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:F(`know.merge`)})]},`${e}:${t}`)}),(0,X.jsxs)(C,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,X.jsx)(d,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,X.jsx)(W,{children:F(`know.summary`)}):null,(0,X.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:St(e.count)})]},e.id)):(0,X.jsx)(D,{children:F(`know.empty`)}):(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,X.jsx)(d,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?F(`know.range`,{min:$(t,t.range.min),max:$(t,t.range.max)}):F(`know.unset`)}),(0,X.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:St(t.count)})]}),t.type===`choice`&&!n?(0,X.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=c.trim();n&&(l(``),u.mutate(()=>O.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,X.jsx)(w,{value:c,placeholder:F(`know.addValue`),onChange:e=>l(e.target.value),className:`h-9`}),(0,X.jsx)(p,{label:F(`know.addValue`),type:`submit`,children:(0,X.jsx)(H,{className:`size-4`})})]}):null]}),u.error?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u.error.message}):null]})}function At(e){return j({queryKey:[`knowledge-value`,e],queryFn:()=>O.get(`/api/studio/values/${e}`),enabled:!!e})}function jt({value:e,readOnly:t,children:n}){let r=i(),a=K({mutationFn:()=>O.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>r.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,X.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,X.jsx)(V,{title:F(`know.summary`),hint:F(`know.summaryHint`),plain:!0,action:t?null:(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,busy:a.isPending,onClick:()=>a.mutate(),children:[e.summary?(0,X.jsx)(te,{className:`size-4`}):null,e.summary?F(`know.summaryAgain`):F(`know.summaryWrite`)]}),children:(0,X.jsxs)(C,{className:`p-4 sm:p-5`,children:[a.isPending?(0,X.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,X.jsx)(_,{})}):e.summary?(0,X.jsx)(M,{text:e.summary,className:`text-[0.875rem]`}):(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`know.summaryEmpty`)}),a.error?(0,X.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error.message}):null]})}),(0,X.jsx)(V,{title:F(`know.toc`),plain:!0,children:n})]})}function Mt(e){return j({queryKey:[`knowledge`,e],queryFn:()=>O.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function Nt(e){return e.kind===`table`?e.format===`faq`?Ue:G:e.kind===`file`?u:e.children?Le:N}function Pt({item:e,categories:t,onOpen:n}){let r=Nt(e),i=[Ct(t,e.categories),e.children?e.children===1?F(`know.oneSub`):F(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?F(`know.row`):F(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,X.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,X.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,X.jsx)(_,{className:`size-3`}),` `,F(`know.reading`)]}):e.review?(0,X.jsx)(W,{tone:`warn`,title:e.review,children:F(`know.review`)}):null]})}function Ft({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let l=Mt(e),d=[r?F(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[l.data?(0,X.jsx)(Et,{projectId:e,itemKey:t,has:n,categories:l.data.categories,readOnly:s}):null,d.length||o||a?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[d.map(e=>(0,X.jsx)(`span`,{children:e},e)),o?(0,X.jsxs)(`a`,{href:U(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,X.jsx)(u,{className:`size-3.5`}),` `,F(`know.original`),`: `,o.name]}):null,a?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,X.jsx)(W,{tone:`warn`,children:F(`know.review`)}),(0,X.jsx)(`span`,{children:a}),s?null:(0,X.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:F(`know.reviewed`)})]}):null]}):null]})}function It(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function Lt({projectId:e,category:t,categories:n,onOpen:r}){let i=j({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>O.get(`/api/studio/categories/${t.id}/items`)});if(!i.data)return i.isLoading?(0,X.jsx)(_,{className:`mx-auto size-4 text-ink-3`}):null;let a=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],o=[...i.data.items].sort((e,t)=>{let n=a(e),r=a(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),R)}),s=t.type===`number`?It(o.map(a).filter(e=>typeof e==`number`)):[],c=new Intl.NumberFormat(R,{notation:`compact`,maximumFractionDigits:1}),l=t.unit?` ${t.unit}`:``,u=new Map;for(let e of o){let n=a(e),r=typeof n==`number`?s.find(e=>n>=e.lo&&n<e.hi):void 0,i=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(R,{month:`long`,year:`numeric`}):r?F(`know.range`,{min:`${c.format(r.lo)}${l}`,max:`${c.format(r.hi)}${l}`}):$(t,n);u.set(i,[...u.get(i)??[],e])}return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...u].map(([e,t])=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,X.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,X.jsx)(C,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,X.jsx)(Pt,{item:e,categories:n,onOpen:r},e.key))})]},e)),i.data.rows.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:F(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function Rt(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function zt(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return F(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${F(`know.contains`)} ${t.contains}`:[n===void 0?``:`${F(`know.minimum`)} ${$(e,n)}`,r===void 0?``:`${F(`know.maximum`)} ${$(e,r)}`].filter(Boolean).join(` `)}return String(t)}function Bt({category:e,value:t,onChange:n}){let[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>!o.current?.contains(e.target)&&a(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let s=Q[e.type],l=typeof t==`object`&&t&&!Array.isArray(t)?t:{},u=(t,r)=>{let i={...l,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,X.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:r(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,X.jsx)(s,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,X.jsxs)(`span`,{className:`font-medium`,children:[`: `,zt(e,t)]}),(0,X.jsx)(c,{className:`size-3.5 text-ink-3`})]}),i?(0,X.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,X.jsx)(y,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,X.jsx)(y,{value:t===!0?F(`know.yes`):t===!1?F(`know.no`):``,options:[F(`know.yes`),F(`know.no`)],onChange:e=>n(e===F(`know.yes`))}):e.type===`text`?(0,X.jsx)(w,{"data-autofocus":!0,value:l.contains??``,placeholder:F(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(n===0?`know.minimum`:`know.maximum`)}),(0,X.jsx)(w,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(l[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>u(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,X.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),a(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:F(`know.clear`)})]}):null]})}function Vt({found:e,onOpen:t}){return e.hits.length?(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?F(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):F(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,X.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,X.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,X.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(R,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,X.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:F(`know.searchNone`)})}function Ht({kind:e,projectId:t,onClose:n,onMade:r}){let a=i(),[o,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(!1),d=K({mutationFn:()=>O.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),...e===`table`&&c?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`knowledge`,t]}),r(`${e===`table`?`t`:`p`}:${n}`),s(``),u(!1)}});return(0,X.jsx)(l,{open:e!==null,onClose:n,title:F(e===`table`?`know.newTable`:`know.newPage`),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&d.mutate()},children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.title`)}),(0,X.jsx)(w,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>s(e.target.value)})]}),e===`table`?(0,X.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[F(`know.asFaq`),(0,X.jsx)(A,{checked:c,onChange:u})]}):null,d.error?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(b,{variant:`ghost`,onClick:n,children:F(`common.cancel`)}),(0,X.jsx)(b,{type:`submit`,busy:d.isPending,disabled:!o.trim(),children:F(`know.create`)})]})]})})}function Ut({projectId:e,data:t,readOnly:n,onOpen:r}){let a=i(),o=T(e,n),[s,c]=(0,Z.useState)({}),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),v=t.categories.filter(e=>!e.proposed&&e.count>0),y=t.categories.filter(e=>e.proposed),x=t.items.filter(e=>Object.entries(s).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?Rt(i,a.values,r):!1})),S=async()=>{if(!l.trim()){f(null);return}m(!0);try{f(await O.post(`/api/studio/projects/${e}/search`,{query:l,...Object.keys(s).length?{where:s}:{}}))}catch{f({hits:[],candidates:0,checked:!1,filtered:null})}finally{m(!1)}},w=K({mutationFn:({id:e,keep:t})=>t?O.patch(`/api/studio/categories/${e}`,{proposed:!1}):O.del(`/api/studio/categories/${e}`),onSuccess:()=>a.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,X.jsxs)(V,{title:F(`know.title`),hint:F(`know.hint`),plain:!0,action:n?null:(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:()=>g(`page`),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`know.page`)]}),(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:()=>g(`table`),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`know.table`)]}),(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:()=>g(`category`),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`know.category`)]})]}),children:[y.length&&!n?(0,X.jsx)(C,{className:`flex flex-col gap-2 p-4`,children:y.map(e=>{let t=Q[e.type];return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,X.jsx)(W,{tone:`ember`,children:F(`know.proposed`)}),(0,X.jsx)(t,{className:`size-4 text-ink-3`}),(0,X.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[F(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,X.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>w.mutate({id:e.id,keep:!1}),children:F(`know.dismiss`)}),(0,X.jsx)(b,{size:`sm`,onClick:()=>w.mutate({id:e.id,keep:!0}),children:F(`know.accept`)})]},e.id)})}):null,t.items.length?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(B,{value:l,placeholder:F(`know.search`),busy:p,onEnter:()=>void S(),onChange:e=>{u(e),e.trim()||f(null)}}),v.length?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[v.map(e=>(0,X.jsx)(Bt,{category:e,value:s[e.name],onChange:t=>{f(null),c(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(s).length?(0,X.jsx)(`button`,{type:`button`,onClick:()=>c({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:F(`know.clear`)}):null]}):null]}):null,(0,X.jsx)(C,{className:`flex flex-col p-1.5`,children:d?(0,X.jsx)(Vt,{found:d,onOpen:r}):x.length?x.map(e=>(0,X.jsx)(Pt,{item:e,categories:t.categories,onOpen:r},e.key)):(0,X.jsx)(D,{children:F(`know.empty`)})}),n?null:(0,X.jsxs)(oe,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await o.upload(`document`,t),await a.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[o.busy?(0,X.jsx)(_,{className:`size-4`}):(0,X.jsx)(q,{className:`size-4`}),F(`know.drop`),` `,(0,X.jsx)(`span`,{className:`underline`,children:F(`know.pick`)})]}),o.error?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,X.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:F(`know.keywordsOnly`),t.checked?``:F(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,X.jsx)(Ht,{kind:h===`page`||h===`table`?h:null,projectId:e,onClose:()=>g(null),onMade:e=>{g(null),r(e)}}),(0,X.jsx)(Ot,{projectId:e,open:h===`category`,onClose:()=>g(null),onMade:e=>{g(null),r(`c:${e}`)}})]})}function Wt({page:e,onGone:t,onOpen:n}){let a=i(),[s,c]=(0,Z.useState)(e.title),[l,u]=(0,Z.useState)(e.markdown),[d,f]=(0,Z.useState)(e.markdown?`read`:`write`),m=e.knowledge,h=async()=>{await a.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await a.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},g=o({title:s.trim()||e.title,markdown:l},async t=>{await O.patch(`/api/studio/pages/${e.id}`,t),a.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await h()}),v=K({mutationFn:()=>O.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await h(),t()}}),y=K({mutationFn:()=>O.post(`/api/studio/projects/${e.projectId}/pages`,{title:F(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await h(),n?.(`p:${e}`)}}),x=K({mutationFn:()=>O.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>a.invalidateQueries({queryKey:[`space-page`,e.id]})}),w=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await O.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},T=e.readOnly,D=m?.file&&(m.file.mime===`application/pdf`||m.file.mime.startsWith(`image/`))?m.file:null,k=(e,t)=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":d===e,onClick:()=>f(e),className:r(`rounded-full px-3 py-1 text-[0.8125rem] transition`,d===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,X.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[m?.parents.length&&n?(0,X.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:m.parents.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,X.jsx)(S,{className:`size-3.5`})]},e.id))}):null,(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,X.jsx)(`input`,{value:s,disabled:T,maxLength:200,onChange:e=>c(e.target.value),"aria-label":F(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),g.state===`saving`?(0,X.jsx)(_,{className:`size-3.5 text-ink-3`}):g.state===`saved`?(0,X.jsx)(E,{className:`size-4 text-moss`,"aria-label":F(`settings.saved`)}):null,T?null:(0,X.jsx)(p,{label:F(`data.deletePage`),onClick:()=>confirm(F(`data.confirmDelete`,{title:e.title}))&&v.mutate(),className:`hover:text-rose`,children:(0,X.jsx)(z,{className:`size-4`})})]}),m?(0,X.jsx)(Ft,{projectId:e.projectId,itemKey:`p:${e.id}`,has:m.categories,originLabel:m.originLabel,kept:m.kept,review:m.review,file:D?null:m.file,readOnly:T,onReviewed:()=>x.mutate()}):null,(0,X.jsxs)(C,{className:`flex flex-col`,children:[T&&!D?null:(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[T?null:k(`write`,F(`data.write`)),k(`read`,F(`data.preview`)),D?k(`original`,F(`know.original`)):null,(0,X.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:d===`original`&&D?D.name:F(`data.markdownHint`)})]}),d===`original`&&D?D.mime===`application/pdf`?(0,X.jsx)(`iframe`,{src:U(e.projectId,D.id),title:D.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,X.jsx)(`img`,{src:U(e.projectId,D.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):d===`write`&&!T?(0,X.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),"aria-label":e.title,placeholder:F(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,X.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:w,children:l.trim()?(0,X.jsx)(M,{text:l}):(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`data.pageEmpty`)})})]}),g.state===`error`&&g.error?(0,X.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:g.error}):null,m&&n&&(m.children.length||!T)?(0,X.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,X.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:m.children.length?F(`know.subPages`):null}),T?null:(0,X.jsxs)(b,{variant:`ghost`,size:`sm`,busy:y.isPending,onClick:()=>y.mutate(),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`know.addSub`)]})]}),m.children.length?(0,X.jsx)(C,{className:`flex flex-col p-1.5`,children:m.children.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,X.jsx)(N,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function Gt({pageId:e,onGone:t,onOpen:n}){let r=j({queryKey:[`space-page`,e],queryFn:()=>O.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{kind:`page`,item:e}),(0,X.jsx)(Wt,{page:r.data,onGone:t,onOpen:n},r.data.id)]}):r.isError?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function Kt(e){return j({queryKey:[`space-data`,e],queryFn:()=>O.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function qt(e){let t=t=>[...e.tables.filter(e=>e.wizardId===t).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,rows:e.rows})),...e.pages.filter(e=>e.wizardId===t).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title}))];return[{key:`own`,label:F(`data.own`),items:t(null)},...e.wizards.map(e=>({key:e.id,label:e.title,items:t(e.id)}))].filter(e=>e.items.length)}var Jt={table:G,page:N};function Yt({kind:e,projectId:t,data:n,onClose:r,onMade:a}){let o=i(),[s,c]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),f=K({mutationFn:()=>O.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:s.trim(),wizardId:u||null}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:[`space-data`,t]}),a(`${e===`table`?`t`:`p`}:${n}`),c(``),d(``)}});return(0,X.jsx)(l,{open:e!==null,onClose:r,title:F(e===`table`?`data.newTable`:`data.newPage`),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&f.mutate()},children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.title`)}),(0,X.jsx)(w,{"data-autofocus":!0,value:s,maxLength:120,onChange:e=>c(e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.owner`)}),(0,X.jsx)(I,{value:u,onChange:d,options:[{value:``,label:F(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),f.error?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(b,{variant:`ghost`,onClick:r,children:F(`common.cancel`)}),(0,X.jsx)(b,{type:`submit`,busy:f.isPending,disabled:!s.trim(),children:F(`data.create`)})]})]})})}function Xt({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,Z.useState)(null);De(n?null:{icon:H,label:F(`data.newTable`),run:()=>a(`table`)});let o=qt(t),s=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),c=new Intl.DateTimeFormat(R,{dateStyle:`medium`});return(0,X.jsxs)(V,{title:F(`space.data`),hint:F(`data.hint`),plain:!0,action:n?null:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`data.table`)]}),(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`data.page`)]})]}),children:[o.length?(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,X.jsx)(C,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Jt[e.kind];return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,X.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,X.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${F(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,X.jsx)(C,{children:(0,X.jsx)(D,{children:F(`data.empty`)})}),(0,X.jsx)(Yt,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function Zt(e,t){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,48)||`column`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}var Qt={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},$t=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function en(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Qt[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}var tn=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function nn({column:e,value:t,readOnly:n,invalid:i,onSave:a}){let o=en(e,t),[s,c]=(0,Z.useState)(o);(0,Z.useEffect)(()=>c(o),[o]);let l=(t=s)=>{t!==o&&a(ee(e,t))};if(e.type===`boolean`)return(0,X.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,X.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>a(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],i=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[i(e),n?null:(0,X.jsx)(`button`,{type:`button`,"aria-label":F(`data.removeOption`),onClick:()=>a(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,X.jsx)(L,{className:`size-3`})})]},e)),n?null:(0,X.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&a([...r,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,X.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,X.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>a(e.target.value||null),"aria-label":e.name,className:tn,children:[(0,X.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,X.jsx)(`textarea`,{value:s,rows:1,disabled:n,onChange:e=>c(e.target.value),onBlur:()=>l(),"aria-label":e.name,className:r(tn,`field-sizing-content max-h-40 resize-none`)});let u=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,X.jsx)(`input`,{type:u,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:s,disabled:n,onChange:t=>{c(t.target.value),e.type===`date`&&l(t.target.value)},onBlur:()=>e.type!==`date`&&l(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&c(o)},"aria-label":e.name,className:r(tn,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,i&&`ring-1 ring-rose`)})}function rn(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?F(`data.unit.${e.format.inputUnit}`):null}function an(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
|
|
3
|
+
`):``,multiple:e?.type===`select`&&!!e.format.multiple}}function on(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
|
|
4
|
+
`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Zt(e,i);return i.push(n),{id:n,label:e}});return{...r,type:`select`,format:{allowCustom:!1,options:a,...e.multiple?{multiple:!0}:{}}}}case`boolean`:return{...r,type:`boolean`};default:return{...r,type:`text`,...e.textStyle===`multiline`?{format:{style:`multiline`}}:{}}}}function sn({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,Z.useState)(()=>an(t)),[s,c]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&(o(an(t)),c(null))},[e,t]);let f=e=>o(t=>({...t,...e})),p=async e=>{d(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{d(!1)}},m=()=>{let e=t?.id??Zt(a.name,n.map(e=>e.id)),r=on(a,e,t);return p(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,X.jsx)(l,{open:e,onClose:r,title:t?t.name:F(`data.newColumn`),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&m()},children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.columnName`)}),(0,X.jsx)(w,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>f({name:e.target.value})})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.columnType`)}),(0,X.jsx)(I,{value:a.type,onChange:e=>f({type:e}),options:$t.map(e=>({value:e,label:F(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,X.jsx)(I,{value:a.textStyle,onChange:e=>f({textStyle:e}),options:[{value:`single`,label:F(`data.text.single`)},{value:`multiline`,label:F(`data.text.multiline`)}]}):null,a.type===`number`?(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)(I,{value:a.numberStyle,onChange:e=>f({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:F(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,X.jsx)(w,{value:a.currency,maxLength:3,"aria-label":F(`data.currency`),placeholder:`EUR`,onChange:e=>f({currency:e.target.value})}):null]}):null,a.type===`date`?(0,X.jsx)(I,{value:a.dateKind,onChange:e=>f({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:F(`data.date.${e}`)}))}):null,a.type===`duration`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.unit`)}),(0,X.jsx)(I,{value:a.unit,onChange:e=>f({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:F(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(k,{children:F(`data.options`)}),(0,X.jsx)(x,{minRows:3,value:a.options,onChange:e=>f({options:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,X.jsx)(A,{checked:a.multiple,onChange:e=>f({multiple:e})}),F(`data.multiple`)]})]}):null,(0,X.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,X.jsx)(A,{checked:a.required,onChange:e=>f({required:e})}),F(`data.required`)]}),s?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,X.jsx)(b,{variant:`ghost`,className:`text-rose`,disabled:u,onClick:()=>confirm(F(`data.confirmDelete`,{title:t.name}))&&void p(n.filter(e=>e.id!==t.id)),children:F(`data.deleteColumn`)}):null,(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(b,{variant:`ghost`,onClick:r,children:F(`common.cancel`)}),(0,X.jsx)(b,{type:`submit`,busy:u,disabled:!a.name.trim(),children:F(`settings.save`)})]})]})})}function cn({tableId:e,onGone:t}){let n=i(),r=[`space-table`,e],o=j({queryKey:r,queryFn:()=>O.get(`/api/studio/tables/${e}`)}),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(``);(0,Z.useEffect)(()=>h(o.data?.title??``),[o.data?.title]);let g=async()=>{await n.invalidateQueries({queryKey:[`space-data`,o.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,o.data?.projectId]})},_=e=>n.setQueryData(r,t=>t&&{...t,rows:e(t.rows)}),v=e=>{u(e.message),o.refetch()},y=async t=>{await O.patch(`/api/studio/tables/${e}`,t),await o.refetch(),await g()},x=K({mutationFn:({row:t,column:n,value:r})=>O.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{u(null),f(e=>e===`${t}:${n}`?null:e),_(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof a&&e.body?.column===n){let e=o.data?.columns.find(e=>e.id===n)?.name??n;f(`${t}:${n}`),u(F(`data.badCell`,{column:e}));return}v(e)}}),S=K({mutationFn:()=>O.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{_(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await g()},onError:v}),w=K({mutationFn:t=>O.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{_(e=>e.filter(e=>e.id!==t)),await g()},onError:v}),T=K({mutationFn:()=>O.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await g(),t()}});if(!o.data)return o.isError?(0,X.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error.message}):null;let{columns:E,rows:D,readOnly:k}=o.data,A=!!o.data.list;return(0,X.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(J,{kind:`table`,item:e}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,X.jsx)(`input`,{value:m,disabled:k,maxLength:120,onChange:e=>h(e.target.value),onBlur:()=>m.trim()&&m!==o.data?.title&&void y({title:m}).catch(v),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":F(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),k?null:(0,X.jsx)(p,{label:F(`data.deleteTable`),onClick:()=>confirm(F(`data.confirmDelete`,{title:o.data.title}))&&T.mutate(),className:`hover:text-rose`,children:(0,X.jsx)(z,{className:`size-4`})})]}),A?(0,X.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:F(`data.fromList`)}):null,o.data.knowledge?(0,X.jsx)(Ft,{projectId:o.data.projectId,itemKey:`t:${o.data.id}`,has:o.data.knowledge.categories,originLabel:o.data.knowledge.originLabel,kept:o.data.knowledge.kept,review:o.data.knowledge.review,file:o.data.knowledge.file,readOnly:k,onReviewed:()=>void O.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>o.refetch()).catch(v)}):null,(0,X.jsxs)(C,{className:`overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[E.map(e=>(0,X.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,X.jsxs)(`button`,{type:`button`,disabled:k||A,onClick:()=>c(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,X.jsx)(`span`,{className:`text-ember`,children:`*`}):null,rn(e)?(0,X.jsx)(`span`,{className:`font-normal text-ink-4`,children:rn(e)}):null]})},e.id)),(0,X.jsx)(`th`,{className:`w-10 p-1`,children:k||A?null:(0,X.jsx)(p,{label:F(`data.newColumn`),onClick:()=>c(`new`),className:`size-8`,children:(0,X.jsx)(H,{className:`size-4`})})})]})}),(0,X.jsx)(`tbody`,{children:D.map(e=>(0,X.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[E.map(t=>(0,X.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,X.jsx)(nn,{column:t,value:e.cells[t.id],readOnly:k,invalid:d===`${e.id}:${t.id}`,onSave:n=>x.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,X.jsx)(`td`,{className:`w-10 p-1 align-top`,children:k?null:(0,X.jsx)(p,{label:F(`data.deleteRow`),onClick:()=>w.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,X.jsx)(z,{className:`size-3.5`})})})]},e.id))})]})}),D.length?null:(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:F(`data.noRows`)}),k?null:(0,X.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,X.jsxs)(b,{variant:`ghost`,size:`sm`,busy:S.isPending,onClick:()=>S.mutate(),children:[(0,X.jsx)(H,{className:`size-4`}),` `,F(`data.addRow`)]})})]}),l?(0,X.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l}):null,(0,X.jsx)(sn,{open:s!==null,column:s===`new`?null:s,columns:E,onClose:()=>c(null),onSave:e=>y({columns:e})})]})}var ln=`wizards.runDrawer.width`,un=`wizards.runDrawer.wide`,dn=680,fn=400,pn=()=>Math.max(fn,window.innerWidth-120);function mn(e){try{return localStorage.getItem(e)}catch{return null}}function hn(e,t){try{localStorage.setItem(e,t)}catch{}}function gn(){let[e,t]=(0,Z.useState)(()=>{let e=Number(mn(ln));return e?Math.min(Math.max(e,fn),pn()):dn}),[n,r]=(0,Z.useState)(()=>mn(un)===`1`),i=(0,Z.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,fn),pn()));t(n),hn(ln,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),hn(un,n?`0`:`1`)},onPointerDown:t=>{t.preventDefault();let n=t.clientX,r=e,a=e=>i(r+n-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),i(e+n)):t.key===`ArrowRight`&&(t.preventDefault(),i(e-n))},reset:()=>i(dn)}}function _n({look:e,onChange:t,ways:n=[`steps`,`chat`]}){let i=[{id:`steps`,label:F(`chat.steps`),Icon:Ve},{id:`chat`,label:F(`chat.chat`),Icon:Ue}].filter(e=>n.includes(e.id));return(0,X.jsx)(`fieldset`,{"aria-label":F(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:i.map(({id:n,label:i,Icon:a})=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:i,onClick:()=>t(n),className:r(`inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,e===n?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[(0,X.jsx)(a,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:r(e!==n&&`sr-only`),children:i})]},n))})}function vn({header:e,actions:t,onClose:n,children:i}){let a=gn();return(0,X.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,X.jsxs)(`div`,{className:r(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!a.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${a.width}px`},onClick:e=>e.stopPropagation(),children:[a.wide?null:(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":F(`editor.resize`),"aria-valuenow":a.width,tabIndex:0,title:F(`editor.resize`),onPointerDown:a.onPointerDown,onKeyDown:a.onKeyDown,onDoubleClick:a.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,X.jsx)(`span`,{className:`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 h-8 w-1 rounded-full bg-ink-4/20 transition group-hover:bg-ember/60 group-focus-visible:bg-ember group-active:h-12 group-active:bg-ember`})}),(0,X.jsxs)(`div`,{className:`kb-hide flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,X.jsx)(p,{label:F(a.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:a.toggleWide,className:`max-sm:hidden`,children:a.wide?(0,X.jsx)(Ge,{className:`size-4`}):(0,X.jsx)(f,{className:`size-4`})}),(0,X.jsx)(p,{label:F(`editor.close`),onClick:n,children:(0,X.jsx)(L,{className:`size-5`})})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:i})]})})}function yn(e,t){return t.deliverables.map(t=>{let n=s(t.from),r=n?e.lists?.find(e=>e.id===n)?.title:e.steps.find(e=>e.id===t.from)?.title;return{from:t.from,label:t.label??r??t.from,formats:t.formats}})}function bn({wizardId:e,def:t,step:n,revision:i,audience:a,onAudience:o,lead:s,under:c,end:l,onTest:u,testBusy:d,testDisabled:f}){let p=j({queryKey:[`share-preview`,e,n.id,i,a,R],queryFn:()=>O.get(`/api/studio/wizards/${e}/share-preview?step=${encodeURIComponent(n.id)}&as=${a}&lang=${R}`),placeholderData:ne}),[m,h]=(0,Z.useState)(!0),[g,v]=(0,Z.useState)(null),y=p.data,x=y?.targets.find(e=>e.key===g),S=yn(t,n),w=y?.run?new Intl.DateTimeFormat(R,{dateStyle:`short`,timeStyle:`short`}).format(new Date(y.run.at)):null;return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-ember border-b-2 px-3`,children:[s,(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`fieldset`,{"aria-label":F(`resultPreview.seenBy`),className:`m-0 flex rounded-full border-0 bg-paper-2 p-0.5`,children:[`visitor`,`owner`].map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>o(e),className:r(`inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 font-medium text-[0.8125rem] transition coarse:h-9`,a===e?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[e===`visitor`?(0,X.jsx)(Me,{className:`size-3.5`}):(0,X.jsx)(nt,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`max-sm:sr-only`,children:F(e===`visitor`?`resultPreview.visitor`:`resultPreview.you`)})]},e))}),(0,X.jsxs)(b,{size:`sm`,variant:`secondary`,busy:d,disabled:f,onClick:u,children:[(0,X.jsx)(Y,{className:`size-3.5`}),F(`editor.test`)]}),l]}),c,(0,X.jsx)(`div`,{className:`@container min-h-0 flex-1 overflow-y-auto`,children:(0,X.jsxs)(`div`,{className:`mx-auto max-w-2xl px-4 py-5 sm:px-6`,children:[(0,X.jsxs)(`p`,{className:`mb-5 flex items-center gap-2 text-[0.75rem] text-ink-3`,children:[p.isFetching?(0,X.jsx)(_,{className:`size-3.5 shrink-0`}):(0,X.jsx)(Oe,{className:`size-3.5 shrink-0`}),w?F(`resultPreview.from`,{time:w}):F(`resultPreview.none`)]}),(0,X.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-x-4 gap-y-4`,children:[(0,X.jsx)(Ce,{kind:t.avatar,costume:t.costume,size:56,interactive:!1}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,X.jsx)(`h2`,{className:`text-balance font-display font-semibold text-[1.5rem] leading-tight tracking-tight`,children:n.title}),n.message?(0,X.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-3`,children:n.message}):null]}),(0,X.jsxs)(b,{variant:`secondary`,"aria-expanded":m,onClick:()=>h(!m),className:r(m&&`ring-2 ring-ember`),children:[(0,X.jsx)(se,{className:`size-4`}),` `,F(`shareRun.button`)]})]}),m?(0,X.jsx)(C,{className:`mb-6 p-4 shadow-elevated sm:p-5`,children:x?(0,X.jsx)(Sn,{target:x,deliverables:S,hasRun:!!y?.run,onBack:()=>v(null)},`${x.key}:${JSON.stringify(x.fields.map(e=>e.value))}`):(0,X.jsx)(xn,{data:y,onPick:v})}):null,(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:S.map(e=>{let t=y?.outputs[e.from];return(0,X.jsxs)(C,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:e.label}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.formats.map(e=>(0,X.jsx)(`span`,{className:`inline-flex h-7 items-center rounded-full bg-paper-2 px-3 font-medium text-[0.75rem] text-ink-2`,children:ue[e]},e))})]}),t?(0,X.jsx)(`div`,{className:`max-h-72 overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]`,children:(0,X.jsx)(M,{text:t})}):(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`resultPreview.notMade`)})]},e.from)})})]})})]})}function xn({data:e,onPick:t}){let n=ce(),r=e?.left.filter(e=>e.why===`agent`)??[],i=e?.left.filter(e=>e.why===`setup`)??[];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(`h3`,{className:`font-medium text-[1.0625rem]`,children:F(`shareRun.title`)}),(0,X.jsxs)(`div`,{className:`grid gap-2.5 @lg:grid-cols-2`,children:[(0,X.jsx)(ke,{icon:d,name:F(`share.link`),description:F(`shareRun.linkHint`)}),(e?.targets??[]).map(e=>(0,X.jsx)(ke,{icon:Ae[e.icon],name:e.name,description:e.description,onClick:()=>t(e.key)},e.key))]}),r.length?(0,X.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg bg-paper-2 px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,X.jsx)(fe,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),F(`resultPreview.agentLeft`,{names:gt(r.map(e=>e.name))})]}):null,i.length?(0,X.jsxs)(`p`,{className:`flex flex-wrap items-start gap-x-2 gap-y-1 rounded-lg bg-amber-tint px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,X.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:F(`resultPreview.setupLeft`,{names:gt(i.map(e=>e.name))})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(`/settings/connectors`),className:`font-medium text-ember-strong hover:underline`,children:F(`shareEditor.setUp`)})]}):null]})}function Sn({target:e,deliverables:t,hasRun:n,onBack:r}){let[i,a]=(0,Z.useState)(()=>Object.fromEntries(e.fields.map(e=>[e.id,e.value??``]))),[o,s]=(0,Z.useState)(()=>Object.fromEntries(t.map(e=>[e.from,e.formats[0]]))),c=[...e.connection?[F(`shareRun.stepAccount`)]:[],F(`shareRun.stepForm`),F(`shareRun.stepSend`)];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(p,{label:F(`run.back`),onClick:r,className:`-ml-2`,children:(0,X.jsx)(v,{className:`size-4`})}),(0,X.jsx)(`h3`,{className:`min-w-0 flex-1 truncate font-medium text-[1.0625rem]`,children:e.name})]}),(0,X.jsx)(`div`,{className:`-mb-6`,children:(0,X.jsx)(Te,{steps:c,now:+!!e.connection})}),e.connection?.account?(0,X.jsx)(`p`,{className:`rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem] text-ink-2`,children:F(`shareRun.as`,{account:e.connection.account.label})}):null,e.agent?(0,X.jsxs)(`p`,{className:`flex items-start gap-2.5 rounded-lg bg-ember-tint px-3 py-2.5 text-[0.8125rem] text-ink-2 leading-relaxed`,children:[(0,X.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-ember-strong`}),` `,F(`shareRun.agentHint`)]}):null,e.fields.map(e=>(0,X.jsx)(je,{field:e,value:i[e.id]??``,choices:[],onChange:t=>a(n=>({...n,[e.id]:t}))},e.id)),n&&e.empty.length?(0,X.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg bg-amber-tint px-3 py-2.5 text-[0.8125rem] text-ink-2`,children:[(0,X.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-amber`}),F(`resultPreview.empty`,{names:e.empty.map(e=>`{{${e}}}`).join(`, `)})]}):null,e.takes===`files`&&t.length?(0,X.jsx)(Ee,{deliverables:t,picked:o,onPick:(e,t)=>s(n=>({...n,[e]:t}))}):null,(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:F(`resultPreview.nothingSent`)})]})}function Cn({label:e,value:t,onChange:n,options:i,named:a}){return(0,X.jsx)(`fieldset`,{"aria-label":e,className:`m-0 flex shrink-0 rounded-full border-0 bg-paper-2 p-0.5`,children:i.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.id,title:e.label,onClick:()=>n(e.id),className:r(`inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,t===e.id?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[e.icon,(0,X.jsx)(`span`,{className:r(!!e.icon&&!(a&&t===e.id)&&`sr-only`,a&&`@min-[26rem]:not-sr-only`),children:e.label})]},e.id))})}function wn({label:e,value:t,onChange:n,options:i}){return(0,X.jsxs)(`label`,{className:`relative flex shrink-0 items-center`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:e}),(0,X.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),title:e,className:r(`h-8 appearance-none truncate rounded-full border-0 bg-paper-2 py-0 pr-7 pl-3 font-medium text-[0.75rem] text-ink outline-none focus-visible:ring-2 focus-visible:ring-ember coarse:h-10 max-w-40`),children:i.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,X.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2.5 size-3 text-ink-3`,viewBox:`0 0 16 16`,fill:`none`,children:(0,X.jsx)(`path`,{d:`M4 6l4 4 4-4`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})]})}function Tn(e){return e.name??F(e.id==="default"?`inspector.lookThemeDefault`:`inspector.lookThemeBrand`)}function En({wizard:e,runId:t,runView:n,onView:i,stepId:a,audience:o,onAudience:s,test:c,column:l,onColumn:u,onClose:d,building:f,log:g,strip:_,lead:v,onShowRun:y,onEdit:x}){let S=e.draft,C=j({queryKey:[`wizard-looks`,e.id,e.revision],queryFn:()=>O.get(`/api/studio/wizards/${e.id}/looks`),placeholderData:ne}).data?.looks,[w,T]=(0,Z.useState)(null),E=C?.find(e=>e.id===w)??C?.[0]??null,D=E?.theme??n?.brand.theme??null,[k,A]=(0,Z.useState)(null),ee=D?.prefer??(D?.dark?`dark`:`light`),te=k??ee,M=ye(D,k),N=e.runners??Ne,P=[`steps`,`chat`].filter(e=>N.enabled.includes(e)||N.default===e),oe=N.default===`chat`&&P.includes(`chat`)?`chat`:`steps`,[se,ce]=(0,Z.useState)(null),I=se??oe,z=h(S),ue=j({queryKey:[`wizard-translations`,e.id],queryFn:()=>O.get(`/api/studio/wizards/${e.id}/translations`),enabled:e.published&&e.translate}),B=[z,...e.translate?(ue.data?.translations??[]).map(e=>e.lang):[]].filter((e,t,n)=>n.indexOf(e)===t),[V,H]=(0,Z.useState)(z),U=(0,Z.useRef)({run:null,lang:z});(0,Z.useEffect)(()=>{if(!t)return;let e=U.current;U.current={run:t,lang:V},!(e.run===t?e.lang===V:V===z)&&O.post(`/api/runs/${t}/lang`,{lang:V===z?null:V}).catch(()=>void 0)},[t,V,z]),(0,Z.useEffect)(()=>(V!==z&&m(V)&&ie(V),()=>ie(R)),[V,z]);let[W,fe]=(0,Z.useState)(`desk`),G=a?S.steps.find(e=>e.id===a)??null:null,pe=j({queryKey:[`draft-step-view`,e.id,G?.id,e.revision,V],queryFn:()=>O.get(`/api/studio/wizards/${e.id}/steps/${encodeURIComponent(G?.id??``)}/view${V===z?``:`?lang=${encodeURIComponent(V)}`}`),enabled:!!(G&&G.type!==`result`),placeholderData:(e,t)=>t?.queryKey[2]===G?.id?e:void 0}),K=async()=>!1,me=G&&pe.data?{view:pe.data,notFound:!1,error:null,busy:!1,fieldErrors:{},submitPage:K,accept:K,regenerate:K,back:K,retry:K}:null,q=G?.type===`result`?G:null,J=l===null?null:(0,X.jsx)(p,{label:F(l?`editor.columnHide`:`editor.columnShow`),onClick:()=>u(!l),children:l?(0,X.jsx)(qe,{className:`size-4`}):(0,X.jsx)(Ye,{className:`size-4`})});return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[q?(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(bn,{wizardId:e.id,def:S,step:q,revision:e.revision,audience:o,onAudience:s,lead:v,under:_,end:J,onTest:c.start,testBusy:c.busy,testDisabled:c.disabled})}):null,(0,X.jsxs)(`div`,{className:r(`flex min-h-0 flex-1 flex-col`,q&&`hidden`),children:[(0,X.jsxs)(`div`,{className:`kb-hide flex h-12 shrink-0 items-center gap-1.5 overflow-x-auto border-border-soft border-b px-3 [scrollbar-width:none]`,children:[v,P.length>1&&!G?(0,X.jsx)(`span`,{className:`shrink-0`,children:(0,X.jsx)(_n,{look:I,onChange:ce,ways:[...P]})}):null,y?(0,X.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-paper-2 px-3 font-medium text-[0.75rem] text-ink-2 transition hover:text-ink`,children:[(0,X.jsx)(Y,{className:`size-3.5`}),F(`run.testChip`)]}):null,(0,X.jsx)(`span`,{className:`flex-1`}),x?(0,X.jsxs)(b,{variant:`secondary`,size:`sm`,onClick:x,children:[(0,X.jsx)(re,{className:`size-3.5`}),F(`editor.edit`)]}):null,C&&C.length>1&&E?(0,X.jsx)(wn,{label:F(`editor.previewTheme`),value:E.id,onChange:T,options:C.map(e=>({value:e.id,label:Tn(e)}))}):null,be(D)?(0,X.jsx)(Cn,{label:F(`editor.previewMode`),value:te,onChange:A,options:[{id:`light`,label:F(`theme.light`),icon:(0,X.jsx)(Se,{className:`size-3.5`})},{id:`dark`,label:F(`theme.dark`),icon:(0,X.jsx)(xe,{className:`size-3.5`})}]}):null,B.length>1?(0,X.jsx)(wn,{label:F(`editor.previewLang`),value:V,onChange:H,options:B.map(e=>({value:e,label:de(e)}))}):null,(0,X.jsx)(`span`,{className:`max-sm:hidden`,children:(0,X.jsx)(Cn,{label:F(`editor.device`),value:W,onChange:fe,options:[{id:`desk`,label:F(`editor.deviceDesk`),icon:(0,X.jsx)(we,{className:`size-3.5`})},{id:`phone`,label:F(`editor.devicePhone`),icon:(0,X.jsx)(he,{className:`size-3.5`})}]})}),t?(0,X.jsx)(p,{label:F(`editor.restart`),disabled:c.disabled||c.busy,onClick:c.start,children:(0,X.jsx)(ae,{className:`size-4`})}):(0,X.jsxs)(b,{size:`sm`,variant:`secondary`,busy:c.busy,disabled:c.disabled,onClick:c.start,children:[(0,X.jsx)(Y,{className:`size-3.5`}),F(`editor.test`)]}),J,t?(0,X.jsx)(p,{label:F(`editor.close`),onClick:d,children:(0,X.jsx)(L,{className:`size-4`})}):null]}),_,(0,X.jsx)(`div`,{className:r(`relative flex min-h-0 flex-1 justify-center`,W===`phone`&&`bg-paper-2 py-4`),children:(0,X.jsxs)(`div`,{className:r(`relative min-h-0 w-full`,M?.className,W===`phone`&&`max-w-[390px] overflow-hidden rounded-[2rem] shadow-elevated ring-8 ring-paper-3`),style:M?.style,children:[(0,X.jsx)(ge,{effects:D?.effects,contained:!0}),(0,X.jsx)(`div`,{className:`absolute inset-0 overflow-y-auto bg-background`,children:f?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-[0.875rem] text-ink-3`,children:f}):G||t?(0,X.jsxs)(X.Fragment,{children:[G&&me?(0,X.jsx)(le,{run:me,compact:!0,studio:!0},G.id):null,t?(0,X.jsx)(`div`,{className:r(G&&`hidden`),children:I===`chat`?(0,X.jsx)(ve,{runId:t,onRestart:c.start,onView:i},t):(0,X.jsx)(_e,{runId:t,compact:!0,studio:!0,onRestart:c.start,onView:i},t)}):null]}):(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,X.jsx)(Ce,{kind:S.avatar,costume:S.costume,size:160,fluffy:!0}),(0,X.jsx)(`h2`,{className:`text-balance font-display font-semibold text-[1.5rem] tracking-tight`,children:S.title}),S.description?(0,X.jsx)(`p`,{className:`max-w-md text-balance text-[0.9375rem] text-ink-2`,children:S.description}):null,(0,X.jsxs)(b,{busy:c.busy,disabled:c.disabled,onClick:c.start,children:[(0,X.jsx)(Y,{className:`size-4`}),F(`editor.test`)]}),(0,X.jsx)(`p`,{className:`max-w-sm text-balance text-[0.8125rem] text-ink-3`,children:F(`editor.previewEmpty`)})]})})]})}),t&&!G?g:null]})]})}export{st as A,it as C,gt as D,mt as E,ze as F,Fe as I,rt as M,et as N,ht as O,Y as P,yt as S,ct as T,jt as _,Jt as a,_t as b,Kt as c,Pt as d,Ft as f,kt as g,Q as h,cn as i,dt as j,ft as k,Gt as l,Mt as m,En as n,Xt as o,Ut as p,vn as r,qt as s,Cn as t,Lt as u,At as v,pt as w,vt as x,bt as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,A as i,Ai as a,Ar as o,B as s,Bt as c,C as l,Cr as u,D as d,Dr as f,E as p,H as m,Ht as h,I as g,Ir as _,Jr as v,Jt as y,Kt as b,L as x,Lt as S,M as C,Mr as w,N as T,O as E,Or as D,P as O,Pr as ee,Qr as k,Qt as A,R as j,Rt as M,S as te,T as N,U as P,Ut as F,V as ne,Vr as I,Vt as re,W as L,Wr as ie,Wt as R,Xn as z,Xr as B,Xt as V,Yt as H,Zt as U,_ as W,_r as G,ai as ae,b as oe,br as se,d as ce,f as le,ft as ue,g as de,h as K,hr as fe,ii as pe,j as me,jr as he,k as ge,kr as _e,m as ve,ni as ye,on as q,p as J,pr as be,qt as xe,ri as Se,ti as Ce,tn as we,ur as Y,v as Te,w as Ee,x as De,y as X,yr as Oe,z as ke,zt as Ae}from"./ui-BI1RPFWT.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-Cnd8BF3q.js";import{t as Le}from"./useMutation-byk81dDj.js";import{F as Re,I as ze,N as Be,S as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at,x as ot,y as st}from"./PreviewPane-GHcVV2Hu.js";import{b as ct,f as lt}from"./theme-HcCfZDzS.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-B_JeZnJ0.js";import{t as ht}from"./phone-BzHhwehj.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-Mv5M2OV9.js";import{t as yt}from"./upload-CwT8oMz0.js";import{Ct as bt,Dt as xt,J as St,St as Ct,_t as wt,c as Tt,ct as Et,d as Dt,f as Ot,gt as kt,h as At,it as jt,jt as Mt,m as Nt,p as Pt,pt as Ft,q as It,s as Lt,u as Rt,v as zt,wt as Bt,y as Vt}from"./index-D3-kv1WF.js";import{a as Ht,c as Ut,f as Wt,i as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./settings-menu-BZRGhsIO.js";var Qt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Qt.node;var $t=v(Qt),en={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};en.node;var tn=v(en),nn={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};nn.node;var rn=v(nn),an={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};an.node;var on=v(an),sn={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};sn.node;var cn=v(sn),ln={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};ln.node;var un=v(ln),dn={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};dn.node;var fn=v(dn),pn={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};pn.node;var mn=v(pn),hn={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};hn.node;var gn=v(hn),Z=e(t(),1),Q=e(n(),1),_n={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function vn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:q(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function yn(e,t){confirm(q(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let i=ke(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:i,alt:``,loading:`lazy`,className:r(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${i}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:i,small:n});let a=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(mn,{className:a}):t.mime===`application/pdf`?(0,Q.jsx)(he,{className:a}):t.mime===`application/json`?(0,Q.jsx)(be,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(o,{className:a}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function xn({src:e,small:t}){let[n,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),i(t)}).catch(()=>i(null))},[e]),(0,Q.jsx)(`div`,{className:r(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Sn=`application/x-wizards-logo`;function Cn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):yn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Sn,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?_n:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(bn,{projectId:e,file:n})}):(0,Q.jsx)(bn,{projectId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(h,{label:q(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(je,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(h,{label:q(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(de,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(vn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(ve,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(Oe,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:i}){let[a,o]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),g=async()=>{l(!0),d(null);try{let r=await t(a.trim());r.file?(n([r.file]),i()):r.candidates?.length?(p(r.candidates),h([r.candidates[0].url])):d(q(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}l(!1)},_=async()=>{l(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}l(!1),e.length&&n(e),e.length===m.length&&i()};return(0,Q.jsx)(c,{open:!0,onClose:i,wide:f?!0:void 0,title:q(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:r(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:_n,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:r(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},t.url)})}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>p(null),children:q(`run.back`)}),(0,Q.jsx)(S,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?q(`project.addMany`,{n:m.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:s,disabled:!a.trim(),children:q(`run.next`)})]})]})})}function Tn(e,t,n){return ae({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>L.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function En(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Dn=e=>[En(e),e.pages?q(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:i}){let o=a(),s=P(e),c=Qe(e),l=ne(e,n),u=s.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,p]=(0,Z.useState)(null);if(!u)return s.isLoading?(0,Q.jsx)(y,{className:`mx-auto text-ink-3`}):null;let m=f??(d?`original`:`text`),g=c.data?.items.find(e=>e.key===`f:${u.id}`),_=ke(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:r(`rounded-full px-3 py-1 text-[0.8125rem] transition`,m===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Dn(u)}),(0,Q.jsx)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{label:q(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(G,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(q(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:g?.categories??[],originLabel:g?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(vn,{file:u,actions:l})}),u.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,Q.jsxs)(M,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[d?v(`original`,q(`project.original`)):null,v(`text`,q(`project.readText`))]}),m===`original`?u.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:_,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:_,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(An,{projectId:e,file:u})]})]})}function An({projectId:e,file:t}){let n=Tn(e,t,On);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(y,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ue,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:q(`project.textCut`,{shown:n.data.text.length.toLocaleString(we),total:n.data.chars.toLocaleString(we)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:q(`project.noText`)})}var jn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),z(e.size)].filter(Boolean).join(` · `);function Nn({projectId:e,file:t,actions:n,onClose:r}){let i=ke(e,t.id);return(0,Q.jsxs)(c,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:_n,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(vn,{file:t,actions:n})})]})}function Pn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(bn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mn(t)})]}),(0,Q.jsx)(vn,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(h,{label:q(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(de,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function Fn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(c,{open:!0,onClose:r,title:q(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:q(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(S,{variant:`danger`,onClick:n,children:q(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(S,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,disabled:!i.trim(),children:q(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:a}){let o=ne(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(r),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=s({assetSections:g},a),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),ee=new Set(g.flatMap(e=>e.assets)),k=g.find(e=>e.id===v)??null,A=k?k.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!ee.has(e.id)),j=D.find(e=>e.id===f),M=u.trim().toLowerCase(),te=M?A.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(M)):A,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),P=async e=>{let t=k?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},F=e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},I=g.length?{options:[{value:``,label:q(`project.assetsGeneral`)},...g.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>g.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,re=[{label:q(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:q(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...g.length<i.logoSections?[{label:q(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],L=g.length||D.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[g.length?(0,Q.jsx)(U,{value:v,onChange:e=>{b(e),d(``)},label:q(`project.assets`),options:[{id:``,label:q(`project.assetsGeneral`)},...g.map(e=>({id:e.id,label:e.title||q(`project.sectionUntitled`)}))]}):null,k&&!n?(0,Q.jsx)(h,{label:q(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(se,{className:`size-4`})}):null]}),A.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Te,{value:u,onChange:d,placeholder:q(`project.assetSearch`)})}),(0,Q.jsx)(h,{label:q(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(bt,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:q(`project.assets`),hint:q(`project.assetsHint`),save:E,tabs:L,action:n?null:(0,Q.jsx)(ce,{entries:re}),children:[(0,Q.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:jn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&P(t)}}),te.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:te,actions:o,moveTo:I,onRemove:F,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:I,onPreview:()=>p(t.id),onRemove:()=>F(t)},t.id))}):A.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.staysLocal`)}):(0,Q.jsxs)(ve,{accept:jn,onFiles:e=>void P(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),q(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:q(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,Q.jsx)(Nn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,Q.jsx)(Fn,{section:x===`current`?k:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&k)_(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=De();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&k?()=>{(!k.assets.length||confirm(q(`project.assetSectionRemoveConfirm`,{name:k.title})))&&(_(e=>e.filter(e=>e.id!==k.id)),b(``),S(null))}:void 0}):null,C?(0,Q.jsx)(wn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,k?.id??null)}}):null]})}var Ln=/^#[0-9a-fA-F]{6}$/;async function Rn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var zn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Bn({projectId:e,gradient:t,isNew:n,brand:i,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[u,f]=(0,Z.useState)(O(t)),[p,m]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!n),T=e=>{l(e),f(O(e)),m(!1)},E=(e,t)=>T({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),D=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));T({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},ee=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:g.trim(),...C?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});T({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),w(!0)}catch(e){x(e.message)}y(!1)};return(0,Q.jsx)(c,{open:!0,onClose:o,wide:!0,title:q(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g.trim()&&!v&&ee()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:g,maxLength:1e3,"aria-label":q(`project.gradientDescribe`),placeholder:q(C?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(S,{type:`submit`,variant:`secondary`,busy:v,disabled:!g.trim(),children:[(0,Q.jsx)(be,{className:`size-4`}),q(C?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??q(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:O(s)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:q(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:q(`project.gradientUse`),onChange:e=>l({...s,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:d.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:q(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":q(`project.gradientAngle`),onChange:e=>T({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(H,{value:Ln.test(e.color)?e.color:`#888888`,onChange:e=>E(t,{color:e.target.value})}),(0,Q.jsx)(F,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Ln.test(n)&&E(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":q(`project.gradientAt`),onChange:e=>E(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(h,{label:q(`project.remove`),disabled:s.stops.length<=2,onClick:()=>T({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.gradientStopAdd`)]}):null,i.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:q(`project.gradientFromBrand`)}),i.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>D(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:`CSS`}),(0,Q.jsx)(F,{value:u,spellCheck:!1,onChange:e=>{f(e.target.value);let t=j(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:q(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:o,children:q(`common.cancel`)}),(0,Q.jsx)(S,{onClick:()=>{a(s),o()},children:q(`settings.save`)})]})]})})}var Vn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Hn=`size-8 bg-card shadow-soft hover:bg-card`;function Un({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(K,{value:e,label:q(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:q(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wn({gradient:e,readOnly:t,onEdit:n,onChange:i,onRemove:a}){let o=O(e),[s,c]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":q(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(h,{label:q(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(_,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),t?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:q(`project.gradientName`),description:e.description,usePlaceholder:q(`project.gradientUse`),readOnly:t,onChange:i})]})}function Gn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kn({projectId:e,pattern:t,fileName:n,readOnly:i,onEdit:a,onChange:o,onRemove:s}){let c=ke(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-label":q(`project.patternEdit`),onClick:a,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gn(c,t.tile)}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(`a`,{href:c,download:n,"aria-label":q(`project.download`),title:q(`project.download`),className:r(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(ee,{className:`size-4`})}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:q(`project.patternUse`),readOnly:i,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:i,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,p]=(0,Z.useState)(t),[m,h]=(0,Z.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:_,wide:!0,title:q(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gn(ke(e,f.file),f.tile),children:(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[a?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(D,{className:`size-4`}),q(`project.patternReplace`)]})}):(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(D,{className:`size-5`}),q(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?i(f.file):q(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:q(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:_,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!f.file||a,onClick:()=>{for(let e of m.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:q(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)([]),h=async()=>{s(!0),u(null);try{let{colors:t}=await L.post(`/api/studio/projects/${e}/colors/scan`,{url:i.trim()});t.length?(f(t),m([])):u(q(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:q(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:r(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>f(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?q(`project.addMany`,{n:p.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorsUrlHint`)})]}),l?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:o,disabled:!i.trim(),children:q(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:a,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:De()}))),[g,_]=(0,Z.useState)(r),[v,y]=(0,Z.useState)(a),[b,x]=(0,Z.useState)(o),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=ne(e,f),D=te(c),[O,ee]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N=s({colors:p.filter(e=>Jn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:g,gradients:v,patterns:b,colorRules:D.rules},d),P=l?g:[],I=P.filter(e=>(e.kind??`colors`)===`colors`),re=e=>I.some(t=>t.id===e.section),L=p.filter(e=>!re(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),B=e=>m(t=>[...t,...e.map(e=>({...e,id:De()}))].slice(0,i.colors)),V=[{value:``,label:q(`project.sectionStandard`)},...I.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],U=(e,t)=>{let n=De();ee(n),_(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},G=e=>({id:De(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&Jn.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&Jn.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),ae=e=>t.files.find(t=>t.id===e)?.name??`pattern`,se=[...p.length<i.colors?[{label:q(`project.colorNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>K()},{label:q(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&g.length<i.logoSections?[{label:q(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>U(`colors`,``)},{label:q(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>U(`gradients`,q(`project.gradientSectionTitle`))},{label:q(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>U(`patterns`,q(`project.patternSectionTitle`))}]:[],...!u||D.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],ue=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(H,{value:Jn.test(e.value)?e.value:`#888888`,onChange:t=>z(e.id,{value:t.target.value})}),(0,Q.jsx)(F,{value:e.name,autoFocus:e.id===k,placeholder:q(`project.colorName`),maxLength:120,onChange:t=>z(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(F,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>z(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===R?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.colorAccent`)})}):f?null:(0,Q.jsx)(h,{label:q(`project.colorFirst`),onClick:()=>m(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(ie,{className:`size-4`})}),f||!I.length?null:(0,Q.jsx)(de,{options:V,value:re(e)?e.section??``:``,onChange:t=>z(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>m(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]},e.id),K=e=>{let t=De();A(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:q(`project.colors`),hint:q(`project.colorsHint`),save:N,locked:f,action:f?null:(0,Q.jsx)(ce,{entries:se}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[L.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:L.map(ue)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.colorsEmpty`)}),P.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),a=v.filter(e=>e.section===t.id),o=b.filter(e=>e.section===t.id),s=n===`gradients`?a.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:t.title,titlePlaceholder:q(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:q(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:q(`project.kindPatterns`)}:{icon:(0,Q.jsx)(kt,{}),label:q(`project.kindColors`)},autoFocus:O===t.id,readOnly:f,onChange:e=>_(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(q(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||q(`project.sectionUntitled`)}))){_(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),y(e=>e.filter(e=>e.section!==t.id));for(let e of o)E.remove(e.file);x(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>C(e),onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>y(t=>t.filter(t=>t.id!==e.id))},e.id)),f||v.length>=i.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>C(G(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(Kn,{projectId:e,pattern:t,fileName:ae(t.file),readOnly:f,onEdit:()=>T(t),onChange:e=>x(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{E.remove(t.file),x(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||b.length>=i.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T({id:De(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ue),f||p.length>=i.colors?null:(0,Q.jsx)(le,{label:q(`project.colorAdd`),onClick:()=>K(t.id)})]})]},t.id)}),u?(0,Q.jsx)(W,{rules:D,placeholder:q(`project.colorRulePlaceholder`),readOnly:f}):null]}),E.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.error}):null,S?(0,Q.jsx)(Bn,{projectId:e,gradient:S,isNew:!v.some(e=>e.id===S.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>C(null),onSave:e=>y(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,w?(0,Q.jsx)(qn,{projectId:e,pattern:w,isNew:!b.some(e=>e.id===w.id),fileName:ae,busy:E.busy,error:E.error,upload:async e=>(await E.upload(`pattern`,[e]))[0]??null,removeFile:e=>void E.remove(e),onClose:()=>T(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,j?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:B}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:f,email:Ct,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let l=Qn[e??t],u=`${q(`project.factType`)}: ${q(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),a(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":i,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:r(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,i?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),i?(0,Q.jsxs)(`div`,{role:`menu`,className:r(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(Fe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=Qn[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),a=(0,Z.useRef)(null),[o,c]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=s(o.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),d=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:q(`project.facts`),hint:q(`project.factsHint`),save:u,locked:n,action:o.length<i.facts&&!n?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=me(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(F,{ref:p(`${e.id}:label`),value:e.label,placeholder:q(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:C(e.label,o.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(V,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:q(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?q(`project.yes`):q(`project.no`)})]}):(0,Q.jsx)(A,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:q(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)($n,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},e.id)})}),o.length<i.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:q(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-3.5`}),` `,q(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[i,a]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),a(!0))},onDragLeave:()=>a(!1),onDrop:t=>{let n=t.dataTransfer.getData(Sn);a(!1),n&&(t.preventDefault(),e(n))},className:r(`-m-2 rounded-xl p-2 transition`,i&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function nr({projectId:e,data:t,readOnly:n,sections:r,rules:a,sectioned:o,ruled:c,save:l}){let u=ne(e,n),[d,f]=(0,Z.useState)(r),p=te(a),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=s({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=o?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=g(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),ee=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},k=C.length?{options:[{value:``,label:q(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,A=(t,n,r)=>(0,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?q(`project.logoAdd`):void 0,onUpload:e=>void ee(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:k,onRemove:e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:q(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:q(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<i.logoSections?[{label:q(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=De();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:q(`project.logos`),hint:q(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(ce,{entries:M}),children:[(0,Q.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ee(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:A(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(tr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:e.title,description:e.description,titlePlaceholder:q(`project.logoSectionTitle`),descriptionPlaceholder:q(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(q(`project.logoSectionRemoveConfirm`,{name:e.title||q(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),A(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(W,{rules:p,placeholder:q(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,Q.jsx)(wn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var rr=e=>URL.canParse(e)?new URL(e).host:e;async function ir(e,t){let n=T({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ar(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function ar(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function or(e,t){let n=e.source;if(!n)return q(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return q(`project.fontSourceFile`,{name:e})}return q(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:i}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=ne(e),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[d,f]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[h,g]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(t.license??``),[C,w]=(0,Z.useState)(!1),T=p.trim(),E=async()=>{v(!0),g({url:T,result:await ir(T,t.family.trim())}),v(!1)},D=l===`file`?d?{file:d}:null:h?.url===T&&h.result===`ok`?{url:T}:null,O=h?.url===T?h.result:null;return(0,Q.jsx)(c,{open:!0,onClose:i,title:q(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontSourceHint`)}),(0,Q.jsx)(b,{value:l,options:[`file`,`url`],label:e=>q(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>f(e.id),className:r(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,d===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&f(n.id)}}),(0,Q.jsxs)(S,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),q(`project.fontSourceUpload`)]}),o.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),E()},children:[(0,Q.jsx)(R,{children:q(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:q(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(S,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:q(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:q(`project.fontCheck.${O}`,{host:rr(T),family:t.family})}):null,O===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:q(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:q(`project.fontLicenseHint`),children:q(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:q(`project.fontLicensePlaceholder`),onChange:e=>x(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:C,onChange:e=>w(e.target.checked)}),q(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(S,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),i()},children:q(`project.fontSourceRemove`)}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!(D&&C),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),i())},children:q(`project.fontSourceSave`)})]})]})})}var cr=new Set;function lr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||cr.has(t))return;cr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${p.join(`,`)}&display=swap`,document.head.append(n)},[e])}var ur=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function dr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var fr=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,pr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function mr({projectId:e,font:t,first:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){lr(t.family);let c=P(e).data?.files??[],[l,u]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:ur(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(K,{value:t.family,label:q(`project.fontFamily`),placeholder:q(`project.fontFamily`),maxLength:80,autoFocus:a,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(K,{value:t.role,label:q(`project.fontRole`),placeholder:q(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:p.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>o({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:ur(t.family),fontWeight:e},className:r(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(K,{value:t.license??``,label:q(`project.fontLicense`),placeholder:q(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),i&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:q(`project.fontUses`)}),N.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):N.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:r(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:[n?(0,Q.jsx)(I,{className:`size-3.5`}):null,q(pr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:or(t,c)}),i||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:q(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:ur(c?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[i?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(K,{value:e.name,label:q(`project.styleName`),placeholder:q(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:i,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":q(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:r(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||q(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":q(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...p,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:q(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:q(`project.styleLine`),label:q(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:q(`project.styleTracking`),label:q(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:q(`project.styleUpper`),"aria-label":q(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:r(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(rn,{className:`size-4`})})]}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gr({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),l(null);try{let{fonts:t}=await L.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(q(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:q(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,Q.jsx)(_r,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?q(`project.addMany`,{n:f.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function _r({font:e,on:t,onToggle:n}){return lr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:r(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:ur(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):q(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:a,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=te(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=s({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:De(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,i.fonts))},x=()=>{let e=De();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<i.fonts?[{label:q(`project.fontNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:q(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<i.textStyles?[{label:q(`project.styleNew`),icon:(0,Q.jsx)(Ft,{className:`size-4 shrink-0`}),onPick:x}]:[],...!a||m.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:q(`project.typography`),hint:q(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(ce,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(mr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:q(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(hr,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,a?(0,Q.jsx)(W,{rules:m,placeholder:q(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(gr,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function yr({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=s({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(X,{title:q(`project.base`),hint:q(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.title`)}),(0,Q.jsx)(F,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.about`)}),(0,Q.jsx)(A,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.aboutHint`)})]})]})})}function br({project:e,group:t,top:n=!1,children:r}){let i=a(),o=P(e.id),[s,l]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(!1),f=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},p=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),m=pt(),h=dt(),g=o.data??{files:[],embeddings:!0},_=`${e.id}:${s}`,v=e.readOnly,y=t===`knowledge`,b=Et(`brandSections`),x=Et(`brandRules`),C=Et(`typography`);return St(v?{}:{title:q(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:q(y?`project.assistantHelloKnowledge`:`project.assistantHello`),about:q(y?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:q(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:q(`assistant.suggest.knowledgeHow`)},{label:q(`assistant.suggest.knowledgeSite`),fill:!0},{label:q(`assistant.suggest.knowledgeCategories`)}]:[{label:q(`assistant.suggest.readSite`),fill:!0},{label:q(`assistant.suggest.missing`)},{label:q(`assistant.suggest.facts`)}],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>l(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,Q.jsx)(vt,{children:gt(e)}):n?(0,Q.jsx)(It,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:f},`base:${_}`)}),(0,Q.jsx)(J,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>f({facts:e}),readOnly:v},`facts:${_}`)}),(0,Q.jsx)(J,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>f({brand:e})},`logos:${_}`)}),(0,Q.jsx)(J,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>f({brand:e}),readOnly:v},`colors:${_}`)}),C?(0,Q.jsx)(J,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||q(`project.typeSample`),save:e=>f({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,Q.jsx)(J,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>f({brand:e})},`assets:${_}`)})]}):null,r,t===`info`&&m&&!v&&h?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(S,{variant:`danger`,onClick:()=>d(!0),children:q(`settings.delete`)}),(0,Q.jsxs)(c,{open:u,onClose:()=>d(!1),title:q(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:q(`settings.deleteBody`)}),p.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:p.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(!1),children:q(`common.cancel`)}),(0,Q.jsx)(S,{variant:`danger`,busy:p.isPending,onClick:()=>p.mutate(),children:q(`common.delete`)})]})]})]}):null]})}var xr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Sr=`font-mono text-[0.875rem]`,Cr=e=>e.slice(e.indexOf(`.`)+1);function wr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Tr(){let e=q(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(B,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:q(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(B,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:q(`project.facts`)},t):e),` `,q(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:i}){let a=ge.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Cr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:i,"aria-label":q(`page.address`),maxLength:E.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:r(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$,!a&&t&&`text-rose`),children:q(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:i}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:i,maxLength:E.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:i,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:r(`mt-1`,$),children:q(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:i,maxLength:E.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.words`)}),(0,Q.jsx)(A,{value:t.intro??``,disabled:i,minRows:3,maxLength:E.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.lang`)}),(0,Q.jsx)(xe,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:q(e.label)}))}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return q(`page.draftNote`);if(!e.shareEnabled)return q(`page.notSharedNote`);let n=e.description.trim();return t?[n,q(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:i,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:r(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`page.moveUp`)} / ${q(`page.moveDown`)}`,onKeyDown:o.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(_e,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(mt,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:r(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(V,{checked:n,disabled:i||!e.published,label:q(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:i,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:i||a,onClick:o,className:r(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:a?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(i||a)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var jr={desktop:1280,tablet:768,mobile:390},Mr=`wizards.pagePreviewDevice`,Nr=`wizards.pagePreviewHeight`,Pr=360,Fr=e=>e?640:480,Ir=()=>Math.max(Pr,window.innerHeight-140);function Lr(){try{let e=Number(localStorage.getItem(Nr));return e>=Pr?e:null}catch{return null}}function Rr(e){try{e===null?localStorage.removeItem(Nr):localStorage.setItem(Nr,String(Math.round(e)))}catch{}}function zr(){try{let e=localStorage.getItem(Mr);return e&&e in jr?e:`desktop`}catch{return`desktop`}}function Br(e){try{localStorage.setItem(Mr,e)}catch{}}function Vr({url:e,version:t,device:n}){let i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let s=jr[n],[c,l]=(0,Z.useState)(Lr),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=Math.min(c??Fr(a.tall),a.width?Ir():9999),m=e=>{let t=Math.round(Math.min(Ir(),Math.max(Pr,e)));return l(t),t},h=n===`mobile`,g=h?12:0,_=a.width?Math.min(1,(a.width-2*g)/s):1,v=(0,Q.jsxs)(`div`,{className:r(`relative overflow-hidden bg-paper-2`,h?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(s*_),height:p},children:[a.width?(0,Q.jsx)(`iframe`,{title:q(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:r(`absolute top-0 left-0 border-0`,u&&`pointer-events-none`),style:{width:s,height:Math.ceil(p/_),transform:`scale(${_})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":q(`page.resize`),title:q(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}f.current={y:e.clientY,height:p},d(!0)},onPointerMove:e=>{f.current&&m(f.current.height+e.clientY-f.current.y)},onPointerUp:e=>{f.current&&=(Rr(m(f.current.height+e.clientY-f.current.y)),null),d(!1)},onPointerCancel:()=>{f.current=null,d(!1)},onDoubleClick:()=>{l(null),Rr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Rr(m(p+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:i,className:`flex w-full justify-center`,children:h?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:v}):v})}function Hr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Ve(t)})),l=s(o,async e=>{if(!(ge.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=st(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Dr,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Ur({project:e}){let t=a(),n=ft(),i=n.data?.tenant.pagesHost??null,o=n.data?.manageUrl??null,s=e.readOnly,c=e.page,l=!!c?.on,u=ae({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[d,f]=(0,Z.useState)(1),[p,m]=(0,Z.useState)(zr),h=(0,Z.useRef)(c);h.current=c;let g=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),f(e=>e+1)},v=Le({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[y,b]=(0,Z.useState)({state:`idle`,error:null}),{copied:C,copy:w}=wr(),T=u.data??[],E=(c?.wizards??[]).map(e=>T.find(t=>t.id===e)).filter(e=>e!==void 0),D=T.filter(e=>!c?.wizards.includes(e.id)),[O,ee]=(0,Z.useState)(null),k=(e,t)=>{let n=[...c?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),v.mutate({wizards:n})},A=(e,t)=>v.mutate({wizards:t?[...c?.wizards??[],e]:(c?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>g({on:!0,slug:x(j)||`page`,title:j,...st(we===`de`?`de-du`:`en`),wizards:T.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{c?v.mutate({on:e}):e&&te.mutate()},P=v.isPending||te.isPending,F=v.error??te.error;if(!i)return(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsx)(X,{title:q(`space.page`),hint:q(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:q(`page.cloudOnly`)})})});let ne=c?.slug||x(j)||`…`,re=We(i,ne),ie=ot(i,ne,o),R=(0,Q.jsxs)(`span`,{className:r(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[i,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:ne})]}),z=s||!c,B=(0,Q.jsxs)(M,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.previewTitle`)}),l?(0,Q.jsx)(rt,{named:!0,label:q(`editor.device`),value:p,onChange:e=>{m(e),Br(e)},options:[{id:`desktop`,label:q(`editor.deviceDesk`),icon:(0,Q.jsx)(wt,{className:`size-3.5`})},{id:`tablet`,label:q(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:q(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),l?(0,Q.jsx)(Vr,{url:ie,version:d,device:p}):(0,Q.jsx)(`p`,{className:$,children:q(`page.previewOff`)}),l?(0,Q.jsx)(`p`,{className:$,children:q(`page.previewHint`)}):null]}),H=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:q(`share.onPage`,{space:c?.title||j})}),(0,Q.jsx)(`span`,{className:r(`block truncate font-mono`,$),children:re})]}),(0,Q.jsx)(V,{checked:!0,disabled:!0,label:q(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:q(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:q(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:q(`page.intro`)})]}),(0,Q.jsxs)(M,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:r(`size-2 shrink-0 rounded-full`,l?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),R]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>w(ie),children:[C?(0,Q.jsx)(I,{className:`size-3.5`}):(0,Q.jsx)(_,{className:`size-3.5`}),q(C?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(S,{size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>window.open(ie,`_blank`,`noopener`),children:[q(`page.open`),` `,(0,Q.jsx)(Mt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:q(`page.sectionPage`),locked:s,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":q(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:q(`page.whoOff`),text:q(`page.whoOffHint`),picked:!l,disabled:s||P,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:q(`page.whoPublic`),text:q(`page.whoPublicHint`),picked:l,disabled:s||P,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:q(`page.whoMembers`),text:q(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),F?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:F.message}):null]})]})}),B,(0,Q.jsx)(J,{id:`page-words`,children:(0,Q.jsx)(X,{title:q(`page.sectionWords`),hint:c?void 0:q(`page.notYet`),save:c?y:void 0,locked:z,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[c?(0,Q.jsx)(Hr,{host:i,page:c,disabled:s,save:g,onState:b},`${e.id}:${c.slug}`):(0,Q.jsx)(Dr,{host:i,disabled:!0,words:{slug:ne,title:j,headline:``,intro:``,voice:we===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:q(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[E.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:z,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>ee(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{O!==null&&k(O,t),ee(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),D.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:z,onToggle:t=>A(e.id,t)},e.id))]}),T.length?null:(0,Q.jsx)(`p`,{className:r(`mt-2`,$),children:q(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:r(`mt-4`,$),children:q(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),H]})}var Wr=`results-search`,Gr={q:``,mode:``,days:0};function Kr(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return ae({queryKey:[`results`,e,i],queryFn:()=>L.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function qr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return jt({icon:fe,label:q(`space.resultsSearch`),run:()=>{let e=document.getElementById(Wr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(xe,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:q(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(fe,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(F,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Wr,placeholder:q(`space.resultsSearch`),"aria-label":q(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(xe,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:q(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(xe,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:q(`space.resultsAnyTime`)},{value:`1`,label:q(`space.resultsDay`)},{value:`7`,label:q(`space.resultsDays`,{n:7})},{value:`30`,label:q(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Jr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(we,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):q(`space.resultsAll`),hint:q(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(qr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(M,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,q(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:q(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(u,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(re,{children:r.q.trim()||r.mode||r.days?q(`space.resultsNone`):q(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(tt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(lt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Yr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=zt(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xr(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=zt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Zr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Qr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ht,{icon:e.icon??Me,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Gt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function $r(){let{group:e}=Se(),[t,n]=pe(),i=ye(),a=Ce(),{hash:o}=a,{project:s,loading:c}=ut(),l=Rt(),u=Zt(),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=Ot(e)?e:void 0,v=_?void 0:l.spaceParts.find(t=>t.id===e),y=_??v?.id,b=a.state?.parts===!0,x=Et(`pages`),S=Nt().filter(e=>x||e.id!==`page`),C=At(S,l).map(e=>({...e,to:`/space/${e.id}`})),w={id:`results`,label:q(`space.results`),icon:xt,to:`/space/results`},T=_===`results`?w:C.find(e=>e.id===y),E=t.get(`show`),D=_===`results`?2:y?E?2:1:0,O=_===`results`?1:u?Math.min(D,1):y&&h!==y&&!b?1:0,ee=Wt(O),A=Wt(D),j=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:m}),[d,u]),M=s?s.brand.name?.trim()||s.name:q(`nav.project`),te=Et(`typography`)?[]:[`typography`],N=v?l.spaceMenus[v.id]??[]:[],P=v?[{plugin:null,label:null,sections:N}]:_&&_!==`results`?Pt(_,l,te):[],F=_?Pt(_,l).filter(e=>e.plugin):[],ne=Yr([...P,..._===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),I=_===`results`&&E&&E!==`all`?E:null,[L,ie]=(0,Z.useState)(Gr),R=Kr(_===`results`?s?.id:void 0,I,L),z=R.data?.wizards.find(e=>e.id===I)?.title,B=_===`data`&&E&&E!==`all`||_===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,V=B?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=_===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(_===`data`?s?.id:void 0),W=Qe(_===`knowledge`?s?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),ae=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),oe=_===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?ae?.name:W.data?.items.find(e=>e.key===B)?.title:U.data?nt(U.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;Vt([..._===`results`?[]:[{label:q(`nav.project`),to:`/space`}],...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(p??z??oe)?[{label:p??z??oe}]:[]]);let se={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};St({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:q(`assistant.suggest.dataWhat`)},{label:q(`assistant.suggest.dataWho`)},{label:q(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:q(`assistant.suggest.resultsFailed`)},{label:q(`assistant.suggest.resultsCost`)},{label:q(`assistant.suggest.resultsShare`)}]}:{},...B&&oe?{open:{kind:se[B[0]]??`item`,id:B.slice(2),label:oe}}:I&&z?{open:{kind:`wizard`,id:I,label:z}}:{}});let ce=_===`results`||_===`data`||B?o.slice(1):E||o.slice(1),le=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${ce}`;ce&&le.current!==e&&document.getElementById(ce)&&(le.current=e,requestAnimationFrame(()=>Zr(ce,!1)))},[y,ce,s?.id,l.spaceSections,N.length]),(0,Z.useEffect)(()=>{!u&&(y===`knowledge`||y===`data`)&&zt().scrollTo({top:0})},[u,y,B]);let ue=Xr();if(!y){let t=o.slice(1),n=t?Dt(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(k,{to:u?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&l.status!==`ready`)return null;if(e!==void 0||!u)return(0,Q.jsx)(k,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(_===`knowledge`&&!E&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let de=e=>{if(u){i({search:`?show=${e}`});return}le.current=`${y}#${e}`,Zr(e,!0),i({search:``,hash:e},{replace:!0})},K=e=>u?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),fe=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(J,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Lt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=u?void 0:ne,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:O===1?T??null:null,onBack:_===`results`?void 0:()=>u?i(`/space`):g(y??null),root:{icon:Bt,label:q(`nav.project`),backLabel:q(`nav.wizards`),onBack:()=>i(`/`)}}),(0,Q.jsx)(`div`,{className:r(Ut(ee)),children:O===0?(0,Q.jsx)(Jt,{entries:C,current:u?void 0:T,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:f})},O)]});return(0,Q.jsx)(qt.Provider,{value:j,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:r(`grid gap-6`,_!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[_===`results`?null:(0,Q.jsx)(`aside`,{className:r(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&D===2&&`hidden`,u&&A===`back`&&Ut(`back`)),style:!u&&ue?{maxHeight:ue-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:he}),y?(0,Q.jsxs)(`div`,{className:r(`min-w-0`,u&&D<2&&`hidden`,u&&A===`deeper`&&Ut(`deeper`)),children:[u&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:T?.label??M,onBack:()=>i(`/space/${y}`)})}):null,_===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:bt,label:q(`data.all`),selected:!u&&!B,onPick:()=>K(`all`)})}),U.data?nt(U.data).map(e=>(0,Q.jsx)(Gt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ht,{icon:Ue[e.kind],label:e.title,selected:!u&&e.key===B,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,Q.jsx)(Qr,{groups:F,current:me,onPick:de})]}):_===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:bt,label:q(`know.all`),selected:!(u||B),onPick:()=>K(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:q(`know.categories`),children:W.data.categories.map(e=>(0,Q.jsx)(Ht,{icon:Ye[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(Qr,{groups:F,current:u?void 0:V?.id,onPick:e=>K(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)(Qr,{groups:P,current:me,onPick:de})}),s&&(_===`info`||_===`knowledge`)?(0,Q.jsxs)(br,{project:s,group:_,top:!B||!!V,children:[_===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>K(`all`),onOpen:K},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>K(`all`)},H):(0,Q.jsx)(kn,{projectId:s.id,fileId:H.slice(2),readOnly:s.readOnly,onGone:()=>K(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(Lt,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?ae?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:s.id,category:ae,readOnly:s.readOnly,onOpen:K,onGone:()=>K(`all`)}),ae.type===`choice`?null:(0,Q.jsx)(it,{projectId:s.id,category:ae,categories:W.data.categories,onOpen:K})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:G.data.items.map(e=>(0,Q.jsx)(Ke,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:K},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(J,{id:`documents`,children:(0,Q.jsx)(et,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:K})}):null:null,_===`info`?fe(F):null]},s.id):null,s&&_===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:s},s.id),fe(F)]}):null,s&&v?(0,Q.jsx)(Lt,{of:v,children:(0,Q.jsx)(Tt,{part:v.id,children:(0,Q.jsx)(v.component,{})},s.id)}):null,s&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:B.slice(2),onGone:()=>K(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>K(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:K}):null,fe(F)]})}):null,s&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,Q.jsx)(Jr,{data:R.data,wizardId:I,onWizard:e=>K(e??`all`),filter:L,onFilter:ie}):null,R.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,fe(F)]}):null,s||c?null:(0,Q.jsx)(re,{children:q(`settings.noProject`)})]}):null]})})})}export{$r as ProjectPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,$t as i,Gr as a,Ht as o,In as s,J as c,Jr as l,Jt as u,Lt as d,Qr as f,W as p,ai as m,at as h,cn as g,et as _,in as v,it as y,jt as b,ni as x,on as S,ri as ee,sr as C}from"./ui-BVQk2DtW.js";import{_ as w,b as T,d as E,f as te,g as D,h as O,m as k,n as ne,p as re,v as A,y as j}from"./theme-D3yDT4QT.js";import{O as ie,S as M,b as N,x as P}from"./session-DvnGHbDz.js";import{W as F}from"./index-BTUtot4r.js";var I={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};I.node;var ae=l(I),L={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};L.node;var oe=l(L),R=e(t(),1);function se(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=se(),ce=z?new URLSearchParams(window.location.search).get(`page`):null,B=new URLSearchParams(window.location.search).get(`theme`),V=B?`?theme=${encodeURIComponent(B)}`:``,H=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),le=()=>H(`close`);function ue(e){(0,R.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>H(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&H(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var U=e(n(),1),W=`wizards.runner.translate`,G=new Set;function de(){try{return localStorage.getItem(W)===`on`}catch{return!1}}function fe(e){try{localStorage.setItem(W,e?`on`:`off`)}catch{}for(let e of G)e()}function pe(){return(0,R.useSyncExternalStore)(e=>(G.add(e),()=>G.delete(e)),de)}function me(e){let t=pe(),[n]=(0,R.useState)(()=>g()),r=e?.lang??`en`,i=e?.translatable&&n&&n!==r?n:null,a=i&&t?i:r,o=e?.token,c=m({queryKey:[`public-translation`,o,a],enabled:!!(o&&a!==r),queryFn:()=>p.post(`/api/public/wizards/${o}/translation${V}`,{lang:a}),staleTime:1/0,retry:!1}),l=m({queryKey:[`public-texts`,o,a],enabled:!(!o||s(a)),queryFn:()=>p.get(`/api/public/wizards/${o}/texts/${a}`),staleTime:1/0,retry:!1}),u=!s(a),d=a===r||c.data&&(!u||l.data),f=a!==r&&(c.isError||u&&l.isError),h=d&&!f?a:r,_=(0,R.useMemo)(()=>!s(h)&&l.data?.lang===h?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[h,l.data]);if((0,R.useEffect)(()=>{e&&v(h,_)},[e,h,_]),(0,R.useEffect)(()=>()=>v(null),[]),!e)return null;let y=h!==r&&c.data?c.data:null;return{own:r,other:i,shown:h,wizard:y??e,translating:a!==r&&!d&&!f,failed:!!f,translated:!!y,machine:y?.translation?.machine??!1,pick:e=>fe(e!==r)}}function K({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,U.jsx)(F,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function q({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,U.jsx)(`p`,{className:i(`text-ink-3`,n),children:S(`translation.failed`)}):e.translated?(0,U.jsxs)(`p`,{className:i(`text-ink-3`,n),children:[e.machine?(0,U.jsxs)(U.Fragment,{children:[S(`translation.machine`),` · `]}):null,(0,U.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:S(`translation.showOriginal`)})]}):null}function he(e,t){let n=(0,R.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,R.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,p.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ge(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=r(`/api/public/wizards/${e}`),i=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of i)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var J=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Y=J||/Android/.test(navigator.userAgent);function _e(){let[e,t]=(0,R.useState)(()=>window.wizardInstall??null),[n,r]=(0,R.useState)(!1);if((0,R.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||Y&&!e&&!J)return null;let i=/Mac/.test(navigator.platform),a=S(Y?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{Y&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[Y?(0,U.jsx)(oe,{className:`size-4`}):(0,U.jsx)(ae,{className:`size-4`}),S(Y?`install.add`:`install.bookmark`)]}),n?(0,U.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function X({brand:e,toggle:t=!0,start:n}){return(0,U.jsx)(`header`,{className:`safe-top`,children:(0,U.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,U.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,U.jsx)(`img`,{src:r(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,U.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,U.jsx)(`div`,{className:`absolute right-3`,children:(0,U.jsx)(M,{})}):null]})})}function Z({siteKey:e,onToken:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,U.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ve({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||_||z?null:(0,U.jsxs)(`a`,{href:y(`${window.location.origin}${c}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,U.jsx)(T,{className:`size-4`}),` `,S(`install.app`)]})}var ye=e=>`wz.run.${e}`,be=_&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=x(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(()=>{try{return localStorage.getItem(ye(e.token))}catch{return null}})();return{busy:i,error:o,captcha:c,setCaptcha:l,start:async()=>{a(!0),s(null);try{let{runId:i}=await p.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:ce??void 0,lang:n??void 0});try{localStorage.setItem(ye(e.token),i)}catch{}r(`${t}/${i}`,{replace:be})}catch(e){s(e.message),a(!1)}},resume:u?()=>r(`${t}/${u}`):null}}function xe({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=be&&e.available&&!e.turnstileSiteKey,f=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{l&&!f.current&&(f.current=!0,s())},[l]),l&&!r?(0,U.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,U.jsx)(u,{})}):(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,U.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,U.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,U.jsx)(`div`,{className:`mt-3`,children:(0,U.jsx)(q,{page:t})}),e.available?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(d,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),e.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.resume`)}):null,(0,U.jsx)(Se,{wizard:e,current:`steps`}),z||_?null:(0,U.jsx)(_e,{}),(0,U.jsx)(ve,{token:e.token})]}):(0,U.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??S(`run.unavailable`)}),r?(0,U.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,U.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,U.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=j();return(0,U.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,U.jsx)(`span`,{className:i(n?.speaking&&`animate-breathe`),children:(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:38})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,U.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,U.jsx)(q,{page:t,small:!0})]}),e.brand.logoUrl&&z!==`popout`?(0,U.jsx)(`img`,{src:r(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,U.jsx)(K,{page:t,tone:`surface`}),z?null:(0,U.jsx)(M,{}),z===`popout`?(0,U.jsx)(o,{label:S(`common.close`),onClick:le,children:(0,U.jsx)(C,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:S(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??S(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(A(`start`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(D,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),d?(0,U.jsx)(D,{onClick:d,children:S(`run.resume`)}):null,t.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,U.jsxs)(k,{header:r,footer:i,children:[(0,U.jsx)(w,{avatar:t.avatar,costume:t.costume,lines:f}),(0,U.jsx)(O,{})]})}function Te({className:e}){return(0,U.jsx)(`footer`,{className:i(`text-center text-ink-4`,e),children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:r=!1}){let{token:a,runId:o}=ee(),s=x(),l=m({queryKey:[`public`,a,V],queryFn:()=>p.get(`/api/public/wizards/${a}${V}`),retry:(e,t)=>b(t)&&e<3}),g=l.data?.runners??[],v=!l.data||g.some(e=>e.id===`talk`),y=!l.data||g.some(e=>e.id===`video`),C=!l.data||g.some(e=>e.id===`chat`)||n&&v||r&&y,w=g[0]?.id,T=e||z===`popout`||!t&&!o&&C&&(w===`chat`||w===`talk`||w===`video`),D=r&&y||!t&&!e&&!n&&w===`video`,O=!D&&(n&&v||!t&&!e&&w===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(l.data);he(o,A),ne(l.data?.brand.theme),ie(l.data?.avatar),ge(a,l.data?.title),ue(T);let j=A?.wizard.title??l.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{a&&o&&h(`run`,{token:a,runId:o})},[a,o]),l.isLoading)return(0,U.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Q),children:(0,U.jsx)(u,{})});if(e&&l.data&&!C||n&&l.data&&!v||r&&l.data&&!y)return(0,U.jsx)(f,{to:`/w/${a}`,replace:!0});if(!l.data){let e=b(l.error);return(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,U.jsx)(P,{kind:`pebble`,size:80}),(0,U.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:S(e?`common.offline`:`run.notFound`)}),e?(0,U.jsx)(d,{variant:`secondary`,onClick:()=>void l.refetch(),children:S(`common.retry`)}):null]})}let M=A?.wizard??l.data,F=A?.translating?(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,U.jsx)(u,{}),(0,U.jsx)(`p`,{className:`text-[0.875rem]`,children:S(`translation.working`)})]}):null;if(T){let e=(0,U.jsx)(Ce,{wizard:M,page:A}),t=_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,U.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),F??(o?(0,U.jsx)(re,{runId:o,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>s(`/w/${a}/${k}`),header:D||O?void 0:e,footer:t}):(0,U.jsx)(we,{wizard:M,page:A,header:e,footer:t,door:k}))]})}return(0,U.jsxs)(`div`,{className:i(`wizard-page flex flex-col`,Q),children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),z===`inline`||_?null:(0,U.jsx)(X,{brand:l.data.brand,toggle:!z,start:(0,U.jsx)(K,{page:A})}),z===`inline`||_?(0,U.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,U.jsx)(K,{page:A,tone:`surface`})}):null,o&&(A?.translated||A?.failed)?(0,U.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,U.jsx)(q,{page:A})}):null,(0,U.jsx)(`div`,{className:`flex-1`,children:F??(o?(0,U.jsx)(te,{runId:o,onRestart:()=>s(`/w/${a}`)}):(0,U.jsx)(xe,{wizard:M,page:A}))}),_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})]})}export{X as BrandHeader,Ee as PublicRunner};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,$t as i,Gr as a,Ht as o,In as s,J as c,Jr as l,Jt as u,Lt as d,Qr as f,W as p,ai as m,at as h,cn as g,et as _,in as v,it as y,jt as b,ni as x,on as S,ri as ee,sr as C}from"./ui-BI1RPFWT.js";import{_ as w,b as T,d as E,f as te,g as D,h as O,m as k,n as ne,p as re,v as A,y as j}from"./theme-HcCfZDzS.js";import{O as ie,S as M,b as N,x as P}from"./session-B_JeZnJ0.js";import{W as F}from"./index-D3-kv1WF.js";var I={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};I.node;var ae=l(I),L={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};L.node;var oe=l(L),R=e(t(),1);function se(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var z=se(),ce=z?new URLSearchParams(window.location.search).get(`page`):null,B=new URLSearchParams(window.location.search).get(`theme`),V=B?`?theme=${encodeURIComponent(B)}`:``,H=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),le=()=>H(`close`);function ue(e){(0,R.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>H(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&H(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var U=e(n(),1),W=`wizards.runner.translate`,G=new Set;function de(){try{return localStorage.getItem(W)===`on`}catch{return!1}}function fe(e){try{localStorage.setItem(W,e?`on`:`off`)}catch{}for(let e of G)e()}function pe(){return(0,R.useSyncExternalStore)(e=>(G.add(e),()=>G.delete(e)),de)}function me(e){let t=pe(),[n]=(0,R.useState)(()=>g()),r=e?.lang??`en`,i=e?.translatable&&n&&n!==r?n:null,a=i&&t?i:r,o=e?.token,c=m({queryKey:[`public-translation`,o,a],enabled:!!(o&&a!==r),queryFn:()=>p.post(`/api/public/wizards/${o}/translation${V}`,{lang:a}),staleTime:1/0,retry:!1}),l=m({queryKey:[`public-texts`,o,a],enabled:!(!o||s(a)),queryFn:()=>p.get(`/api/public/wizards/${o}/texts/${a}`),staleTime:1/0,retry:!1}),u=!s(a),d=a===r||c.data&&(!u||l.data),f=a!==r&&(c.isError||u&&l.isError),h=d&&!f?a:r,_=(0,R.useMemo)(()=>!s(h)&&l.data?.lang===h?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[h,l.data]);if((0,R.useEffect)(()=>{e&&v(h,_)},[e,h,_]),(0,R.useEffect)(()=>()=>v(null),[]),!e)return null;let y=h!==r&&c.data?c.data:null;return{own:r,other:i,shown:h,wizard:y??e,translating:a!==r&&!d&&!f,failed:!!f,translated:!!y,machine:y?.translation?.machine??!1,pick:e=>fe(e!==r)}}function K({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,U.jsx)(F,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function q({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,U.jsx)(`p`,{className:i(`text-ink-3`,n),children:S(`translation.failed`)}):e.translated?(0,U.jsxs)(`p`,{className:i(`text-ink-3`,n),children:[e.machine?(0,U.jsxs)(U.Fragment,{children:[S(`translation.machine`),` · `]}):null,(0,U.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:S(`translation.showOriginal`)})]}):null}function he(e,t){let n=(0,R.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,R.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,p.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ge(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=r(`/api/public/wizards/${e}`),i=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of i)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var J=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Y=J||/Android/.test(navigator.userAgent);function _e(){let[e,t]=(0,R.useState)(()=>window.wizardInstall??null),[n,r]=(0,R.useState)(!1);if((0,R.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||Y&&!e&&!J)return null;let i=/Mac/.test(navigator.platform),a=S(Y?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{Y&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[Y?(0,U.jsx)(oe,{className:`size-4`}):(0,U.jsx)(ae,{className:`size-4`}),S(Y?`install.add`:`install.bookmark`)]}),n?(0,U.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function X({brand:e,toggle:t=!0,start:n}){return(0,U.jsx)(`header`,{className:`safe-top`,children:(0,U.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,U.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,U.jsx)(`img`,{src:r(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,U.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,U.jsx)(`div`,{className:`absolute right-3`,children:(0,U.jsx)(M,{})}):null]})})}function Z({siteKey:e,onToken:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,U.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ve({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||_||z?null:(0,U.jsxs)(`a`,{href:y(`${window.location.origin}${c}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,U.jsx)(T,{className:`size-4`}),` `,S(`install.app`)]})}var ye=e=>`wz.run.${e}`,be=_&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=x(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(()=>{try{return localStorage.getItem(ye(e.token))}catch{return null}})();return{busy:i,error:o,captcha:c,setCaptcha:l,start:async()=>{a(!0),s(null);try{let{runId:i}=await p.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:ce??void 0,lang:n??void 0});try{localStorage.setItem(ye(e.token),i)}catch{}r(`${t}/${i}`,{replace:be})}catch(e){s(e.message),a(!1)}},resume:u?()=>r(`${t}/${u}`):null}}function xe({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=be&&e.available&&!e.turnstileSiteKey,f=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{l&&!f.current&&(f.current=!0,s())},[l]),l&&!r?(0,U.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,U.jsx)(u,{})}):(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,U.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,U.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,U.jsx)(`div`,{className:`mt-3`,children:(0,U.jsx)(q,{page:t})}),e.available?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(d,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),e.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.resume`)}):null,(0,U.jsx)(Se,{wizard:e,current:`steps`}),z||_?null:(0,U.jsx)(_e,{}),(0,U.jsx)(ve,{token:e.token})]}):(0,U.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??S(`run.unavailable`)}),r?(0,U.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,U.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,U.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:S(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=j();return(0,U.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,U.jsx)(`span`,{className:i(n?.speaking&&`animate-breathe`),children:(0,U.jsx)(P,{kind:e.avatar,costume:e.costume,size:38})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,U.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,U.jsx)(q,{page:t,small:!0})]}),e.brand.logoUrl&&z!==`popout`?(0,U.jsx)(`img`,{src:r(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,U.jsx)(K,{page:t,tone:`surface`}),z?null:(0,U.jsx)(M,{}),z===`popout`?(0,U.jsx)(o,{label:S(`common.close`),onClick:le,children:(0,U.jsx)(C,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:S(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??S(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(A(`start`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(D,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[S(`run.start`),` `,(0,U.jsx)(a,{className:`size-4`})]}),d?(0,U.jsx)(D,{onClick:d,children:S(`run.resume`)}):null,t.turnstileSiteKey?(0,U.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,U.jsxs)(k,{header:r,footer:i,children:[(0,U.jsx)(w,{avatar:t.avatar,costume:t.costume,lines:f}),(0,U.jsx)(O,{})]})}function Te({className:e}){return(0,U.jsx)(`footer`,{className:i(`text-center text-ink-4`,e),children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:r=!1}){let{token:a,runId:o}=ee(),s=x(),l=m({queryKey:[`public`,a,V],queryFn:()=>p.get(`/api/public/wizards/${a}${V}`),retry:(e,t)=>b(t)&&e<3}),g=l.data?.runners??[],v=!l.data||g.some(e=>e.id===`talk`),y=!l.data||g.some(e=>e.id===`video`),C=!l.data||g.some(e=>e.id===`chat`)||n&&v||r&&y,w=g[0]?.id,T=e||z===`popout`||!t&&!o&&C&&(w===`chat`||w===`talk`||w===`video`),D=r&&y||!t&&!e&&!n&&w===`video`,O=!D&&(n&&v||!t&&!e&&w===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(l.data);he(o,A),ne(l.data?.brand.theme),ie(l.data?.avatar),ge(a,l.data?.title),ue(T);let j=A?.wizard.title??l.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{a&&o&&h(`run`,{token:a,runId:o})},[a,o]),l.isLoading)return(0,U.jsx)(`div`,{className:i(`flex items-center justify-center text-ink-4`,Q),children:(0,U.jsx)(u,{})});if(e&&l.data&&!C||n&&l.data&&!v||r&&l.data&&!y)return(0,U.jsx)(f,{to:`/w/${a}`,replace:!0});if(!l.data){let e=b(l.error);return(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,U.jsx)(P,{kind:`pebble`,size:80}),(0,U.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:S(e?`common.offline`:`run.notFound`)}),e?(0,U.jsx)(d,{variant:`secondary`,onClick:()=>void l.refetch(),children:S(`common.retry`)}):null]})}let M=A?.wizard??l.data,F=A?.translating?(0,U.jsxs)(`div`,{className:i(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,U.jsx)(u,{}),(0,U.jsx)(`p`,{className:`text-[0.875rem]`,children:S(`translation.working`)})]}):null;if(T){let e=(0,U.jsx)(Ce,{wizard:M,page:A}),t=_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,U.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),F??(o?(0,U.jsx)(re,{runId:o,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>s(`/w/${a}/${k}`),header:D||O?void 0:e,footer:t}):(0,U.jsx)(we,{wizard:M,page:A,header:e,footer:t,door:k}))]})}return(0,U.jsxs)(`div`,{className:i(`wizard-page flex flex-col`,Q),children:[(0,U.jsx)(E,{effects:l.data.brand.theme.effects}),z===`inline`||_?null:(0,U.jsx)(X,{brand:l.data.brand,toggle:!z,start:(0,U.jsx)(K,{page:A})}),z===`inline`||_?(0,U.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,U.jsx)(K,{page:A,tone:`surface`})}):null,o&&(A?.translated||A?.failed)?(0,U.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,U.jsx)(q,{page:A})}):null,(0,U.jsx)(`div`,{className:`flex-1`,children:F??(o?(0,U.jsx)(te,{runId:o,onRestart:()=>s(`/w/${a}`)}):(0,U.jsx)(xe,{wizard:M,page:A}))}),_?(0,U.jsx)(`div`,{className:`safe-bottom`}):(0,U.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,U.jsx)(`a`,{href:`${c}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:S(`run.madeWith`).replace(`engenty wizards`,N.name)})})]})}export{X as BrandHeader,Ee as PublicRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Jr as n,on as r}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Jr as n,on as r}from"./ui-BI1RPFWT.js";import{Tt as i}from"./index-D3-kv1WF.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return r(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
|