wizards 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/apps/runtime/dist/engine/requirements.js +140 -12
  2. package/apps/runtime/dist/engine/runner.js +27 -4
  3. package/apps/runtime/dist/services/marketplace.js +33 -6
  4. package/apps/web/dist/assets/{Account-CbcLDgwW.js → Account-BE_W101C.js} +1 -1
  5. package/apps/web/dist/assets/{ChangelogDialog-CPaoAyWM.js → ChangelogDialog-DjKQJAos.js} +1 -1
  6. package/apps/web/dist/assets/{ChatPanel-DzIGwA0b.js → ChatPanel-BWrcDs4s.js} +1 -1
  7. package/apps/web/dist/assets/{CreditsDialog-o9h0Nrui.js → CreditsDialog-DUjR5xkl.js} +1 -1
  8. package/apps/web/dist/assets/EditorPage-CrOqikP2.js +2 -0
  9. package/apps/web/dist/assets/{FlowPreview-DdZKsXNh.js → FlowPreview-DK4RZqTW.js} +1 -1
  10. package/apps/web/dist/assets/{Harness-CKcyJvtw.js → Harness-DcI94f1U.js} +1 -1
  11. package/apps/web/dist/assets/{HomePage-DVPGy7jW.js → HomePage-BBNFgryu.js} +1 -1
  12. package/apps/web/dist/assets/{ImportWizard-CK9fXKct.js → ImportWizard-BoYqovdl.js} +1 -1
  13. package/apps/web/dist/assets/{LocalRuntime-Cjftoi3j.js → LocalRuntime-BD8zGN8w.js} +1 -1
  14. package/apps/web/dist/assets/NewWizardPage-tKV2S4eK.js +2 -0
  15. package/apps/web/dist/assets/{ProjectPage-DURhRvUm.js → ProjectPage-voR0hvzy.js} +1 -1
  16. package/apps/web/dist/assets/{PublicRunner-BCHg6lbj.js → PublicRunner-CYZE_hSi.js} +1 -1
  17. package/apps/web/dist/assets/RunnerView-D_C7hn81.js +70 -0
  18. package/apps/web/dist/assets/{SettingsPage-DPHW6HRz.js → SettingsPage-DguoPF_3.js} +1 -1
  19. package/apps/web/dist/assets/{SetupPage-r6tj7oTr.js → SetupPage-qxHvlf87.js} +1 -1
  20. package/apps/web/dist/assets/{SharePage-2Q8SoJLs.js → SharePage-Cf3i7KB-.js} +1 -1
  21. package/apps/web/dist/assets/{api-DTLkC0ge.js → api-t9_w1XNe.js} +1 -1
  22. package/apps/web/dist/assets/changelog-kz0DmHY4.js +1 -0
  23. package/apps/web/dist/assets/{esm-Buv7Ma3z.js → esm-D0YVMTdo.js} +1 -1
  24. package/apps/web/dist/assets/index-BPpKz65x.css +1 -0
  25. package/apps/web/dist/assets/{index-C5pRB5Ah.js → index-D5w3fW1p.js} +3 -3
  26. package/apps/web/dist/assets/{meta-CDimdOlV.js → meta-BJHYbMh7.js} +1 -1
  27. package/apps/web/dist/assets/{settings-menu-D1tMZ82V.js → settings-menu-BqqUAvIY.js} +1 -1
  28. package/apps/web/dist/assets/ui-BHXO_e0e.js +1 -0
  29. package/apps/web/dist/index.html +4 -4
  30. package/apps/web/dist/mcp/flow.html +5 -5
  31. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +1 -0
  32. package/node_modules/@engenty-wizards/shared/dist/definition.js +2 -2
  33. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +2 -0
  34. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +9 -0
  35. package/package.json +1 -1
  36. package/apps/web/dist/assets/EditorPage-BPL4_GlP.js +0 -2
  37. package/apps/web/dist/assets/NewWizardPage-0GHmokBt.js +0 -2
  38. package/apps/web/dist/assets/RunnerView-a_2EqHPo.js +0 -70
  39. package/apps/web/dist/assets/changelog-5ArxeGsu.js +0 -1
  40. package/apps/web/dist/assets/index-DMwk_afK.css +0 -1
  41. package/apps/web/dist/assets/ui-CHX2gEQl.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{A as r,D as i,O as a,d as o,i as s,j as c,k as l,n as u,nt as d,t as f,w as p}from"./api-DTLkC0ge.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{f as h,g,h as _,i as v,m as y,p as ee,t as b,u as te}from"./RunnerView-a_2EqHPo.js";import{t as x}from"./refresh-cw-BNtHis1x.js";import{n as S}from"./HomePage-DVPGy7jW.js";import{t as C}from"./check-CUpby_J9.js";import{r as w,t as T}from"./ChatPanel-DzIGwA0b.js";import{n as E,t as ne}from"./upload-DNRENWzQ.js";import{t as D}from"./plus-Du-Jx8aI.js";import{t as re}from"./external-link-MAL7vJYj.js";import{n as O,t as ie}from"./wand-sparkles-Clj3VRB5.js";import{a as ae,c as k,d as A,f as oe,h as se,i as j,l as ce,m as M,o as le,p as N,s as P,u as F}from"./Account-CbcLDgwW.js";import{n as I,t as L}from"./trash-0IafyhZB.js";import{n as ue,t as R}from"./table-2-BdDuBcF2.js";import{_ as z,a as de,c as B,d as V,f as fe,h as H,i as U,m as pe,n as W,o as G,p as me,r as K,s as q,t as J,u as Y,y as X}from"./ui-CHX2gEQl.js";import{A as he,F as ge,T as _e,U as Z,_ as ve,b as ye,g as be,i as xe,k as Se,m as Ce,v as we,w as Te,y as Ee}from"./index-C5pRB5Ah.js";import"./definition-Dp0DR2D6.js";import{a as De,c as Oe,f as ke,i as Ae,m as je,n as Me,o as Ne,p as Pe,r as Fe,s as Ie,t as Le,u as Re}from"./settings-menu-D1tMZ82V.js";var ze={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`}]]};ze.node;var Be=m(ze),Ve={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Ve.node;var He=m(Ve),Ue={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`}]]};Ue.node;var We=m(Ue),Ge={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ge.node;var Ke=m(Ge),qe={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`}]]};qe.node;var Je=m(qe),Ye={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};Ye.node;var Xe=m(Ye),Ze={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};Ze.node;var Qe=m(Ze),$e={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`]};$e.node;var et=m($e),tt={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`}]]};tt.node;var nt=m(tt),Q=e(t(),1),$=e(n(),1);function rt({page:e,onGone:t}){let n=d(),[r,i]=(0,Q.useState)(e.title),[a,o]=(0,Q.useState)(e.markdown),[s,c]=(0,Q.useState)(!e.markdown),l=()=>n.invalidateQueries({queryKey:[`space-data`,e.projectId]}),f=A({title:r.trim()||e.title,markdown:a},async t=>{await u.patch(`/api/studio/pages/${e.id}`,t),n.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await l()}),p=Z({mutationFn:()=>u.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await l(),t()}}),m=e.readOnly,h=(e,t,n)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:H(`rounded-full px-3 py-1 text-[0.8125rem] transition`,e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`input`,{value:r,disabled:m,maxLength:200,onChange:e=>i(e.target.value),"aria-label":X(`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`}),f.state===`saving`?(0,$.jsx)(V,{className:`size-3.5 text-ink-3`}):f.state===`saved`?(0,$.jsx)(C,{className:`size-4 text-moss`,"aria-label":X(`settings.saved`)}):null,m?null:(0,$.jsx)(G,{label:X(`data.deletePage`),onClick:()=>confirm(X(`data.confirmDelete`,{title:e.title}))&&p.mutate(),className:`hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]}),(0,$.jsxs)(W,{className:`flex flex-col`,children:[m?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[h(s,X(`data.write`),()=>c(!0)),h(!s,X(`data.preview`),()=>c(!1)),(0,$.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:X(`data.markdownHint`)})]}),s&&!m?(0,$.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),"aria-label":e.title,placeholder:X(`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,$.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,children:a.trim()?(0,$.jsx)(v,{text:a}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`data.pageEmpty`)})})]}),f.state===`error`&&f.error?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error}):null]})}function it({pageId:e,onGone:t}){let n=c({queryKey:[`space-page`,e],queryFn:()=>u.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return n.data?(0,$.jsx)(rt,{page:n.data,onGone:t},n.data.id):n.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:n.error.message}):null}function at(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}function ot(e,t){let n=d(),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(`idle`),[c,l]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=()=>(g.current??=(async()=>{await Promise.all([n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`project-files`,e]})]),t(),g.current=null})(),g.current);return{messages:r,phase:a,activity:f,startedAt:m,error:c,send:async(t,c=[])=>{if(!(t.trim()||c.length)||a!==`idle`)return!1;if(l(null),o(`thinking`),h(Date.now()),c.length){try{for(let t of c)await u.upload(`/api/studio/projects/${e}/files?kind=${at(t)}`,t)}catch(e){return l(e.message),o(`idle`),h(null),await _(),!1}await _();let n=`${X(`editor.attached`)}: ${c.map(e=>e.name).join(`, `)}`;t=t.trim()?`${t}\n\n${n}`:n}let d=r.map(({role:e,content:t})=>({role:e,content:t})).slice(-12),f=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:t,previews:w(c)},{id:f,role:`assistant`,content:``,pending:!0}]),p(null);let m=!1;try{await s(`/api/studio/projects/${e}/assist`,{message:t,history:d},(e,t)=>{if(e===`text`){let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:t.content+e}:t))}else if(e===`activity`)p(JSON.parse(t));else if(e===`card`){let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,cards:[...t.cards??[],{...e,id:`${f}-${t.cards?.length??0}`}]}:t))}else if(e===`changed`)o(`building`),_();else if(e===`done`){m=!0;let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:e.reply,changed:e.changed,pending:!1}:t))}else e===`error`&&(m=!0,l(JSON.parse(t).message))}),m||l(X(`editor.chatBroken`))}catch(e){l(e.message)}finally{p(null),h(null),i(e=>e.filter(e=>!(e.id===f&&!e.content&&!e.cards?.length)).map(e=>({...e,pending:!1}))),o(`idle`),await g.current,await _(),await n.invalidateQueries({queryKey:[`me`]})}return!0}}}function st({card:e,send:t}){let n=be().cards.find(t=>t.plugin===e.plugin&&t.tool===e.tool);return n?(0,$.jsx)(Ce,{of:n,children:(0,$.jsx)(n.component,{data:e.data,send:e=>void t(e)})}):null}function ct(){return(0,$.jsxs)(`div`,{className:`sm:pr-36`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-tight tracking-tight`,children:X(`project.assistantTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:X(`project.assistantHello`)})]})}var lt=72,ut=720;function dt({projectId:e,onChanged:t}){let n=ot(e,t),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=()=>{let e=r.current?.getBoundingClientRect();e&&a(t=>{if(e.bottom>=lt)return null;let n=Math.min(e.width,ut),r=e.left+(e.width-n)/2;return t&&t.left===r&&t.width===n?t:{left:r,width:n,height:t?.height??e.height}})};return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[]),(0,$.jsxs)(`div`,{ref:r,style:i?{minHeight:i.height}:void 0,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 px-1 font-medium text-[0.75rem] text-ember-strong uppercase tracking-[0.07em]`,children:[(0,$.jsx)(te,{className:`size-3.5`}),` `,X(`project.assistant`)]}),(0,$.jsxs)(`div`,{className:`relative`,children:[!i&&n.messages.length===0?(0,$.jsx)(`div`,{className:`absolute -top-14 right-10 z-10 max-sm:hidden`,children:(0,$.jsx)(o,{kind:`round`,size:104})}):null,(0,$.jsx)(`div`,{className:H(`flex flex-col overflow-hidden bg-card`,i?`fixed bottom-4 z-30 max-h-[70dvh] animate-dock rounded-2xl shadow-overlay ring-1 ring-border`:`max-h-[520px] rounded-xl bg-linear-to-br from-ember-tint via-card to-card shadow-soft ring-1 ring-ember-veil`),style:i?{left:i.left,width:i.width}:void 0,children:(0,$.jsx)(T,{chat:n,avatar:`round`,compact:!!i,intro:(0,$.jsx)(ct,{}),placeholder:X(`project.assistantComposer`),changedLabel:X(`project.assistantChanged`),card:e=>(0,$.jsx)(st,{card:e,send:n.send})})})]})]})}var ft=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],pt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,mt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,ht=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,gt=/^(https?:\/\/|www\.)\S+$/i,_t=/^\+?[\d\s()/.-]{7,20}$/,vt=/^(ja|nein|yes|no|true|false)$/i;function yt(e){let t=e.trim();return t?t.includes(`
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{A as r,D as i,O as a,d as o,i as s,j as c,k as l,n as u,nt as d,t as f,w as p}from"./api-t9_w1XNe.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{f as h,g,h as _,i as v,m as y,p as ee,t as b,u as te}from"./RunnerView-D_C7hn81.js";import{t as x}from"./refresh-cw-BNtHis1x.js";import{n as S}from"./HomePage-BBNFgryu.js";import{t as C}from"./check-CUpby_J9.js";import{r as w,t as T}from"./ChatPanel-BWrcDs4s.js";import{n as E,t as ne}from"./upload-DNRENWzQ.js";import{t as D}from"./plus-Du-Jx8aI.js";import{t as re}from"./external-link-MAL7vJYj.js";import{n as O,t as ie}from"./wand-sparkles-Clj3VRB5.js";import{a as ae,c as k,d as A,f as oe,h as se,i as j,l as ce,m as M,o as le,p as N,s as P,u as F}from"./Account-BE_W101C.js";import{n as I,t as L}from"./trash-0IafyhZB.js";import{n as ue,t as R}from"./table-2-BdDuBcF2.js";import{_ as z,a as de,c as B,d as V,f as fe,h as H,i as U,m as pe,n as W,o as G,p as me,r as K,s as q,t as J,u as Y,y as X}from"./ui-BHXO_e0e.js";import{A as he,F as ge,T as _e,U as Z,_ as ve,b as ye,g as be,i as xe,k as Se,m as Ce,v as we,w as Te,y as Ee}from"./index-D5w3fW1p.js";import"./definition-Dp0DR2D6.js";import{a as De,c as Oe,f as ke,i as Ae,m as je,n as Me,o as Ne,p as Pe,r as Fe,s as Ie,t as Le,u as Re}from"./settings-menu-BqqUAvIY.js";var ze={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`}]]};ze.node;var Be=m(ze),Ve={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Ve.node;var He=m(Ve),Ue={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`}]]};Ue.node;var We=m(Ue),Ge={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ge.node;var Ke=m(Ge),qe={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`}]]};qe.node;var Je=m(qe),Ye={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};Ye.node;var Xe=m(Ye),Ze={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};Ze.node;var Qe=m(Ze),$e={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`]};$e.node;var et=m($e),tt={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`}]]};tt.node;var nt=m(tt),Q=e(t(),1),$=e(n(),1);function rt({page:e,onGone:t}){let n=d(),[r,i]=(0,Q.useState)(e.title),[a,o]=(0,Q.useState)(e.markdown),[s,c]=(0,Q.useState)(!e.markdown),l=()=>n.invalidateQueries({queryKey:[`space-data`,e.projectId]}),f=A({title:r.trim()||e.title,markdown:a},async t=>{await u.patch(`/api/studio/pages/${e.id}`,t),n.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await l()}),p=Z({mutationFn:()=>u.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await l(),t()}}),m=e.readOnly,h=(e,t,n)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:H(`rounded-full px-3 py-1 text-[0.8125rem] transition`,e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`input`,{value:r,disabled:m,maxLength:200,onChange:e=>i(e.target.value),"aria-label":X(`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`}),f.state===`saving`?(0,$.jsx)(V,{className:`size-3.5 text-ink-3`}):f.state===`saved`?(0,$.jsx)(C,{className:`size-4 text-moss`,"aria-label":X(`settings.saved`)}):null,m?null:(0,$.jsx)(G,{label:X(`data.deletePage`),onClick:()=>confirm(X(`data.confirmDelete`,{title:e.title}))&&p.mutate(),className:`hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]}),(0,$.jsxs)(W,{className:`flex flex-col`,children:[m?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[h(s,X(`data.write`),()=>c(!0)),h(!s,X(`data.preview`),()=>c(!1)),(0,$.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:X(`data.markdownHint`)})]}),s&&!m?(0,$.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),"aria-label":e.title,placeholder:X(`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,$.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,children:a.trim()?(0,$.jsx)(v,{text:a}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`data.pageEmpty`)})})]}),f.state===`error`&&f.error?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error}):null]})}function it({pageId:e,onGone:t}){let n=c({queryKey:[`space-page`,e],queryFn:()=>u.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return n.data?(0,$.jsx)(rt,{page:n.data,onGone:t},n.data.id):n.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:n.error.message}):null}function at(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}function ot(e,t){let n=d(),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(`idle`),[c,l]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=()=>(g.current??=(async()=>{await Promise.all([n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`project-files`,e]})]),t(),g.current=null})(),g.current);return{messages:r,phase:a,activity:f,startedAt:m,error:c,send:async(t,c=[])=>{if(!(t.trim()||c.length)||a!==`idle`)return!1;if(l(null),o(`thinking`),h(Date.now()),c.length){try{for(let t of c)await u.upload(`/api/studio/projects/${e}/files?kind=${at(t)}`,t)}catch(e){return l(e.message),o(`idle`),h(null),await _(),!1}await _();let n=`${X(`editor.attached`)}: ${c.map(e=>e.name).join(`, `)}`;t=t.trim()?`${t}\n\n${n}`:n}let d=r.map(({role:e,content:t})=>({role:e,content:t})).slice(-12),f=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:t,previews:w(c)},{id:f,role:`assistant`,content:``,pending:!0}]),p(null);let m=!1;try{await s(`/api/studio/projects/${e}/assist`,{message:t,history:d},(e,t)=>{if(e===`text`){let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:t.content+e}:t))}else if(e===`activity`)p(JSON.parse(t));else if(e===`card`){let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,cards:[...t.cards??[],{...e,id:`${f}-${t.cards?.length??0}`}]}:t))}else if(e===`changed`)o(`building`),_();else if(e===`done`){m=!0;let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:e.reply,changed:e.changed,pending:!1}:t))}else e===`error`&&(m=!0,l(JSON.parse(t).message))}),m||l(X(`editor.chatBroken`))}catch(e){l(e.message)}finally{p(null),h(null),i(e=>e.filter(e=>!(e.id===f&&!e.content&&!e.cards?.length)).map(e=>({...e,pending:!1}))),o(`idle`),await g.current,await _(),await n.invalidateQueries({queryKey:[`me`]})}return!0}}}function st({card:e,send:t}){let n=be().cards.find(t=>t.plugin===e.plugin&&t.tool===e.tool);return n?(0,$.jsx)(Ce,{of:n,children:(0,$.jsx)(n.component,{data:e.data,send:e=>void t(e)})}):null}function ct(){return(0,$.jsxs)(`div`,{className:`sm:pr-36`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-tight tracking-tight`,children:X(`project.assistantTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:X(`project.assistantHello`)})]})}var lt=72,ut=720;function dt({projectId:e,onChanged:t}){let n=ot(e,t),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=()=>{let e=r.current?.getBoundingClientRect();e&&a(t=>{if(e.bottom>=lt)return null;let n=Math.min(e.width,ut),r=e.left+(e.width-n)/2;return t&&t.left===r&&t.width===n?t:{left:r,width:n,height:t?.height??e.height}})};return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[]),(0,$.jsxs)(`div`,{ref:r,style:i?{minHeight:i.height}:void 0,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 px-1 font-medium text-[0.75rem] text-ember-strong uppercase tracking-[0.07em]`,children:[(0,$.jsx)(te,{className:`size-3.5`}),` `,X(`project.assistant`)]}),(0,$.jsxs)(`div`,{className:`relative`,children:[!i&&n.messages.length===0?(0,$.jsx)(`div`,{className:`absolute -top-14 right-10 z-10 max-sm:hidden`,children:(0,$.jsx)(o,{kind:`round`,size:104})}):null,(0,$.jsx)(`div`,{className:H(`flex flex-col overflow-hidden bg-card`,i?`fixed bottom-4 z-30 max-h-[70dvh] animate-dock rounded-2xl shadow-overlay ring-1 ring-border`:`max-h-[520px] rounded-xl bg-linear-to-br from-ember-tint via-card to-card shadow-soft ring-1 ring-ember-veil`),style:i?{left:i.left,width:i.width}:void 0,children:(0,$.jsx)(T,{chat:n,avatar:`round`,compact:!!i,intro:(0,$.jsx)(ct,{}),placeholder:X(`project.assistantComposer`),changedLabel:X(`project.assistantChanged`),card:e=>(0,$.jsx)(st,{card:e,send:n.send})})})]})]})}var ft=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],pt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,mt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,ht=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,gt=/^(https?:\/\/|www\.)\S+$/i,_t=/^\+?[\d\s()/.-]{7,20}$/,vt=/^(ja|nein|yes|no|true|false)$/i;function yt(e){let t=e.trim();return t?t.includes(`
2
2
  `)||t.length>140?`longtext`:vt.test(t)?`boolean`:ht.test(t)?`email`:gt.test(t)?`url`:pt.test(t)?`date`:mt.test(t)&&!/^(\+|0\d)/.test(t)?`number`:_t.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function bt(e,t=[]){let n=e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFD`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`fakt`,r=n;for(let e=2;t.includes(r);e++)r=`${n}_${e}`;return r}var xt=[{key:`adresse`,de:`Adresse`,en:`Address`},{key:`plz`,de:`PLZ`,en:`Postcode`},{key:`ort`,de:`Ort`,en:`City`},{key:`uid`,de:`UID`,en:`VAT id`},{key:`telefon`,de:`Telefon`,en:`Phone`},{key:`e_mail`,de:`E-Mail`,en:`Email`},{key:`website`,de:`Website`,en:`Website`},{key:`iban`,de:`IBAN`,en:`IBAN`}],St={facts:100,colors:12,files:{logo:8,asset:100,document:50},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},Ct=/^#[0-9a-fA-F]{6}$/;function wt({onAdd:e,onClose:t}){let[n,r]=(0,Q.useState)(`#e0531b`),[i,a]=(0,Q.useState)(``),o=Ct.test(n);return(0,$.jsx)(U,{open:!0,onClose:t,title:X(`project.colorAddTitle`),children:(0,$.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(fe,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,$.jsx)(q,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`project.colorUseLabel`)}),(0,$.jsx)(q,{autoFocus:!0,value:i,maxLength:120,placeholder:X(`project.colorName`),onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.colorUse`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:t,children:X(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,disabled:!o,children:X(`project.add`)})]})]})})}function Tt({colors:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),[i,a]=(0,Q.useState)(()=>e.map(e=>({...e,id:`c${r.current++}`}))),[o,s]=(0,Q.useState)(!1),c=A(i.filter(e=>Ct.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),l=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,$.jsxs)(k,{title:X(`project.colors`),hint:X(`project.colorsHint`),save:c,locked:n,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(fe,{value:Ct.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,$.jsx)(q,{value:e.name,placeholder:X(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(q,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>l(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(K,{tone:`ember`,children:X(`project.colorAccent`)})}):n?null:(0,$.jsx)(G,{label:X(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,$.jsx)(g,{className:`size-4`})}),n?null:(0,$.jsx)(G,{label:X(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.colorUse`)}):null,i.length<St.colors&&!n?(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,$.jsx)(D,{className:`size-4`}),` `,X(`project.colorAdd`)]}):null,o?(0,$.jsx)(wt,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var Et={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Dt({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:X(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 Ot(e,t){confirm(X(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function kt({projectId:e,file:t,small:n}){let r=F(e,t.id);return t.mime.startsWith(`image/`)?(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:H(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,$.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,$.jsx)(Je,{className:n?`size-5`:`size-7`}):(0,$.jsx)(_,{className:n?`size-5`:`size-7`})})}function At({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:o}){return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,$.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&a===0?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(K,{tone:`ember`,children:X(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Et:void 0,children:[o&&i.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${X(`project.preview`)}: ${i.name}`,onClick:()=>o(i),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(kt,{projectId:e,file:i})}):(0,$.jsx)(kt,{projectId:e,file:i}),(0,$.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[o?(0,$.jsx)(G,{label:X(`project.preview`),onClick:()=>o(i),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(O,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,$.jsx)(G,{label:X(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(ue,{className:`size-4`})}):null,r.readOnly?null:(0,$.jsx)(G,{label:X(`project.remove`),onClick:()=>Ot(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:i.name,children:i.name}):null,(0,$.jsx)(Dt,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,$.jsxs)(ae,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(V,{className:`size-5`}):(0,$.jsx)(D,{className:`size-5`}),a]}):null]})}function jt({projectId:e,data:t,readOnly:n}){let r=oe(e,n);return(0,$.jsxs)(k,{title:X(`project.logos`),hint:X(`project.logosHint`),children:[(0,$.jsx)(At,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:X(`project.logoAdd`)}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var Mt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),ce(e.size)].filter(Boolean).join(` · `);function Nt({projectId:e,file:t,actions:n,onClose:r}){let i=F(e,t.id);return(0,$.jsxs)(U,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mt(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":X(`project.openOriginal`),title:X(`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,$.jsx)(re,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Et,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Dt,{file:t,actions:n})})]})}function Pt({projectId:e,file:t,actions:n,onPreview:r}){return(0,$.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${X(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(kt,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mt(t)})]}),(0,$.jsx)(Dt,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,$.jsx)(G,{label:X(`project.preview`),onClick:r,children:(0,$.jsx)(O,{className:`size-4`})}),n.readOnly?null:(0,$.jsx)(G,{label:X(`project.remove`),onClick:()=>Ot(t,n),className:`hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]})]})}function Ft({projectId:e,data:t,readOnly:n}){let r=oe(e,n),[i,a]=N(`assets`,`cards`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,$.jsxs)(k,{title:X(`project.assets`),hint:X(`project.assetsHint`),children:[u.length?(0,$.jsx)(le,{layout:i,onToggle:a,children:(0,$.jsx)(P,{value:o,onChange:s,placeholder:X(`project.assetSearch`)})}):null,p.length?(0,$.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,$.jsx)(At,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,$.jsx)(Pt,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.staysLocal`)}):(0,$.jsxs)(ae,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,$.jsx)(V,{className:`size-4`}):(0,$.jsx)(ne,{className:`size-4`}),X(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:X(`project.assetAdd`)})]}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,$.jsx)(Nt,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function It(e,t,n){return c({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>u.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function Lt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Rt=e=>[Lt(e),e.pages?X(`project.pages`,{n:e.pages}):null,ce(e.size)].filter(Boolean).join(` · `);function zt({file:e}){return e.status===`pending`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,$.jsx)(V,{className:`size-3`}),` `,X(`project.reading`)]}):e.status===`failed`?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:e.error}):e.indexed?(0,$.jsx)(K,{tone:`live`,children:e.indexed===`embeddings`?X(`project.indexed`):X(`project.indexedKeywords`)}):(0,$.jsx)(K,{tone:`warn`,children:X(`project.notIndexed`)})}function Bt({file:e,actions:t,onPreview:n}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:X(`project.preview`),onClick:n,children:(0,$.jsx)(O,{className:`size-4`})}),e.status!==`pending`&&!t.readOnly?(0,$.jsx)(G,{label:X(`project.reindex`),onClick:()=>t.reindex(e.id),children:(0,$.jsx)(x,{className:`size-4`})}):null,t.readOnly?null:(0,$.jsx)(G,{label:X(`project.remove`),onClick:()=>Ot(e,t),className:`hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]})}function Vt({file:e,actions:t,onPreview:n}){let r=/sheet|csv|excel/.test(e.mime);return(0,$.jsxs)(`li`,{className:`flex gap-3 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 text-ink-3`,children:r?(0,$.jsx)(He,{className:`size-5`}):(0,$.jsx)(ge,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:n,title:e.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Rt(e)}),(0,$.jsx)(zt,{file:e})]}),(0,$.jsx)(Dt,{file:e,actions:t})]}),(0,$.jsx)(`div`,{className:`-my-1 flex shrink-0 items-start`,children:(0,$.jsx)(Bt,{file:e,actions:t,onPreview:n})})]})}function Ht({projectId:e,file:t}){let n=It(e,t,1500);return t.mime.startsWith(`image/`)?(0,$.jsx)(`img`,{src:F(e,t.id),alt:``,className:`size-full object-cover`}):t.status===`pending`||n.isLoading?(0,$.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-4`,children:(0,$.jsx)(V,{className:`size-5`})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-[222%] origin-top-left scale-[0.45] p-6`,children:(0,$.jsx)(v,{text:n.data?.text??``})}),(0,$.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-12 bg-linear-to-t from-card to-transparent`})]})}function Ut({projectId:e,file:t,actions:n,onPreview:r}){return(0,$.jsxs)(`li`,{className:`group flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`${X(`project.preview`)}: ${t.name}`,className:`relative block h-44 w-full overflow-hidden rounded-md bg-card text-left ring-1 ring-border-soft transition hover:ring-border`,children:(0,$.jsx)(Ht,{projectId:e,file:t})}),(0,$.jsx)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100 [&>button]:size-8 [&>button]:bg-card [&>button]:shadow-soft`,children:(0,$.jsx)(Bt,{file:t,actions:n,onPreview:r})})]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1 px-0.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium text-[0.8125rem]`,title:t.name,children:t.name}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Rt(t)}),(0,$.jsx)(zt,{file:t})]})]}),(0,$.jsx)(Dt,{file:t,actions:n})]})}var Wt=2e5;function Gt({projectId:e,file:t,onClose:n}){let r=t.mime===`application/pdf`||t.mime.startsWith(`image/`),[i,a]=(0,Q.useState)(r?`original`:`text`),o=It(e,t,Wt),s=F(e,t.id),c=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>a(e),className:H(`h-8 rounded-full px-3 text-[0.8125rem] transition`,i===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(U,{open:!0,onClose:n,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Rt(t)}),(0,$.jsx)(zt,{file:t}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[r?(0,$.jsxs)($.Fragment,{children:[c(`original`,X(`project.original`)),c(`text`,X(`project.readText`))]}):null,(0,$.jsx)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,"aria-label":X(`project.openOriginal`),title:X(`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,$.jsx)(re,{className:`size-4`})})]})]}),i===`original`?t.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:s,title:t.name,className:`h-[70dvh] w-full rounded-lg bg-paper-2 ring-1 ring-border-soft`}):(0,$.jsx)(`img`,{src:s,alt:``,className:`mx-auto max-h-[70dvh] rounded-lg object-contain`}):o.isLoading?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(V,{})}):o.data?.text?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-lg bg-paper p-5 ring-1 ring-border-soft`,children:(0,$.jsx)(v,{text:o.data.text,className:`text-[0.875rem]`})}),o.data.chars>o.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:X(`project.textCut`,{shown:o.data.text.length.toLocaleString(),total:o.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:X(`project.noText`)})]})}function Kt({projectId:e}){let[t,n]=(0,Q.useState)(``),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),s=async()=>{if(!t.trim()){i(null);return}o(!0);try{let n=await u.post(`/api/studio/projects/${e}/search`,{query:t});i(n.hits)}catch{i([])}finally{o(!1)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{value:t,placeholder:X(`project.searchTest`),busy:a,onEnter:()=>void s(),onChange:e=>{n(e),e.trim()||i(null)}}),r?r.length?(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2`,children:r.map((e,t)=>(0,$.jsxs)(`li`,{className:`rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem]`,children:[(0,$.jsx)(`div`,{className:`mb-0.5 font-medium text-[0.75rem] text-ink-3`,children:e.name}),(0,$.jsx)(`p`,{className:`line-clamp-3 whitespace-pre-line text-ink-2`,children:e.text})]},t))}):(0,$.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:X(`project.searchNone`)}):null]})}function qt({projectId:e,data:t,readOnly:n}){let r=oe(e,n),[i,a]=N(`documents`,`list`),[o,s]=(0,Q.useState)(null),c=t.files.filter(e=>e.kind===`document`),l=c.find(e=>e.id===o),u=i===`cards`?Ut:Vt;return(0,$.jsxs)(k,{title:X(`project.documents`),hint:X(`project.documentsHint`),children:[c.length?(0,$.jsx)(le,{layout:i,onToggle:a,children:(0,$.jsx)(Kt,{projectId:e})}):null,c.length?(0,$.jsx)(`ul`,{className:H(`mb-3`,i===`cards`?`grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-3`:`flex flex-col gap-2`),children:c.map(t=>(0,$.jsx)(u,{projectId:e,file:t,actions:r,onPreview:()=>s(t.id)},t.id))}):null,n?c.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.staysLocal`)}):(0,$.jsxs)(ae,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:e=>r.upload(`document`,e),className:`h-16 w-full`,children:[r.busy?(0,$.jsx)(V,{className:`size-4`}):(0,$.jsx)(ne,{className:`size-4`}),X(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:X(`project.documentAdd`)})]}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,c.length&&!t.embeddings?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:X(`project.keywordsOnly`)}):null,l?(0,$.jsx)(Gt,{projectId:e,file:l,onClose:()=>s(null)}):null]})}var Jt=e=>/^(ja|yes|true)$/i.test(e.trim()),Yt={text:he,longtext:et,number:We,date:Be,url:I,email:y,phone:Xe,boolean:nt};function Xt({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=Yt[e??t],l=`${X(`project.factType`)}: ${X(`project.type.${e??t}`)}`,u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:H(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,$.jsx)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:H(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,$.jsx)(ie,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:X(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:X(`project.type.${t}`)}),(0,$.jsx)(C,{className:H(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),ft.map(t=>{let n=Yt[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:X(`project.type.${t}`)}),(0,$.jsx)(C,{className:H(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Zt({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=A(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=xt.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(k,{title:X(`project.facts`),hint:X(`project.factsHint`),save:s,locked:n,action:a.length<St.facts&&!n?(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(D,{className:`size-4`}),` `,X(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=yt(e.value),r=e.type??t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,$.jsx)(q,{ref:u(`${e.id}:label`),value:e.label,placeholder:X(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:bt(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(me,{checked:Jt(e.value),label:e.label,onChange:t=>c(e.id,{value:X(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Jt(e.value)?X(`project.yes`):X(`project.no`)})]}):(0,$.jsx)(pe,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:X(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Xt,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(G,{label:X(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]},e.id)})}),a.length<St.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,X(`project.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:z===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(D,{className:`size-3.5`}),` `,z===`en`?e.en:e.de]},e.key))]}):null]})}function Qt({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=A({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(k,{title:X(`project.base`),hint:X(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`project.title`)}),(0,$.jsx)(q,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`project.about`)}),(0,$.jsx)(pe,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.aboutHint`)})]})]})})}function $t({project:e,group:t,children:n}){let r=d(),i=M(e.id),[a,o]=(0,Q.useState)(0),s=async t=>{await u.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},c=Z({mutationFn:()=>u.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),l=_e(),f=i.data??{files:[],embeddings:!0},p=`${e.id}:${a}`,m=e.readOnly;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[m?(0,$.jsx)(Pe,{children:je(e)}):(0,$.jsx)(dt,{projectId:e.id,onChanged:()=>o(e=>e+1)},e.id),t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(j,{id:`base`,children:(0,$.jsx)(Qt,{project:e,save:s},`base:${p}`)}),(0,$.jsx)(j,{id:`logos`,children:(0,$.jsx)(jt,{projectId:e.id,data:f,readOnly:m})}),(0,$.jsx)(j,{id:`colors`,children:(0,$.jsx)(Tt,{colors:e.brand.colors??[],save:e=>s({brand:{colors:e}}),readOnly:m},`colors:${p}`)}),(0,$.jsx)(j,{id:`assets`,children:(0,$.jsx)(Ft,{projectId:e.id,data:f,readOnly:m})}),(0,$.jsx)(j,{id:`facts`,children:(0,$.jsx)(Zt,{facts:e.facts,save:e=>s({facts:e}),readOnly:m},`facts:${p}`)})]}):(0,$.jsx)(j,{id:`documents`,children:(0,$.jsx)(qt,{projectId:e.id,data:f,readOnly:m})}),n,t===`info`&&l&&!m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(J,{variant:`danger`,busy:c.isPending,onClick:()=>confirm(`${X(`settings.delete`)}?`)&&c.mutate(),children:X(`settings.delete`)}),c.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:c.error.message}):null]}):null]})}var en={q:``,mode:``,days:0};function tn(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 c({queryKey:[`results`,e,i],queryFn:()=>u.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function nn({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(E,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(q,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:X(`space.resultsSearch`),"aria-label":X(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(Y,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:X(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(Y,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:X(`space.resultsAnyTime`)},{value:`1`,label:X(`space.resultsDay`)},{value:`7`,label:X(`space.resultsDays`,{n:7})},{value:`30`,label:X(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function rn({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(z,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(k,{title:t?o(t):X(`space.resultsAll`),hint:X(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(nn,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,X(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:X(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(ee,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(K,{children:`Test`}):(0,$.jsxs)(K,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(W,{children:(0,$.jsx)(de,{children:n.q.trim()||n.mode||n.days?X(`space.resultsNone`):X(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:()=>a(null),children:(0,$.jsxs)(`div`,{className:`flex h-full w-full max-w-[680px] animate-rise flex-col bg-background shadow-overlay`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(K,{children:`Test`}):(0,$.jsxs)(K,{tone:`live`,children:[`Live v`,i.version]}),(0,$.jsx)(G,{label:X(`editor.close`),onClick:()=>a(null),children:(0,$.jsx)(Se,{className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(b,{runId:i.id,compact:!0},i.id)})]})}):null]})}function an(e){return c({queryKey:[`space-data`,e],queryFn:()=>u.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function on(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:X(`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 sn={table:R,page:ge};function cn({kind:e,projectId:t,data:n,onClose:r,onMade:i}){let a=d(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),f=Z({mutationFn:()=>u.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),wizardId:c||null}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`space-data`,t]}),i(`${e===`table`?`t`:`p`}:${n}`),s(``),l(``)}});return(0,$.jsx)(U,{open:e!==null,onClose:r,title:X(e===`table`?`data.newTable`:`data.newPage`),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&f.mutate()},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`data.title`)}),(0,$.jsx)(q,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>s(e.target.value)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`data.owner`)}),(0,$.jsx)(Y,{value:c,onChange:l,options:[{value:``,label:X(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),f.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:f.isPending,disabled:!o.trim(),children:X(`data.create`)})]})]})})}function ln({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,Q.useState)(null),o=on(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(z,{dateStyle:`medium`});return(0,$.jsxs)(k,{title:X(`space.data`),hint:X(`data.hint`),plain:!0,action:n?null:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,X(`data.table`)]}),(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,X(`data.page`)]})]}),children:[o.length?(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=sn[e.kind];return(0,$.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,$.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,$.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${X(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,$.jsx)(W,{children:(0,$.jsx)(de,{children:X(`data.empty`)})}),(0,$.jsx)(cn,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function un({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=Z({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:X(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(h,{className:`size-4`})}),(0,$.jsx)(U,{open:n,onClose:()=>r(!1),title:X(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(q,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>r(!1),children:X(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:X(`settings.save`)})]})]})})]})}function dn({project:e}){let t=d();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(S,{}),e.readOnly?null:(0,$.jsx)(un,{project:e,save:async n=>{await u.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function fn(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 pn={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},mn=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function hn(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/pn[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)}function gn(e,t){return t.trim()===``?null:e.type===`date`&&e.format.kind===`datetime`?new Date(t).toISOString():t}var _n=`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 vn({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=hn(e,t),[o,s]=(0,Q.useState)(a);(0,Q.useEffect)(()=>s(a),[a]);let c=(t=o)=>{t!==a&&i(gn(e,t))};if(e.type===`boolean`)return(0,$.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,$.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(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:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,$.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:[a(e),n?null:(0,$.jsx)(`button`,{type:`button`,"aria-label":X(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,$.jsx)(Se,{className:`size-3`})})]},e)),n?null:(0,$.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...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,$.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,$.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:_n,children:[(0,$.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,$.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>c(),"aria-label":e.name,className:H(_n,`field-sizing-content max-h-40 resize-none`)});let l=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,$.jsx)(`input`,{type:l,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&c(t.target.value)},onBlur:()=>e.type!==`date`&&c(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:H(_n,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function yn(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?X(`data.unit.${e.format.inputUnit}`):null}function bn(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
