wizards 0.2.42 → 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/app.js +37 -3
- package/apps/runtime/dist/authoring/guide.js +5 -2
- package/apps/runtime/dist/browser/fast/action-space.js +162 -0
- package/apps/runtime/dist/browser/fast/classifier.js +91 -0
- package/apps/runtime/dist/browser/fast/decide.js +171 -0
- package/apps/runtime/dist/browser/fast/driver.js +141 -0
- package/apps/runtime/dist/browser/fast/instructions.js +33 -0
- package/apps/runtime/dist/browser/fast/run.js +249 -0
- package/apps/runtime/dist/browser/fast/span-picker.js +153 -0
- package/apps/runtime/dist/browser/fast/text-helper.js +178 -0
- package/apps/runtime/dist/browser/snapshot.js +335 -0
- package/apps/runtime/dist/db/migrations/tenant/0011_runners.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0011_snapshot.json +2956 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +4 -0
- package/apps/runtime/dist/engine/resources.js +109 -0
- package/apps/runtime/dist/engine/runner.js +7 -3
- package/apps/runtime/dist/engine/steps.js +89 -10
- package/apps/runtime/dist/env.js +9 -0
- package/apps/runtime/dist/harness/claude.js +9 -1
- package/apps/runtime/dist/link-preview.js +4 -3
- package/apps/runtime/dist/mcp/tools.js +1 -1
- package/apps/runtime/dist/media/conversation.js +177 -0
- package/apps/runtime/dist/models.js +17 -0
- package/apps/runtime/dist/plugins/loader.js +48 -2
- package/apps/runtime/dist/plugins/registry.js +1 -0
- package/apps/runtime/dist/plugins/runs.js +205 -0
- package/apps/runtime/dist/routes/runs.js +206 -22
- package/apps/runtime/dist/routes/studio.js +12 -1
- package/apps/runtime/dist/services/cloud.js +1 -0
- package/apps/runtime/dist/services/runners.js +138 -0
- package/apps/runtime/dist/services/runs.js +83 -45
- package/apps/runtime/dist/services/wizard-icon.js +12 -0
- package/apps/runtime/dist/services/wizards.js +5 -1
- package/apps/runtime/dist/tools/browser.js +426 -97
- package/apps/runtime/dist/tools/index.js +50 -3
- package/apps/web/dist/assets/ChangelogDialog-8qS5utcR.js +1 -0
- package/apps/web/dist/assets/ChatView-Bx1KVCEf.js +10 -0
- package/apps/web/dist/assets/{CreditsDialog-DPglouDr.js → CreditsDialog-BCuDsatt.js} +1 -1
- package/apps/web/dist/assets/EditorPage-_Sbj-mSD.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-CQN5acxA.js → FlowPreview-COgjib4H.js} +1 -1
- package/apps/web/dist/assets/{Harness-BFxUFB7B.js → Harness-BaxjV1Ng.js} +2 -2
- package/apps/web/dist/assets/HomePage-BlD0wZB0.js +1 -0
- package/apps/web/dist/assets/ImportWizard-BZDtNJg1.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-Ci_x__p9.js +2 -0
- package/apps/web/dist/assets/ProjectPage-NwFut2Z-.js +2 -0
- package/apps/web/dist/assets/PublicRunner-rHdvK18v.js +1 -0
- package/apps/web/dist/assets/RunDrawer-Dp-JowDX.js +4 -0
- package/apps/web/dist/assets/RunnerView-DSlReODC.js +2 -0
- package/apps/web/dist/assets/SettingsPage-2Bw-D3hC.js +1 -0
- package/apps/web/dist/assets/SetupPage-DHESCsTb.js +1 -0
- package/apps/web/dist/assets/SharePage-DdJ-qD-B.js +1 -0
- package/apps/web/dist/assets/ThemeSwitch-BkodFy16.js +1 -0
- package/apps/web/dist/assets/arrow-right-pf8p4FIz.js +1 -0
- package/apps/web/dist/assets/changelog-cmQb-lZW.js +1 -0
- package/apps/web/dist/assets/{circle-alert-B0rwkpC7.js → circle-alert-Gn4D6etf.js} +1 -1
- package/apps/web/dist/assets/{copy-DgbMaHoj.js → copy-C3D7PBYL.js} +1 -1
- package/apps/web/dist/assets/{definition-FVgbAXOo.js → definition-AlI4g-wR.js} +2 -2
- package/apps/web/dist/assets/{external-link-pP6YfR9-.js → external-link-M3mEgZA-.js} +1 -1
- package/apps/web/dist/assets/globe-BnaeE83w.js +1 -0
- package/apps/web/dist/assets/{image-D2X6TWdq.js → image-BuasG4Jr.js} +1 -1
- package/apps/web/dist/assets/index-BdrX1tJ4.js +78 -0
- package/apps/web/dist/assets/index-D6vcOCCh.css +1 -0
- package/apps/web/dist/assets/{lock-BG4mi_lJ.js → lock-CrB_z7n3.js} +1 -1
- package/apps/web/dist/assets/{meta-BD9yulXs.js → meta-CT4LmQ7g.js} +1 -1
- package/apps/web/dist/assets/mouse-pointer-click-BurvPVO8.js +1 -0
- package/apps/web/dist/assets/{pen-line-D54vxrGl.js → pen-line-BA6l84zC.js} +1 -1
- package/apps/web/dist/assets/{refresh-cw-DvTgdpdf.js → refresh-cw-DEKCEuIO.js} +1 -1
- package/apps/web/dist/assets/{session-CT1AZIlE.js → session-DCcgTTmG.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-DJATAPGg.js → settings-menu-C9fE9M0f.js} +1 -1
- package/apps/web/dist/assets/star-BwhVXiJM.js +1 -0
- package/apps/web/dist/assets/{trash-DAcf34LR.js → trash-WwlTeE_V.js} +1 -1
- package/apps/web/dist/assets/{type-BU0mWqf3.js → type-kpWj7Zf1.js} +1 -1
- package/apps/web/dist/assets/ui-Wxaw_APn.js +9 -0
- package/apps/web/dist/assets/{video-C6qoFAAs.js → video-U-idAC66.js} +1 -1
- package/apps/web/dist/assets/volume-2-BwidpioC.js +1 -0
- package/apps/web/dist/assets/{wand-sparkles-Bw4tu2An.js → wand-sparkles-DaINku4r.js} +1 -1
- package/apps/web/dist/embed.js +119 -4
- package/apps/web/dist/index.html +12 -11
- package/apps/web/dist/mcp/flow.html +45 -45
- package/modules/calls/dist/client.css +3 -0
- package/modules/calls/dist/client.js +1 -0
- package/modules/calls/engenty.plugin.json +8 -0
- package/modules/calls/migrations/0001_init.sql +26 -0
- package/modules/calls/package.json +25 -0
- package/modules/calls/src/openai.ts +155 -0
- package/modules/calls/src/plugin.ts +407 -0
- package/modules/calls/src/rules.ts +226 -0
- package/modules/calls/src/schema.ts +39 -0
- package/modules/calls/src/session.ts +353 -0
- package/modules/calls/src/store.ts +124 -0
- package/modules/calls/src/twilio.ts +90 -0
- package/modules/calls/tsconfig.json +10 -0
- package/modules/calls/ui/Settings.tsx +137 -0
- package/modules/calls/ui/app.ts +50 -0
- package/modules/calls/ui/messages.ts +81 -0
- package/modules/calls/ui/parts.tsx +36 -0
- package/modules/calls/ui/plugin.tsx +15 -0
- package/modules/sms/dist/client.css +3 -0
- package/modules/sms/dist/client.js +1 -0
- package/modules/sms/engenty.plugin.json +8 -0
- package/modules/sms/migrations/0001_init.sql +26 -0
- package/modules/sms/package.json +25 -0
- package/modules/sms/src/plugin.ts +324 -0
- package/modules/sms/src/schema.ts +26 -0
- package/modules/sms/src/store.ts +140 -0
- package/modules/sms/src/surface.ts +70 -0
- package/modules/sms/src/twilio.ts +130 -0
- package/modules/sms/tsconfig.json +10 -0
- package/modules/sms/ui/Settings.tsx +113 -0
- package/modules/sms/ui/Share.tsx +78 -0
- package/modules/sms/ui/app.ts +51 -0
- package/modules/sms/ui/messages.ts +72 -0
- package/modules/sms/ui/parts.tsx +36 -0
- package/modules/sms/ui/plugin.tsx +20 -0
- package/modules/whatsapp/dist/client.css +3 -0
- package/modules/whatsapp/dist/client.js +1 -0
- package/modules/whatsapp/engenty.plugin.json +8 -0
- package/modules/whatsapp/migrations/0001_init.sql +30 -0
- package/modules/whatsapp/package.json +25 -0
- package/modules/whatsapp/src/graph.ts +271 -0
- package/modules/whatsapp/src/inbound.ts +143 -0
- package/modules/whatsapp/src/plugin.ts +369 -0
- package/modules/whatsapp/src/schema.ts +32 -0
- package/modules/whatsapp/src/store.ts +156 -0
- package/modules/whatsapp/src/surface.ts +127 -0
- package/modules/whatsapp/tsconfig.json +10 -0
- package/modules/whatsapp/ui/Settings.tsx +141 -0
- package/modules/whatsapp/ui/Share.tsx +78 -0
- package/modules/whatsapp/ui/app.ts +54 -0
- package/modules/whatsapp/ui/messages.ts +82 -0
- package/modules/whatsapp/ui/parts.tsx +36 -0
- package/modules/whatsapp/ui/plugin.tsx +20 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +259 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +17 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.d.ts +174 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.js +816 -0
- package/node_modules/@engenty-wizards/plugin-sdk/package.json +2 -1
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +8 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.js +21 -0
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +61 -3
- package/node_modules/@engenty-wizards/shared/dist/run.js +16 -0
- package/node_modules/@engenty-wizards/shared/dist/runners.d.ts +81 -0
- package/node_modules/@engenty-wizards/shared/dist/runners.js +146 -0
- package/package.json +1 -1
- package/apps/web/dist/assets/ChangelogDialog-BxRBTR8P.js +0 -1
- package/apps/web/dist/assets/EditorPage-BKAFzzWk.js +0 -3
- package/apps/web/dist/assets/HomePage-BZuwrr-b.js +0 -1
- package/apps/web/dist/assets/ImportWizard-JGMemER4.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-BwHAsJwj.js +0 -2
- package/apps/web/dist/assets/ProjectPage--ijr1jPE.js +0 -2
- package/apps/web/dist/assets/PublicRunner-D9Oe-_vs.js +0 -1
- package/apps/web/dist/assets/RunDrawer-BfociUm2.js +0 -4
- package/apps/web/dist/assets/RunnerView-D2b84UTY.js +0 -2
- package/apps/web/dist/assets/SettingsPage-9rk9IRdr.js +0 -1
- package/apps/web/dist/assets/SetupPage-BUJh_v9q.js +0 -1
- package/apps/web/dist/assets/SharePage-sNJ_s1RE.js +0 -1
- package/apps/web/dist/assets/ThemeSwitch-NDTEeh0R.js +0 -1
- package/apps/web/dist/assets/arrow-right-C1xLSnNa.js +0 -1
- package/apps/web/dist/assets/changelog-BSVi9hHS.js +0 -1
- package/apps/web/dist/assets/index-CBjgitjd.js +0 -78
- package/apps/web/dist/assets/index-gTcC8eX6.css +0 -1
- package/apps/web/dist/assets/star-CaOg5c-D.js +0 -1
- package/apps/web/dist/assets/ui-Bxf6zX5k.js +0 -9
- package/apps/web/dist/assets/volume-2-Dw4p9Ln4.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{R as r,lt as i}from"./definition-FVgbAXOo.js";import{c as a,l as o,m as s,s as c}from"./session-CT1AZIlE.js";import{$ as l,F as u,G as d,H as f,I as p,Q as m,U as h,Y as g,a as _,c as v,d as ee,et as te,f as y,g as b,h as ne,i as x,j as S,k as C,m as re,n as w,o as T,p as E,r as D,s as O,t as k,tt as ie,x as A}from"./ui-Bxf6zX5k.js";import{t as ae}from"./type-BU0mWqf3.js";import{a as oe,i as se,r as j,t as ce}from"./RunnerView-D2b84UTY.js";import{S as M,_ as N,b as P,f as F,g as I,h as L,m as le,p as R,r as z,v as B,w as ue,x as V,y as H}from"./HomePage-BZuwrr-b.js";import{_ as U,a as de,c as fe,d as pe,f as me,g as he,h as ge,i as _e,l as ve,m as ye,n as be,o as xe,p as Se,r as Ce,s as we,t as W,u as Te,v as G,y as K}from"./RunDrawer-BfociUm2.js";import{n as Ee,r as q}from"./ImportWizard-JGMemER4.js";import{t as J}from"./external-link-pP6YfR9-.js";import{r as Y,t as De}from"./wand-sparkles-Bw4tu2An.js";import{n as Oe,t as X}from"./trash-DAcf34LR.js";import{n as ke,t as Ae}from"./star-CaOg5c-D.js";import{t as je}from"./refresh-cw-DvTgdpdf.js";import{N as Me,P as Ne,a as Pe,c as Fe,i as Ie,m as Le,o as Re,r as ze,s as Be,t as Ve}from"./index-CBjgitjd.js";import{a as Z,c as He,f as Ue,i as We,m as Ge,n as Ke,o as qe,p as Je,r as Ye,s as Xe,t as Ze,u as Qe}from"./settings-menu-DJATAPGg.js";var $e={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`]};$e.node;var et=d($e),tt={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`}]]};tt.node;var nt=d(tt),rt={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`}]]};rt.node;var it=d(rt),at={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`]};at.node;var ot=d(at),Q=e(t(),1),$=e(n(),1),st={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function ct({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:S(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 lt(e,t){confirm(S(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function ut({projectId:e,file:t,small:n}){let r=B(e,t.id);return t.mime.startsWith(`image/`)?(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:b(`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)(nt,{className:n?`size-5`:`size-7`}):(0,$.jsx)(oe,{className:n?`size-5`:`size-7`})})}function dt({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)(D,{tone:`ember`,children:S(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?st:void 0,children:[o&&i.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${S(`project.preview`)}: ${i.name}`,onClick:()=>o(i),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(ut,{projectId:e,file:i})}):(0,$.jsx)(ut,{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)(T,{label:S(`project.preview`),onClick:()=>o(i),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Y,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,$.jsx)(T,{label:S(`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)(Ae,{className:`size-4`})}):null,r.readOnly?null:(0,$.jsx)(T,{label:S(`project.remove`),onClick:()=>lt(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(X,{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)(ct,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,$.jsxs)(R,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(y,{className:`size-5`}):(0,$.jsx)(u,{className:`size-5`}),a]}):null]})}function ft({projectId:e,data:t,readOnly:n}){let r=P(e,n);return(0,$.jsxs)(I,{title:S(`project.logos`),hint:S(`project.logosHint`),children:[(0,$.jsx)(dt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:S(`project.logoAdd`)}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var pt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),N(e.size)].filter(Boolean).join(` · `);function mt({projectId:e,file:t,actions:n,onClose:r}){let i=B(e,t.id);return(0,$.jsxs)(x,{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:pt(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":S(`project.openOriginal`),title:S(`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)(J,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:st,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)(ct,{file:t,actions:n})})]})}function ht({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":`${S(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(ut,{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:pt(t)})]}),(0,$.jsx)(ct,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,$.jsx)(T,{label:S(`project.preview`),onClick:r,children:(0,$.jsx)(Y,{className:`size-4`})}),n.readOnly?null:(0,$.jsx)(T,{label:S(`project.remove`),onClick:()=>lt(t,n),className:`hover:text-rose`,children:(0,$.jsx)(X,{className:`size-4`})})]})]})}function gt({projectId:e,data:t,readOnly:n}){let r=P(e,n),[i,a]=V(`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)(I,{title:S(`project.assets`),hint:S(`project.assetsHint`),children:[u.length?(0,$.jsx)(le,{layout:i,onToggle:a,children:(0,$.jsx)(L,{value:o,onChange:s,placeholder:S(`project.assetSearch`)})}):null,p.length?(0,$.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,$.jsx)(dt,{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)(ht,{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:S(`project.staysLocal`)}):(0,$.jsxs)(R,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,$.jsx)(y,{className:`size-4`}):(0,$.jsx)(Ee,{className:`size-4`}),S(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:S(`project.assetAdd`)})]}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,$.jsx)(mt,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function _t(e,t,n){return r({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>A.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function vt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var yt=e=>[vt(e),e.pages?S(`project.pages`,{n:e.pages}):null,N(e.size)].filter(Boolean).join(` · `),bt=2e5;function xt({projectId:e,fileId:t,readOnly:n,onGone:r}){let a=i(),o=M(e),s=me(e),c=P(e,n),l=o.data?.files.find(e=>e.id===t),u=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[d,f]=(0,Q.useState)(null);if(!l)return o.isLoading?(0,$.jsx)(y,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),h=B(e,l.id),g=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:b(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:l.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:yt(l)}),(0,$.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":S(`project.openOriginal`),title:S(`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)(J,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{label:S(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(je,{className:`size-4`})}),(0,$.jsx)(T,{label:S(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(S(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(X,{className:`size-4`})})]})]}),(0,$.jsx)(Te,{projectId:e,itemKey:`f:${l.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(ct,{file:l,actions:c})}),l.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,$.jsxs)(w,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?g(`original`,S(`project.original`)):null,g(`text`,S(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:h,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(St,{projectId:e,file:l})]})]})}function St({projectId:e,file:t}){let n=_t(e,t,bt);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(y,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(Le,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:S(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:S(`project.noText`)})}var Ct=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],wt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Tt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,Et=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Dt=/^(https?:\/\/|www\.)\S+$/i,Ot=/^\+?[\d\s()/.-]{7,20}$/,kt=/^(ja|nein|yes|no|true|false)$/i;function At(e){let t=e.trim();return t?t.includes(`
|
|
2
|
-
`)||t.length>140?`longtext`:kt.test(t)?`boolean`:Et.test(t)?`email`:Dt.test(t)?`url`:wt.test(t)?`date`:Tt.test(t)&&!/^(\+|0\d)/.test(t)?`number`:Ot.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function jt(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 Mt=[{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`}],Nt={facts:100,colors:12,files:{logo:8,asset:100,document:2e3},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},Pt=/^#[0-9a-fA-F]{6}$/;function Ft({onAdd:e,onClose:t}){let[n,r]=(0,Q.useState)(`#e0531b`),[i,a]=(0,Q.useState)(``),o=Pt.test(n);return(0,$.jsx)(x,{open:!0,onClose:t,title:S(`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)(v,{children:S(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,$.jsx)(O,{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)(v,{children:S(`project.colorUseLabel`)}),(0,$.jsx)(O,{autoFocus:!0,value:i,maxLength:120,placeholder:S(`project.colorName`),onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:S(`project.colorUse`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(k,{variant:`ghost`,onClick:t,children:S(`common.cancel`)}),(0,$.jsx)(k,{type:`submit`,disabled:!o,children:S(`project.add`)})]})]})})}function It({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=H(i.filter(e=>Pt.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)(I,{title:S(`project.colors`),hint:S(`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)(E,{value:Pt.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,$.jsx)(O,{value:e.name,placeholder:S(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(O,{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)(D,{tone:`ember`,children:S(`project.colorAccent`)})}):n?null:(0,$.jsx)(T,{label:S(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,$.jsx)(h,{className:`size-4`})}),n?null:(0,$.jsx)(T,{label:S(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,$.jsx)(X,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:S(`project.colorUse`)}):null,i.length<Nt.colors&&!n?(0,$.jsxs)(k,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,$.jsx)(u,{className:`size-4`}),` `,S(`project.colorAdd`)]}):null,o?(0,$.jsx)(Ft,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var Lt=e=>/^(ja|yes|true)$/i.test(e.trim()),Rt={text:ae,longtext:ot,number:G,date:K,url:Oe,email:se,phone:it,boolean:U};function zt({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=Rt[e??t],l=`${S(`project.factType`)}: ${S(`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:b(`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:b(`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)(De,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:S(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:S(`project.type.${t}`)}),(0,$.jsx)(f,{className:b(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ct.map(t=>{let n=Rt[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:S(`project.type.${t}`)}),(0,$.jsx)(f,{className:b(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Bt({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=H(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])},d=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},f=Mt.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(I,{title:S(`project.facts`),hint:S(`project.factsHint`),save:s,locked:n,action:a.length<Nt.facts&&!n?(0,$.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(u,{className:`size-4`}),` `,S(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=At(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)(O,{ref:d(`${e.id}:label`),value:e.label,placeholder:S(`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:jt(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)(re,{checked:Lt(e.value),label:e.label,onChange:t=>c(e.id,{value:S(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Lt(e.value)?S(`project.yes`):S(`project.no`)})]}):(0,$.jsx)(ne,{ref:d(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:S(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(zt,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(T,{label:S(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(X,{className:`size-4`})})]},e.id)})}),a.length<Nt.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(u,{className:`size-4`}),` `,S(`project.factAdd`)]}),f.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:C===`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)(u,{className:`size-3.5`}),` `,C===`en`?e.en:e.de]},e.key))]}):null]})}function Vt({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=H({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(I,{title:S(`project.base`),hint:S(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(v,{children:S(`project.title`)}),(0,$.jsx)(O,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:S(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(v,{children:S(`project.about`)}),(0,$.jsx)(ne,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:S(`project.aboutHint`)})]})]})})}function Ht({project:e,group:t,docked:n=!1,children:r}){let c=i(),l=M(e.id),[u,d]=(0,Q.useState)(0),f=async t=>{await A.patch(`/api/studio/projects/${e.id}`,t),await c.invalidateQueries({queryKey:[`projects`]})},p=s({mutationFn:()=>A.del(`/api/studio/projects/${e.id}`),onSuccess:()=>c.invalidateQueries({queryKey:[`projects`]})}),m=o(),h=a(),g=l.data??{files:[],embeddings:!0},_=`${e.id}:${u}`,v=e.readOnly;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-32`,children:[v?(0,$.jsx)(Je,{children:Ge(e)}):(0,$.jsx)(Fe,{projectId:e.id,part:t,docked:n,onChanged:()=>d(e=>e+1)},e.id),t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{id:`base`,children:(0,$.jsx)(Vt,{project:e,save:f},`base:${_}`)}),(0,$.jsx)(F,{id:`logos`,children:(0,$.jsx)(ft,{projectId:e.id,data:g,readOnly:v})}),(0,$.jsx)(F,{id:`colors`,children:(0,$.jsx)(It,{colors:e.brand.colors??[],save:e=>f({brand:{colors:e}}),readOnly:v},`colors:${_}`)}),(0,$.jsx)(F,{id:`assets`,children:(0,$.jsx)(gt,{projectId:e.id,data:g,readOnly:v})}),(0,$.jsx)(F,{id:`facts`,children:(0,$.jsx)(Bt,{facts:e.facts,save:e=>f({facts:e}),readOnly:v},`facts:${_}`)})]}):null,r,t===`info`&&m&&!v&&h?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{variant:`danger`,busy:p.isPending,onClick:()=>confirm(`${S(`settings.delete`)}?`)&&p.mutate(),children:S(`settings.delete`)}),p.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:p.error.message}):null]}):null]})}var Ut={q:``,mode:``,days:0};function Wt(e,t,n){let i=new URLSearchParams;t&&i.set(`wizard`,t),n.q.trim()&&i.set(`q`,n.q.trim()),n.mode&&i.set(`mode`,n.mode),n.days&&i.set(`days`,String(n.days));let a=i.toString();return r({queryKey:[`results`,e,a],queryFn:()=>A.get(`/api/studio/projects/${e}/results${a&&`?${a}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Gt({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)(q,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(O,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:S(`space.resultsSearch`),"aria-label":S(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(ee,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:S(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(ee,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:S(`space.resultsAnyTime`)},{value:`1`,label:S(`space.resultsDay`)},{value:`7`,label:S(`space.resultsDays`,{n:7})},{value:`30`,label:S(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Kt({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(C,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{title:t?o(t):S(`space.resultsAll`),hint:S(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Gt,{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))} · `,S(`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:S(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(p,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(D,{children:`Test`}):(0,$.jsxs)(D,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(w,{children:(0,$.jsx)(_,{children:n.q.trim()||n.mode||n.days?S(`space.resultsNone`):S(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(W,{header:(0,$.jsxs)($.Fragment,{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)(D,{children:`Test`}):(0,$.jsxs)(D,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(ce,{runId:i.id,compact:!0},i.id)}):null]})}function qt({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=s({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{label:S(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(j,{className:`size-4`})}),(0,$.jsx)(x,{open:n,onClose:()=>r(!1),title:S(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(O,{"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)(k,{variant:`ghost`,onClick:()=>r(!1),children:S(`common.cancel`)}),(0,$.jsx)(k,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:S(`settings.save`)})]})]})})]})}function Jt({project:e}){let t=i();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(z,{}),e.readOnly?null:(0,$.jsx)(qt,{project:e,save:async n=>{await A.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Yt(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=Me(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xt(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Zt({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Z,{icon:e.icon??ke,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(We,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Qt(){let{group:e}=te(),[t,n]=ie(),r=l(),i=m(),{hash:a}=i,{project:s,loading:u}=c(),d=o(),f=ze(),p=Qe(),[h,v]=(0,Q.useState)(null),[ee,y]=(0,Q.useState)(null),[ne,x]=(0,Q.useState)(null),C=Pe(e)?e:void 0,re=i.state?.parts===!0,w=Be().map(e=>({...e,to:`/space/${e.id}`})),T=w.find(e=>e.id===C),E=t.get(`show`),D=C?E?2:1:0,O=p?Math.min(D,1):C&&ne!==C&&!re?1:0,k=Ue(O),A=Ue(D),ae=(0,Q.useMemo)(()=>({slot:h,narrow:p,setDetail:y}),[h,p]),oe=s?s.brand.name?.trim()||s.name:S(`nav.project`),se=C&&C!==`results`?Re(C,f):[],j=C?Re(C,f).filter(e=>e.plugin):[],ce=Yt([...se,...C===`results`?j:[]].flatMap(e=>e.sections.map(e=>e.id))),M=C===`results`&&E&&E!==`all`?E:null,[N,P]=(0,Q.useState)(Ut),L=Wt(C===`results`?s?.id:void 0,M,N),le=L.data?.wizards.find(e=>e.id===M)?.title,R=C===`data`&&E&&E!==`all`||C===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,z=R?.startsWith(`s:`)?f.spaceSections.find(e=>e.id===R.slice(2)):void 0,B=C===`knowledge`&&R&&/^[ptf]:/.test(R)?R:null,V=xe(C===`data`?s?.id:void 0),H=me(C===`knowledge`?s?.id:void 0),U=he(R?.startsWith(`v:`)?R.slice(2):``),W=H.data?.categories.find(e=>e.id===(R?.startsWith(`c:`)?R.slice(2):U.data?.category.id)),Te=C===`knowledge`?z?z.label():R?.startsWith(`v:`)?U.data&&`${U.data.category.name}: ${U.data.value}`:R?.startsWith(`c:`)?W?.name:H.data?.items.find(e=>e.key===R)?.title:V.data?de(V.data).flatMap(e=>e.items).find(e=>e.key===R)?.title:void 0;Ne([{label:S(`nav.project`),to:`/space`},...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(ee??le??Te)?[{label:ee??le??Te}]:[]]);let G=C===`results`||C===`data`||R?a.slice(1):E||a.slice(1),K=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${C}#${G}`;G&&K.current!==e&&document.getElementById(G)&&(K.current=e,requestAnimationFrame(()=>Xt(G,!1)))},[C,G,s?.id,f.spaceSections]),!C){let t=a.slice(1),n=t?Ie(t,f):null;if(n===`knowledge`&&f.spaceSections.some(e=>e.id===t))return(0,$.jsx)(g,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(g,{to:p?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&f.status!==`ready`)return null;if(e!==void 0||!p)return(0,$.jsx)(g,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(C===`knowledge`&&!E&&f.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(g,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let Ee=e=>{if(p){r({search:`?show=${e}`});return}K.current=`${C}#${e}`,Xt(e,!0),r({search:``,hash:e},{replace:!0})},q=e=>p?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),J=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)(F,{id:e.id,children:(0,$.jsx)(I,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Ve,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),Y=p?void 0:ce;return(0,$.jsx)(qe.Provider,{value:ae,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:b(`min-w-0 md:sticky md:top-6 md:self-start`,p&&D===2&&`hidden`,p&&A===`back`&&He(`back`)),children:[(0,$.jsx)(Ke,{title:oe,open:O===1?T??null:null,onBack:()=>p?r(`/space`):x(C??null)}),(0,$.jsx)(`div`,{className:b(He(k)),children:O===0?(0,$.jsx)(Ye,{entries:w,current:p?void 0:T,onPick:()=>x(null)}):(0,$.jsx)(`div`,{ref:v})},O)]}),C?(0,$.jsxs)(`div`,{className:b(`min-w-0`,p&&D<2&&`hidden`,p&&A===`deeper`&&He(`deeper`)),children:[p?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Ze,{label:T?.label??oe,onBack:()=>r(`/space/${C}`)})}):null,d&&s?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(Jt,{project:s})}):null,C===`results`?(0,$.jsxs)(Xe,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Z,{icon:et,label:S(`space.resultsAll`),selected:!p&&!M,onPick:()=>q(`all`)}),L.data?.wizards.filter(e=>e.results||e.id===M).map(e=>(0,$.jsx)(Z,{icon:De,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!p&&e.id===M,onPick:()=>q(e.id)},e.id))]}),(0,$.jsx)(Zt,{groups:j,current:Y,onPick:Ee})]}):C===`data`?(0,$.jsxs)(Xe,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:ue,label:S(`data.all`),selected:!p&&!R,onPick:()=>q(`all`)})}),V.data?de(V.data).map(e=>(0,$.jsx)(We,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Z,{icon:Ce[e.kind],label:e.title,selected:!p&&e.key===R,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,$.jsx)(Zt,{groups:j,current:Y,onPick:Ee})]}):C===`knowledge`?(0,$.jsxs)(Xe,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:ue,label:S(`know.all`),selected:!(p||R),onPick:()=>q(`all`)})}),H.data?.categories.length?(0,$.jsx)(We,{label:S(`know.categories`),children:H.data.categories.map(e=>(0,$.jsx)(Z,{icon:Se[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!p&&(R===`c:${e.id}`||U.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Zt,{groups:j,current:p?void 0:z?.id,onPick:e=>q(`s:${e}`)})]}):(0,$.jsx)(Xe,{children:(0,$.jsx)(Zt,{groups:se,current:Y,onPick:Ee})}),s&&(C===`info`||C===`knowledge`)?(0,$.jsxs)(Ht,{project:s,group:C,docked:C===`knowledge`&&!!R&&!z,children:[C===`knowledge`?B?B.startsWith(`p:`)?(0,$.jsx)(we,{pageId:B.slice(2),onGone:()=>q(`all`),onOpen:q},B):B.startsWith(`t:`)?(0,$.jsx)(be,{tableId:B.slice(2),onGone:()=>q(`all`)},B):(0,$.jsx)(xt,{projectId:s.id,fileId:B.slice(2),readOnly:s.readOnly,onGone:()=>q(`all`)},B):H.data?z?(0,$.jsx)(I,{title:z.label(),hint:z.hint?.(),plain:!0,children:(0,$.jsx)(Ve,{of:z,children:(0,$.jsx)(z.component,{})})},R):R?.startsWith(`c:`)?W?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(ye,{projectId:s.id,category:W,readOnly:s.readOnly,onOpen:q,onGone:()=>q(`all`)}),W.type===`choice`?null:(0,$.jsx)(fe,{projectId:s.id,category:W,categories:H.data.categories,onOpen:q})]},R):null:R?.startsWith(`v:`)?U.data?(0,$.jsx)(ge,{value:U.data,readOnly:s.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[U.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:U.data.items.map(e=>(0,$.jsx)(ve,{item:e,categories:H.data.categories.filter(e=>e.id!==U.data?.category.id),onOpen:q},e.key))}):null,U.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:S(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},R):null:(0,$.jsx)(F,{id:`documents`,children:(0,$.jsx)(pe,{projectId:s.id,data:H.data,readOnly:s.readOnly,onOpen:q})}):null:null,C===`info`?J(j):null]},s.id):null,s&&C===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:R?.startsWith(`t:`)?(0,$.jsx)(be,{tableId:R.slice(2),onGone:()=>q(`all`)},R):R?.startsWith(`p:`)?(0,$.jsx)(we,{pageId:R.slice(2),onGone:()=>q(`all`)},R):(0,$.jsxs)($.Fragment,{children:[V.data?(0,$.jsx)(_e,{projectId:s.id,data:V.data,readOnly:s.readOnly,onOpen:q}):null,J(j)]})}):null,s&&C===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[L.data?(0,$.jsx)(Kt,{data:L.data,wizardId:M,filter:N,onFilter:P}):null,L.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:L.error.message}):null,J(j)]}):null,s||u?null:(0,$.jsx)(_,{children:S(`settings.noProject`)})]}):null]})})})}export{Qt as ProjectPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{D as r,M as i,O as a,R as o,T as s}from"./definition-FVgbAXOo.js";import{$ as c,D as l,G as u,S as d,et as f,f as p,g as m,j as h,t as g,w as _,x as v}from"./ui-Bxf6zX5k.js";import{t as y}from"./RunnerView-D2b84UTY.js";import{t as b}from"./arrow-right-C1xLSnNa.js";import{A as x,E as S,k as C}from"./index-CBjgitjd.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=u(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=u(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=u(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=l(`/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=h(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`}),h(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:l(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)(a,{})}):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)||S||M?null:(0,F.jsxs)(`a`,{href:C(`${window.location.origin}${_}/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`}),` `,h(`install.app`)]})}var W=e=>`wz.run.${e}`,G=S&&new URLSearchParams(window.location.search).get(`start`)===`1`,K=M===`inline`?`min-h-80`:`min-h-dvh`;function q({wizard:e}){let t=c(),[n,i]=(0,A.useState)(!1),[a,o]=(0,A.useState)(null),[s,l]=(0,A.useState)(null),u=(()=>{try{return localStorage.getItem(W(e.token))}catch{return null}})(),d=async()=>{i(!0),o(null);try{let{runId:n}=await v.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:s??void 0,embedded:M!==null});try{localStorage.setItem(W(e.token),n)}catch{}t(`/w/${e.token}/${n}`,{replace:G})}catch(e){o(e.message),i(!1)}},f=G&&e.available&&!e.turnstileSiteKey,m=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{f&&!m.current&&(m.current=!0,d())},[f]),f&&!a?(0,F.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,F.jsx)(p,{})}):(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)(r,{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)(g,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!s,onClick:d,children:[h(`run.start`),` `,(0,F.jsx)(b,{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:h(`run.resume`)}):null,M||S?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??h(`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}=f(),n=c(),a=o({queryKey:[`public`,e],queryFn:()=>v.get(`/api/public/wizards/${e}`),retry:(e,t)=>d(t)&&e<3});if(I(a.data?.brand.accent),i(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&&x(`run`,{token:e,runId:t})},[e,t]),a.isLoading)return(0,F.jsx)(`div`,{className:m(`flex items-center justify-center text-ink-4`,K),children:(0,F.jsx)(p,{})});if(!a.data){let e=d(a.error);return(0,F.jsxs)(`div`,{className:m(`flex flex-col items-center justify-center gap-4 px-6 text-center`,K),children:[(0,F.jsx)(r,{kind:`pebble`,size:80}),(0,F.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:h(e?`common.offline`:`run.notFound`)}),e?(0,F.jsx)(g,{variant:`secondary`,onClick:()=>void a.refetch(),children:h(`common.retry`)}):null]})}return(0,F.jsxs)(`div`,{className:m(`flex flex-col`,K),children:[M===`inline`||S?null:(0,F.jsx)(V,{brand:a.data.brand,toggle:!M}),(0,F.jsx)(`div`,{className:`flex-1`,children:t?(0,F.jsx)(y,{runId:t,onRestart:()=>n(`/w/${e}`)}):(0,F.jsx)(q,{wizard:a.data})}),S?(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:`${_}/`,target:M?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:h(`run.madeWith`).replace(`engenty wizards`,s.name)})})]})}export{V as BrandHeader,J as PublicRunner,I as useBrandAccent};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{R as r,lt as i}from"./definition-FVgbAXOo.js";import{m as a}from"./session-CT1AZIlE.js";import{F as o,G as s,H as c,I as l,N as u,V as d,a as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,j as b,k as x,m as S,n as C,o as w,r as T,s as E,t as D,u as O,x as k,z as A}from"./ui-Bxf6zX5k.js";import{t as j}from"./type-BU0mWqf3.js";import{b as M,g as N,h as P,p as ee,v as F,y as te}from"./HomePage-BZuwrr-b.js";import{n as ne}from"./ImportWizard-JGMemER4.js";import{n as re}from"./wand-sparkles-Bw4tu2An.js";import{t as I}from"./trash-DAcf34LR.js";import{t as ie}from"./refresh-cw-DvTgdpdf.js";import{R as ae,m as oe,z as L}from"./index-CBjgitjd.js";var se={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`}]]};se.node;var ce=s(se),le={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};le.node;var ue=s(le),R={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`}]]};R.node;var z=s(R),B={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};B.node;var de=s(B),V={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};V.node;var fe=s(V),H={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};H.node;var pe=s(H),U={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`}]]};U.node;var me=s(U),W=e(t(),1),G=e(n(),1),K={choice:pe,date:ce,number:z,text:j,boolean:me},q=e=>[`knowledge`,e];function he(e){return e===1?b(`know.item`):b(`know.items`,{n:e})}function J(e,t){if(e.type===`boolean`||typeof t==`boolean`)return b(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(x,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(x)}${e.unit?` ${e.unit}`:``}`:String(t)}function ge(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>J(e,t)).join(`, `)]:[]}).join(` · `)}function _e({trigger:e,open:t,onOpen:n,children:r}){let i=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,G.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,G.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function ve({category:e,current:t,onSave:n}){let[r,i]=(0,W.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,G.jsx)(O,{multi:!0,value:a,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!a.includes(e)).slice(0,1))}):null,(0,G.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,G.jsx)(E,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:b(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,G.jsx)(w,{label:b(`know.addValue`),type:`submit`,children:(0,G.jsx)(o,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,G.jsx)(O,{value:t[0]===!0?b(`know.yes`):t[0]===!1?b(`know.no`):``,options:[b(`know.yes`),b(`know.no`)],onChange:e=>n([e===b(`know.yes`)])}):(0,G.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,G.jsx)(E,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,G.jsx)(D,{type:`submit`,size:`sm`,children:`OK`})]})}function ye({projectId:e,itemKey:t,has:n,categories:r,readOnly:s}){let c=i(),[l,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(n);(0,W.useEffect)(()=>p(n),[n]);let m=a({mutationFn:({categoryId:n,next:r})=>k.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>c.invalidateQueries({queryKey:q(e)})}),h=r.filter(e=>!(e.proposed||e.tableId)),g=(e,t)=>{p(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),m.mutate({categoryId:e.id,next:t}),d(null)},_=h.filter(e=>f.some(t=>t.categoryId===e.id)),v=h.filter(e=>!f.some(t=>t.categoryId===e.id));return h.length?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[_.map(e=>{let t=f.find(t=>t.categoryId===e.id),n=K[e.type],r=(0,G.jsxs)(`button`,{type:`button`,disabled:s,title:`${e.name} · ${b(`know.by.${t.by}`)}`,onClick:()=>d(l===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,G.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,G.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,G.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>J(e,t)).join(`, `)})]},e.id);return s?(0,G.jsx)(`span`,{children:r},e.id):(0,G.jsxs)(_e,{trigger:r,open:l===e.id,onOpen:t=>d(t?e.id:null),children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,G.jsx)(w,{label:b(`know.remove`),onClick:()=>g(e,[]),className:`size-7`,children:(0,G.jsx)(u,{className:`size-3.5`})})]}),(0,G.jsx)(ve,{category:e,current:t.values,onSave:t=>g(e,t)})]},e.id)}),s||!v.length?null:(0,G.jsx)(_e,{open:l===`+`,onOpen:e=>d(e?`+`:null),trigger:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(l===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,G.jsx)(o,{className:`size-3.5`}),` `,b(`know.category`)]}),children:(0,G.jsx)(be,{categories:v,onSave:g})})]}):null}function be({categories:e,onSave:t}){let[n,r]=(0,W.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsx)(h,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,G.jsx)(ve,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function xe({projectId:e,open:t,onClose:n,onMade:r}){let o=i(),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(`choice`),[d,f]=(0,W.useState)(``),[p,g]=(0,W.useState)(!1),[_,x]=(0,W.useState)(!1),[C,w]=(0,W.useState)(``),[T,O]=(0,W.useState)(``),A=a({mutationFn:()=>k.post(`/api/studio/projects/${e}/categories`,{name:s.trim(),type:l,unit:l===`number`&&d.trim()||null,multiple:l===`choice`&&p,ordered:l===`choice`&&_,hint:T.trim()||null,values:l===`choice`?C.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await o.invalidateQueries({queryKey:q(e)}),c(``),w(``),O(``),r(t)}});return(0,G.jsx)(y,{open:t,onClose:n,title:b(`know.newCategory`),children:(0,G.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&A.mutate()},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`know.name`)}),(0,G.jsx)(E,{"data-autofocus":!0,value:s,maxLength:80,onChange:e=>c(e.target.value)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`know.type`)}),(0,G.jsx)(h,{value:l,onChange:e=>u(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:b(`know.type.${e}`)}))})]}),l===`number`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{hint:b(`know.unitHint`),children:b(`know.unit`)}),(0,G.jsx)(E,{value:d,maxLength:20,onChange:e=>f(e.target.value)})]}):null,l===`choice`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{hint:b(`know.valuesHint`),children:b(`know.values`)}),(0,G.jsx)(v,{minRows:3,value:C,onChange:e=>w(e.target.value)})]}),(0,G.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[b(`know.multiple`),(0,G.jsx)(S,{checked:p,onChange:g})]}),(0,G.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[b(`know.ordered`),(0,G.jsx)(S,{checked:_,onChange:x})]})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{hint:b(`know.hintFieldHint`),children:b(`know.hintField`)}),(0,G.jsx)(E,{value:T,maxLength:120,onChange:e=>O(e.target.value)})]}),A.error?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:A.error.message}):null,(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(D,{variant:`ghost`,onClick:n,children:b(`common.cancel`)}),(0,G.jsx)(D,{type:`submit`,busy:A.isPending,disabled:!s.trim(),children:b(`know.create`)})]})]})})}function Se({projectId:e,category:t,readOnly:n,onOpen:r,onGone:s}){let c=i(),l=()=>c.invalidateQueries({queryKey:q(e)}),[u,d]=(0,W.useState)(``),p=a({mutationFn:e=>e(),onSuccess:l}),m=K[t.type],h=new Map(t.values.map(e=>[e.id,e]));return(0,G.jsxs)(N,{title:t.name,hint:[b(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,G.jsx)(w,{label:b(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(b(`know.confirmCategory`,{name:t.name}))&&p.mutate(async()=>{await k.del(`/api/studio/categories/${t.id}`),s()}),children:(0,G.jsx)(I,{className:`size-4`})}),children:[t.proposed&&!n?(0,G.jsxs)(C,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,G.jsx)(T,{tone:`ember`,children:b(`know.proposed`)}),(0,G.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:b(`know.proposedHint`)}),(0,G.jsx)(D,{size:`sm`,onClick:()=>p.mutate(()=>k.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:b(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=h.get(e),i=h.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,G.jsxs)(C,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,G.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:b(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,G.jsx)(D,{size:`sm`,variant:`secondary`,busy:p.isPending,onClick:()=>p.mutate(()=>k.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:b(`know.merge`)})]},`${e}:${t}`)}),(0,G.jsxs)(C,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,G.jsx)(m,{className:`size-4 shrink-0 text-ink-3`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,G.jsx)(T,{children:b(`know.summary`)}):null,(0,G.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:he(e.count)})]},e.id)):(0,G.jsx)(f,{children:b(`know.empty`)}):(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,G.jsx)(m,{className:`size-4 shrink-0 text-ink-3`}),(0,G.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?b(`know.range`,{min:J(t,t.range.min),max:J(t,t.range.max)}):b(`know.unset`)}),(0,G.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:he(t.count)})]}),t.type===`choice`&&!n?(0,G.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=u.trim();n&&(d(``),p.mutate(()=>k.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,G.jsx)(E,{value:u,placeholder:b(`know.addValue`),onChange:e=>d(e.target.value),className:`h-9`}),(0,G.jsx)(w,{label:b(`know.addValue`),type:`submit`,children:(0,G.jsx)(o,{className:`size-4`})})]}):null]}),p.error?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null]})}function Ce(e){return r({queryKey:[`knowledge-value`,e],queryFn:()=>k.get(`/api/studio/values/${e}`),enabled:!!e})}function we({value:e,readOnly:t,children:n}){let r=i(),o=a({mutationFn:()=>k.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>r.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,G.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,G.jsx)(N,{title:b(`know.summary`),hint:b(`know.summaryHint`),plain:!0,action:t?null:(0,G.jsxs)(D,{variant:`secondary`,size:`sm`,busy:o.isPending,onClick:()=>o.mutate(),children:[e.summary?(0,G.jsx)(ie,{className:`size-4`}):null,e.summary?b(`know.summaryAgain`):b(`know.summaryWrite`)]}),children:(0,G.jsxs)(C,{className:`p-4 sm:p-5`,children:[o.isPending?(0,G.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,G.jsx)(g,{})}):e.summary?(0,G.jsx)(oe,{text:e.summary,className:`text-[0.875rem]`}):(0,G.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:b(`know.summaryEmpty`)}),o.error?(0,G.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null]})}),(0,G.jsx)(N,{title:b(`know.toc`),plain:!0,children:n})]})}function Te(e){return r({queryKey:[`knowledge`,e],queryFn:()=>k.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function Ee(e){return e.kind===`table`?e.format===`faq`?de:re:e.kind===`file`?l:e.children?ue:L}function Y({item:e,categories:t,onOpen:n}){let r=Ee(e),i=[ge(t,e.categories),e.children?e.children===1?b(`know.oneSub`):b(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?b(`know.row`):b(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,G.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,G.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,G.jsx)(g,{className:`size-3`}),` `,b(`know.reading`)]}):e.review?(0,G.jsx)(T,{tone:`warn`,title:e.review,children:b(`know.review`)}):null]})}function X({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let u=Te(e),d=[r?b(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[u.data?(0,G.jsx)(ye,{projectId:e,itemKey:t,has:n,categories:u.data.categories,readOnly:s}):null,d.length||o||a?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[d.map(e=>(0,G.jsx)(`span`,{children:e},e)),o?(0,G.jsxs)(`a`,{href:F(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,G.jsx)(l,{className:`size-3.5`}),` `,b(`know.original`),`: `,o.name]}):null,a?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(T,{tone:`warn`,children:b(`know.review`)}),(0,G.jsx)(`span`,{children:a}),s?null:(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:b(`know.reviewed`)})]}):null]}):null]})}function De(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function Oe({projectId:e,category:t,categories:n,onOpen:i}){let a=r({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>k.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,G.jsx)(g,{className:`mx-auto size-4 text-ink-3`}):null;let o=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],s=[...a.data.items].sort((e,t)=>{let n=o(e),r=o(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),x)}),c=t.type===`number`?De(s.map(o).filter(e=>typeof e==`number`)):[],l=new Intl.NumberFormat(x,{notation:`compact`,maximumFractionDigits:1}),u=t.unit?` ${t.unit}`:``,d=new Map;for(let e of s){let n=o(e),r=typeof n==`number`?c.find(e=>n>=e.lo&&n<e.hi):void 0,i=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(x,{month:`long`,year:`numeric`}):r?b(`know.range`,{min:`${l.format(r.lo)}${u}`,max:`${l.format(r.hi)}${u}`}):J(t,n);d.set(i,[...d.get(i)??[],e])}return(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...d].map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,G.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,G.jsx)(C,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,G.jsx)(Y,{item:e,categories:n,onOpen:i},e.key))})]},e)),a.data.rows.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:b(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function ke(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function Ae(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return b(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${b(`know.contains`)} ${t.contains}`:[n===void 0?``:`${b(`know.minimum`)} ${J(e,n)}`,r===void 0?``:`${b(`know.maximum`)} ${J(e,r)}`].filter(Boolean).join(` `)}return String(t)}function je({category:e,value:t,onChange:n}){let[r,i]=(0,W.useState)(!1),a=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!r)return;let e=e=>!a.current?.contains(e.target)&&i(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let o=K[e.type],s=typeof t==`object`&&t&&!Array.isArray(t)?t:{},c=(t,r)=>{let i={...s,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,G.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:_(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,G.jsx)(o,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,G.jsxs)(`span`,{className:`font-medium`,children:[`: `,Ae(e,t)]}),(0,G.jsx)(d,{className:`size-3.5 text-ink-3`})]}),r?(0,G.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,G.jsx)(O,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,G.jsx)(O,{value:t===!0?b(`know.yes`):t===!1?b(`know.no`):``,options:[b(`know.yes`),b(`know.no`)],onChange:e=>n(e===b(`know.yes`))}):e.type===`text`?(0,G.jsx)(E,{"data-autofocus":!0,value:s.contains??``,placeholder:b(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(n===0?`know.minimum`:`know.maximum`)}),(0,G.jsx)(E,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(s[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>c(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,G.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),i(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:b(`know.clear`)})]}):null]})}function Me({found:e,onOpen:t}){return e.hits.length?(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?b(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):b(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,G.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,G.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,G.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,G.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(x,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,G.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:b(`know.searchNone`)})}function Ne({kind:e,projectId:t,onClose:n,onMade:r}){let o=i(),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(!1),d=a({mutationFn:()=>k.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:s.trim(),...e===`table`&&l?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:[`knowledge`,t]}),r(`${e===`table`?`t`:`p`}:${n}`),c(``),u(!1)}});return(0,G.jsx)(y,{open:e!==null,onClose:n,title:b(e===`table`?`know.newTable`:`know.newPage`),children:(0,G.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&d.mutate()},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.title`)}),(0,G.jsx)(E,{"data-autofocus":!0,value:s,maxLength:120,onChange:e=>c(e.target.value)})]}),e===`table`?(0,G.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[b(`know.asFaq`),(0,G.jsx)(S,{checked:l,onChange:u})]}):null,d.error?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(D,{variant:`ghost`,onClick:n,children:b(`common.cancel`)}),(0,G.jsx)(D,{type:`submit`,busy:d.isPending,disabled:!s.trim(),children:b(`know.create`)})]})]})})}function Pe({projectId:e,data:t,readOnly:n,onOpen:r}){let s=i(),c=M(e,n),[l,u]=(0,W.useState)({}),[d,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(null),[_,v]=(0,W.useState)(!1),[y,x]=(0,W.useState)(null),S=t.categories.filter(e=>!e.proposed&&e.count>0),w=t.categories.filter(e=>e.proposed),E=t.items.filter(e=>Object.entries(l).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?ke(i,a.values,r):!1})),O=async()=>{if(!d.trim()){h(null);return}v(!0);try{h(await k.post(`/api/studio/projects/${e}/search`,{query:d,...Object.keys(l).length?{where:l}:{}}))}catch{h({hits:[],candidates:0,checked:!1,filtered:null})}finally{v(!1)}},A=a({mutationFn:({id:e,keep:t})=>t?k.patch(`/api/studio/categories/${e}`,{proposed:!1}):k.del(`/api/studio/categories/${e}`),onSuccess:()=>s.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,G.jsxs)(N,{title:b(`know.title`),hint:b(`know.hint`),plain:!0,action:n?null:(0,G.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,G.jsxs)(D,{variant:`secondary`,size:`sm`,onClick:()=>x(`page`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`know.page`)]}),(0,G.jsxs)(D,{variant:`secondary`,size:`sm`,onClick:()=>x(`table`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`know.table`)]}),(0,G.jsxs)(D,{variant:`secondary`,size:`sm`,onClick:()=>x(`category`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`know.category`)]})]}),children:[w.length&&!n?(0,G.jsx)(C,{className:`flex flex-col gap-2 p-4`,children:w.map(e=>{let t=K[e.type];return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,G.jsx)(T,{tone:`ember`,children:b(`know.proposed`)}),(0,G.jsx)(t,{className:`size-4 text-ink-3`}),(0,G.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[b(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,G.jsx)(D,{size:`sm`,variant:`ghost`,onClick:()=>A.mutate({id:e.id,keep:!1}),children:b(`know.dismiss`)}),(0,G.jsx)(D,{size:`sm`,onClick:()=>A.mutate({id:e.id,keep:!0}),children:b(`know.accept`)})]},e.id)})}):null,t.items.length?(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(P,{value:d,placeholder:b(`know.search`),busy:_,onEnter:()=>void O(),onChange:e=>{p(e),e.trim()||h(null)}}),S.length?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[S.map(e=>(0,G.jsx)(je,{category:e,value:l[e.name],onChange:t=>{h(null),u(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(l).length?(0,G.jsx)(`button`,{type:`button`,onClick:()=>u({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:b(`know.clear`)}):null]}):null]}):null,(0,G.jsx)(C,{className:`flex flex-col p-1.5`,children:m?(0,G.jsx)(Me,{found:m,onOpen:r}):E.length?E.map(e=>(0,G.jsx)(Y,{item:e,categories:t.categories,onOpen:r},e.key)):(0,G.jsx)(f,{children:b(`know.empty`)})}),n?null:(0,G.jsxs)(ee,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await c.upload(`document`,t),await s.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[c.busy?(0,G.jsx)(g,{className:`size-4`}):(0,G.jsx)(ne,{className:`size-4`}),b(`know.drop`),` `,(0,G.jsx)(`span`,{className:`underline`,children:b(`know.pick`)})]}),c.error?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,G.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:b(`know.keywordsOnly`),t.checked?``:b(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,G.jsx)(Ne,{kind:y===`page`||y===`table`?y:null,projectId:e,onClose:()=>x(null),onMade:e=>{x(null),r(e)}}),(0,G.jsx)(xe,{projectId:e,open:y===`category`,onClose:()=>x(null),onMade:e=>{x(null),r(`c:${e}`)}})]})}function Fe({page:e,onGone:t,onOpen:n}){let r=i(),[s,l]=(0,W.useState)(e.title),[u,d]=(0,W.useState)(e.markdown),[f,p]=(0,W.useState)(e.markdown?`read`:`write`),m=e.knowledge,h=async()=>{await r.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await r.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},v=te({title:s.trim()||e.title,markdown:u},async t=>{await k.patch(`/api/studio/pages/${e.id}`,t),r.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await h()}),y=a({mutationFn:()=>k.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await h(),t()}}),x=a({mutationFn:()=>k.post(`/api/studio/projects/${e.projectId}/pages`,{title:b(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await h(),n?.(`p:${e}`)}}),S=a({mutationFn:()=>k.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>r.invalidateQueries({queryKey:[`space-page`,e.id]})}),T=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await k.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},E=e.readOnly,O=m?.file&&(m.file.mime===`application/pdf`||m.file.mime.startsWith(`image/`))?m.file:null,j=(e,t)=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>p(e),className:_(`rounded-full px-3 py-1 text-[0.8125rem] transition`,f===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,G.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[m?.parents.length&&n?(0,G.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:m.parents.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,G.jsx)(A,{className:`size-3.5`})]},e.id))}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,G.jsx)(`input`,{value:s,disabled:E,maxLength:200,onChange:e=>l(e.target.value),"aria-label":b(`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`}),v.state===`saving`?(0,G.jsx)(g,{className:`size-3.5 text-ink-3`}):v.state===`saved`?(0,G.jsx)(c,{className:`size-4 text-moss`,"aria-label":b(`settings.saved`)}):null,E?null:(0,G.jsx)(w,{label:b(`data.deletePage`),onClick:()=>confirm(b(`data.confirmDelete`,{title:e.title}))&&y.mutate(),className:`hover:text-rose`,children:(0,G.jsx)(I,{className:`size-4`})})]}),m?(0,G.jsx)(X,{projectId:e.projectId,itemKey:`p:${e.id}`,has:m.categories,originLabel:m.originLabel,kept:m.kept,review:m.review,file:O?null:m.file,readOnly:E,onReviewed:()=>S.mutate()}):null,(0,G.jsxs)(C,{className:`flex flex-col`,children:[E&&!O?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[E?null:j(`write`,b(`data.write`)),j(`read`,b(`data.preview`)),O?j(`original`,b(`know.original`)):null,(0,G.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:f===`original`&&O?O.name:b(`data.markdownHint`)})]}),f===`original`&&O?O.mime===`application/pdf`?(0,G.jsx)(`iframe`,{src:F(e.projectId,O.id),title:O.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,G.jsx)(`img`,{src:F(e.projectId,O.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):f===`write`&&!E?(0,G.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),"aria-label":e.title,placeholder:b(`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,G.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:T,children:u.trim()?(0,G.jsx)(oe,{text:u}):(0,G.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:b(`data.pageEmpty`)})})]}),v.state===`error`&&v.error?(0,G.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:v.error}):null,m&&n&&(m.children.length||!E)?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,G.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:m.children.length?b(`know.subPages`):null}),E?null:(0,G.jsxs)(D,{variant:`ghost`,size:`sm`,busy:x.isPending,onClick:()=>x.mutate(),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`know.addSub`)]})]}),m.children.length?(0,G.jsx)(C,{className:`flex flex-col p-1.5`,children:m.children.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,G.jsx)(L,{className:`size-4 shrink-0 text-ink-3`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function Ie({pageId:e,onGone:t,onOpen:n}){let i=r({queryKey:[`space-page`,e],queryFn:()=>k.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return i.data?(0,G.jsx)(Fe,{page:i.data,onGone:t,onOpen:n},i.data.id):i.isError?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i.error.message}):null}function Le(e){return r({queryKey:[`space-data`,e],queryFn:()=>k.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function Re(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:b(`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 ze={table:re,page:L};function Be({kind:e,projectId:t,data:n,onClose:r,onMade:o}){let s=i(),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(``),f=a({mutationFn:()=>k.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:c.trim(),wizardId:u||null}),onSuccess:async({id:n})=>{await s.invalidateQueries({queryKey:[`space-data`,t]}),o(`${e===`table`?`t`:`p`}:${n}`),l(``),d(``)}});return(0,G.jsx)(y,{open:e!==null,onClose:r,title:b(e===`table`?`data.newTable`:`data.newPage`),children:(0,G.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c.trim()&&f.mutate()},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.title`)}),(0,G.jsx)(E,{"data-autofocus":!0,value:c,maxLength:120,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.owner`)}),(0,G.jsx)(h,{value:u,onChange:d,options:[{value:``,label:b(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),f.error?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(D,{variant:`ghost`,onClick:r,children:b(`common.cancel`)}),(0,G.jsx)(D,{type:`submit`,busy:f.isPending,disabled:!c.trim(),children:b(`data.create`)})]})]})})}function Ve({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,W.useState)(null),s=Re(t),c=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),l=new Intl.DateTimeFormat(x,{dateStyle:`medium`});return(0,G.jsxs)(N,{title:b(`space.data`),hint:b(`data.hint`),plain:!0,action:n?null:(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(D,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`data.table`)]}),(0,G.jsxs)(D,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`data.page`)]})]}),children:[s.length?(0,G.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,G.jsx)(C,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=ze[e.kind];return(0,G.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,G.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,G.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${b(`data.rows`,{n:e.rows??0})} · `:``,l.format(new Date(c.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,G.jsx)(C,{children:(0,G.jsx)(f,{children:b(`data.empty`)})}),(0,G.jsx)(Be,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function He(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 Ue={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},We=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Ge(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Ue[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 Ke(e,t){return t.trim()===``?null:e.type===`date`&&e.format.kind===`datetime`?new Date(t).toISOString():t}var Z=`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 qe({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Ge(e,t),[o,s]=(0,W.useState)(a);(0,W.useEffect)(()=>s(a),[a]);let c=(t=o)=>{t!==a&&i(Ke(e,t))};if(e.type===`boolean`)return(0,G.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,G.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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,G.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,G.jsx)(`button`,{type:`button`,"aria-label":b(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,G.jsx)(u,{className:`size-3`})})]},e)),n?null:(0,G.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,G.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,G.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:Z,children:[(0,G.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,G.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>c(),"aria-label":e.name,className:_(Z,`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,G.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:_(Z,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function Je(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?b(`data.unit.${e.format.inputUnit}`):null}function Ye(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
|
|
3
|
-
`):``,multiple:e?.type===`select`&&!!e.format.multiple}}function Xe(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
|
|
4
|
-
`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??He(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 Ze({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,W.useState)(()=>Ye(t)),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(!1);(0,W.useEffect)(()=>{e&&(o(Ye(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??He(a.name,n.map(e=>e.id)),r=Xe(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,G.jsx)(y,{open:e,onClose:r,title:t?t.name:b(`data.newColumn`),children:(0,G.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&p()},children:[(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.columnName`)}),(0,G.jsx)(E,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.columnType`)}),(0,G.jsx)(h,{value:a.type,onChange:e=>d({type:e}),options:We.map(e=>({value:e,label:b(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,G.jsx)(h,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:b(`data.text.single`)},{value:`multiline`,label:b(`data.text.multiline`)}]}):null,a.type===`number`?(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,G.jsx)(h,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:b(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,G.jsx)(E,{value:a.currency,maxLength:3,"aria-label":b(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,G.jsx)(h,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:b(`data.date.${e}`)}))}):null,a.type===`duration`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.unit`)}),(0,G.jsx)(h,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:b(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(m,{children:b(`data.options`)}),(0,G.jsx)(v,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,G.jsx)(S,{checked:a.multiple,onChange:e=>d({multiple:e})}),b(`data.multiple`)]})]}):null,(0,G.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,G.jsx)(S,{checked:a.required,onChange:e=>d({required:e})}),b(`data.required`)]}),s?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,G.jsx)(D,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(b(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:b(`data.deleteColumn`)}):null,(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(D,{variant:`ghost`,onClick:r,children:b(`common.cancel`)}),(0,G.jsx)(D,{type:`submit`,busy:l,disabled:!a.name.trim(),children:b(`settings.save`)})]})]})})}function Qe({tableId:e,onGone:t}){let n=i(),s=[`space-table`,e],c=r({queryKey:s,queryFn:()=>k.get(`/api/studio/tables/${e}`)}),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(``);(0,W.useEffect)(()=>_(c.data?.title??``),[c.data?.title]);let v=async()=>{await n.invalidateQueries({queryKey:[`space-data`,c.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,c.data?.projectId]})},y=e=>n.setQueryData(s,t=>t&&{...t,rows:e(t.rows)}),x=e=>{f(e.message),c.refetch()},S=async t=>{await k.patch(`/api/studio/tables/${e}`,t),await c.refetch(),await v()},T=a({mutationFn:({row:t,column:n,value:r})=>k.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{f(null),h(e=>e===`${t}:${n}`?null:e),y(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof p&&e.body?.column===n){let e=c.data?.columns.find(e=>e.id===n)?.name??n;h(`${t}:${n}`),f(b(`data.badCell`,{column:e}));return}x(e)}}),E=a({mutationFn:()=>k.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{y(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await v()},onError:x}),O=a({mutationFn:t=>k.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{y(e=>e.filter(e=>e.id!==t)),await v()},onError:x}),A=a({mutationFn:()=>k.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await v(),t()}});if(!c.data)return c.isError?(0,G.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c.error.message}):null;let{columns:j,rows:M,readOnly:N}=c.data,P=!!c.data.list;return(0,G.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,G.jsx)(`input`,{value:g,disabled:N,maxLength:120,onChange:e=>_(e.target.value),onBlur:()=>g.trim()&&g!==c.data?.title&&void S({title:g}).catch(x),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":b(`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`}),N?null:(0,G.jsx)(w,{label:b(`data.deleteTable`),onClick:()=>confirm(b(`data.confirmDelete`,{title:c.data.title}))&&A.mutate(),className:`hover:text-rose`,children:(0,G.jsx)(I,{className:`size-4`})})]}),P?(0,G.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:b(`data.fromList`)}):null,c.data.knowledge?(0,G.jsx)(X,{projectId:c.data.projectId,itemKey:`t:${c.data.id}`,has:c.data.knowledge.categories,originLabel:c.data.knowledge.originLabel,kept:c.data.knowledge.kept,review:c.data.knowledge.review,file:c.data.knowledge.file,readOnly:N,onReviewed:()=>void k.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>c.refetch()).catch(x)}):null,(0,G.jsxs)(C,{className:`overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[j.map(e=>(0,G.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,G.jsxs)(`button`,{type:`button`,disabled:N||P,onClick:()=>u(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,G.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,G.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Je(e)?(0,G.jsx)(`span`,{className:`font-normal text-ink-4`,children:Je(e)}):null]})},e.id)),(0,G.jsx)(`th`,{className:`w-10 p-1`,children:N||P?null:(0,G.jsx)(w,{label:b(`data.newColumn`),onClick:()=>u(`new`),className:`size-8`,children:(0,G.jsx)(o,{className:`size-4`})})})]})}),(0,G.jsx)(`tbody`,{children:M.map(e=>(0,G.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[j.map(t=>(0,G.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,G.jsx)(qe,{column:t,value:e.cells[t.id],readOnly:N,invalid:m===`${e.id}:${t.id}`,onSave:n=>T.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,G.jsx)(`td`,{className:`w-10 p-1 align-top`,children:N?null:(0,G.jsx)(w,{label:b(`data.deleteRow`),onClick:()=>O.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,G.jsx)(I,{className:`size-3.5`})})})]},e.id))})]})}),M.length?null:(0,G.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:b(`data.noRows`)}),N?null:(0,G.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,G.jsxs)(D,{variant:`ghost`,size:`sm`,busy:E.isPending,onClick:()=>E.mutate(),children:[(0,G.jsx)(o,{className:`size-4`}),` `,b(`data.addRow`)]})})]}),d?(0,G.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:d}):null,(0,G.jsx)(Ze,{open:l!==null,column:l===`new`?null:l,columns:j,onClose:()=>u(null),onSave:e=>S({columns:e})})]})}var Q=`wizards.runDrawer.width`,$e=`wizards.runDrawer.wide`,et=680,$=400,tt=()=>Math.max($,window.innerWidth-120);function nt(e){try{return localStorage.getItem(e)}catch{return null}}function rt(e,t){try{localStorage.setItem(e,t)}catch{}}function it(){let[e,t]=(0,W.useState)(()=>{let e=Number(nt(Q));return e?Math.min(Math.max(e,$),tt()):et}),[n,r]=(0,W.useState)(()=>nt($e)===`1`),i=(0,W.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,$),tt()));t(n),rt(Q,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),rt($e,n?`0`:`1`)},onPointerDown:t=>{t.preventDefault();let n=t.clientX,r=e,a=e=>i(r+n-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),i(e+n)):t.key===`ArrowRight`&&(t.preventDefault(),i(e-n))},reset:()=>i(et)}}function at({header:e,actions:t,onClose:n,children:r}){let i=it();return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,G.jsxs)(`div`,{className:_(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!i.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${i.width}px`},onClick:e=>e.stopPropagation(),children:[i.wide?null:(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":b(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:b(`editor.resize`),onPointerDown:i.onPointerDown,onKeyDown:i.onKeyDown,onDoubleClick:i.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,G.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,G.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,G.jsx)(w,{label:b(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,G.jsx)(fe,{className:`size-4`}):(0,G.jsx)(ae,{className:`size-4`})}),(0,G.jsx)(w,{label:b(`editor.close`),onClick:n,children:(0,G.jsx)(u,{className:`size-5`})})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r})]})})}export{me as _,Re as a,Oe as c,Pe as d,Te as f,Ce as g,we as h,Ve as i,Y as l,Se as m,Qe as n,Le as o,K as p,ze as r,Ie as s,at as t,X as u,z as v,ce as y};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/qr-scanner.min-C_UI0gH-.js","assets/preload-helper-CNEI7N0N.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{C as r,D as i,S as a,_ as o,h as s,m as c,x as l,y as u}from"./definition-FVgbAXOo.js";import{t as d}from"./preload-helper-CNEI7N0N.js";import{D as f,F as p,G as m,H as h,I as g,L as _,N as v,O as y,P as b,U as x,W as S,b as C,c as w,d as T,f as E,g as D,h as O,i as k,j as A,k as j,l as M,m as N,n as P,o as F,p as I,s as L,t as R,u as ee,x as z}from"./ui-Bxf6zX5k.js";import{t as B}from"./arrow-right-C1xLSnNa.js";import{t as te}from"./copy-DgbMaHoj.js";import{t as V}from"./external-link-pP6YfR9-.js";import{n as ne,t as H}from"./trash-DAcf34LR.js";import{t as re}from"./pen-line-D54vxrGl.js";import{t as ie}from"./refresh-cw-DvTgdpdf.js";import{t as ae}from"./video-C6qoFAAs.js";import{C as oe,D as U,L as se,O as W,S as ce,T as le,V as ue,_ as G,b as de,f as fe,h as pe,v as me,w as he,x as ge,y as _e,z as ve}from"./index-CBjgitjd.js";var ye={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};ye.node;var be=m(ye),xe={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};xe.node;var Se=m(xe),Ce={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};Ce.node;var we=m(Ce),Te={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};Te.node;var Ee=m(Te),De={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};De.node;var Oe=m(De),ke={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};ke.node;var Ae=m(ke),je={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};je.node;var Me=m(je),Ne={name:`film`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]};Ne.node;var Pe=m(Ne),Fe={name:`flashlight-off`,size:24,node:[[`path`,{d:`M11.652 6H18`,key:`voqkpr`}],[`path`,{d:`M12 13v1`,key:`176q98`}],[`path`,{d:`M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-8a4 4 0 0 0-.8-2.4l-.6-.8A3 3 0 0 1 6 7V6`,key:`dzyf92`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M7.649 2H17a1 1 0 0 1 1 1v4a3 3 0 0 1-.6 1.8l-.6.8a4 4 0 0 0-.55 1.007`,key:`1hvcfn`}]]};Fe.node;var Ie=m(Fe),Le={name:`flashlight`,size:24,node:[[`path`,{d:`M12 13v1`,key:`176q98`}],[`path`,{d:`M17 2a1 1 0 0 1 1 1v4a3 3 0 0 1-.6 1.8l-.6.8A4 4 0 0 0 16 12v8a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2v-8a4 4 0 0 0-.8-2.4l-.6-.8A3 3 0 0 1 6 7V3a1 1 0 0 1 1-1z`,key:`17vh7j`}],[`path`,{d:`M6 6h12`,key:`n6hhss`}]]};Le.node;var Re=m(Le),ze={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};ze.node;var Be=m(ze),Ve={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};Ve.node;var He=m(Ve),Ue={name:`image-up`,size:24,node:[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};Ue.node;var We=m(Ue),Ge={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Ge.node;var Ke=m(Ge),qe={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};qe.node;var Je=m(qe),Ye={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};Ye.node;var Xe=m(Ye),Ze={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};Ze.node;var Qe=m(Ze),$e={name:`pencil-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]};$e.node;var et=m($e),tt={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};tt.node;var nt=m(tt),rt={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};rt.node;var it=m(rt),at={name:`scan-line`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]};at.node;var ot=m(at),st={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};st.node;var ct=m(st),lt={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};lt.node;var ut=m(lt),dt={name:`switch-camera`,size:24,node:[[`path`,{d:`M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5`,key:`mtk2lu`}],[`path`,{d:`M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5`,key:`120jsl`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m18 22-3-3 3-3`,key:`kgdoj7`}],[`path`,{d:`m6 2 3 3-3 3`,key:`1fnbkv`}]]};dt.node;var ft=m(dt),pt={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};pt.node;var mt=m(pt),ht={name:`unplug`,size:24,node:[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]};ht.node;var gt=m(ht),K=36e5,q=6e4,_t=1e3;function vt(e){return e.fractionDigits===void 0?e.style===`integer`?0:2:e.fractionDigits}function yt(e,t,n=`en`){if(typeof e!=`number`||!Number.isFinite(e))return``;let r=vt(t),i=t.grouping!==!1;return t.style===`percent`?new Intl.NumberFormat(n,{maximumFractionDigits:r,minimumFractionDigits:r,style:`percent`,useGrouping:i}).format(e):t.style===`currency`&&t.currency?new Intl.NumberFormat(n,{currency:t.currency,maximumFractionDigits:r,minimumFractionDigits:r,style:`currency`,useGrouping:i}).format(e):new Intl.NumberFormat(n,{maximumFractionDigits:r,minimumFractionDigits:r,useGrouping:i}).format(e)}function bt(e,t,n=`en`){if(typeof e!=`string`||e.length===0)return``;if(t.kind===`time`)return xt(e,t.timePrecision??`minutes`);if(t.dateStyle===`iso`)return t.kind===`date`?e.slice(0,10):e;let r=t.kind===`date`?new Date(`${e}T00:00:00`):new Date(e);if(Number.isNaN(r.getTime()))return e;let i=t.dateStyle??`medium`;if(t.kind===`date`)return new Intl.DateTimeFormat(n,{dateStyle:i}).format(r);let a=t.timePrecision??`minutes`;return new Intl.DateTimeFormat(n,{dateStyle:i,timeStyle:a===`hours`?`short`:`medium`}).format(r)}function xt(e,t){let[n=`0`,r=`00`,i=`00`]=e.split(`:`);return t===`hours`?`${n.padStart(2,`0`)}:00`:t===`minutes`?`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`:`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}:${i.padStart(2,`0`)}`}function St(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=Math.max(0,Math.round(e));if(t.display===`iso`)return Ct(n);if(t.display===`minutes`)return`${Math.round(n/q)} min`;if(t.display===`hours`)return`${(n/K).toFixed(2)} h`;if(t.display===`decimal-hours`)return(n/K).toFixed(2);let r=Math.floor(n/K),i=Math.floor(n%K/q),a=Math.floor(n%q/_t);return`${r}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function Ct(e){let t=Math.floor(e/K),n=Math.floor(e%K/q),r=Math.floor(e%q/_t);return`${t>=24?`P${Math.floor(t/24)}D`:`P`}T${t%24}H${n}M${r}S`}function J(e,t,n=`en`){if(t==null)return``;switch(e.type){case`number`:return yt(t,e.format,n);case`date`:return bt(t,e.format,n);case`duration`:return St(t,e.format);case`boolean`:return t===!0?`true`:t===!1?`false`:``;case`select`:return wt(e,t);default:return String(t)}}function wt(e,t){let n=Array.isArray(t)?t:[t],r=e.format.options.reduce((e,t)=>(e[t.id]=t.label,e),{});return n.filter(e=>typeof e==`string`&&e.length>0).map(e=>r[e]??e).join(`, `)}var Y=e(t(),1),X=e(n(),1);function Tt(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:A(`shareRun.email`),href:`mailto:?subject=${r}&body=${r}%0A%0A${n}`},{id:`x`,label:`X`,href:`https://x.com/intent/post?text=${r}&url=${n}`},{id:`linkedin`,label:`LinkedIn`,href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`},{id:`whatsapp`,label:`WhatsApp`,href:`https://wa.me/?text=${r}%20${n}`},{id:`facebook`,label:`Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${n}`}]}var Et={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function Dt({runId:e,title:t,initial:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(n),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),p=async()=>{if(i(!0),!a){c(!0),f(null);try{o(await z.post(`/api/runs/${e}/share`))}catch(e){f(e.message)}finally{c(!1)}}},m=async()=>{await z.del(`/api/runs/${e}/share`),o(null),i(!1)},g=()=>{a&&(navigator.clipboard.writeText(a.url),u(!0),setTimeout(()=>u(!1),1500))},_=W(`share`)||typeof navigator<`u`&&`share`in navigator,v=a?.expiresAt?new Intl.DateTimeFormat(j,{dateStyle:`long`}).format(new Date(a.expiresAt)):null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{variant:`secondary`,onClick:()=>void p(),children:[(0,X.jsx)(ct,{className:`size-4`}),` `,A(`shareRun.button`)]}),(0,X.jsx)(k,{open:r,onClose:()=>i(!1),title:A(`shareRun.title`),children:s?(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,X.jsx)(E,{})}):d?(0,X.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:d}):a?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,X.jsx)(ne,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`input`,{readOnly:!0,value:a.url,onFocus:e=>e.target.select(),"aria-label":A(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] outline-none coarse:h-11`}),(0,X.jsxs)(R,{size:`sm`,onClick:g,children:[l?(0,X.jsx)(h,{className:`size-3.5`}):(0,X.jsx)(te,{className:`size-3.5`}),A(l?`share.copied`:`share.copy`)]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[Tt(a.url,t).map(e=>(0,X.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[0.9375rem] transition hover:bg-paper-3`,children:e.id===`mail`?(0,X.jsx)(Xe,{className:`size-5`}):Et[e.id]}),e.label]},e.id)),_?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void(W(`share`)?U(`share`,{link:a.url,title:t}):navigator.share({title:t,url:a.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,X.jsx)(ct,{className:`size-5`})}),A(`shareRun.more`)]}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(`span`,{children:v?A(`shareRun.until`,{date:v}):A(`shareRun.kept`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:A(`shareRun.withdraw`)})]})]}):null})]})}function Ot({runId:e,ask:t}){return t.kind===`confirm`?(0,X.jsx)(kt,{runId:e,ask:t}):(0,X.jsx)(At,{runId:e,ask:t})}function kt({runId:e,ask:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=async n=>{a(!0),s(null);try{await z.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){s(e.message),a(!1)}},l=t.action.destructive?mt:et;return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:D(`flex size-10 shrink-0 items-center justify-center rounded-full`,t.action.destructive?`bg-rose-tint text-rose`:`bg-ember-tint text-ember-strong`),children:(0,X.jsx)(l,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:A(`ask.wants`,{service:t.service})}),(0,X.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-snug tracking-tight`,children:t.reason})]})]}),(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-paper-2 p-4 text-[0.8125rem] leading-relaxed ring-1 ring-border-soft`,children:t.input}),(0,X.jsxs)(`div`,{className:`mt-5 flex items-center gap-4`,children:[(0,X.jsx)(N,{checked:n,onChange:r,label:A(`ask.allowRest`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.8125rem] text-ink-2`,children:A(`ask.allowRest`)})]}),o?(0,X.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:o}):null,(0,X.jsxs)(`div`,{className:`action-bar mt-6 flex items-center justify-between gap-3`,children:[(0,X.jsx)(R,{variant:`ghost`,disabled:i,onClick:()=>void c({type:`skip`}),children:A(`ask.deny`)}),(0,X.jsx)(R,{busy:i,onClick:()=>void c({type:`done`,remember:n}),children:A(`ask.allow`)})]})]})}function At({runId:e,ask:t}){let[n,r]=(0,Y.useState)({}),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(0),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(!1),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(()=>d(e=>e+1),[]);(0,Y.useEffect)(()=>{let e=setInterval(v,2500);return()=>clearInterval(e)},[v]);let y=async n=>{s(!0),l(null);try{await z.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){l(e.message),s(!1)}},b=async t=>{l(null);try{await z.post(`/api/runs/${e}/browser/act`,t)}catch(e){l(e.message)}v()},S=e=>{let t=_.current;if(!t?.naturalWidth)return;let n=t.getBoundingClientRect();b({type:`click`,x:Math.round((e.clientX-n.left)/n.width*t.naturalWidth),y:Math.round((e.clientY-n.top)/n.height*t.naturalHeight)})},C=t.fields.some(e=>n[e.id]);return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-ember-tint text-ember-strong`,children:(0,X.jsx)(Je,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-snug tracking-tight`,children:t.reason}),(0,X.jsxs)(`p`,{className:`mt-0.5 truncate text-[0.8125rem] text-ink-3`,children:[t.site.host,t.site.title?` · ${t.site.title}`:``]})]})]}),(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-paper-2 ring-1 ring-border-soft`,children:[(0,X.jsx)(`img`,{ref:_,src:f(`/api/runs/${e}/browser/screen?t=${u}`),alt:t.site.host,onClick:S,className:`block w-full cursor-pointer`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-border-soft border-t bg-card p-2`,children:[(0,X.jsx)(L,{type:h?`password`:`text`,autoComplete:`off`,value:p,placeholder:A(`ask.typeInto`),onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b({type:`type`,text:p}).then(()=>m(``)))},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`send`,className:`h-9 min-w-[9rem] flex-1 basis-full text-[0.8125rem] sm:basis-0 coarse:h-11`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:D(`h-9 shrink-0 rounded-md px-2.5 text-[0.75rem] coarse:h-11 coarse:px-3.5`,h?`bg-ember-veil text-ink`:`text-ink-3 hover:bg-paper-2`),children:A(`ask.hide`)}),(0,X.jsx)(jt,{label:`Enter`,onClick:()=>void b({type:`key`,key:`Enter`}),children:(0,X.jsx)(Oe,{className:`size-4`})}),(0,X.jsx)(jt,{label:A(`ask.up`),onClick:()=>void b({type:`scroll`,dy:-500}),children:(0,X.jsx)(x,{className:`size-4`})}),(0,X.jsx)(jt,{label:A(`ask.down`),onClick:()=>void b({type:`scroll`,dy:500}),children:(0,X.jsx)(be,{className:`size-4`})})]})]}),(0,X.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-4`,children:A(`ask.pictureHint`)}),t.fields.length?(0,X.jsxs)(`form`,{className:`mt-5 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y({type:`fill`,values:n,remember:i})},children:[t.fields.map((e,i)=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(w,{children:e.label}),(0,X.jsx)(L,{autoFocus:i===0,type:e.secret?`password`:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:i===t.fields.length-1?`go`:`next`,value:n[e.id]??``,onChange:t=>r(n=>({...n,[e.id]:t.target.value}))})]},e.id)),(0,X.jsx)(`button`,{type:`submit`,hidden:!0})]}):null,(0,X.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-4`,children:[(0,X.jsx)(N,{checked:i,onChange:a,label:A(`ask.remember`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.8125rem] text-ink-2`,children:A(`ask.remember`)})]}),(0,X.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(ut,{className:`mt-0.5 size-4 shrink-0 text-moss`}),` `,A(`ask.private`)]}),c?(0,X.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:c}):null,(0,X.jsxs)(`div`,{className:`action-bar mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(R,{variant:`ghost`,disabled:o,onClick:()=>void y({type:`skip`}),children:A(`ask.skip`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.fields.length?(0,X.jsx)(R,{variant:`secondary`,disabled:o,onClick:()=>void y({type:`done`,remember:i}),children:A(`ask.done`)}):null,t.fields.length?(0,X.jsx)(R,{busy:o,disabled:!C,onClick:()=>void y({type:`fill`,values:n,remember:i}),children:A(`ask.signIn`)}):(0,X.jsx)(R,{busy:o,onClick:()=>void y({type:`done`,remember:i}),children:A(`ask.done`)})]})]})]})}function jt({label:e,onClick:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:t,className:`flex size-9 shrink-0 items-center justify-center rounded-md text-ink-3 hover:bg-paper-2 hover:text-ink coarse:size-11`,children:n})}async function Mt(e,t=2400){if(!/^image\/(jpeg|png|webp)$/.test(e.type)||e.size<12e5)return e;try{let n=await createImageBitmap(e),r=Math.min(1,t/Math.max(n.width,n.height)),i=document.createElement(`canvas`);i.width=Math.round(n.width*r),i.height=Math.round(n.height*r),i.getContext(`2d`)?.drawImage(n,0,0,i.width,i.height);let a=await new Promise(e=>i.toBlob(e,`image/jpeg`,.86));return a&&a.size<e.size?new File([a],`${e.name.replace(/\.[^.]+$/,``)}.jpg`,{type:`image/jpeg`}):e}catch{return e}}function Nt(){return new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`)}function Pt(e){let t=e?.name;return t===`NotFoundError`||t===`OverconstrainedError`?`missing`:t===`NotReadableError`||t===`AbortError`?`busy`:`denied`}function Ft(e){return!!e?.getCapabilities?.()?.torch}function It(e,t,n=!1){let r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(!e)return;let r=null,i=!1;s(null),a(null),d(!1),p(!1);let o={facingMode:{ideal:t},width:{ideal:2560},height:{ideal:1440}};return(async()=>{if(!navigator.mediaDevices?.getUserMedia)throw new DOMException(`no camera api`,`NotAllowedError`);try{r=await navigator.mediaDevices.getUserMedia({video:o,audio:n})}catch(e){if(!n)throw e;r=await navigator.mediaDevices.getUserMedia({video:o})}if(i){for(let e of r.getTracks())e.stop();return}a(r);let e=r.getVideoTracks()[0],t=()=>!i&&d(Ft(e));t(),setTimeout(t,600);let s=await navigator.mediaDevices.enumerateDevices().catch(()=>[]);i||l(s.filter(e=>e.kind===`videoinput`).length)})().catch(e=>!i&&s(Pt(e))),()=>{i=!0;for(let e of r?.getTracks()??[])e.stop()}},[e,t,n]),(0,Y.useEffect)(()=>{r.current&&i&&(r.current.srcObject=i)},[i]),{video:r,stream:i,error:o,cameras:c,torchable:u,torch:f,setTorch:async e=>{let t=i?.getVideoTracks()[0];try{await t?.applyConstraints({advanced:[{torch:e}]}),p(e)}catch{d(!1)}},mirrored:i?.getVideoTracks()[0]?.getSettings().facingMode===`user`}}function Lt({open:e,onClose:t,label:n,children:r}){let i=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=i.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,X.jsx)(`dialog`,{ref:i,onClose:t,"aria-label":n,className:`media-sheet`,children:e?(0,X.jsx)(`div`,{className:`flex h-full flex-col`,children:r}):null})}function Rt({label:e,onClick:t,active:n,children:r}){return(0,X.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":n,onClick:t,className:D(`flex size-11 shrink-0 items-center justify-center rounded-full transition`,n?`bg-white text-black`:`bg-white/12 text-white hover:bg-white/20`),children:r})}function zt({title:e,onClose:t,camera:n,onFlip:r}){return(0,X.jsx)(`div`,{className:`safe-top`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,X.jsx)(Rt,{label:A(`common.close`),onClick:t,children:(0,X.jsx)(v,{className:`size-5`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-center font-medium text-[0.9375rem]`,children:e}),n.torchable?(0,X.jsx)(Rt,{label:A(`camera.torch`),active:n.torch,onClick:()=>void n.setTorch(!n.torch),children:n.torch?(0,X.jsx)(Re,{className:`size-5`}):(0,X.jsx)(Ie,{className:`size-5`})}):null,n.stream&&(n.cameras>1||de)?(0,X.jsx)(Rt,{label:A(`camera.flip`),onClick:r,children:(0,X.jsx)(ft,{className:`size-5`})}):(0,X.jsx)(`span`,{className:`size-11`})]})})}function Bt({camera:e,asking:t,children:n,actions:r}){return(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[(0,X.jsx)(`video`,{ref:e.video,autoPlay:!0,playsInline:!0,muted:!0,className:D(`absolute inset-0 size-full object-contain`,e.mirrored&&`-scale-x-100`)}),e.error?(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-5 bg-black px-8 text-center`,children:[(0,X.jsx)(`p`,{className:`max-w-sm text-[0.9375rem] text-white/85 leading-relaxed`,children:A(`camera.${e.error}`)}),r]}):e.stream?n:(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 px-8 text-center text-white/75`,children:[(0,X.jsx)(E,{}),(0,X.jsx)(`p`,{className:`max-w-xs text-[0.875rem] leading-relaxed`,children:t})]})]})}var Vt=30;function Ht(){if(typeof MediaRecorder<`u`)return[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`].find(e=>MediaRecorder.isTypeSupported(e))}var Ut=!!Ht();function Wt({open:e,multiple:t,video:n,onClose:r,onCapture:i,onNative:a}){let[o,s]=(0,Y.useState)(`environment`),[c,l]=(0,Y.useState)(`photo`),[u,d]=(0,Y.useState)(0),[f,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=It(e,o,c===`video`);(0,Y.useEffect)(()=>{e&&(d(0),l(`photo`),g(null))},[e]);let y=async e=>{p(!0);try{await i(e),d(e=>e+1),t||r()}finally{p(!1)}},b=async()=>{let e=v.video.current;if(!e?.videoWidth)return;let t=document.createElement(`canvas`);t.width=e.videoWidth,t.height=e.videoHeight,t.getContext(`2d`)?.drawImage(e,0,0);let n=await new Promise(e=>t.toBlob(e,`image/jpeg`,.9));n&&await y(new File([n],`foto-${Nt()}.jpg`,{type:`image/jpeg`}))},x=()=>{_.current?.state===`recording`&&_.current.stop()},S=()=>{let e=Ht();if(!v.stream||!e)return;let t=[],n=new MediaRecorder(v.stream,{mimeType:e,videoBitsPerSecond:25e5,audioBitsPerSecond:96e3});n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{g(null),_.current=null;let n=e.split(`;`)[0];if(t.length){let e=n===`video/mp4`?`mp4`:`webm`;y(new File(t,`video-${Nt()}.${e}`,{type:n}))}},_.current=n,n.start(1e3),g(0)};(0,Y.useEffect)(()=>{if(m===null)return;if(m>=Vt){_.current?.state===`recording`&&_.current.stop();return}let e=setTimeout(()=>g(e=>e===null?null:e+1),1e3);return()=>clearTimeout(e)},[m]),(0,Y.useEffect)(()=>{!e&&_.current&&(_.current.onstop=null,_.current.stop(),_.current=null)},[e]);let C=e=>`0:${String(e).padStart(2,`0`)}`;return(0,X.jsxs)(Lt,{open:e,onClose:r,label:A(`camera.title`),children:[(0,X.jsx)(zt,{title:m===null?u?A(`camera.taken`,{n:u}):A(`camera.title`):`${C(m)} / ${C(Vt)}`,onClose:r,camera:v,onFlip:()=>s(e=>e===`environment`?`user`:`environment`)}),(0,X.jsx)(Bt,{camera:v,asking:A(`camera.asking`),actions:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,X.jsxs)(Z,{onClick:()=>{r(),a()},children:[(0,X.jsx)(Ee,{className:`size-4`}),` `,A(de?`camera.native`:`camera.pick`)]}):null,(0,X.jsx)(Z,{quiet:!0,onClick:r,children:A(`common.close`)})]})}),(0,X.jsxs)(`div`,{className:D(`safe-bottom px-4 pt-3`,v.error&&`invisible`),children:[n&&Ut&&m===null?(0,X.jsx)(`div`,{className:`mb-3 flex justify-center gap-1 text-[0.8125rem]`,children:[`photo`,`video`].map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:D(`h-9 rounded-full px-4 font-medium transition`,c===e?`bg-white text-black`:`text-white/70 hover:text-white`),children:A(e===`photo`?`camera.photo`:`camera.video`)},e))}):null,(0,X.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[0.8125rem] text-white/70 leading-snug`,children:m===null?c===`video`?A(`camera.clipHint`,{s:Vt}):A(t?`camera.hintMany`:`camera.hint`):A(`camera.recording`)}),(0,X.jsx)(`button`,{type:`button`,"aria-label":A(c===`photo`?`camera.shoot`:m===null?`camera.record`:`camera.stop`),disabled:!v.stream||f,onClick:()=>c===`photo`?void b():m===null?S():x(),className:`flex size-[72px] items-center justify-center rounded-full border-4 border-white transition active:scale-95 disabled:opacity-40`,children:f?(0,X.jsx)(E,{className:`text-white`}):c===`photo`?(0,X.jsx)(`span`,{className:`size-[54px] rounded-full bg-white`}):m===null?(0,X.jsx)(`span`,{className:`flex size-[54px] items-center justify-center rounded-full bg-[#e5484d]`,children:(0,X.jsx)(ae,{className:`size-6 text-white`})}):(0,X.jsx)(`span`,{className:`size-7 rounded-md bg-[#e5484d]`})}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:t&&u&&m===null?(0,X.jsxs)(Z,{onClick:r,children:[(0,X.jsx)(h,{className:`size-4`}),` `,A(`camera.done`)]}):null})]})]})]})}function Z({onClick:e,quiet:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,onClick:e,className:D(`inline-flex h-11 items-center justify-center gap-2 rounded-full px-5 font-medium text-[0.875rem] transition`,t?`text-white/75 hover:text-white`:`bg-white text-black hover:bg-white/90`),children:n})}var Gt=25,Kt=9e3;function qt(e){return e.code===e.PERMISSION_DENIED?`denied`:e.code===e.TIMEOUT?`timeout`:`unavailable`}function Jt({value:e,runId:t,placeholder:n,onChange:r,onBusy:i}){let a=o(e)?e:null,[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(!!a?.label),p=(0,Y.useRef)(a);p.current=a;let m=a?.lat!==void 0&&a.lng!==void 0,h=typeof navigator<`u`&&`geolocation`in navigator,g=()=>{d.current!==null&&(navigator.geolocation.clearWatch(d.current),d.current=null),c(!1),i?.(!1)};(0,Y.useEffect)(()=>()=>{d.current!==null&&navigator.geolocation.clearWatch(d.current)},[]);let _=async(e,n)=>{try{let{label:i}=await z.post(`/api/runs/${t}/geocode`,{lat:e,lng:n,language:j}),a=p.current;i&&!f.current&&a?.lat===e&&a.lng===n&&r({...a,label:i})}catch{}},y=()=>{u(null),c(!0),i?.(!0);let e=Date.now(),t=1/0;d.current=navigator.geolocation.watchPosition(n=>{let{latitude:i,longitude:a,accuracy:o}=n.coords;if(o<t){t=o;let e=Math.round(i*1e6)/1e6,n=Math.round(a*1e6)/1e6,s=f.current?p.current?.label:void 0,c={lat:e,lng:n,accuracy:Math.round(o),...s?{label:s}:{}};p.current=c,r(c)}if(t<=Gt||Date.now()-e>Kt){g();let e=p.current;e?.lat!==void 0&&e.lng!==void 0&&_(e.lat,e.lng)}},e=>{g(),t===1/0&&u(qt(e))},{enableHighAccuracy:!0,timeout:15e3,maximumAge:1e4})},b=e=>{f.current=e.trim().length>0;let t={...m?a:{},label:e};r(m||e.trim()?t:void 0)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,X.jsx)(Qe,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`truncate font-medium text-[0.9375rem] tabular-nums`,children:[a.lat?.toFixed(5),`, `,a.lng?.toFixed(5)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(`span`,{children:s?A(`location.refining`):a.accuracy?A(`location.accuracy`,{m:a.accuracy}):null}),(0,X.jsxs)(`a`,{href:`https://www.openstreetmap.org/?mlat=${a.lat}&mlon=${a.lng}#map=17/${a.lat}/${a.lng}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline coarse:-my-3 coarse:min-h-11 coarse:min-w-11`,children:[A(`location.map`),` `,(0,X.jsx)(V,{className:`size-3`})]})]})]}),(0,X.jsx)(F,{label:A(`location.remove`),onClick:()=>{g(),f.current=!1,r(void 0)},children:(0,X.jsx)(v,{className:`size-4`})})]}):h?(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(R,{variant:`secondary`,size:`lg`,busy:s,onClick:y,className:`w-full sm:w-auto`,children:[s?null:(0,X.jsx)(Ke,{className:`size-4`}),A(s?`location.locating`:`location.use`)]}),l?(0,X.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2 leading-relaxed`,children:A(`location.${l}`)}):(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3 leading-relaxed`,children:A(`location.why`)})]}):null,(0,X.jsx)(L,{value:a?.label??``,placeholder:n??A(m?`location.label`:`location.manual`),autoComplete:`street-address`,enterKeyHint:`done`,"aria-label":A(`location.manual`),onChange:e=>b(e.target.value)})]})}var Yt=null;function Xt(){return Yt??=(async()=>{let e=window.BarcodeDetector;if(e)try{let t=await e.getSupportedFormats();if(t.includes(`qr_code`)){let n=new e({formats:t});return{qrOnly:!1,detect:async e=>(await n.detect(e))[0]?.rawValue||null}}}catch{}let{default:t}=await d(async()=>{let{default:e}=await import(`./qr-scanner.min-C_UI0gH-.js`);return{default:e}},__vite__mapDeps([0,1])),n=t.createQrEngine();return{qrOnly:!0,detect:async e=>{try{return(await t.scanImage(e,{qrEngine:n,returnDetailedScanResult:!0})).data||null}catch{return null}}}})(),Yt}function Zt({open:e,onClose:t,onResult:n}){let r=(0,Y.useRef)(n);r.current=n;let i=(0,Y.useRef)(t);return i.current=t,(0,Y.useEffect)(()=>{e&&U(`scan`).then(e=>{e&&r.current(e)}).catch(()=>void 0).finally(()=>i.current())},[e]),null}function Qt(e){return W(`scan`)?(0,X.jsx)(Zt,{...e}):(0,X.jsx)($t,{...e})}function $t({open:e,onClose:t,onResult:n}){let[r,i]=(0,Y.useState)(`environment`),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null),u=It(e,r),d=(0,Y.useRef)(n);d.current=n;let f=(0,Y.useRef)(t);f.current=t,(0,Y.useEffect)(()=>{e&&(c(!1),Xt().then(e=>o(e.qrOnly)))},[e]),(0,Y.useEffect)(()=>{if(!e||!u.stream)return;let t=!1,n,r=async()=>{let e=u.video.current;if(!t&&e&&e.readyState>=2&&e.videoWidth){let n=await(await Xt()).detect(e).catch(()=>null);if(n&&!t){navigator.vibrate?.(60),d.current(n),f.current();return}}t||(n=setTimeout(r,200))};return r(),()=>{t=!0,clearTimeout(n)}},[e,u.stream,u.video]);let p=async e=>{if(!e)return;c(!1);let r=await createImageBitmap(e).catch(()=>null),i=r?await(await Xt()).detect(r).catch(()=>null):null;i?(n(i),t()):c(!0)};return(0,X.jsxs)(Lt,{open:e,onClose:t,label:A(`scan.title`),children:[(0,X.jsx)(zt,{title:A(`scan.title`),onClose:t,camera:u,onFlip:()=>i(e=>e===`environment`?`user`:`environment`)}),(0,X.jsx)(Bt,{camera:u,asking:A(`scan.asking`),actions:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(Z,{onClick:()=>l.current?.click(),children:[(0,X.jsx)(We,{className:`size-4`}),` `,A(`scan.fromPhoto`)]}),(0,X.jsx)(Z,{quiet:!0,onClick:t,children:A(`scan.typeInstead`)})]}),children:(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(`div`,{className:`aspect-square w-[min(68%,320px)] rounded-3xl border-2 border-white/90 shadow-[0_0_0_100vmax_rgb(0_0_0/0.35)]`})})}),(0,X.jsxs)(`div`,{className:`safe-bottom flex flex-col items-center gap-3 px-5 pt-3 text-center`,children:[(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-white/75 leading-snug`,children:A(s?`scan.miss`:a?`scan.hintQr`:`scan.hint`)}),u.stream?(0,X.jsxs)(Z,{quiet:!0,onClick:()=>l.current?.click(),children:[(0,X.jsx)(We,{className:`size-4`}),` `,A(`scan.fromPhoto`)]}):null]}),(0,X.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}})]})}var en=`#1d1a17`,Q={width:1200,height:480};function tn(e,t,n,r,i){e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=en,e.fillStyle=en,e.lineWidth=i;for(let a of t){if(a.length===1){e.beginPath(),e.arc(a[0].x*n,a[0].y*r,i/2,0,Math.PI*2),e.fill();continue}e.beginPath(),e.moveTo(a[0].x*n,a[0].y*r);for(let t=1;t<a.length-1;t++){let i=a[t],o=a[t+1];e.quadraticCurveTo(i.x*n,i.y*r,(i.x+o.x)/2*n,(i.y+o.y)/2*r)}let t=a[a.length-1];e.lineTo(t.x*n,t.y*r),e.stroke()}}function nn({strokes:e,onStrokes:t}){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(e);i.current=e;let a=()=>{let e=n.current,t=e?.getContext(`2d`);if(!e||!t)return;let a=window.devicePixelRatio||1,o=Math.round(e.clientWidth*a),s=Math.round(e.clientHeight*a);(e.width!==o||e.height!==s)&&(e.width=o,e.height=s),t.clearRect(0,0,o,s),tn(t,r.current?[...i.current,r.current]:i.current,o,s,2.4*a)};(0,Y.useEffect)(()=>{a();let e=n.current;if(!e)return;let t=new ResizeObserver(a);return t.observe(e),()=>t.disconnect()},[e]);let o=e=>{let t=e.currentTarget.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),y:Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))}};return(0,X.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl bg-white ring-1 ring-input`,children:[(0,X.jsx)(`canvas`,{ref:n,"aria-label":A(`sign.pad`),className:`block aspect-[5/2] w-full cursor-crosshair touch-none select-none`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),r.current=[o(e)],a()},onPointerMove:e=>{r.current&&(r.current.push(o(e)),a())},onPointerUp:()=>{if(r.current){let e=r.current;r.current=null,t([...i.current,e])}},onPointerCancel:()=>{r.current=null,a()}}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-6 bottom-[22%] border-[#1d1a17]/25 border-b`}),e.length?null:(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-[#1d1a17]/40 text-[0.875rem]`,children:A(`sign.hint`)})]})}async function rn(e){let t=document.createElement(`canvas`);t.width=Q.width,t.height=Q.height;let n=t.getContext(`2d`);if(!n)return null;tn(n,e,Q.width,Q.height,7);let r=await new Promise(e=>t.toBlob(e,`image/png`));return r?new File([r],`unterschrift.png`,{type:`image/png`}):null}function an({label:e,value:t,runId:n,onChange:r}){let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),p=typeof t==`string`&&t?t:null,m=async()=>{l(!0),d(null);try{let e=await rn(o);if(!e)return;r((await z.upload(`/api/runs/${n}/uploads`,e)).id),a(!1)}catch(e){d(e.message)}finally{l(!1)}};return(0,X.jsxs)(`div`,{children:[p?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>{s([]),a(!0)},className:`min-w-0 flex-1 rounded-lg bg-white px-3`,"aria-label":A(`sign.again`),children:(0,X.jsx)(`img`,{src:f(`/api/runs/${n}/assets/${p}`),alt:e,className:`mx-auto h-20 object-contain`})}),(0,X.jsx)(F,{label:A(`sign.remove`),onClick:()=>r(void 0),children:(0,X.jsx)(v,{className:`size-4`})})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{s([]),a(!0)},className:`flex w-full flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-4 py-7 text-[0.875rem] text-ink-3 transition hover:border-ember hover:text-ink`,children:[(0,X.jsx)(re,{className:`size-6`}),A(`sign.open`)]}),(0,X.jsxs)(k,{open:i,onClose:()=>a(!1),title:e,wide:!0,children:[(0,X.jsx)(nn,{strokes:o,onStrokes:s}),u?(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:u}):null,(0,X.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(R,{variant:`ghost`,disabled:!o.length||c,onClick:()=>s([]),children:[(0,X.jsx)(Ae,{className:`size-4`}),` `,A(`sign.clear`)]}),(0,X.jsx)(R,{busy:c,disabled:!o.length,onClick:()=>void m(),children:A(`sign.accept`)})]})]})]})}function on({runId:e,connectionId:t,connector:n,onCancel:r}){let[i,a]=(0,Y.useState)({}),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=async()=>{s(!0),l(null);try{await z.post(`/api/runs/${e}/connections/${t}/credentials/${n.id}`,{values:i})}catch(e){l(e.message)}finally{s(!1)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-card p-4 ring-1 ring-input`,children:[(n.fields??[]).map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(w,{children:e.label}),(0,X.jsx)(L,{type:e.secret?`password`:`text`,autoComplete:`off`,value:i[e.key]??``,placeholder:e.placeholder,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())}})]},e.key)),n.hint?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:n.hint}):null,c?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(R,{variant:`ghost`,size:`sm`,onClick:r,children:A(`common.cancel`)}),(0,X.jsx)(R,{size:`sm`,busy:o,onClick:()=>void u(),children:A(`connect.go`)})]})]})}function sn({runId:e,connection:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null);if(!t)return null;if(t.account){let n=t.connectors.find(e=>e.id===t.account?.connector)?.name??``;return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,X.jsx)(h,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:t.account.label}),(0,X.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:A(`connect.connected`,{name:n})})]}),(0,X.jsx)(F,{label:A(`connect.disconnect`),onClick:()=>void z.del(`/api/runs/${e}/connections/${t.id}`),children:(0,X.jsx)(gt,{className:`size-4`})})]})}let c=async n=>{if(s(null),a(null),W(`signIn`)){try{let{url:r}=await z.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);await U(`signIn`,{url:r})}catch(e){s(e.message)}return}let r=window.open(`about:blank`,`wizard-connect`,`width=540,height=700`);try{let{url:i}=await z.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);r?r.location.replace(i):a(i)}catch(e){r?.close(),s(e.message)}},l=t.connectors.find(e=>e.id===n);return t.connectors.length?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.connectors.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>e.auth===`oauth2`?void c(e):r(n===e.id?null:e.id),className:D(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[0.875rem] ring-1 transition`,n===e.id?`bg-ember-veil text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink hover:ring-ember`),children:[(0,X.jsx)(ne,{className:`size-4`}),` `,e.name]},e.id))}),l?(0,X.jsx)(on,{runId:e,connectionId:t.id,connector:l,onCancel:()=>r(null)}):null,i?(0,X.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-[0.875rem] text-ember underline`,children:A(`connect.openLink`)}):null,o?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:o}):null]}):(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:A(`connect.none`)})}function cn(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function ln(e,t){if(t.trim()===``)return null;if(e.type===`number`){let e=Number(t.replace(/\s/g,``).replace(`,`,`.`));return Number.isFinite(e)?e:t}return e.type===`boolean`?t===`true`:t}function $({column:e,value:t,boxed:n,onCommit:r}){let[i,a]=(0,Y.useState)(cn(t));(0,Y.useEffect)(()=>a(cn(t)),[t]);let o=D(`w-full min-w-0 rounded-md border border-transparent px-2 text-[0.8125rem] outline-none focus:border-ember focus:bg-card`,n?`h-11 bg-paper-2`:`h-9 bg-transparent hover:bg-paper-2 coarse:h-11`);return e.type===`boolean`?(0,X.jsx)(`label`,{className:`flex size-9 cursor-pointer items-center justify-center coarse:size-11`,children:(0,X.jsx)(`input`,{type:`checkbox`,"aria-label":e.name,checked:t===!0,onChange:e=>r(e.target.checked),className:`size-4 accent-[var(--ember)] coarse:size-6`})}):e.type===`select`&&!e.format.multiple&&!e.format.allowCustom?(0,X.jsxs)(`select`,{value:i,onChange:e=>r(e.target.value||null),className:o,children:[(0,X.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]}):(0,X.jsx)(`input`,{"aria-label":e.name,type:e.type===`date`&&e.format.kind===`date`?`date`:`text`,inputMode:e.type===`number`?`decimal`:void 0,enterKeyHint:`done`,autoComplete:`off`,value:i,onChange:e=>a(e.target.value),onBlur:()=>{i!==cn(t)&&r(ln(e,i))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},className:D(o,e.type===`number`&&`text-right tabular-nums`)})}function un({runId:e,list:t,editable:n}){let{def:r,rows:i}=t,[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)({}),l=`/api/runs/${e}/lists/${r.id}/rows`,u=async e=>{o(null);try{await e()}catch(e){o(e instanceof C?e.message:String(e))}},d=()=>u(async()=>{await z.post(l,{cells:s}),c({})}),f=Object.values(s).some(e=>e!=null&&e!==``);if(!i.length&&!n)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:A(`list.empty`)});let m=(e,t)=>t===0||e.type===`text`&&e.format?.style===`multiline`,h=(e,t,n)=>void u(()=>z.patch(`${l}/${e}`,{cells:{[t]:n}}));return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[i.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((t,r)=>(0,X.jsxs)(`div`,{className:D(`min-w-0`,m(t,r)&&`col-span-2`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:t.name}),n?(0,X.jsx)($,{boxed:!0,column:t,value:e.cells[t.id],onCommit:n=>h(e.id,t.id,n)}):(0,X.jsx)(`div`,{className:D(`break-words px-1 text-[0.875rem]`,t.type===`number`&&`tabular-nums`),children:J(t,e.cells[t.id],j)||`—`})]},t.id))}),n?(0,X.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,X.jsx)(F,{label:A(`list.delete`),onClick:()=>void u(()=>z.del(`${l}/${e.id}`)),children:(0,X.jsx)(H,{className:`size-4`})})}):null]},e.id)),n?(0,X.jsxs)(`div`,{className:`rounded-lg border border-input border-dashed p-2`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((e,t)=>(0,X.jsxs)(`div`,{className:D(`min-w-0`,m(e,t)&&`col-span-2`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:e.name}),(0,X.jsx)($,{boxed:!0,column:e,value:s[e.id],onCommit:t=>c(n=>({...n,[e.id]:t}))})]},e.id))}),(0,X.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,X.jsxs)(R,{variant:`secondary`,size:`sm`,onClick:()=>f?void d():void 0,children:[(0,X.jsx)(p,{className:`size-4`}),` `,A(`run.addRow`)]})})]}):null]}),(0,X.jsx)(`div`,{className:`hidden overflow-x-auto rounded-lg ring-1 ring-border-soft sm:block`,children:(0,X.jsxs)(`table`,{className:`w-full text-[0.8125rem]`,children:[(0,X.jsx)(`thead`,{className:`bg-paper-2 text-ink-2`,children:(0,X.jsxs)(`tr`,{children:[r.columns.map(e=>(0,X.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 text-left font-medium`,children:e.name},e.id)),n?(0,X.jsx)(`th`,{className:`w-10`}):null]})}),(0,X.jsxs)(`tbody`,{children:[i.map(e=>(0,X.jsxs)(`tr`,{className:`border-border-soft border-t align-top`,children:[r.columns.map(t=>(0,X.jsx)(`td`,{className:D(`min-w-[7.5rem]`,n?`px-1 py-0.5`:`px-3 py-2`),children:n?(0,X.jsx)($,{column:t,value:e.cells[t.id],onCommit:n=>h(e.id,t.id,n)}):(0,X.jsx)(`span`,{className:D(t.type===`number`&&`tabular-nums`),children:J(t,e.cells[t.id],j)})},t.id)),n?(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)(F,{label:A(`list.delete`),className:`size-9`,onClick:()=>void u(()=>z.del(`${l}/${e.id}`)),children:(0,X.jsx)(H,{className:`size-3.5`})})}):null]},e.id)),n?(0,X.jsxs)(`tr`,{className:`border-border-soft border-t bg-paper`,children:[r.columns.map(e=>(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)($,{column:e,value:s[e.id],onCommit:t=>c(n=>({...n,[e.id]:t}))})},e.id)),(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)(F,{label:A(`run.addRow`),className:`size-9`,onClick:()=>f?void d():void 0,children:(0,X.jsx)(p,{className:`size-4`})})})]}):null]})]})}),a?(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:a}):null]})}function dn(e,t,n){let r=t.split(`/`).map(encodeURIComponent).join(`/`);return f(`/api/runs/${e}/store/files/${r}${n?`?inline=1`:``}`)}var fn=[`bg-paper-3 text-ink-3`,`bg-moss-tint text-moss`,`bg-rose-tint text-rose`,`bg-ember-tint text-ember-strong`];function pn({runId:e,list:t}){let{def:n,rows:r}=t,i=n.columns.find(e=>e.id===n.check?.file),a=n.columns.find(e=>e.id===n.check?.status),o=a?.type===`select`?a.format.options:[],s=o[0]?.id,c=e=>a?String(e.cells[a.id]??s??``):``,l=e=>!a||c(e)===s,[u,d]=(0,Y.useState)(()=>(r.find(l)??r[0])?.id??null),[f,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(null),_=`/api/runs/${e}/lists/${n.id}/rows`,v=r.find(e=>e.id===u)??r[0],y=f?r.filter(e=>l(e)||e.id===v?.id):r,b=r.filter(e=>!l(e)).length,x=n.columns.filter(e=>e!==i&&e!==a),S=x.filter(e=>e.id!==n.key),w=S.find(e=>e.type===`text`)??S[0],T=S.filter(e=>e!==w),E=async(e,t)=>{g(null);try{await z.patch(`${_}/${e}`,{cells:t})}catch(e){g(e instanceof C?e.message:String(e))}},O=e=>{let t=y.findIndex(e=>e.id===v?.id),n=y[Math.min(y.length-1,Math.max(0,t+e))];n&&d(n.id)},k=async e=>{if(!v||!a)return;let t=r.findIndex(e=>e.id===v.id),n=[...r.slice(t+1),...r.slice(0,t)].find(l);await E(v.id,{[a.id]:e}),n&&e!==s&&d(n.id)},M=e=>{e.target.closest(`input, textarea, select`)||(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),O(e.key===`ArrowDown`?1:-1)):/^[1-9]$/.test(e.key)&&o[Number(e.key)]&&(e.preventDefault(),k(o[Number(e.key)].id)))};if(!r.length)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:A(`list.empty`)});let N=i&&v?String(v.cells[i.id]??``).trim():``,P=N.split(`.`).pop()?.toLowerCase()??``,F=e=>fn[Math.min(Math.max(0,o.findIndex(t=>t.id===c(e))),3)];return(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(280px,360px)_minmax(0,1fr)]`,onKeyDown:M,children:[(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:A(`check.progress`,{done:b,total:r.length})}),a?(0,X.jsx)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:D(`inline-flex h-8 items-center rounded-full px-3 text-[0.8125rem] ring-1 transition coarse:h-11`,f?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:A(`check.onlyOpen`)}):null]}),(0,X.jsx)(`ul`,{className:`flex max-h-[38vh] flex-col gap-1.5 overflow-y-auto p-0.5 pr-1 lg:max-h-[calc(100vh-15rem)]`,children:y.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),"aria-current":e.id===v?.id,className:D(`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left ring-1 transition`,e.id===v?.id?`bg-card shadow-soft ring-ember`:`bg-paper ring-border-soft hover:bg-card`),children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:w&&J(w,e.cells[w.id],j)||`—`}),(0,X.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3 tabular-nums`,children:T.slice(0,2).map(t=>J(t,e.cells[t.id],j)).filter(Boolean).join(` · `)})]}),a?(0,X.jsx)(`span`,{className:D(`shrink-0 rounded-full px-2 py-0.5 font-medium text-[0.6875rem]`,F(e)),children:o.find(t=>t.id===c(e))?.label??c(e)}):null]})},e.id))})]}),v?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o.length>1?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o.slice(1).map((e,t)=>(0,X.jsxs)(R,{size:`md`,variant:c(v)===e.id?`primary`:`secondary`,onClick:()=>void k(e.id),children:[c(v)===e.id?(0,X.jsx)(h,{className:`size-4`}):null,e.label,(0,X.jsx)(`kbd`,{className:`ml-1 hidden rounded bg-black/10 px-1.5 text-[0.6875rem] lg:inline`,children:t+1})]},e.id)),c(v)===s?null:(0,X.jsx)(R,{size:`md`,variant:`ghost`,onClick:()=>void k(s??``),children:A(`check.reopen`)})]}):null,(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-paper-2 ring-1 ring-border-soft`,children:N?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-border-soft border-b bg-card px-3 py-2 text-[0.8125rem]`,children:[(0,X.jsx)(ve,{className:`size-3.5 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:N.split(`/`).pop()}),(0,X.jsx)(`a`,{href:dn(e,N,P===`pdf`),target:`_blank`,rel:`noreferrer`,className:`shrink-0 text-ink-2 underline-offset-2 hover:text-ink hover:underline`,children:A(`run.openFull`)})]}),P===`pdf`?(0,X.jsx)(`iframe`,{title:N,src:`${dn(e,N,!0)}#toolbar=0&navpanes=0&view=FitH`,className:`h-[46vh] w-full border-0 bg-white lg:h-[calc(100vh-27rem)] lg:min-h-[360px]`},N):[`png`,`jpg`,`jpeg`,`webp`].includes(P)?(0,X.jsx)(`div`,{className:`flex max-h-[46vh] justify-center overflow-auto bg-white lg:max-h-[calc(100vh-27rem)]`,children:(0,X.jsx)(`img`,{src:dn(e,N,!0),alt:N,className:`max-w-full object-contain`},N)}):(0,X.jsx)(`p`,{className:`px-4 py-10 text-center text-[0.875rem] text-ink-3`,children:A(`check.noPreview`)})]}):(0,X.jsx)(`p`,{className:`px-4 py-14 text-center text-[0.875rem] text-ink-3`,children:A(`check.noFile`)})}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3`,children:x.map(e=>(0,X.jsxs)(`div`,{className:D(`min-w-0`,e.type===`text`&&e.format?.style===`multiline`&&`col-span-full`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:e.name}),(0,X.jsx)($,{boxed:!0,column:e,value:v.cells[e.id],onCommit:t=>void E(v.id,{[e.id]:t})})]},e.id))}),m?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:m}):null]}):null]})}var mn={xlsx:`Excel`,csv:`CSV`,json:`JSON`,md:`Markdown`,zip:`ZIP`};function hn({runId:e,list:t}){return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.formats.map(n=>(0,X.jsx)(`a`,{href:f(`/api/runs/${e}/lists/${t.def.id}/download?format=${n}`),className:`inline-flex h-9 items-center rounded-full bg-paper-2 px-3.5 font-medium text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink coarse:h-11 coarse:px-4`,children:mn[n]??n},n))})}function gn(e){return e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} KB`}function _n({runId:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{t&&(o(!1),z.get(`/api/runs/${e}/store`).then(i))},[t,e]);let s=r&&!r.files.length&&!r.connections.length&&!r.keepsSignIns&&r.lists.every(e=>!e.rows);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-11`,children:[(0,X.jsx)(ue,{className:`size-3.5`}),` `,A(`store.open`)]}),(0,X.jsx)(k,{open:t,onClose:()=>n(!1),title:A(`store.title`),wide:!0,children:r?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5 text-[0.875rem]`,children:[(0,X.jsx)(`p`,{className:`text-ink-3`,children:A(`store.explain`)}),s?(0,X.jsx)(`p`,{className:`text-ink-2`,children:A(`store.empty`)}):null,r.lists.some(e=>e.rows)?(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:r.lists.filter(e=>e.rows).map(e=>(0,X.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:e.title}),(0,X.jsx)(`span`,{className:`text-ink-3 tabular-nums`,children:A(`store.rows`,{n:e.rows})})]},e.id))}):null,r.connections.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(ne,{className:`size-4 text-ink-3`}),` `,e.account?.label]},e.id)),r.keepsSignIns?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(h,{className:`size-4 text-ink-3`}),` `,A(`store.signIns`)]}):null,r.files.length?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-ink-3`,children:A(`store.files`,{n:r.files.length,size:gn(r.files.reduce((e,t)=>e+t.size,0))})}),(0,X.jsx)(`ul`,{className:`max-h-56 overflow-y-auto rounded-lg ring-1 ring-border-soft`,children:r.files.map(t=>(0,X.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,X.jsxs)(`a`,{href:f(`/api/runs/${e}/store/files/${t.path}`),className:`flex items-center gap-2 px-3 py-2 text-[0.8125rem] hover:bg-paper-2 coarse:min-h-11`,title:t.source??void 0,children:[(0,X.jsx)(ve,{className:`size-3.5 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.path}),(0,X.jsx)(`span`,{className:`text-ink-4 tabular-nums`,children:gn(t.size)})]})},t.path))})]}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[s?(0,X.jsx)(`span`,{}):a?(0,X.jsxs)(R,{variant:`secondary`,onClick:async()=>{await z.del(`/api/runs/${e}/store`),i(await z.get(`/api/runs/${e}/store`)),o(!1)},children:[(0,X.jsx)(H,{className:`size-4`}),` `,A(`store.confirmDelete`)]}):(0,X.jsxs)(R,{variant:`ghost`,onClick:()=>o(!0),children:[(0,X.jsx)(H,{className:`size-4`}),` `,A(`store.delete`)]}),(0,X.jsx)(R,{onClick:()=>n(!1),children:A(`common.close`)})]})]}):(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,X.jsx)(E,{})})})]})}var vn=300;function yn(){if(typeof MediaRecorder<`u`)return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/webm`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function bn(e){return`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function xn({value:e,runId:t,onChange:n,onBusy:r}){let i=c(e)?e:null,[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(0),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,v]=(0,Y.useState)(null),y=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=yn(),C=G&&!!S;(0,Y.useEffect)(()=>()=>{y.current&&(y.current.recorder.onstop=null,y.current.stop())},[]),(0,Y.useEffect)(()=>()=>{g&&URL.revokeObjectURL(g.url)},[g]);let w=async(e,i)=>{d(!0),r?.(!0),p(null);try{let r=await z.upload(`/api/runs/${t}/uploads`,e);v({asset:r.id,url:URL.createObjectURL(e)}),n({asset:r.id,...i===void 0?{}:{seconds:i}})}catch(e){p(e.message)}finally{d(!1),r?.(!1)}},T=async()=>{p(null),h(!1);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{h(!0);return}let t=[],n=new MediaRecorder(e,{mimeType:S,audioBitsPerSecond:48e3}),i=Date.now(),a=new AudioContext,s=a.createAnalyser();s.fftSize=256,a.createMediaStreamSource(e).connect(s);let c=new Uint8Array(s.fftSize),u=0,d=()=>{s.getByteTimeDomainData(c);let e=0;for(let t of c)e=Math.max(e,Math.abs(t-128));if(l(Math.min(1,e/64)),o((Date.now()-i)/1e3),(Date.now()-i)/1e3>=vn){f();return}u=requestAnimationFrame(d)},f=()=>{cancelAnimationFrame(u),n.state!==`inactive`&&n.stop();for(let t of e.getTracks())t.stop();a.close().catch(()=>void 0),y.current=null,o(null),l(0)};n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{let e=(n.mimeType||S||`audio/webm`).split(`;`)[0],r=e===`audio/mp4`?`m4a`:e===`audio/ogg`?`ogg`:`webm`,a=Math.max(1,Math.round((Date.now()-i)/1e3));w(new File(t,`sprachnotiz-${Nt()}.${r}`,{type:e}),a)},y.current={recorder:n,stop:f},r?.(!0),n.start(1e3),u=requestAnimationFrame(d)},D=a!==null,O=(0,X.jsxs)(R,{variant:`secondary`,onClick:()=>x.current?.click(),children:[(0,X.jsx)(Me,{className:`size-4`}),` `,A(`voice.pick`)]});return(0,X.jsxs)(`div`,{children:[D?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-ember`,children:[(0,X.jsxs)(`span`,{className:`relative flex size-11 shrink-0 items-center justify-center`,children:[(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-rose-tint transition-transform duration-75`,style:{transform:`scale(${.7+s*.5})`}}),(0,X.jsx)(`span`,{className:`relative size-3.5 animate-pulse-dot rounded-full bg-rose`})]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`font-medium text-[0.9375rem] tabular-nums`,children:bn(a)}),(0,X.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:a>270?A(`voice.left`,{s:Math.ceil(vn-a)}):A(`voice.recording`)})]}),(0,X.jsxs)(R,{onClick:()=>y.current?.stop(),children:[(0,X.jsx)(b,{className:`size-3.5 fill-current`}),` `,A(`voice.stop`)]})]}):u?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-4 text-[0.875rem] text-ink-3 ring-1 ring-input`,children:[(0,X.jsx)(E,{className:`size-4`}),` `,A(`run.uploading`)]}):i?(0,X.jsxs)(`div`,{className:`rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:g?.asset===i.asset?g.url:`/api/runs/${t}/assets/${i.asset}`,className:`h-11 w-full`}),i.transcript?(0,X.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap px-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:i.transcript}):null,(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:i.seconds?bn(i.seconds):null}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[C?(0,X.jsxs)(R,{variant:`ghost`,size:`sm`,onClick:()=>void T(),children:[(0,X.jsx)(it,{className:`size-3.5`}),` `,A(`voice.again`)]}):null,(0,X.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>n(void 0),children:A(`voice.remove`)})]})]})]}):(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C?(0,X.jsxs)(R,{variant:`secondary`,size:`lg`,onClick:()=>void T(),className:`w-full sm:w-auto`,children:[(0,X.jsx)(_,{className:`size-4`}),` `,A(`voice.start`)]}):O,C&&m?O:null]}),m?(0,X.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2 leading-relaxed`,children:A(`voice.denied`)}):(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3 leading-relaxed`,children:A(C?`voice.why`:`voice.noRecorder`)})]}),(0,X.jsx)(`input`,{ref:x,type:`file`,hidden:!0,accept:`audio/*`,capture:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&w(t,void 0)}}),f?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-rose`,children:f}):null]})}function Sn(e,t){try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function Cn({field:e,value:t,values:n,onChange:r}){let i=e.columns??[],a=Array.isArray(t)&&t.length?t:[{}],o=u(e,a,n),s=(e,t,n)=>{r(a.map((r,i)=>i===e?{...r,[t]:n}:r))},c=i.map(e=>e.kind===`text`&&e===i[0]?`minmax(0,3fr)`:`minmax(0,1fr)`).join(` `);return(0,X.jsxs)(`div`,{className:`rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`hidden gap-2 px-2 pt-1 pb-2 text-[0.75rem] text-ink-3 sm:grid`,style:{gridTemplateColumns:`${c} 36px`},children:i.map(e=>(0,X.jsx)(`div`,{className:e.kind===`text`?``:`text-right`,children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map((e,t)=>(0,X.jsxs)(`div`,{className:`grid grid-cols-6 gap-2 rounded-lg bg-paper p-2 sm:bg-transparent sm:p-0 sm:[grid-template-columns:var(--cols)]`,style:{"--cols":`${c} 36px`},children:[i.map((n,r)=>(0,X.jsxs)(`label`,{className:D(`flex min-w-0 flex-col gap-1 sm:col-span-1`,r===0?`col-span-5`:i.length-1<=2?`col-span-3`:`col-span-2`),children:[(0,X.jsx)(`span`,{className:`px-0.5 text-[0.6875rem] text-ink-3 sm:hidden`,children:n.label}),(0,X.jsx)(`input`,{"aria-label":n.label,placeholder:n.label,inputMode:n.kind===`text`?`text`:`decimal`,autoComplete:`off`,value:String(e[n.id]??``),onChange:e=>s(t,n.id,e.target.value),className:D(`h-11 w-full min-w-0 rounded-md border border-transparent bg-paper-2 px-2.5 text-[0.875rem] outline-none placeholder:text-transparent focus:border-focus focus:bg-card sm:placeholder:text-ink-4`,n.kind!==`text`&&`text-right tabular-nums`)})]},n.id)),(0,X.jsx)(F,{label:A(`list.delete`),onClick:()=>r(a.filter((e,n)=>n!==t)),className:`order-first col-start-6 row-start-1 size-11 justify-self-end self-end sm:order-none sm:col-start-auto sm:row-start-auto`,children:(0,X.jsx)(H,{className:`size-4`})})]},t))}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-end justify-between gap-3 px-2 pb-1`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r([...a,{}]),className:`inline-flex h-9 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-2 hover:bg-accent coarse:h-11`,children:[(0,X.jsx)(p,{className:`size-4`}),` `,A(`run.addRow`)]}),(0,X.jsxs)(`div`,{className:`text-right text-[0.8125rem] tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`text-ink-3`,children:[A(`run.net`),` `,Sn(o.net,o.currency)]}),o.vatRate?(0,X.jsxs)(`div`,{className:`text-ink-3`,children:[A(`run.vat`,{r:o.vatRate}),` `,Sn(o.vat,o.currency)]}):null,(0,X.jsxs)(`div`,{className:`font-semibold text-[0.9375rem] text-ink`,children:[A(`run.total`),` `,Sn(o.gross,o.currency)]})]})]})]})}function wn(e){return!!e?.closest(`input, textarea, [contenteditable='true']`)}function Tn({field:e,value:t,runId:n,onChange:r,onBusy:i}){let a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)({}),[m,h]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),w=(0,Y.useRef)(null),T=e=>{w.current=e,C(e)},E=e.kind===`image`,O=!!e.multiple,k=O?e.max??30:1,j=E||!!e.camera||!!e.video,M=!E&&!!e.video,N=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],P=(0,Y.useRef)(N);P.current=N;let I=N.length<k,L=async e=>{let t=(E?e.filter(e=>e.type.startsWith(`image/`)):e).sort((e,t)=>e.name.localeCompare(t.name,void 0,{numeric:!0}));if(!t.length)return;let a=k-(O?P.current.length:0);u(!0),i?.(!0),h(t.length>a&&O?A(`run.maxFiles`,{n:k}):null);try{for(let e of t.slice(0,Math.max(0,a))){let t=await Mt(e),i=await z.upload(`/api/runs/${n}/uploads`,t);p(e=>({...e,[i.id]:{name:i.name,mime:i.mime}}));let a=O?[...P.current,i.id]:i.id;P.current=O?a:[i.id],r(a)}}catch(e){h(e.message)}finally{u(!1),i?.(!1)}},R=(0,Y.useRef)(L);R.current=L;let ee=e=>{let t=N.filter(t=>t!==e);r(O?t:void 0)},B=(e,t)=>{let n=P.current.indexOf(e),i=Math.min(P.current.length-1,Math.max(0,t));if(n<0||n===i)return;let a=P.current.filter(t=>t!==e);a.splice(i,0,e),P.current=a,r(a)},te=O&&N.length>1;(0,Y.useEffect)(()=>{if(!I)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]),n=a.current;if(!t.length||!n||wn(document.activeElement))return;let r=document.querySelectorAll(`[data-upload-field]`);(n.matches(`:hover`)||n.contains(document.activeElement)||r.length===1)&&(e.preventDefault(),R.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[I]);let V=D(`flex flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-3 text-[0.875rem] text-ink-3 transition hover:border-ember hover:text-ink`,N.length?`py-4`:`py-8`);return(0,X.jsxs)(`div`,{ref:a,"data-upload-field":``,onDragOver:e=>{I&&(e.preventDefault(),x(!0))},onDragLeave:()=>x(!1),onDrop:e=>{x(!1),I&&(e.preventDefault(),L(Array.from(e.dataTransfer.files)))},children:[N.length?(0,X.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:N.map((e,t)=>{let r=d[e],i=r?.mime??(E?`image/`:``);return(0,X.jsxs)(`div`,{"data-file-id":e,className:D(`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input transition-shadow`,S===e&&`relative z-10 shadow-elevated ring-2 ring-ember`),children:[te?(0,X.jsxs)(`button`,{type:`button`,"aria-label":A(`run.moveFile`,{n:t+1}),title:A(`run.moveFileHint`),className:D(`-mr-1 flex h-14 w-9 shrink-0 touch-none flex-col items-center justify-center gap-0.5 rounded-lg text-ink-3 hover:bg-paper-2 hover:text-ink`,S===e?`cursor-grabbing`:`cursor-grab`),onPointerDown:t=>{try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}T(e)},onPointerMove:t=>{if(w.current!==e)return;let n=document.elementFromPoint(t.clientX,t.clientY)?.closest(`[data-file-id]`),r=n?.getAttribute(`data-file-id`);r&&r!==e&&a.current?.contains(n??null)&&B(e,P.current.indexOf(r))},onPointerUp:()=>T(null),onPointerCancel:()=>T(null),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),B(e,t+(n.key===`ArrowUp`?-1:1)))},children:[(0,X.jsx)(`span`,{className:`font-medium text-[0.75rem] tabular-nums`,children:t+1}),(0,X.jsx)(Be,{className:`size-4`})]}):null,i.startsWith(`image/`)?(0,X.jsx)(`img`,{src:f(`/api/runs/${n}/assets/${e}`),alt:``,className:`size-14 rounded-lg object-cover`}):(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg bg-paper-2`,children:i.startsWith(`video/`)?(0,X.jsx)(Pe,{className:`size-5 text-ink-3`}):(0,X.jsx)(g,{className:`size-5 text-ink-3`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:r?.name??`✓`}),(0,X.jsx)(F,{label:A(`run.removeFile`),onClick:()=>ee(e),children:(0,X.jsx)(v,{className:`size-4`})})]},e)})}):null,I?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o.current?.click(),className:D(V,`min-w-[9rem] flex-1 px-4`,b&&`border-ember text-ink`),children:[E?(0,X.jsx)(He,{className:`size-6`}):(0,X.jsx)(g,{className:`size-6`}),l?A(`run.uploading`):N.length?A(`run.uploadMore`):A(de?`run.uploadTouch`:`run.upload`)]}),j?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>G?y(!0):s.current?.click(),className:D(V,`w-28`),children:[(0,X.jsx)(Ee,{className:`size-6`}),A(`run.camera`)]}):null,M&&!(G&&Ut)?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),className:D(V,`w-28`),children:[(0,X.jsx)(ae,{className:`size-6`}),A(`camera.video`)]}):null]}):null,(0,X.jsx)(`input`,{ref:o,type:`file`,hidden:!0,multiple:O,accept:E?`image/*`:void 0,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}),(0,X.jsx)(`input`,{ref:s,type:`file`,hidden:!0,accept:`image/*`,capture:`environment`,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}),M?(0,X.jsx)(`input`,{ref:c,type:`file`,hidden:!0,accept:`video/*`,capture:`environment`,onChange:e=>{L(Array.from(e.target.files??[])),e.target.value=``}}):null,(0,X.jsx)(Wt,{open:_,multiple:O,video:M,onClose:()=>y(!1),onCapture:e=>L([e]),onNative:()=>s.current?.click()}),O&&(e.min||e.max)?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.min&&N.length<e.min?A(`run.filesMin`,{n:N.length,min:e.min}):e.max?A(`run.filesOf`,{n:N.length,max:e.max}):null}):null,m?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-rose`,children:m}):null]})}function En(e){let t=`${e.id} ${e.label}`.toLowerCase();return/telefon|phone|handy|mobil(?!it)|\btel\b|rückruf/.test(t)?{type:`tel`,inputMode:`tel`,autoComplete:`tel`}:/\bplz\b|postleitzahl|postal|zip/.test(t)?{inputMode:`numeric`,autoComplete:`postal-code`}:/iban/.test(t)?{autoCapitalize:`characters`,autoCorrect:`off`,spellCheck:!1}:/vorname|first.?name/.test(t)?{autoComplete:`given-name`,autoCapitalize:`words`}:/nachname|last.?name|surname/.test(t)?{autoComplete:`family-name`,autoCapitalize:`words`}:/firma|unternehmen|company|organi[sz]ation/.test(t)?{autoComplete:`organization`,autoCapitalize:`words`}:/straße|strasse|street|anschrift|adresse|address/.test(t)?{autoComplete:`street-address`,autoCapitalize:`words`}:/\b(ort|stadt|city|town)\b/.test(t)?{autoComplete:`address-level2`,autoCapitalize:`words`}:/\bname\b|ansprechp/.test(t)?{autoComplete:`name`,autoCapitalize:`words`}:{autoCapitalize:`sentences`}}function Dn({field:e,value:t,onChange:n}){let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(L,{value:t,placeholder:e.placeholder,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>n(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex h-11 shrink-0 items-center gap-2 rounded-lg border border-input bg-card px-3.5 font-medium text-[0.875rem] text-ink-2 transition hover:border-ember hover:text-ink`,children:[(0,X.jsx)(ot,{className:`size-4`}),` `,A(`scan.button`)]}),(0,X.jsx)(Qt,{open:r,onClose:()=>i(!1),onResult:n})]})}var On=4;function kn(e){let t=new Map,n=e.map(e=>({value:e,slot:r(e)})).filter(e=>e.slot).sort((e,t)=>Date.parse(e.value)-Date.parse(t.value));for(let{value:e,slot:r}of n){if(!r)continue;let n=t.get(r.day)??{label:a(e,j),times:[]};n.times.push({value:e,time:r.time}),t.set(r.day,n)}return[...t.values()]}function An({name:e,label:t,options:n,value:r,onChange:i,disabled:a}){let o=kn(n),s=o.findIndex(e=>e.times.some(e=>e.value===r)),[c,l]=(0,Y.useState)(s>=On);if(!o.length)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:A(`slot.none`)});let u=c?o:o.slice(0,On);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:t}),u.map(t=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3`,children:t.label}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.times.map(n=>(0,X.jsxs)(`label`,{className:`relative`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`slot-${e}`,value:n.value,checked:n.value===r,disabled:a.has(n.value),"aria-label":`${t.label}, ${n.time}`,onChange:()=>i(n.value),className:`peer sr-only`}),(0,X.jsx)(`span`,{className:D(`inline-flex h-10 cursor-pointer items-center rounded-full border px-4 text-sm tabular-nums transition coarse:h-11`,`border-input bg-card text-ink-2 hover:border-ink-4 hover:text-ink`,`peer-checked:border-ember peer-checked:bg-ember-tint peer-checked:text-ink`,`peer-disabled:pointer-events-none peer-disabled:line-through peer-disabled:opacity-60`,`peer-focus-visible:outline-[1.5px] peer-focus-visible:outline-offset-2 peer-focus-visible:outline-(--focus-line) peer-focus-visible:outline-solid`),children:n.time})]},n.value))})]},t.label))]}),o.length>u.length?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`self-start text-[0.8125rem] text-ink-3 underline-offset-4 transition hover:text-ink hover:underline coarse:min-h-11`,children:A(`slot.later`)}):null]})}function jn({field:e,value:t,values:n,runId:r,view:i,onChange:a,onBusy:o,error:s,closed:c}){let l=t==null?``:String(t),u=new Set(c?.values.map(String)),d;switch(e.kind){case`textarea`:d=(0,X.jsx)(O,{value:l,placeholder:e.placeholder,autoCapitalize:`sentences`,enterKeyHint:`enter`,onChange:e=>a(e.target.value)});break;case`number`:d=(0,X.jsx)(L,{inputMode:`decimal`,autoComplete:`off`,value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`select`:{let t=e.options??[];d=t.length<=5&&t.every(e=>e.length<=28)?(0,X.jsx)(ee,{value:l,options:t,onChange:a,disabled:[...u]}):(0,X.jsx)(T,{value:l,placeholder:`—`,onChange:a,options:t.map(e=>({value:e,label:e,disabled:u.has(e)}))});break}case`slot`:d=(0,X.jsx)(An,{name:e.id,label:e.label,options:e.options??[],value:l,onChange:a,disabled:u});break;case`multiselect`:d=(0,X.jsx)(ee,{multi:!0,value:Array.isArray(t)?t:[],options:e.options??[],onChange:a});break;case`date`:d=(0,X.jsx)(L,{type:`date`,value:l,onChange:e=>a(e.target.value),className:`w-full sm:w-56`});break;case`email`:d=(0,X.jsx)(L,{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`url`:d=(0,X.jsx)(L,{type:`url`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:l,placeholder:e.placeholder??`https://`,onChange:e=>a(e.target.value)});break;case`toggle`:d=(0,X.jsx)(N,{checked:t===!0,onChange:a,label:e.label,disabled:u.has(String(t!==!0))});break;case`color`:d=(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(I,{value:l||`#e0531b`,onChange:e=>a(e.target.value)}),(0,X.jsx)(L,{value:l,placeholder:`#e0531b`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>a(e.target.value),className:`w-36`})]});break;case`image`:case`file`:d=(0,X.jsx)(Tn,{field:e,value:t,runId:r,onChange:a,onBusy:o});break;case`items`:d=(0,X.jsx)(Cn,{field:e,value:t,values:n,onChange:a});break;case`connection`:d=(0,X.jsx)(sn,{runId:r,connection:i?.connections.find(t=>t.id===e.connection)});break;case`list`:{let t=i?.lists.find(t=>t.def.id===e.list);d=t?(0,X.jsx)(un,{runId:r,list:t,editable:!0}):null;break}case`location`:d=(0,X.jsx)(Jt,{value:t,runId:r,placeholder:e.placeholder,onChange:a,onBusy:o});break;case`audio`:d=c?null:(0,X.jsx)(xn,{value:t,runId:r,onChange:a,onBusy:o});break;case`signature`:d=(0,X.jsx)(an,{label:e.label,value:t,runId:r,onChange:a});break;default:d=e.scan?(0,X.jsx)(Dn,{field:e,value:l,onChange:a}):(0,X.jsx)(L,{...En(e),value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)})}return(0,X.jsxs)(`div`,{children:[e.kind===`toggle`?(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,X.jsx)(w,{hint:e.help,children:e.label}),d]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(w,{hint:e.help,required:e.required,children:e.label}),d]}),c?(0,X.jsx)(`div`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:A(`run.closed`,{list:c.classes.map(e=>A(`run.cls.${Mn[e]}`)).join(`, `)})}):null,s?(0,X.jsx)(`div`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:s}):null]})}var Mn={classifier:`text`,standard:`text`,high:`text`,highest:`text`,image:`image`,video:`video`,speech:`speech`,audio:`audio`},Nn=45e3;function Pn(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)({});(0,Y.useEffect)(()=>{if(n(null),o(!1),!e)return;let t=!1,r=0,i,a=null,s=Date.now(),c=()=>{t=!0,a?.close(),o(!0)},l=async()=>{try{let r=await z.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof C&&e.status===404&&c()}},u=()=>{if(clearTimeout(i),a?.close(),t)return;let o=new EventSource(f(`/api/runs/${e}/stream`),{withCredentials:!0});a=o,s=Date.now(),o.addEventListener(`view`,e=>{r=0,s=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{s=Date.now()}),o.onerror=()=>{o.close(),!(t||a!==o)&&(a=null,l(),r=Math.min(r+1,6),i=setTimeout(u,500*2**r))}},d=()=>{t||document.visibilityState!==`visible`||(!a||a.readyState===EventSource.CLOSED||Date.now()-s>Nn?(r=0,u()):l())},p=setInterval(()=>{!t&&a&&Date.now()-s>Nn&&(r=0,u())},15e3);return u(),document.addEventListener(`visibilitychange`,d),window.addEventListener(`pageshow`,d),window.addEventListener(`online`,d),()=>{t=!0,clearTimeout(i),clearInterval(p),document.removeEventListener(`visibilitychange`,d),window.removeEventListener(`pageshow`,d),window.removeEventListener(`online`,d),a?.close()}},[e]);let d=(0,Y.useCallback)(async(t,n)=>{if(!e)return!1;c(!0),i(null),u({});try{return await z.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof C&&e.status===422&&Array.isArray(e.body?.fields)&&u(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{c(!1)}},[e]);return{view:t,notFound:a,error:r,busy:s,fieldErrors:l,submitPage:(e,t)=>d(`pages/${e}`,{values:t}),accept:(e,t)=>d(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>d(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>d(`back`),retry:()=>d(`retry`)}}function Fn({view:e}){let t=Math.round(Math.min(e.progress.done,e.progress.total)/Math.max(1,e.progress.total)*100);return(0,X.jsx)(`div`,{className:`h-[3px] w-full bg-paper-2`,children:(0,X.jsx)(`div`,{className:`h-full bg-ember transition-[width] duration-700 ease-out`,style:{width:`${t}%`}})})}function In({title:e,description:t,kicker:n}){return(0,X.jsxs)(`div`,{className:`mb-8`,children:[n?(0,X.jsx)(`p`,{className:`mb-4 text-[0.9375rem] text-ink-2 leading-relaxed`,children:n}):null,(0,X.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] leading-[1.15] tracking-tight sm:text-[2rem]`,children:e}),t?(0,X.jsx)(`p`,{className:`mt-2 text-[0.9375rem] text-ink-3 leading-relaxed`,children:t}):null]})}function Ln(e,t){let n={};for(let r of e.fields)n[r.id]=t.values[r.id]??t.prefill?.[r.id]??r.default??(r.kind===`multiselect`?[]:void 0);return n}function Rn(e){return Array.from(e.querySelectorAll(`input:not([type="hidden"], [type="file"], [type="checkbox"], [type="color"], [type="range"], [disabled]), textarea:not([disabled])`)).filter(e=>!e.closest(`dialog`)&&e.offsetParent!==null)}function zn({view:e,run:t,step:n}){let[r,i]=(0,Y.useState)(()=>Ln(n,e)),[a,o]=(0,Y.useState)(new Set),c=(0,Y.useRef)(null),u=e.progress.done===0,d=(0,Y.useMemo)(()=>n.fields.filter(t=>!s(t)||e.decidedFields?.includes(t.id)).map(t=>e.options?.[t.id]?.length?{...t,options:e.options[t.id]}:t),[n.fields,e.options,e.decidedFields]),f=l(d,e.known??{},r),p=()=>void t.submitPage(n.id,r);return(0,Y.useEffect)(()=>{if(!c.current)return;let e=Rn(c.current).filter(e=>e instanceof HTMLInputElement);for(let[t,n]of e.entries())(n.dataset.hint||!n.hasAttribute(`enterkeyhint`))&&(n.dataset.hint=`1`,n.setAttribute(`enterkeyhint`,t===e.length-1?`go`:`next`))}),(0,X.jsxs)(`form`,{ref:c,className:`animate-rise`,onSubmit:e=>{e.preventDefault(),a.size||p()},onKeyDown:e=>{let t=e.target;if(e.key!==`Enter`||e.defaultPrevented||e.nativeEvent.isComposing||!(t instanceof HTMLInputElement)||t.closest(`dialog`))return;let n=Rn(e.currentTarget),r=n[n.indexOf(t)+1];r&&(e.preventDefault(),r.focus())},children:[(0,X.jsx)(In,{title:n.title,description:n.description,kicker:u?e.wizard.intro:null}),(0,X.jsx)(`div`,{className:`flex flex-col gap-7`,children:f.map(n=>(0,X.jsx)(jn,{field:n,value:r[n.id],values:r,runId:e.id,view:e,error:t.fieldErrors[n.id],closed:e.closed?.[n.id],onChange:e=>i(t=>({...t,[n.id]:e})),onBusy:e=>o(t=>{if(t.has(n.id)===e)return t;let r=new Set(t);return e?r.add(n.id):r.delete(n.id),r})},n.id))}),(0,X.jsx)(Bn,{view:e,run:t,sticky:!0,children:(0,X.jsxs)(R,{type:`submit`,size:`lg`,busy:t.busy,disabled:a.size>0,children:[n.cta||A(`run.next`),` `,(0,X.jsx)(B,{className:`size-4`})]})})]})}function Bn({view:e,run:t,sticky:n,children:r}){return(0,X.jsxs)(`div`,{className:D(`mt-10 flex items-center justify-between gap-3`,n&&`action-bar`),children:[e.canBack?(0,X.jsxs)(R,{variant:`ghost`,onClick:()=>void t.back(),disabled:t.busy,children:[(0,X.jsx)(S,{className:`size-4`}),` `,A(`run.back`)]}):(0,X.jsx)(`span`,{}),r]})}function Vn(){let e=he(),[t,n]=(0,Y.useState)(!1),r=e!==`off`;return(0,X.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:t,onClick:async()=>{if(r){me();return}n(!0),await _e(),n(!1)},className:D(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[0.875rem] ring-1 transition`,r?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink hover:ring-ink-4`),children:[r?(0,X.jsx)(Se,{className:`size-4 text-ember-strong`}):(0,X.jsx)(we,{className:`size-4`}),A(r?`notify.on`:`notify.ask`)]}),(0,X.jsx)(`p`,{className:`max-w-xs text-[0.75rem] text-ink-4 leading-relaxed`,children:A(e===`off`?`notify.why`:e===`on`?`notify.onHint`:ge()?`notify.blocked`:`notify.quiet`)})]})}function Hn({view:e,compact:t,awake:n}){let r=(0,Y.useMemo)(()=>{let t=[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id);return t?new Date(t.at).getTime():Date.now()},[e.events,e.step?.id]),[a,o]=(0,Y.useState)(Date.now());(0,Y.useEffect)(()=>{let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[]);let s=[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id)?.message??e.step?.title??A(`run.working`),c=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=r-500),l=c.slice(-4),u=[...new Set(c.map(e=>e.asset).filter(e=>!!e))],d=[...c].reverse().find(e=>e.asset)?.asset;return(0,X.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-6 text-center`,children:[(0,X.jsx)(i,{kind:e.wizard.avatar,size:t?130:170,fluffy:!0}),(0,X.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[1.375rem] tracking-tight`,children:s}),(0,X.jsx)(`div`,{className:`mt-1 text-[0.8125rem] text-ink-4 tabular-nums`,children:A(`run.elapsed`,{s:Math.max(0,Math.round((a-r)/1e3))})}),u.length?(0,X.jsx)(`div`,{className:`mt-5 flex max-w-full flex-wrap justify-center gap-2`,children:u.slice(-8).map(t=>(0,X.jsx)(`img`,{src:f(`/api/runs/${e.id}/assets/${t}`),alt:``,className:D(`size-16 animate-rise rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft transition sm:size-20`,t===d?`ring-2 ring-ember`:`opacity-70`)},t))}):null,(0,X.jsx)(`div`,{className:`mt-6 flex min-h-[7rem] w-full max-w-sm flex-col gap-1.5`,children:l.map((e,t)=>(0,X.jsxs)(`div`,{className:D(`flex items-center justify-center gap-2 text-[0.8125rem] transition-opacity`,t===l.length-1?`text-ink-2`:`text-ink-4`),children:[t===l.length-1?(0,X.jsx)(se,{className:`size-3.5 animate-breathe text-ember`}):null,(0,X.jsx)(`span`,{className:`truncate`,children:y(e)})]},e.id))}),t?null:(0,X.jsx)(Vn,{}),n?(0,X.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-4`,children:A(`run.awake`)}):null]})}function Un(e){let t=(0,Y.useRef)({running:!1,since:0,ask:null});(0,Y.useEffect)(()=>{if(!e)return;let n=t.current,r=e.status===`running`,i=r?n.running?n.since:Date.now():0,a=t=>{document.visibilityState!==`visible`&&!document.title.startsWith(`● `)&&(document.title=`● ${document.title}`),ce({title:e.wizard.title,body:t,tag:e.id})};r&&e.ask&&e.ask.id!==n.ask?a(A(`notify.needsYou`)):!r&&n.running&&Date.now()-n.since>8e3&&a(e.status===`failed`?A(`run.failed`):e.status===`done`?A(`notify.done`):A(`notify.next`)),t.current={running:r,since:i,ask:e.ask?.id??null}},[e]),(0,Y.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&document.title.startsWith(`● `)&&(document.title=document.title.slice(2))};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[])}function Wn({view:e,run:t,step:n}){let[r,i]=(0,Y.useState)({}),[a,o]=(0,Y.useState)({}),[s,c]=(0,Y.useState)(``),l=e.shown.filter(e=>e.output),[u,d]=(0,Y.useState)(l.length===1?l[0].step.id:null),[f,p]=(0,Y.useState)({}),m=(0,Y.useRef)(null),h=l.find(e=>e.step.id===u),g=h?.step.type===`generate`&&(h.output?.assets?.length??0)>1,_=()=>{h&&s.trim()&&t.regenerate(n.id,h.step.id,s.trim(),f[h.step.id])};return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsx)(In,{title:n.title,description:n.description}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e.shown.filter(e=>e.output).map(({step:t,output:s})=>{let c=!!n.edit&&t.type===`agent`&&t.output.format!==`json`;return(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.06em]`,children:t.title}),(0,X.jsx)(`div`,{className:`flex items-center`,children:c&&!a[t.id]?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>({...e,[t.id]:!0})),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-2 hover:bg-accent hover:text-ink coarse:h-11`,children:[(0,X.jsx)(nt,{className:`size-3.5`}),` `,A(`run.edit`)]}):null})]}),(0,X.jsx)(pe,{base:`/api/runs/${e.id}`,step:t,output:s,editable:c&&a[t.id],draft:r[t.id],onDraft:e=>i(n=>({...n,[t.id]:e})),picked:f[t.id],onPick:n.regenerate?e=>{d(t.id),p(n=>{let r=n[t.id]??[];return{...n,[t.id]:r.includes(e)?r.filter(t=>t!==e):[...r,e]}}),m.current?.focus()}:void 0,onSurfaceAction:n.regenerate?()=>{d(t.id),m.current?.focus()}:void 0})]},t.id)}),e.lists.map(t=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.06em]`,children:t.def.title}),t.def.check?(0,X.jsx)(pn,{runId:e.id,list:t}):(0,X.jsx)(un,{runId:e.id,list:t,editable:!0})]},t.def.id)),n.regenerate&&l.length?(0,X.jsxs)(P,{className:`p-3`,children:[l.length>1?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 pb-2`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:A(`run.feedbackTarget`)}),l.map(({step:e})=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>{d(e.id),m.current?.focus()},className:D(`inline-flex h-8 items-center rounded-full px-3 text-[0.8125rem] ring-1 transition coarse:h-11`,u===e.id?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:e.title},e.id))]}):null,(0,X.jsx)(O,{ref:m,minRows:2,maxRows:8,value:s,placeholder:A(`run.feedbackPlaceholder`),onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_())},className:`border-0 bg-transparent shadow-none focus:ring-0`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pt-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 text-[0.75rem] text-ink-3`,children:g?f[h.step.id]?.length?A(`run.regeneratePicked`,{n:[...f[h.step.id]].sort((e,t)=>e-t).map(e=>e+1).join(`, `)}):A(`run.regenerateAll`):!h&&s.trim()?A(`run.feedbackPick`):null}),(0,X.jsxs)(R,{size:`sm`,variant:`secondary`,busy:t.busy,disabled:!s.trim()||!h,onClick:_,children:[(0,X.jsx)(ie,{className:`size-3.5`}),` `,A(`run.regenerateGo`)]})]})]}):null]}),(0,X.jsx)(Bn,{view:e,run:t,sticky:!0,children:(0,X.jsxs)(R,{size:`lg`,busy:t.busy,onClick:()=>void t.accept(n.id,Object.keys(r).length?r:void 0),children:[A(`run.accept`),` `,(0,X.jsx)(B,{className:`size-4`})]})})]})}function Gn({view:e,run:t,step:n,onRestart:r}){let a=e.shown.filter(e=>e.output);return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-wrap items-center gap-x-4 gap-y-5`,children:[(0,X.jsx)(i,{kind:e.wizard.avatar,size:64}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,X.jsx)(`h1`,{className:`text-balance font-display font-semibold text-[1.75rem] leading-tight tracking-tight sm:text-[2rem]`,children:n.title}),n.message?(0,X.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-3`,children:n.message}):null]}),e.shown.some(e=>e.output)?(0,X.jsx)(`div`,{className:`max-sm:basis-full`,children:(0,X.jsx)(Dt,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null})}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.map(({step:t,output:n,formats:r,label:i})=>(0,X.jsxs)(P,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:i??t.title}),(0,X.jsx)(fe,{base:`/api/runs/${e.id}`,stepId:t.id,formats:r,title:i??t.title})]}),(0,X.jsx)(pe,{base:`/api/runs/${e.id}`,step:t,output:n}),n?.assets?.some(e=>e.ai)?(0,X.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:A(`ai.publish`)}):null]},t.id)),e.lists.map(t=>(0,X.jsxs)(P,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:t.label??t.def.title}),(0,X.jsx)(hn,{runId:e.id,list:t})]}),(0,X.jsx)(un,{runId:e.id,list:t,editable:!0})]},t.def.id))]}),(0,X.jsx)(Bn,{view:e,run:t,children:r?(0,X.jsxs)(R,{variant:`secondary`,onClick:r,children:[(0,X.jsx)(it,{className:`size-4`}),` `,A(`run.again`)]}):(0,X.jsx)(`span`,{})})]})}function Kn({view:e,run:t}){return(0,X.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-8 text-center`,children:[(0,X.jsx)(i,{kind:e.wizard.avatar,size:90}),(0,X.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[1.375rem]`,children:A(`run.failed`)}),(0,X.jsx)(`p`,{className:`mt-2 max-w-md text-[0.9375rem] text-ink-3`,children:(0,X.jsx)(M,{text:e.error??``})}),(0,X.jsxs)(`div`,{className:`mt-8 flex gap-3`,children:[e.canBack?(0,X.jsxs)(R,{variant:`ghost`,onClick:()=>void t.back(),children:[(0,X.jsx)(S,{className:`size-4`}),` `,A(`run.back`)]}):null,(0,X.jsxs)(R,{onClick:()=>void t.retry(),busy:t.busy,children:[(0,X.jsx)(it,{className:`size-4`}),` `,A(`run.retry`)]})]})]})}function qn({runId:e,compact:t,onRestart:n,onView:r,stickyProgress:i}){let a=Pn(e),{view:o}=a;(0,Y.useEffect)(()=>{r?.(o)},[o,r]),oe();let s=le(o?.status===`running`&&!o.ask);if(Un(o),a.notFound)return(0,X.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:A(`run.notFound`)});if(!o)return(0,X.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,X.jsx)(E,{})});let c=o.step,l=null;if(o.status===`running`&&o.ask)l=(0,X.jsx)(Ot,{runId:o.id,ask:o.ask},o.ask.id);else if(o.status===`running`)l=(0,X.jsx)(Hn,{view:o,compact:t,awake:s});else if(o.status===`failed`)l=(0,X.jsx)(Kn,{view:o,run:a});else if(o.status===`cancelled`)l=(0,X.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:A(`run.cancelled`)});else if(c?.type===`page`)l=(0,X.jsx)(zn,{view:o,run:a,step:c},c.id);else if(c?.type===`review`){let e=o.shown.map(e=>e.output?.at??``).join(`|`);l=(0,X.jsx)(Wn,{view:o,run:a,step:c},`${c.id}:${e}`)}else c?.type===`result`&&(l=(0,X.jsx)(Gn,{view:o,run:a,step:c,onRestart:n}));let u=c?.type===`review`&&o.status===`waiting_input`&&o.lists.some(e=>e.def.check);return(0,X.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[i?(0,X.jsx)(`div`,{className:`sticky top-0 z-10`,children:(0,X.jsx)(Fn,{view:o})}):(0,X.jsx)(Fn,{view:o}),(0,X.jsxs)(`div`,{className:D(`safe-x mx-auto w-full flex-1`,u?`max-w-[1240px] py-8`:t?`max-w-[620px] py-8`:`max-w-[640px] py-8 sm:py-16`),children:[l,a.error&&o.status!==`failed`?(0,X.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:a.error}):null,o.keeps&&o.status!==`running`?(0,X.jsx)(`div`,{className:`mt-10 flex justify-center`,children:(0,X.jsx)(_n,{runId:o.id})}):null]})]})}export{Pe as a,Xe as i,ct as n,be as o,nt as r,qn as t};
|