3
  `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function xn(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
4
  `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??fn(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,Q.useState)(()=>bn(t)),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(o(bn(t)),c(null))},[e,t]);let d=e=>o(t=>({...t,...e})),f=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},p=()=>{let e=t?.id??fn(a.name,n.map(e=>e.id)),r=xn(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,$.jsx)(U,{open:e,onClose:r,title:t?t.name:X(`data.newColumn`),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&p()},children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`data.columnName`)}),(0,$.jsx)(q,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`data.columnType`)}),(0,$.jsx)(Y,{value:a.type,onChange:e=>d({type:e}),options:mn.map(e=>({value:e,label:X(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,$.jsx)(Y,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:X(`data.text.single`)},{value:`multiline`,label:X(`data.text.multiline`)}]}):null,a.type===`number`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(Y,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:X(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,$.jsx)(q,{value:a.currency,maxLength:3,"aria-label":X(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,$.jsx)(Y,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:X(`data.date.${e}`)}))}):null,a.type===`duration`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`data.unit`)}),(0,$.jsx)(Y,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:X(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:X(`data.options`)}),(0,$.jsx)(pe,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,$.jsx)(me,{checked:a.multiple,onChange:e=>d({multiple:e})}),X(`data.multiple`)]})]}):null,(0,$.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,$.jsx)(me,{checked:a.required,onChange:e=>d({required:e})}),X(`data.required`)]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,$.jsx)(J,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(X(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:X(`data.deleteColumn`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(J,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:l,disabled:!a.name.trim(),children:X(`settings.save`)})]})]})})}function Cn({tableId:e,onGone:t}){let n=d(),r=[`space-table`,e],i=c({queryKey:r,queryFn:()=>u.get(`/api/studio/tables/${e}`)}),[a,o]=(0,Q.useState)(null),[s,l]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``);(0,Q.useEffect)(()=>g(i.data?.title??``),[i.data?.title]);let _=()=>n.invalidateQueries({queryKey:[`space-data`,i.data?.projectId]}),v=e=>n.setQueryData(r,t=>t&&{...t,rows:e(t.rows)}),y=e=>{l(e.message),i.refetch()},ee=async t=>{await u.patch(`/api/studio/tables/${e}`,t),await i.refetch(),await _()},b=Z({mutationFn:({row:t,column:n,value:r})=>u.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{l(null),m(e=>e===`${t}:${n}`?null:e),v(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof f&&e.body?.column===n){let e=i.data?.columns.find(e=>e.id===n)?.name??n;m(`${t}:${n}`),l(X(`data.badCell`,{column:e}));return}y(e)}}),te=Z({mutationFn:()=>u.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{v(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await _()},onError:y}),x=Z({mutationFn:t=>u.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{v(e=>e.filter(e=>e.id!==t)),await _()},onError:y}),S=Z({mutationFn:()=>u.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await _(),t()}});if(!i.data)return i.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i.error.message}):null;let{columns:C,rows:w,readOnly:T}=i.data,E=!!i.data.list;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`input`,{value:h,disabled:T,maxLength:120,onChange:e=>g(e.target.value),onBlur:()=>h.trim()&&h!==i.data?.title&&void ee({title:h}).catch(y),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":X(`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`}),T?null:(0,$.jsx)(G,{label:X(`data.deleteTable`),onClick:()=>confirm(X(`data.confirmDelete`,{title:i.data.title}))&&S.mutate(),className:`hover:text-rose`,children:(0,$.jsx)(L,{className:`size-4`})})]}),E?(0,$.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:X(`data.fromList`)}):null,(0,$.jsxs)(W,{className:`overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[C.map(e=>(0,$.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:T||E,onClick:()=>o(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,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,$.jsx)(`span`,{className:`text-ember`,children:`*`}):null,yn(e)?(0,$.jsx)(`span`,{className:`font-normal text-ink-4`,children:yn(e)}):null]})},e.id)),(0,$.jsx)(`th`,{className:`w-10 p-1`,children:T||E?null:(0,$.jsx)(G,{label:X(`data.newColumn`),onClick:()=>o(`new`),className:`size-8`,children:(0,$.jsx)(D,{className:`size-4`})})})]})}),(0,$.jsx)(`tbody`,{children:w.map(e=>(0,$.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[C.map(t=>(0,$.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,$.jsx)(vn,{column:t,value:e.cells[t.id],readOnly:T,invalid:p===`${e.id}:${t.id}`,onSave:n=>b.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,$.jsx)(`td`,{className:`w-10 p-1 align-top`,children:T?null:(0,$.jsx)(G,{label:X(`data.deleteRow`),onClick:()=>x.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,$.jsx)(L,{className:`size-3.5`})})})]},e.id))})]})}),w.length?null:(0,$.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:X(`data.noRows`)}),T?null:(0,$.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,busy:te.isPending,onClick:()=>te.mutate(),children:[(0,$.jsx)(D,{className:`size-4`}),` `,X(`data.addRow`)]})})]}),s?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:s}):null,(0,$.jsx)(Sn,{open:a!==null,column:a===`new`?null:a,columns:C,onClose:()=>o(null),onSave:e=>ee({columns:e})})]})}function wn(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=window.scrollY>0&&window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-4,i=Math.max(160,window.innerHeight/3),a=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=i&&(a=t)}r(t?e.at(-1):a)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a)}},[t]),n}function Tn(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function En({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(De,{icon:e.icon??Qe,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Ae,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Dn(){let{group:e}=l(),[t,n]=r(),o=a(),{hash:s}=i(),{project:c,loading:u}=Te(),d=_e(),f=be(),m=Re(),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[y,ee]=(0,Q.useState)(null),b=we(e)?e:void 0,te=ye().map(e=>({...e,to:`/space/${e.id}`})),x=te.find(e=>e.id===b),S=t.get(`show`),C=b?S?2:1:0,w=m?Math.min(C,1):b&&y!==b?1:0,T=ke(w),E=ke(C),ne=(0,Q.useMemo)(()=>({slot:h,narrow:m,setDetail:v}),[h,m]),D=c?c.brand.name?.trim()||c.name:X(`nav.project`),re=b&&b!==`results`?Ee(b,f):[],O=b?Ee(b,f).filter(e=>e.plugin):[],ae=wn([...re,...b===`results`?O:[]].flatMap(e=>e.sections.map(e=>e.id))),A=b===`results`&&S&&S!==`all`?S:null,[oe,ce]=(0,Q.useState)(en),M=tn(b===`results`?c?.id:void 0,A,oe),le=M.data?.wizards.find(e=>e.id===A)?.title,N=b===`data`&&S&&S!==`all`?S:null,P=an(b===`data`?c?.id:void 0),F=P.data?on(P.data).flatMap(e=>e.items).find(e=>e.key===N)?.title:void 0;xe([{label:D,to:`/space`},...x?[{label:x.label,to:`/space/${x.id}`}]:[],...x&&(_??le??F)?[{label:_??le??F}]:[]]);let I=b===`results`||b===`data`?s.slice(1):S||s.slice(1),L=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${b}#${I}`;I&&L.current!==e&&document.getElementById(I)&&(L.current=e,requestAnimationFrame(()=>Tn(I,!1)))},[b,I,c?.id,f.spaceSections]),!b){let t=s.slice(1),n=t?ve(t,f):null;if(n)return(0,$.jsx)(p,{to:m?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&f.status!==`ready`)return null;if(e!==void 0||!m)return(0,$.jsx)(p,{to:`/space/info`,replace:!0})}let ue=e=>{if(m){o({search:`?show=${e}`});return}L.current=`${b}#${e}`,Tn(e,!0),o({search:``,hash:e},{replace:!0})},R=e=>m?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),z=e=>e.flatMap(e=>e.sections).map(e=>f.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(j,{id:e.id,children:(0,$.jsx)(k,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Ce,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),B=m?void 0:ae;return(0,$.jsx)(Ne.Provider,{value:ne,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:H(`min-w-0 md:sticky md:top-20 md:self-start`,m&&C===2&&`hidden`,m&&E===`back`&&Oe(`back`)),children:[(0,$.jsx)(Me,{title:D,open:w===1?x??null:null,onBack:()=>m?o(`/space`):ee(b??null)}),(0,$.jsx)(`div`,{className:H(Oe(T)),children:w===0?(0,$.jsx)(Fe,{entries:te,current:m?void 0:x,onPick:()=>ee(null)}):(0,$.jsx)(`div`,{ref:g})},w)]}),b?(0,$.jsxs)(`div`,{className:H(`min-w-0`,m&&C<2&&`hidden`,m&&E===`deeper`&&Oe(`deeper`)),children:[m?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Le,{label:x?.label??D,onBack:()=>o(`/space/${b}`)})}):null,d&&c?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(dn,{project:c})}):null,b===`results`?(0,$.jsxs)(Ie,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(De,{icon:Ke,label:X(`space.resultsAll`),selected:!m&&!A,onPick:()=>R(`all`)}),M.data?.wizards.filter(e=>e.results||e.id===A).map(e=>(0,$.jsx)(De,{icon:ie,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!m&&e.id===A,onPick:()=>R(e.id)},e.id))]}),(0,$.jsx)(En,{groups:O,current:B,onPick:ue})]}):b===`data`?(0,$.jsxs)(Ie,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(De,{icon:se,label:X(`data.all`),selected:!m&&!N,onPick:()=>R(`all`)})}),P.data?on(P.data).map(e=>(0,$.jsx)(Ae,{label:e.label,children:e.items.map(e=>(0,$.jsx)(De,{icon:sn[e.kind],label:e.title,selected:!m&&e.key===N,onPick:()=>R(e.key)},e.key))},e.key)):null,(0,$.jsx)(En,{groups:O,current:B,onPick:ue})]}):(0,$.jsx)(Ie,{children:(0,$.jsx)(En,{groups:re,current:B,onPick:ue})}),c&&(b===`info`||b===`knowledge`)?(0,$.jsx)($t,{project:c,group:b,children:z(O)},c.id):null,c&&b===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:N?.startsWith(`t:`)?(0,$.jsx)(Cn,{tableId:N.slice(2),onGone:()=>R(`all`)},N):N?.startsWith(`p:`)?(0,$.jsx)(it,{pageId:N.slice(2),onGone:()=>R(`all`)},N):(0,$.jsxs)($.Fragment,{children:[P.data?(0,$.jsx)(ln,{projectId:c.id,data:P.data,readOnly:c.readOnly,onOpen:R}):null,z(O)]})}):null,c&&b===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[M.data?(0,$.jsx)(rn,{data:M.data,wizardId:A,filter:oe,onFilter:ce}):null,M.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:M.error.message}):null,z(O)]}):null,c||u?null:(0,$.jsx)(de,{children:X(`settings.noProject`)})]}):null]})})})}export{Dn as ProjectPage};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,d as o,f as s,h as c,j as l,k as u,l as d,n as f,r as p}from"./api-DTLkC0ge.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{c as h,o as g,s as _,t as v}from"./RunnerView-a_2EqHPo.js";import{t as y}from"./arrow-right-6FyN3e7D.js";import{d as b,h as x,t as S,y as C}from"./ui-CHX2gEQl.js";var w={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`}]]};w.node;var T=m(w),E={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};E.node;var D=m(E),O={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`]};O.node;var k=m(O),A=e(t(),1);function j(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`?e:null}var M=j(),N=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`);function P(){(0,A.useEffect)(()=>{if(M===`inline`){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>N(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(M===`modal`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&N(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[])}var F=e(n(),1);function I(e){(0,A.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function L(e,t){(0,A.useEffect)(()=>{if(!e||!t)return;let n=a(`/api/public/wizards/${e}`),r=[{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}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var R=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,z=R||/Android/.test(navigator.userAgent);function B(){let[e,t]=(0,A.useState)(()=>window.wizardInstall??null),[n,r]=(0,A.useState)(!1);if((0,A.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||z&&!e&&!R)return null;let i=/Mac/.test(navigator.platform),a=C(z?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,F.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{z&&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:[z?(0,F.jsx)(k,{className:`size-4`}):(0,F.jsx)(T,{className:`size-4`}),C(z?`install.add`:`install.bookmark`)]}),n?(0,F.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function V({brand:e,toggle:t=!0}){return(0,F.jsx)(`header`,{className:`safe-top`,children:(0,F.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,F.jsx)(`img`,{src:a(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,F.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,F.jsx)(`div`,{className:`absolute right-3`,children:(0,F.jsx)(s,{})}):null]})})}function H({siteKey:e,onToken:t}){let n=(0,A.useRef)(null);return(0,A.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,F.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function U({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||g||M?null:(0,F.jsxs)(`a`,{href:_(`${window.location.origin}${i}/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,F.jsx)(D,{className:`size-4`}),` `,C(`install.app`)]})}var W=e=>`wz.run.${e}`,G=g&&new URLSearchParams(window.location.search).get(`start`)===`1`,K=M===`inline`?`min-h-80`:`min-h-dvh`;function q({wizard:e}){let t=r(),[n,i]=(0,A.useState)(!1),[a,s]=(0,A.useState)(null),[c,l]=(0,A.useState)(null),u=(()=>{try{return localStorage.getItem(W(e.token))}catch{return null}})(),d=async()=>{i(!0),s(null);try{let{runId:n}=await f.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:M!==null});try{localStorage.setItem(W(e.token),n)}catch{}t(`/w/${e.token}/${n}`,{replace:G})}catch(e){s(e.message),i(!1)}},p=G&&e.available&&!e.turnstileSiteKey,m=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{p&&!m.current&&(m.current=!0,d())},[p]),p&&!a?(0,F.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,F.jsx)(b,{})}):(0,F.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,F.jsx)(o,{kind:e.avatar,size:190,fluffy:!0}),(0,F.jsx)(`h1`,{className:`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,F.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(S,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!c,onClick:d,children:[C(`run.start`),` `,(0,F.jsx)(y,{className:`size-4`})]}),e.turnstileSiteKey?(0,F.jsx)(H,{siteKey:e.turnstileSiteKey,onToken:l}):null,u?(0,F.jsx)(`button`,{type:`button`,onClick:()=>t(`/w/${e.token}/${u}`),className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:C(`run.resume`)}):null,M||g?null:(0,F.jsx)(B,{}),(0,F.jsx)(U,{token:e.token})]}):(0,F.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??C(`run.unavailable`)}),a?(0,F.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:a}):null]})}function J(){let{token:e,runId:t}=u(),n=r(),a=l({queryKey:[`public`,e],queryFn:()=>f.get(`/api/public/wizards/${e}`),retry:(e,t)=>p(t)&&e<3});if(I(a.data?.brand.accent),c(a.data?.avatar),L(e,a.data?.title),P(),(0,A.useEffect)(()=>{a.data&&(document.title=a.data.title)},[a.data]),(0,A.useEffect)(()=>{e&&t&&h(`run`,{token:e,runId:t})},[e,t]),a.isLoading)return(0,F.jsx)(`div`,{className:x(`flex items-center justify-center text-ink-4`,K),children:(0,F.jsx)(b,{})});if(!a.data){let e=p(a.error);return(0,F.jsxs)(`div`,{className:x(`flex flex-col items-center justify-center gap-4 px-6 text-center`,K),children:[(0,F.jsx)(o,{kind:`pebble`,size:80}),(0,F.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:C(e?`common.offline`:`run.notFound`)}),e?(0,F.jsx)(S,{variant:`secondary`,onClick:()=>void a.refetch(),children:C(`common.retry`)}):null]})}return(0,F.jsxs)(`div`,{className:x(`flex flex-col`,K),children:[M===`inline`||g?null:(0,F.jsx)(V,{brand:a.data.brand,toggle:!M}),(0,F.jsx)(`div`,{className:`flex-1`,children:t?(0,F.jsx)(v,{runId:t,onRestart:()=>n(`/w/${e}`)}):(0,F.jsx)(q,{wizard:a.data})}),g?(0,F.jsx)(`div`,{className:`safe-bottom`}):(0,F.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,F.jsx)(`a`,{href:`${i}/`,target:M?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:C(`run.madeWith`).replace(`engenty wizards`,d.name)})})]})}export{V as BrandHeader,J as PublicRunner,I as useBrandAccent};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,d as o,f as s,h as c,j as l,k as u,l as d,n as f,r as p}from"./api-t9_w1XNe.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{c as h,o as g,s as _,t as v}from"./RunnerView-D_C7hn81.js";import{t as y}from"./arrow-right-6FyN3e7D.js";import{d as b,h as x,t as S,y as C}from"./ui-BHXO_e0e.js";var w={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`}]]};w.node;var T=m(w),E={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};E.node;var D=m(E),O={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`]};O.node;var k=m(O),A=e(t(),1);function j(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`?e:null}var M=j(),N=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`);function P(){(0,A.useEffect)(()=>{if(M===`inline`){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>N(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(M===`modal`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&N(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[])}var F=e(n(),1);function I(e){(0,A.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function L(e,t){(0,A.useEffect)(()=>{if(!e||!t)return;let n=a(`/api/public/wizards/${e}`),r=[{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}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var R=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,z=R||/Android/.test(navigator.userAgent);function B(){let[e,t]=(0,A.useState)(()=>window.wizardInstall??null),[n,r]=(0,A.useState)(!1);if((0,A.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||z&&!e&&!R)return null;let i=/Mac/.test(navigator.platform),a=C(z?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,F.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{z&&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:[z?(0,F.jsx)(k,{className:`size-4`}):(0,F.jsx)(T,{className:`size-4`}),C(z?`install.add`:`install.bookmark`)]}),n?(0,F.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function V({brand:e,toggle:t=!0}){return(0,F.jsx)(`header`,{className:`safe-top`,children:(0,F.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,F.jsx)(`img`,{src:a(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,F.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,F.jsx)(`div`,{className:`absolute right-3`,children:(0,F.jsx)(s,{})}):null]})})}function H({siteKey:e,onToken:t}){let n=(0,A.useRef)(null);return(0,A.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,F.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function U({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||g||M?null:(0,F.jsxs)(`a`,{href:_(`${window.location.origin}${i}/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,F.jsx)(D,{className:`size-4`}),` `,C(`install.app`)]})}var W=e=>`wz.run.${e}`,G=g&&new URLSearchParams(window.location.search).get(`start`)===`1`,K=M===`inline`?`min-h-80`:`min-h-dvh`;function q({wizard:e}){let t=r(),[n,i]=(0,A.useState)(!1),[a,s]=(0,A.useState)(null),[c,l]=(0,A.useState)(null),u=(()=>{try{return localStorage.getItem(W(e.token))}catch{return null}})(),d=async()=>{i(!0),s(null);try{let{runId:n}=await f.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:M!==null});try{localStorage.setItem(W(e.token),n)}catch{}t(`/w/${e.token}/${n}`,{replace:G})}catch(e){s(e.message),i(!1)}},p=G&&e.available&&!e.turnstileSiteKey,m=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{p&&!m.current&&(m.current=!0,d())},[p]),p&&!a?(0,F.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,F.jsx)(b,{})}):(0,F.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,F.jsx)(o,{kind:e.avatar,size:190,fluffy:!0}),(0,F.jsx)(`h1`,{className:`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,F.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(S,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!c,onClick:d,children:[C(`run.start`),` `,(0,F.jsx)(y,{className:`size-4`})]}),e.turnstileSiteKey?(0,F.jsx)(H,{siteKey:e.turnstileSiteKey,onToken:l}):null,u?(0,F.jsx)(`button`,{type:`button`,onClick:()=>t(`/w/${e.token}/${u}`),className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:C(`run.resume`)}):null,M||g?null:(0,F.jsx)(B,{}),(0,F.jsx)(U,{token:e.token})]}):(0,F.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??C(`run.unavailable`)}),a?(0,F.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:a}):null]})}function J(){let{token:e,runId:t}=u(),n=r(),a=l({queryKey:[`public`,e],queryFn:()=>f.get(`/api/public/wizards/${e}`),retry:(e,t)=>p(t)&&e<3});if(I(a.data?.brand.accent),c(a.data?.avatar),L(e,a.data?.title),P(),(0,A.useEffect)(()=>{a.data&&(document.title=a.data.title)},[a.data]),(0,A.useEffect)(()=>{e&&t&&h(`run`,{token:e,runId:t})},[e,t]),a.isLoading)return(0,F.jsx)(`div`,{className:x(`flex items-center justify-center text-ink-4`,K),children:(0,F.jsx)(b,{})});if(!a.data){let e=p(a.error);return(0,F.jsxs)(`div`,{className:x(`flex flex-col items-center justify-center gap-4 px-6 text-center`,K),children:[(0,F.jsx)(o,{kind:`pebble`,size:80}),(0,F.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:C(e?`common.offline`:`run.notFound`)}),e?(0,F.jsx)(S,{variant:`secondary`,onClick:()=>void a.refetch(),children:C(`common.retry`)}):null]})}return(0,F.jsxs)(`div`,{className:x(`flex flex-col`,K),children:[M===`inline`||g?null:(0,F.jsx)(V,{brand:a.data.brand,toggle:!M}),(0,F.jsx)(`div`,{className:`flex-1`,children:t?(0,F.jsx)(v,{runId:t,onRestart:()=>n(`/w/${e}`)}):(0,F.jsx)(q,{wizard:a.data})}),g?(0,F.jsx)(`div`,{className:`safe-bottom`}):(0,F.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,F.jsx)(`a`,{href:`${i}/`,target:M?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:C(`run.madeWith`).replace(`engenty wizards`,d.name)})})]})}export{V as BrandHeader,J as PublicRunner,I as useBrandAccent};