@engenty/wizards-runtime 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/apps/runtime/dist/cli/move-files.js +27 -11
  2. package/apps/runtime/dist/documents/parse.js +9 -0
  3. package/apps/runtime/dist/services/work-files.js +25 -1
  4. package/apps/web/dist/assets/{AboutDialog-0q4P80yv.js → AboutDialog-C9SnsGno.js} +1 -1
  5. package/apps/web/dist/assets/{CapabilitiesPage-BlZP8DYb.js → CapabilitiesPage-DvSSybt0.js} +1 -1
  6. package/apps/web/dist/assets/{ChangelogDialog-CDN7kMs1.js → ChangelogDialog-B28TK333.js} +1 -1
  7. package/apps/web/dist/assets/{EditorPage-CrMVsgUt.js → EditorPage-Duu8swX6.js} +1 -1
  8. package/apps/web/dist/assets/{NewWizardChannels-Czool7s1.js → NewWizardChannels-B12l2_Jh.js} +1 -1
  9. package/apps/web/dist/assets/{NewWizardPage-CfVe_4a2.js → NewWizardPage-B10K8vND.js} +1 -1
  10. package/apps/web/dist/assets/{PreviewPane-CQDKQO6z.js → PreviewPane-DhhQ06Ic.js} +1 -1
  11. package/apps/web/dist/assets/{PublicRunner-BDZNnlQw.js → PublicRunner-B8ncIxIP.js} +1 -1
  12. package/apps/web/dist/assets/{ReadOnly-B7MUySpC.js → ReadOnly-DwewuYi8.js} +1 -1
  13. package/apps/web/dist/assets/{SettingsPage-Bgurv3l2.js → SettingsPage-C-gGIJLJ.js} +2 -2
  14. package/apps/web/dist/assets/{SetupPage-C3km8vqv.js → SetupPage-CdsrHW-w.js} +1 -1
  15. package/apps/web/dist/assets/{SharePage-UwEJBIzq.js → SharePage-CZClatA_.js} +1 -1
  16. package/apps/web/dist/assets/{SpacePage-D9PXLSU_.js → SpacePage-CYhxcjj0.js} +1 -1
  17. package/apps/web/dist/assets/{UpdateCheck-C7I43zFZ.js → UpdateCheck-CLPUsKVT.js} +2 -2
  18. package/apps/web/dist/assets/{changelog-DwgWiSZb.js → changelog-y5oxYzPd.js} +1 -1
  19. package/apps/web/dist/assets/{connection-sign-in-hI3HXhq4.js → connection-sign-in-DECedzrs.js} +1 -1
  20. package/apps/web/dist/assets/{host-D5hNHbhF.js → host-CJdLkzfY.js} +4 -4
  21. package/apps/web/dist/assets/{index-CyBrvupM.js → index-CmonJZHC.js} +3 -3
  22. package/apps/web/dist/assets/{theme-CdX0marK.js → theme-D6KUBJnh.js} +1 -1
  23. package/apps/web/dist/index.html +3 -3
  24. package/package.json +1 -1
  25. package/plugin/.claude-plugin/plugin.json +1 -1
  26. package/plugin/plugin.json +1 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,Fn as i,gn as a,mn as o}from"./ui-BCfu5sia.js";import{i as s,u as c}from"./marked.esm-DQ7XA7AC.js";import{Mn as l,Nn as u}from"./host-D5hNHbhF.js";import{r as d}from"./volume-2-BqlBtCIJ.js";import{t as f}from"./list-checks-DaxmUPqK.js";import{t as p}from"./phone-B4uKDBFq.js";import{s as m}from"./i18n-BBzMbGoo.js";import{t as h}from"./runners-CUpBpSji.js";var g=e(t(),1),_=e(n(),1),v=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:f},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:u},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:r},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:a},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:p},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:i},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],y=[{id:`web`,label:`new.web`,icon:d},{id:`phone`,label:`new.phone`,icon:p},{id:`message`,label:`new.messages`,icon:l}],b=v.filter(e=>h.enabled.includes(e.id)).map(e=>e.id),x=e=>v.filter(t=>e.includes(t.id));function S(e){return e.length===b.length&&b.every(t=>e.includes(t))}function C(e){let t=x(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??h.default,enabled:n}}var w=e=>e.map(e=>m(e.label));function T(e){return v.find(t=>t.runner===e)}function E(e){return v.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function D(e){let t=x(e),n=y.flatMap(e=>{let n=w(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${m(e.label)}: ${n.join(`, `)}`]:[]});return`${m(`new.runsAs`)}: ${n.join(` · `)}`}function O(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function k({channel:e,className:t}){let n=e.icon;return n?(0,_.jsx)(n,{className:t??`size-4`}):(0,_.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function A(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`]);return v.filter(e=>t.has(e.runner))}function j({value:e,onChange:t,runners:n,without:r,disabled:i}){let a=A(n).filter(e=>!r?.includes(e.id)),s=t=>e.includes(t.id),l=n=>{i||s(n)&&e.length===1||t(s(n)?e.filter(e=>e!==n.id):[...e,n.id])},u=t=>{let n=y.find(e=>e.id===t),r=a.filter(e=>e.group===t);if(!(n&&r.length))return null;let u=n.icon;return(0,_.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,_.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,_.jsx)(u,{className:`size-3.5`}),` `,m(n.label)]}),r.map(t=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`label`,{className:o(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,s(t)&&`bg-paper-2`),children:[(0,_.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,_.jsx)(k,{channel:t})}),(0,_.jsx)(`span`,{className:`flex-1`,children:m(t.label)}),(0,_.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":m(t.label),checked:s(t),disabled:i,"aria-disabled":s(t)&&e.length===1,onChange:()=>l(t)}),(0,_.jsx)(`span`,{"aria-hidden":`true`,className:o(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,s(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:s(t)?(0,_.jsx)(c,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&s(t)?(0,_.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:m(`new.callHandoff`)}):null]},t.id))]})};return(0,_.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[u(`web`),(0,_.jsxs)(`div`,{className:`flex flex-col`,children:[u(`phone`),u(`message`)]})]})}function M({value:e,onChange:t,runners:n,className:r}){let[i,a]=(0,g.useState)(!1),[c,l]=(0,g.useState)(0),u=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!i)return;let e=e=>{u.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[i]);let d=A(n),f=y.filter(e=>d.some(t=>t.group===e.id)),p=t=>e.includes(t.id);return(0,_.jsxs)(`div`,{ref:u,className:o(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,_.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:m(`new.runsAs`)}),f.map(e=>{let t=w(d.filter(t=>t.group===e.id&&p(t))),n=e.icon;return(0,_.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":`${m(e.label)}: ${t.length?t.join(`, `):m(`new.off`)}`,onClick:e=>{let t=e.currentTarget;l(t.offsetLeft+t.offsetWidth/2),a(e=>!e)},className:o(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full font-medium text-[0.8125rem] transition coarse:h-11`,t.length?`bg-ink px-3 text-paper`:`w-9 text-ink-3 ring-1 ring-border hover:text-ink coarse:w-11`),children:[(0,_.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,_.jsx)(`span`,{className:`truncate`,children:O(t)}):null]},e.id)}),(0,_.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":m(`new.where`),onClick:e=>{let t=e.currentTarget;l(t.offsetLeft+t.offsetWidth/2),a(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,_.jsx)(s,{className:`size-4`})}),i?(0,_.jsxs)(`div`,{role:`dialog`,"aria-label":m(`new.where`),style:{transformOrigin:`${c}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,_.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:m(`new.where`)}),(0,_.jsx)(j,{value:e,onChange:t,runners:n})]}):null]})}export{D as a,S as c,M as i,C as l,k as n,T as o,j as r,E as s,y as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,Fn as i,gn as a,mn as o}from"./ui-BCfu5sia.js";import{i as s,u as c}from"./marked.esm-DQ7XA7AC.js";import{Mn as l,Nn as u}from"./host-CJdLkzfY.js";import{r as d}from"./volume-2-BqlBtCIJ.js";import{t as f}from"./list-checks-DaxmUPqK.js";import{t as p}from"./phone-B4uKDBFq.js";import{s as m}from"./i18n-BBzMbGoo.js";import{t as h}from"./runners-CUpBpSji.js";var g=e(t(),1),_=e(n(),1),v=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:f},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:u},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:r},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:a},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:p},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:i},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],y=[{id:`web`,label:`new.web`,icon:d},{id:`phone`,label:`new.phone`,icon:p},{id:`message`,label:`new.messages`,icon:l}],b=v.filter(e=>h.enabled.includes(e.id)).map(e=>e.id),x=e=>v.filter(t=>e.includes(t.id));function S(e){return e.length===b.length&&b.every(t=>e.includes(t))}function C(e){let t=x(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??h.default,enabled:n}}var w=e=>e.map(e=>m(e.label));function T(e){return v.find(t=>t.runner===e)}function E(e){return v.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function D(e){let t=x(e),n=y.flatMap(e=>{let n=w(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${m(e.label)}: ${n.join(`, `)}`]:[]});return`${m(`new.runsAs`)}: ${n.join(` · `)}`}function O(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function k({channel:e,className:t}){let n=e.icon;return n?(0,_.jsx)(n,{className:t??`size-4`}):(0,_.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function A(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`]);return v.filter(e=>t.has(e.runner))}function j({value:e,onChange:t,runners:n,without:r,disabled:i}){let a=A(n).filter(e=>!r?.includes(e.id)),s=t=>e.includes(t.id),l=n=>{i||s(n)&&e.length===1||t(s(n)?e.filter(e=>e!==n.id):[...e,n.id])},u=t=>{let n=y.find(e=>e.id===t),r=a.filter(e=>e.group===t);if(!(n&&r.length))return null;let u=n.icon;return(0,_.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,_.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,_.jsx)(u,{className:`size-3.5`}),` `,m(n.label)]}),r.map(t=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`label`,{className:o(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,s(t)&&`bg-paper-2`),children:[(0,_.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,_.jsx)(k,{channel:t})}),(0,_.jsx)(`span`,{className:`flex-1`,children:m(t.label)}),(0,_.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":m(t.label),checked:s(t),disabled:i,"aria-disabled":s(t)&&e.length===1,onChange:()=>l(t)}),(0,_.jsx)(`span`,{"aria-hidden":`true`,className:o(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,s(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:s(t)?(0,_.jsx)(c,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&s(t)?(0,_.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:m(`new.callHandoff`)}):null]},t.id))]})};return(0,_.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[u(`web`),(0,_.jsxs)(`div`,{className:`flex flex-col`,children:[u(`phone`),u(`message`)]})]})}function M({value:e,onChange:t,runners:n,className:r}){let[i,a]=(0,g.useState)(!1),[c,l]=(0,g.useState)(0),u=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!i)return;let e=e=>{u.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[i]);let d=A(n),f=y.filter(e=>d.some(t=>t.group===e.id)),p=t=>e.includes(t.id);return(0,_.jsxs)(`div`,{ref:u,className:o(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,_.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:m(`new.runsAs`)}),f.map(e=>{let t=w(d.filter(t=>t.group===e.id&&p(t))),n=e.icon;return(0,_.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":`${m(e.label)}: ${t.length?t.join(`, `):m(`new.off`)}`,onClick:e=>{let t=e.currentTarget;l(t.offsetLeft+t.offsetWidth/2),a(e=>!e)},className:o(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full font-medium text-[0.8125rem] transition coarse:h-11`,t.length?`bg-ink px-3 text-paper`:`w-9 text-ink-3 ring-1 ring-border hover:text-ink coarse:w-11`),children:[(0,_.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,_.jsx)(`span`,{className:`truncate`,children:O(t)}):null]},e.id)}),(0,_.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-label":m(`new.where`),onClick:e=>{let t=e.currentTarget;l(t.offsetLeft+t.offsetWidth/2),a(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,_.jsx)(s,{className:`size-4`})}),i?(0,_.jsxs)(`div`,{role:`dialog`,"aria-label":m(`new.where`),style:{transformOrigin:`${c}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,_.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:m(`new.where`)}),(0,_.jsx)(j,{value:e,onChange:t,runners:n})]}):null]})}export{D as a,S as c,M as i,C as l,k as n,T as o,j as r,E as s,y as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ar as r,Br as i,Gt as a,Q as o,Qt as s,X as c,c as l,cr as u,d,en as f,f as p,hr as m,l as h,mn as g,o as _,p as v,pn as y,pr as b,pt as x,sr as ee,tn as S,tr as te,u as ne}from"./ui-BCfu5sia.js";import{c as C,n as re,o as w,r as ie,s as ae,t as T}from"./Marketplace-Cty40VwG.js";import{t as E}from"./useMutation-1fV4Nnxq.js";import{i as oe}from"./marked.esm-DQ7XA7AC.js";import{an as se,fn as ce}from"./host-D5hNHbhF.js";import{S as le,h as ue,i as D,m as O,t as de,u as k}from"./session-CMQo8P-G.js";import{t as A}from"./upload-CAlHC232.js";import{n as j,s as M}from"./i18n-BBzMbGoo.js";import{a as fe,c as pe,i as me,l as he}from"./NewWizardChannels-Czool7s1.js";var N=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function P(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function F(e){return P(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function I(e){return e==null?``:Array.isArray(e)?e.map(I).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(I).filter(Boolean).join(` `):String(e)}function L(e,t){let n=t.map(([t,n])=>({text:I(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>F(e.text))}}function R(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function z(e,t){if(e===t)return 1;let n=0;for(let r of R(e))for(let i of R(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function B(e,t){return e.reduce((e,n)=>e+z(t,n),0)}function V(e,t,n=N){if(!t?.trim())return 0;let r=F(t);if(r.length===0)return 0;let i=L(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>B(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=F(n.text),i=B(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var H=new Set(F(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ar as r,Br as i,Gt as a,Q as o,Qt as s,X as c,c as l,cr as u,d,en as f,f as p,hr as m,l as h,mn as g,o as _,p as v,pn as y,pr as b,pt as x,sr as ee,tn as S,tr as te,u as ne}from"./ui-BCfu5sia.js";import{c as C,n as re,o as w,r as ie,s as ae,t as T}from"./Marketplace-Cty40VwG.js";import{t as E}from"./useMutation-1fV4Nnxq.js";import{i as oe}from"./marked.esm-DQ7XA7AC.js";import{an as se,fn as ce}from"./host-CJdLkzfY.js";import{S as le,h as ue,i as D,m as O,t as de,u as k}from"./session-CMQo8P-G.js";import{t as A}from"./upload-CAlHC232.js";import{n as j,s as M}from"./i18n-BBzMbGoo.js";import{a as fe,c as pe,i as me,l as he}from"./NewWizardChannels-B12l2_Jh.js";var N=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function P(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function F(e){return P(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function I(e){return e==null?``:Array.isArray(e)?e.map(I).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(I).filter(Boolean).join(` `):String(e)}function L(e,t){let n=t.map(([t,n])=>({text:I(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>F(e.text))}}function R(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function z(e,t){if(e===t)return 1;let n=0;for(let r of R(e))for(let i of R(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function B(e,t){return e.reduce((e,n)=>e+z(t,n),0)}function V(e,t,n=N){if(!t?.trim())return 0;let r=F(t);if(r.length===0)return 0;let i=L(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>B(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=F(n.text),i=B(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var H=new Set(F(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
2
2
  des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
3
3
  habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
4
4
  meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlockEditor-CUYFH_CU.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/react-dom-hf6EcyAr.js","assets/marked.esm-DQ7XA7AC.js","assets/code-DsnwzN1x.js","assets/list-checks-DaxmUPqK.js","assets/link-CPL8pB1P.js","assets/table-5B9G3oA6.js","assets/floating-ui.dom-pwdNGv4b.js","assets/upload-CAlHC232.js","assets/i18n-BBzMbGoo.js","assets/with-selector-CoMyWBAX.js","assets/w3c-keyname-BOAvb0qz.js","assets/BlockEditor-CtW6lw0y.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,An as i,Ar as a,Br as o,Cn as s,Et as c,G as l,Gt as u,H as d,In as f,It as p,Jn as m,K as h,Ln as g,On as _,Q as v,Qt as y,S as b,Tn as ee,X as x,Y as S,_n as C,an as w,bt as T,cn as E,dn as D,en as O,hr as k,i as te,in as A,ln as j,mn as M,nn as N,nr as P,pn as F,pr as ne,q as re,rn as I,tn as L,vn as ie,wt as R}from"./ui-BCfu5sia.js";import{t as z}from"./useMutation-1fV4Nnxq.js";import{t as B}from"./preload-helper-DpV6A1kQ.js";import{d as V,i as H,n as ae,r as oe,s as se,u as U}from"./marked.esm-DQ7XA7AC.js";import{An as ce,C as le,D as W,E as ue,Nt as G,On as de,Pt as fe,S as pe,T as me,Wn as he,X as ge,b as _e,ct as ve,dt as ye,fn as be,hn as xe,jn as Se,kn as K,on as q,w as Ce,x as we,y as Te}from"./host-D5hNHbhF.js";import{i as Ee}from"./volume-2-BqlBtCIJ.js";import{t as De}from"./eye-TJSuiHHO.js";import{b as Oe,d as ke,f as Ae,p as J,r as je,t as Y}from"./theme-CdX0marK.js";import{n as Me,t as Ne}from"./table-5B9G3oA6.js";import{N as Pe,P as Fe,S as Ie,h as Le}from"./session-CMQo8P-G.js";import{$ as Re,Q as ze,ft as Be,h as Ve,n as X,q as He,s as Z,ut as Ue}from"./i18n-BBzMbGoo.js";import{t as We}from"./code-editor-Ca5EAxmd.js";import{a as Ge,i as Ke,n as qe,o as Je,r as Ye}from"./index-CyBrvupM.js";import{t as Xe}from"./runners-CUpBpSji.js";var Ze={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`}]]};Ze.node;var Qe=V(Ze),$e={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};$e.node;var et=V($e),tt={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};tt.node;var nt=V(tt),rt={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};rt.node;var it=V(rt),at={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};at.node;var ot=V(at),Q=e(n(),1),$=e(t(),1);function st(e){return k({queryKey:[`share-targets`,e,X],queryFn:()=>v.get(`/api/studio/wizards/${e}/share-targets?lang=${X}`),enabled:!!e,staleTime:6e4})}var ct=(0,$.createContext)(null);function lt(e){return e.share?e.share.length?`own`:`off`:`default`}var ut=e=>e.byDefault&&e.usable;function dt(e,t){let n=lt(e),r=e.share??[],i=new Map,a=e=>{let t=i.get(e)??0;return i.set(e,t+1),`${e}#${t}`},o=e=>({key:a(e.id),target:e.id,info:e,index:null,option:null,on:!1,name:e.name});if(n==="default")return{mode:n,rows:t.filter(ut).map(e=>({...o(e),on:!0})),unset:t.filter(e=>e.byDefault&&!e.usable)};let s=r.map((e,n)=>{let r=t.find(t=>t.id===e.target);return{key:a(e.target),target:e.target,info:r,index:n,option:e,on:!0,name:e.label||r?.name||e.target}}),c=new Set(r.map(e=>e.target));return s.push(...t.filter(e=>ut(e)&&!c.has(e.id)).map(o)),{mode:n,rows:s,unset:t.filter(e=>e.byDefault&&!e.usable&&!c.has(e.id))}}function ft(e,t){let n=t.filter(e=>e.on&&e.info?.usable);return{visitors:n.filter(t=>!(e==="default"&&t.info?.agent)),onlyYou:e==="default"?n.filter(e=>e.info?.agent):[],broken:t.filter(e=>e.on&&!e.info?.usable)}}function pt(e){return e.filter(e=>ut(e)&&!e.agent).map(e=>({target:e.id}))}function mt(e,t){let n=lt(e);return n===`own`?e.share??[]:n==="default"?pt(t):[]}function ht(e,t,n,r){let i=mt(e,t);return r?[...i,{target:n.target}]:n.index===null?i.filter(e=>e.target!==n.target):i.filter((e,t)=>t!==n.index)}function gt(e,t,n,r){let i=mt(e,t),a=n.index??i.findIndex(e=>e.target===n.target);return a===-1?[...i,r]:i.map((e,t)=>t===a?r:e)}function _t(e,t,n){return[...mt(e,t),{target:n}]}function vt(e,t){let n=new Set(e.map(e=>e.target));return t.filter(e=>e.usable&&!e.byDefault&&!n.has(e.id))}function yt(e,t){let n=e.steps.slice(0,e.steps.indexOf(t));return[...n.flatMap(e=>e.type===`page`?e.fields.filter(e=>e.kind!==`image`&&e.kind!==`file`&&e.kind!==`signature`).map(e=>({ref:e.id,label:e.label})):[]),...n.flatMap(e=>e.type===`agent`&&e.output.format!==`json`?[{ref:`steps.${e.id}`,label:e.title}]:[]),{ref:`brand.name`,label:Z(`shareEditor.brandName`)}]}function bt(e){return new Intl.ListFormat(X===`en`?`en-GB`:X,{style:`long`,type:`conjunction`}).format(e)}var xt=(e,t)=>`${e}/${t}`;function St(e,t,n){if(e.endsWith(`.localhost`)){let r=n&&URL.canParse(n)?new URL(n).port:``;return`http://${e}${r?`:${r}`:``}/${t}`}return`https://${e}/${t}`}var Ct=e=>e.lang===`en`?`en`:e.form===`sie`?`de-sie`:`de-du`;function wt(e){return e===`en`?{lang:`en`}:{lang:`de`,form:e===`de-sie`?`sie`:`du`}}var Tt=class extends Error{theirs;constructor(e){super(`changed elsewhere`),this.theirs=e}},Et=(e,t)=>Date.parse(e)>Date.parse(t);function Dt(e){let t=(0,$.useRef)(e);t.current=e;let n=(0,$.useRef)(e.initial),r=(0,$.useRef)(null),i=(0,$.useRef)(null),[a,o]=(0,$.useState)(null),s=(0,$.useCallback)(e=>{n.current=e,t.current.surface.apply(e.value)},[]);(0,$.useEffect)(()=>W(e.kind,e.id,e=>{let a=e.view===void 0?null:t.current.fromView(e.view);a&&Et(a.at,n.current.at)&&(i.current?i.current=a:t.current.surface.hasUnsavedEdits()?r.current=a:s(a))}),[e.kind,e.id,s]),(0,$.useEffect)(()=>{if(a!==`merged`)return;let e=setTimeout(()=>o(null),6e3);return()=>clearTimeout(e)},[a]);let c=(0,$.useCallback)(async(e,a=1)=>{let s=t.current;if(i.current)return;let l=e,u=n.current.at,d=r.current;if(r.current=null,d){let t=s.merge(n.current.value,e,d.value);if(!t.clean){i.current=d,o(`conflict`);return}l=t.value,u=d.at,s.same(l,e)||s.surface.apply(l),o(`merged`)}try{let e=await s.send(l,u);n.current={value:l,at:e}}catch(e){if(e instanceof Tt&&a>0)return r.current=e.theirs,c(l,a-1);throw e}},[]);return{save:e=>c(e),notice:a,keepMine:(0,$.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&(n.current={value:n.current.value,at:e.at}),t.current.surface.saveNow()},[]),takeTheirs:(0,$.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&s(e)},[s])}}var Ot=12;function kt({spaceId:e,href:t,onOpen:n}){let r=k({queryKey:[`space-resolve`,e,t],queryFn:()=>v.get(`/api/studio/spaces/${e}/resolve?path=${encodeURIComponent(t)}`),retry:!1,staleTime:6e4}),i=r.data?.kind===`table`?r.data.id:null,a=k({queryKey:x.table(i??``),queryFn:()=>v.get(`/api/studio/tables/${i}`),enabled:!!i});if(r.isError||r.data&&!i)return(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:Z(`blocks.tableGone`)});if(!a.data)return(0,Q.jsx)(j,{className:`size-4 text-ink-3`});let{columns:o,rows:s,title:c}=a.data,l=s.length-Ot;return(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border-soft text-[0.8125rem]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i&&n?.(`t:${i}`),className:`flex w-full items-center gap-2 border-border-soft border-b bg-paper-2 px-3 py-2 text-left font-medium text-ink-2 hover:text-ink`,children:[(0,Q.jsx)(Ne,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c}),(0,Q.jsx)(`span`,{className:`shrink-0 font-normal text-ink-3`,children:Z(`blocks.tableFrom`)})]}),(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:o.map(e=>(0,Q.jsx)(`th`,{className:`border-border-soft border-b px-3 py-1.5 font-medium text-ink-3`,style:e.type===`number`?{textAlign:`right`}:void 0,children:e.name},e.id))})}),(0,Q.jsx)(`tbody`,{children:s.slice(0,Ot).map(e=>(0,Q.jsx)(`tr`,{className:`border-border-soft border-b last:border-b-0`,children:o.map(t=>(0,Q.jsx)(`td`,{className:`px-3 py-1.5 text-ink-2 tabular-nums`,style:t.type===`number`?{textAlign:`right`}:void 0,children:p(t,e.cells[t.id],X)},t.id))},e.id))})]})}),l>0?(0,Q.jsx)(`p`,{className:`border-border-soft border-t px-3 py-1.5 text-ink-3`,children:Z(`blocks.moreRows`,{n:l})}):null]})}var At=(0,$.lazy)(()=>B(()=>import(`./BlockEditor-CUYFH_CU.js`).then(e=>({default:e.BlockEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function jt({page:e,onGone:t,onOpen:n}){let a=o(),[s,l]=(0,$.useState)(e.title),[f,p]=(0,$.useState)(e.markdown),g=be(`knowledgeTree`),[_,b]=(0,$.useState)(g||!e.markdown?`write`:`read`),[ee,C]=(0,$.useState)(!e.markdown.trim()),w=e.knowledge,T=Le().data?.user.id,[E,D]=(0,$.useState)(!1),[k,A]=(0,$.useState)(null);(0,$.useEffect)(()=>{if(!E)return;let e=setTimeout(()=>D(!1),1e4);return()=>clearTimeout(e)},[E,f,s]),ue(`page`,e.id,{state:E?`editing`:`viewing`,place:k?.id,placeLabel:k?.label});let N=pe(`page`,e.id,T,E?k?.id:null),P=le(`page`,e.id,T),F=P.filter(e=>e.place?.startsWith(`h:`)&&e.placeLabel).map(e=>({heading:e.placeLabel??``,color:_e(e.who),title:we(e)})),ne=(e,t)=>{let n=It(e,t);A(e=>e?.id===n?.id?e:n)},L=async()=>{await a.invalidateQueries({queryKey:x.spaceData(e.spaceId)}),await a.invalidateQueries({queryKey:x.knowledge(e.spaceId)})},ie=(0,$.useRef)(()=>{});(0,$.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),ie.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let R=h({title:s.trim()||e.title,markdown:f},e=>B.save(e));ie.current=R.saveNow;let B=Dt({kind:`page`,id:e.id,initial:{value:{title:e.title,markdown:e.markdown},at:e.updatedAt},fromView:e=>{let t=e;return{value:{title:t.title,markdown:t.markdown},at:t.updatedAt}},merge:(e,t,n)=>{let r=fe(e.markdown,t.markdown,n.markdown),i=t.title===n.title||n.title===e.title?t.title:t.title===e.title?n.title:null;return{value:{title:i??t.title,markdown:r.text},clean:r.clean&&i!==null}},same:(e,t)=>e.title===t.title&&e.markdown===t.markdown,surface:{apply:t=>{l(t.title),p(t.markdown),R.markSaved(t),a.setQueryData(x.page(e.id),e=>e&&{...e,...t})},hasUnsavedEdits:()=>R.pending(),saveNow:()=>R.saveNow()},send:async(t,n)=>{try{let{updatedAt:r}=await v.patch(`/api/studio/pages/${e.id}`,{...t,baseUpdatedAt:n});return a.setQueryData(x.page(e.id),e=>e&&{...e,...t,updatedAt:r}),t.title!==e.title&&await L(),r}catch(e){let t=e instanceof u&&e.status===409?e.body?.page:null;throw t?new Tt({value:{title:t.title,markdown:t.markdown},at:t.updatedAt}):e}}}),V=z({mutationFn:()=>v.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await L(),t()}}),ae=z({mutationFn:()=>v.post(`/api/studio/spaces/${e.spaceId}/pages`,{title:Z(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await L(),n?.(`p:${e}`)}}),U=z({mutationFn:()=>v.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>a.invalidateQueries({queryKey:x.page(e.id)})}),ce=async t=>{let r=n?await Bt(e.spaceId,t):null;r&&n?.(r)},W=e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);t&&Lt.test(t)&&n&&(e.preventDefault(),ce(t))},G=ye(e.spaceId),de=S(e.spaceId),me=G.data?.items,xe=(me??[]).filter(t=>t.id!==e.id).map(e=>({title:e.title,path:e.path,kind:Z(zt[e.kind])})),Se=g&&!!w?.origin?.startsWith(`source:`)&&!w?.kept,K=e.readOnly||Se,q=!K&&(!g||ee),Ce=()=>{R.saveNow(),b(`write`),C(!1)},Ee=(me??[]).map(e=>({path:e.path,title:e.title,kind:e.kind===`file`&&Rt.test(e.path)?`image`:e.kind})),De=new Map((de.data?.files??[]).filter(e=>e.kind===`document`).map(e=>[`files/${e.name.replace(/[/\\]/g,`-`)}`.toLowerCase(),e.id])),Oe=t=>{let n=Mt.exec(t);if(n)return d(e.spaceId,n[1]);let r=De.get(t.toLowerCase());return r?d(e.spaceId,r):t},ke=re(e.spaceId,K),Ae=async e=>{let t=await ke.upload(`document`,e),n=(await G.refetch()).data?.items??[];return await de.refetch(),t.map(e=>{let t=n.find(t=>t.key===`f:${e.id}`),r=t?.path??`files/${e.name.replace(/[/\\]/g,`-`)}`,i=(t?.title??e.name).replace(/[[\]]/g,`\\$&`);return`${e.mime.startsWith(`image/`)?`!`:``}[${i}](${r})`}).join(`
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,An as i,Ar as a,Br as o,Cn as s,Et as c,G as l,Gt as u,H as d,In as f,It as p,Jn as m,K as h,Ln as g,On as _,Q as v,Qt as y,S as b,Tn as ee,X as x,Y as S,_n as C,an as w,bt as T,cn as E,dn as D,en as O,hr as k,i as te,in as A,ln as j,mn as M,nn as N,nr as P,pn as F,pr as ne,q as re,rn as I,tn as L,vn as ie,wt as R}from"./ui-BCfu5sia.js";import{t as z}from"./useMutation-1fV4Nnxq.js";import{t as B}from"./preload-helper-DpV6A1kQ.js";import{d as V,i as H,n as ae,r as oe,s as se,u as U}from"./marked.esm-DQ7XA7AC.js";import{An as ce,C as le,D as W,E as ue,Nt as G,On as de,Pt as fe,S as pe,T as me,Wn as he,X as ge,b as _e,ct as ve,dt as ye,fn as be,hn as xe,jn as Se,kn as K,on as q,w as Ce,x as we,y as Te}from"./host-CJdLkzfY.js";import{i as Ee}from"./volume-2-BqlBtCIJ.js";import{t as De}from"./eye-TJSuiHHO.js";import{b as Oe,d as ke,f as Ae,p as J,r as je,t as Y}from"./theme-D6KUBJnh.js";import{n as Me,t as Ne}from"./table-5B9G3oA6.js";import{N as Pe,P as Fe,S as Ie,h as Le}from"./session-CMQo8P-G.js";import{$ as Re,Q as ze,ft as Be,h as Ve,n as X,q as He,s as Z,ut as Ue}from"./i18n-BBzMbGoo.js";import{t as We}from"./code-editor-Ca5EAxmd.js";import{a as Ge,i as Ke,n as qe,o as Je,r as Ye}from"./index-CmonJZHC.js";import{t as Xe}from"./runners-CUpBpSji.js";var Ze={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`}]]};Ze.node;var Qe=V(Ze),$e={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};$e.node;var et=V($e),tt={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};tt.node;var nt=V(tt),rt={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};rt.node;var it=V(rt),at={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};at.node;var ot=V(at),Q=e(n(),1),$=e(t(),1);function st(e){return k({queryKey:[`share-targets`,e,X],queryFn:()=>v.get(`/api/studio/wizards/${e}/share-targets?lang=${X}`),enabled:!!e,staleTime:6e4})}var ct=(0,$.createContext)(null);function lt(e){return e.share?e.share.length?`own`:`off`:`default`}var ut=e=>e.byDefault&&e.usable;function dt(e,t){let n=lt(e),r=e.share??[],i=new Map,a=e=>{let t=i.get(e)??0;return i.set(e,t+1),`${e}#${t}`},o=e=>({key:a(e.id),target:e.id,info:e,index:null,option:null,on:!1,name:e.name});if(n==="default")return{mode:n,rows:t.filter(ut).map(e=>({...o(e),on:!0})),unset:t.filter(e=>e.byDefault&&!e.usable)};let s=r.map((e,n)=>{let r=t.find(t=>t.id===e.target);return{key:a(e.target),target:e.target,info:r,index:n,option:e,on:!0,name:e.label||r?.name||e.target}}),c=new Set(r.map(e=>e.target));return s.push(...t.filter(e=>ut(e)&&!c.has(e.id)).map(o)),{mode:n,rows:s,unset:t.filter(e=>e.byDefault&&!e.usable&&!c.has(e.id))}}function ft(e,t){let n=t.filter(e=>e.on&&e.info?.usable);return{visitors:n.filter(t=>!(e==="default"&&t.info?.agent)),onlyYou:e==="default"?n.filter(e=>e.info?.agent):[],broken:t.filter(e=>e.on&&!e.info?.usable)}}function pt(e){return e.filter(e=>ut(e)&&!e.agent).map(e=>({target:e.id}))}function mt(e,t){let n=lt(e);return n===`own`?e.share??[]:n==="default"?pt(t):[]}function ht(e,t,n,r){let i=mt(e,t);return r?[...i,{target:n.target}]:n.index===null?i.filter(e=>e.target!==n.target):i.filter((e,t)=>t!==n.index)}function gt(e,t,n,r){let i=mt(e,t),a=n.index??i.findIndex(e=>e.target===n.target);return a===-1?[...i,r]:i.map((e,t)=>t===a?r:e)}function _t(e,t,n){return[...mt(e,t),{target:n}]}function vt(e,t){let n=new Set(e.map(e=>e.target));return t.filter(e=>e.usable&&!e.byDefault&&!n.has(e.id))}function yt(e,t){let n=e.steps.slice(0,e.steps.indexOf(t));return[...n.flatMap(e=>e.type===`page`?e.fields.filter(e=>e.kind!==`image`&&e.kind!==`file`&&e.kind!==`signature`).map(e=>({ref:e.id,label:e.label})):[]),...n.flatMap(e=>e.type===`agent`&&e.output.format!==`json`?[{ref:`steps.${e.id}`,label:e.title}]:[]),{ref:`brand.name`,label:Z(`shareEditor.brandName`)}]}function bt(e){return new Intl.ListFormat(X===`en`?`en-GB`:X,{style:`long`,type:`conjunction`}).format(e)}var xt=(e,t)=>`${e}/${t}`;function St(e,t,n){if(e.endsWith(`.localhost`)){let r=n&&URL.canParse(n)?new URL(n).port:``;return`http://${e}${r?`:${r}`:``}/${t}`}return`https://${e}/${t}`}var Ct=e=>e.lang===`en`?`en`:e.form===`sie`?`de-sie`:`de-du`;function wt(e){return e===`en`?{lang:`en`}:{lang:`de`,form:e===`de-sie`?`sie`:`du`}}var Tt=class extends Error{theirs;constructor(e){super(`changed elsewhere`),this.theirs=e}},Et=(e,t)=>Date.parse(e)>Date.parse(t);function Dt(e){let t=(0,$.useRef)(e);t.current=e;let n=(0,$.useRef)(e.initial),r=(0,$.useRef)(null),i=(0,$.useRef)(null),[a,o]=(0,$.useState)(null),s=(0,$.useCallback)(e=>{n.current=e,t.current.surface.apply(e.value)},[]);(0,$.useEffect)(()=>W(e.kind,e.id,e=>{let a=e.view===void 0?null:t.current.fromView(e.view);a&&Et(a.at,n.current.at)&&(i.current?i.current=a:t.current.surface.hasUnsavedEdits()?r.current=a:s(a))}),[e.kind,e.id,s]),(0,$.useEffect)(()=>{if(a!==`merged`)return;let e=setTimeout(()=>o(null),6e3);return()=>clearTimeout(e)},[a]);let c=(0,$.useCallback)(async(e,a=1)=>{let s=t.current;if(i.current)return;let l=e,u=n.current.at,d=r.current;if(r.current=null,d){let t=s.merge(n.current.value,e,d.value);if(!t.clean){i.current=d,o(`conflict`);return}l=t.value,u=d.at,s.same(l,e)||s.surface.apply(l),o(`merged`)}try{let e=await s.send(l,u);n.current={value:l,at:e}}catch(e){if(e instanceof Tt&&a>0)return r.current=e.theirs,c(l,a-1);throw e}},[]);return{save:e=>c(e),notice:a,keepMine:(0,$.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&(n.current={value:n.current.value,at:e.at}),t.current.surface.saveNow()},[]),takeTheirs:(0,$.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&s(e)},[s])}}var Ot=12;function kt({spaceId:e,href:t,onOpen:n}){let r=k({queryKey:[`space-resolve`,e,t],queryFn:()=>v.get(`/api/studio/spaces/${e}/resolve?path=${encodeURIComponent(t)}`),retry:!1,staleTime:6e4}),i=r.data?.kind===`table`?r.data.id:null,a=k({queryKey:x.table(i??``),queryFn:()=>v.get(`/api/studio/tables/${i}`),enabled:!!i});if(r.isError||r.data&&!i)return(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:Z(`blocks.tableGone`)});if(!a.data)return(0,Q.jsx)(j,{className:`size-4 text-ink-3`});let{columns:o,rows:s,title:c}=a.data,l=s.length-Ot;return(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border-soft text-[0.8125rem]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i&&n?.(`t:${i}`),className:`flex w-full items-center gap-2 border-border-soft border-b bg-paper-2 px-3 py-2 text-left font-medium text-ink-2 hover:text-ink`,children:[(0,Q.jsx)(Ne,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c}),(0,Q.jsx)(`span`,{className:`shrink-0 font-normal text-ink-3`,children:Z(`blocks.tableFrom`)})]}),(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:o.map(e=>(0,Q.jsx)(`th`,{className:`border-border-soft border-b px-3 py-1.5 font-medium text-ink-3`,style:e.type===`number`?{textAlign:`right`}:void 0,children:e.name},e.id))})}),(0,Q.jsx)(`tbody`,{children:s.slice(0,Ot).map(e=>(0,Q.jsx)(`tr`,{className:`border-border-soft border-b last:border-b-0`,children:o.map(t=>(0,Q.jsx)(`td`,{className:`px-3 py-1.5 text-ink-2 tabular-nums`,style:t.type===`number`?{textAlign:`right`}:void 0,children:p(t,e.cells[t.id],X)},t.id))},e.id))})]})}),l>0?(0,Q.jsx)(`p`,{className:`border-border-soft border-t px-3 py-1.5 text-ink-3`,children:Z(`blocks.moreRows`,{n:l})}):null]})}var At=(0,$.lazy)(()=>B(()=>import(`./BlockEditor-CUYFH_CU.js`).then(e=>({default:e.BlockEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function jt({page:e,onGone:t,onOpen:n}){let a=o(),[s,l]=(0,$.useState)(e.title),[f,p]=(0,$.useState)(e.markdown),g=be(`knowledgeTree`),[_,b]=(0,$.useState)(g||!e.markdown?`write`:`read`),[ee,C]=(0,$.useState)(!e.markdown.trim()),w=e.knowledge,T=Le().data?.user.id,[E,D]=(0,$.useState)(!1),[k,A]=(0,$.useState)(null);(0,$.useEffect)(()=>{if(!E)return;let e=setTimeout(()=>D(!1),1e4);return()=>clearTimeout(e)},[E,f,s]),ue(`page`,e.id,{state:E?`editing`:`viewing`,place:k?.id,placeLabel:k?.label});let N=pe(`page`,e.id,T,E?k?.id:null),P=le(`page`,e.id,T),F=P.filter(e=>e.place?.startsWith(`h:`)&&e.placeLabel).map(e=>({heading:e.placeLabel??``,color:_e(e.who),title:we(e)})),ne=(e,t)=>{let n=It(e,t);A(e=>e?.id===n?.id?e:n)},L=async()=>{await a.invalidateQueries({queryKey:x.spaceData(e.spaceId)}),await a.invalidateQueries({queryKey:x.knowledge(e.spaceId)})},ie=(0,$.useRef)(()=>{});(0,$.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),ie.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let R=h({title:s.trim()||e.title,markdown:f},e=>B.save(e));ie.current=R.saveNow;let B=Dt({kind:`page`,id:e.id,initial:{value:{title:e.title,markdown:e.markdown},at:e.updatedAt},fromView:e=>{let t=e;return{value:{title:t.title,markdown:t.markdown},at:t.updatedAt}},merge:(e,t,n)=>{let r=fe(e.markdown,t.markdown,n.markdown),i=t.title===n.title||n.title===e.title?t.title:t.title===e.title?n.title:null;return{value:{title:i??t.title,markdown:r.text},clean:r.clean&&i!==null}},same:(e,t)=>e.title===t.title&&e.markdown===t.markdown,surface:{apply:t=>{l(t.title),p(t.markdown),R.markSaved(t),a.setQueryData(x.page(e.id),e=>e&&{...e,...t})},hasUnsavedEdits:()=>R.pending(),saveNow:()=>R.saveNow()},send:async(t,n)=>{try{let{updatedAt:r}=await v.patch(`/api/studio/pages/${e.id}`,{...t,baseUpdatedAt:n});return a.setQueryData(x.page(e.id),e=>e&&{...e,...t,updatedAt:r}),t.title!==e.title&&await L(),r}catch(e){let t=e instanceof u&&e.status===409?e.body?.page:null;throw t?new Tt({value:{title:t.title,markdown:t.markdown},at:t.updatedAt}):e}}}),V=z({mutationFn:()=>v.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await L(),t()}}),ae=z({mutationFn:()=>v.post(`/api/studio/spaces/${e.spaceId}/pages`,{title:Z(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await L(),n?.(`p:${e}`)}}),U=z({mutationFn:()=>v.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>a.invalidateQueries({queryKey:x.page(e.id)})}),ce=async t=>{let r=n?await Bt(e.spaceId,t):null;r&&n?.(r)},W=e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);t&&Lt.test(t)&&n&&(e.preventDefault(),ce(t))},G=ye(e.spaceId),de=S(e.spaceId),me=G.data?.items,xe=(me??[]).filter(t=>t.id!==e.id).map(e=>({title:e.title,path:e.path,kind:Z(zt[e.kind])})),Se=g&&!!w?.origin?.startsWith(`source:`)&&!w?.kept,K=e.readOnly||Se,q=!K&&(!g||ee),Ce=()=>{R.saveNow(),b(`write`),C(!1)},Ee=(me??[]).map(e=>({path:e.path,title:e.title,kind:e.kind===`file`&&Rt.test(e.path)?`image`:e.kind})),De=new Map((de.data?.files??[]).filter(e=>e.kind===`document`).map(e=>[`files/${e.name.replace(/[/\\]/g,`-`)}`.toLowerCase(),e.id])),Oe=t=>{let n=Mt.exec(t);if(n)return d(e.spaceId,n[1]);let r=De.get(t.toLowerCase());return r?d(e.spaceId,r):t},ke=re(e.spaceId,K),Ae=async e=>{let t=await ke.upload(`document`,e),n=(await G.refetch()).data?.items??[];return await de.refetch(),t.map(e=>{let t=n.find(t=>t.key===`f:${e.id}`),r=t?.path??`files/${e.name.replace(/[/\\]/g,`-`)}`,i=(t?.title??e.name).replace(/[[\]]/g,`\\$&`);return`${e.mime.startsWith(`image/`)?`!`:``}[${i}](${r})`}).join(`
3
3
 
4
4
  `)},J=w?.file&&(w.file.mime===`application/pdf`||w.file.mime.startsWith(`image/`))?w.file:null,je=g&&!q&&_===`write`?`div`:r,Y=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":_===e,onClick:()=>b(e),className:M(`rounded-full px-3 py-1 text-[0.8125rem] transition`,_===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[w?.parents.length&&n?(0,Q.jsx)(`nav`,{className:`-mb-2 flex flex-wrap items-center gap-1 px-1 text-[0.75rem] text-ink-4`,children:w.parents.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,Q.jsx)(m,{className:`size-3`})]},e.id))}):null,(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`input`,{value:s,disabled:!q,maxLength:200,onChange:e=>{l(e.target.value),D(!0)},"aria-label":Z(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-[1.75rem] leading-tight tracking-tight outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),B.notice===`merged`?(0,Q.jsx)(O,{icon:(0,Q.jsx)(he,{className:`size-3`}),children:P[0]?Z(`editor.mergedWith`,{name:P[0].name}):Z(`editor.merged`)}):null,(0,Q.jsx)(Te,{kind:`page`,item:e.id,me:T}),B.notice===`conflict`||K?null:(0,Q.jsx)(Vt,{state:R.state,error:R.error,onRetry:R.saveNow}),q?(0,Q.jsx)(I,{label:Z(`data.deletePage`),onClick:async()=>await te(Z(`data.confirmDelete`,{title:e.title}))&&V.mutate(),className:`hover:text-rose`,children:(0,Q.jsx)(oe,{className:`size-4`})}):null,g&&!K?q?(0,Q.jsx)(y,{size:`sm`,onClick:Ce,title:Z(`editor.saveHint`),children:Z(`settings.save`)}):(0,Q.jsxs)(y,{size:`sm`,variant:`secondary`,onClick:()=>C(!0),children:[(0,Q.jsx)(i,{className:`size-4`}),` `,Z(`editor.edit`)]}):null]}),N&&B.notice!==`conflict`?(0,Q.jsx)(`p`,{className:`-mt-1 px-1 text-[0.8125rem] text-ink-3`,children:Z(`presence.alsoHere`,{name:N.name})}):null,B.notice===`conflict`?(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-2 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem]`,children:[(0,Q.jsx)(he,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:Z(`data.changedElsewhere`)}),(0,Q.jsx)(y,{size:`sm`,variant:`ghost`,onClick:B.takeTheirs,children:Z(`data.takeTheirs`)}),(0,Q.jsx)(y,{size:`sm`,onClick:B.keepMine,children:Z(`data.keepMine`)})]}):null,Se?(0,Q.jsx)(ge,{spaceId:e.spaceId,itemKey:`p:${e.id}`,label:w?.originLabel??``,readOnly:e.readOnly}):null,w?(0,Q.jsx)(ve,{spaceId:e.spaceId,itemKey:`p:${e.id}`,has:w.categories,originLabel:Se?null:w.originLabel,kept:w.kept,review:w.review,file:J?null:w.file,readOnly:!q,onReviewed:()=>U.mutate()}):null,(0,Q.jsxs)(je,{className:`flex flex-col`,children:[!q&&!J||g&&_===`write`&&q?null:g?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[Y(`write`,Z(q?`data.write`:`data.preview`)),q?Y(`markdown`,Z(`blocks.markdown`)):null,J?Y(`original`,Z(`know.original`)):null,(0,Q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:_===`original`&&J?J.name:_===`markdown`?Z(`data.markdownHint`):q?Z(`blocks.hint`):null})]}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[K?null:Y(`write`,Z(`data.write`)),Y(`read`,Z(`data.preview`)),J?Y(`original`,Z(`know.original`)):null,(0,Q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:_===`original`&&J?J.name:Z(`data.markdownHint`)})]}),_===`original`&&J?J.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:d(e.spaceId,J.id),title:J.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:d(e.spaceId,J.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):g&&_===`write`?(0,Q.jsx)($.Suspense,{fallback:(0,Q.jsx)(j,{className:`m-5 size-4 text-ink-3`}),children:(0,Q.jsx)(At,{text:f,onChange:e=>{p(e),D(!0)},readOnly:!q,targets:Ee,self:w?.path,onFiles:q?Ae:void 0,resolve:Oe,onOpen:e=>void ce(e),embed:{test:e=>e.startsWith(`tables/`),render:t=>(0,Q.jsx)(kt,{spaceId:e.spaceId,href:t,onOpen:n})},onHeading:e=>A(t=>t?.id===e?.id?t:e),marks:F,ariaLabel:e.title,tools:q?(0,Q.jsxs)(Q.Fragment,{children:[Y(`write`,Z(`data.write`)),Y(`markdown`,Z(`blocks.markdown`)),J?Y(`original`,Z(`know.original`)):null]}):void 0})}):(_===`write`||_===`markdown`)&&q?(0,Q.jsx)(We,{value:f,onChange:e=>{p(e),D(!0)},onCaret:ne,marks:F,links:xe,onLink:e=>void ce(e),language:`markdown`,ariaLabel:e.title,placeholder:Z(`data.pageEmpty`),className:`min-h-[50vh] [&_.cm-editor]:min-h-[50vh] sm:[&_.cm-content]:py-5 sm:[&_.cm-line]:px-5`}):(0,Q.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:W,children:f.trim()?(0,Q.jsx)(c,{text:f.replace(/asset:\/\/([A-Za-z0-9_-]{6,40})/g,(t,n)=>d(e.spaceId,n))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Z(`data.pageEmpty`)})})]}),R.state===`error`&&R.error?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:R.error}):null,(0,Q.jsx)(Pt,{spaceId:e.spaceId,markdown:f}),w&&n&&(w.children.length||q)?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:w.children.length?Z(`know.subPages`):null}),q?(0,Q.jsxs)(y,{variant:`ghost`,size:`sm`,busy:ae.isPending,onClick:()=>ae.mutate(),children:[(0,Q.jsx)(H,{className:`size-4`}),` `,Z(`know.addSub`)]}):null]}),w.children.length?(0,Q.jsx)(r,{className:`flex flex-col p-1.5`,children:w.children.map(e=>(0,Q.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,Q.jsx)(se,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}var Mt=/^asset:\/\/([A-Za-z0-9_-]{6,40})$/;function Nt(e){let t=new Map;for(let n of e.matchAll(/!\[([^\]\n]*)\]\(asset:\/\/([A-Za-z0-9_-]{6,40})\)/g))t.has(n[2])||t.set(n[2],n[1].trim());return[...t].map(([e,t])=>({id:e,alt:t}))}function Pt({spaceId:e,markdown:t}){let n=o(),r=be(`knowledgeMedia`),[i,a]=(0,$.useState)([]),s=z({mutationFn:t=>v.post(`/api/studio/spaces/${e}/files/${t}/brand`,{}),onSuccess:async(t,r)=>{a(e=>[...e,r]),await n.invalidateQueries({queryKey:x.files(e)})}}),c=Nt(t);return!r||!c.length?null:(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,Q.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:Z(`know.pictures`)}),(0,Q.jsx)(`div`,{className:`flex gap-3 overflow-x-auto px-1 pb-1`,children:c.map(t=>(0,Q.jsxs)(`figure`,{className:`flex w-40 shrink-0 flex-col gap-1.5`,children:[(0,Q.jsx)(`a`,{href:d(e,t.id),target:`_blank`,rel:`noreferrer`,children:(0,Q.jsx)(`img`,{src:l(e,t.id),alt:t.alt,loading:`lazy`,className:`aspect-[4/3] w-full rounded-lg bg-paper-2 object-cover`})}),t.alt?(0,Q.jsx)(`figcaption`,{className:`truncate text-[0.75rem] text-ink-3`,children:t.alt}):null,i.includes(t.id)?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-moss`,children:[(0,Q.jsx)(U,{className:`size-3.5`}),` `,Z(`know.inBrand`)]}):(0,Q.jsxs)(y,{variant:`ghost`,size:`sm`,busy:s.isPending&&s.variables===t.id,onClick:()=>s.mutate(t.id),className:`self-start`,children:[(0,Q.jsx)(K,{className:`size-3.5`}),` `,Z(`know.toBrand`)]})]},t.id))}),s.error?(0,Q.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-rose`,children:s.error.message}):null]})}function Ft({pageId:e,onGone:t,onOpen:n}){let r=k({queryKey:x.page(e),queryFn:()=>v.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{kind:`page`,item:e}),(0,Q.jsx)(jt,{page:r.data,onGone:t,onOpen:n},r.data.id)]}):r.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function It(e,t){let n=e.slice(0,t).split(`
5
5
  `);for(let e=n.length-1;e>=0;e--){let t=/^#{1,6}\s+(.+?)\s*#*$/.exec(n[e]??``);if(t?.[1])return{id:`h:${t[1].toLowerCase()}`,label:t[1]}}return null}var Lt=/^(pages|tables|files)\//,Rt=/\.(png|jpe?g|gif|webp|avif|svg)$/i,zt={page:`know.kind.page`,table:`know.kind.table`,file:`know.kind.file`};async function Bt(e,t){if(!Lt.test(t))return null;let n=await v.get(`/api/studio/spaces/${e}/resolve?path=${encodeURIComponent(t)}`).catch(()=>null);return n?`${n.kind[0]}:${n.id}`:null}function Vt({state:e,error:t,onRetry:n}){return e===`error`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-rose`,title:t??``,children:[Z(`editor.notSaved`),(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`underline hover:no-underline`,children:Z(`editor.retrySave`)})]}):e===`idle`?null:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,title:Z(`editor.saveHint`),children:[e===`saving`?(0,Q.jsx)(j,{className:`size-3`}):(0,Q.jsx)(U,{className:`size-3.5 text-moss`}),Z(e===`saving`?`editor.saving`:`settings.saved`)]})}function Ht(e){return k({queryKey:x.spaceData(e),queryFn:()=>v.get(`/api/studio/spaces/${e}/data`),enabled:!!e})}function Ut(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:Z(`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 Wt={table:ie,page:se};function Gt({kind:e,spaceId:t,data:n,onClose:r,onMade:i}){let a=o(),[s,c]=(0,$.useState)(``),[l,u]=(0,$.useState)(``),d=z({mutationFn:()=>v.post(`/api/studio/spaces/${t}/${e===`table`?`tables`:`pages`}`,{title:s.trim(),wizardId:l||null}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:x.spaceData(t)}),i(`${e===`table`?`t`:`p`}:${n}`),c(``),u(``)}});return(0,Q.jsx)(L,{open:e!==null,onClose:r,title:Z(e===`table`?`data.newTable`:`data.newPage`),children:(0,Q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&d.mutate()},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(w,{children:Z(`data.title`)}),(0,Q.jsx)(A,{"data-autofocus":!0,value:s,maxLength:120,onChange:e=>c(e.target.value)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(w,{children:Z(`data.owner`)}),(0,Q.jsx)(E,{value:l,onChange:u,options:[{value:``,label:Z(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),d.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(y,{variant:`ghost`,onClick:r,children:Z(`common.cancel`)}),(0,Q.jsx)(y,{type:`submit`,busy:d.isPending,disabled:!s.trim(),children:Z(`data.create`)})]})]})})}function Kt({spaceId:e,data:t,readOnly:n,onOpen:i}){let[a,o]=(0,$.useState)(null);q(n?null:{icon:H,label:Z(`data.newTable`),run:()=>o(`table`)});let s=Ut(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,Q.jsxs)(b,{title:Z(`space.data`),hint:Z(`data.hint`),plain:!0,action:n?null:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(y,{variant:`secondary`,size:`sm`,onClick:()=>o(`table`),children:[(0,Q.jsx)(H,{className:`size-4`}),` `,Z(`data.table`)]}),(0,Q.jsxs)(y,{variant:`secondary`,size:`sm`,onClick:()=>o(`page`),children:[(0,Q.jsx)(H,{className:`size-4`}),` `,Z(`data.page`)]})]}),children:[s.length?(0,Q.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,Q.jsx)(r,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Wt[e.kind];return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${Z(`data.rows`,{n:e.rows??0})} · `:``,l.format(new Date(c.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,Q.jsx)(r,{children:(0,Q.jsx)(N,{children:Z(`data.empty`)})}),(0,Q.jsx)(Gt,{kind:a,spaceId:e,data:t,onClose:()=>o(null),onMade:e=>{o(null),i(e)}})]})}function qt(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 Jt={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},Yt=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Xt(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Jt[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}var Zt=`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 Qt({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Xt(e,t),[o,s]=(0,$.useState)(a),c=(0,$.useRef)(a);(0,$.useEffect)(()=>{s(e=>e===c.current?a:e),c.current=a},[a]);let l=(t=o)=>{t!==a&&i(Be(e,t))};if(e.type===`boolean`)return(0,Q.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,Q.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,Q.jsx)(`button`,{type:`button`,"aria-label":Z(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,Q.jsx)(ae,{className:`size-3`})})]},e)),n?null:(0,Q.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,Q.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,Q.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:Zt,children:[(0,Q.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,Q.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>l(),"aria-label":e.name,className:M(Zt,`field-sizing-content max-h-40 resize-none`)});let u=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,Q.jsx)(`input`,{type:u,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&l(t.target.value)},onBlur:()=>e.type!==`date`&&l(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:M(Zt,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function $t(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?Z(`data.unit.${e.format.inputUnit}`):null}function en(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(`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Kt as r,Q as i,Qt as a,at as o,cr as s,fr as c,hr as l,ln as u,mn as d,mr as f,mt as p,pr as m,pt as h,rn as g,tr as _,vt as v,yt as ee}from"./ui-BCfu5sia.js";import{d as y,n as b}from"./marked.esm-DQ7XA7AC.js";import{c as te}from"./read-aloud-Bfp9_bUY.js";import{_ as x,b as S,d as ne,f as re,g as C,h as w,m as T,n as ie,p as ae,v as E,y as D}from"./theme-CdX0marK.js";import{C as O,S as k,k as oe,x as A}from"./session-CMQo8P-G.js";import{a as j,l as M,q as N,s as P}from"./i18n-BBzMbGoo.js";import{n as F}from"./LangSwitch-Dkd0FBIH.js";var se={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`}]]};se.node;var ce=y(se),I={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`]};I.node;var le=y(I),L=e(t(),1);function ue(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var R=ue(),de=R?new URLSearchParams(window.location.search).get(`page`):null,z=new URLSearchParams(window.location.search).get(`theme`),B=z?`?theme=${encodeURIComponent(z)}`:``,V=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),fe=()=>V(`close`);function pe(e){(0,L.useEffect)(()=>{if(R===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>V(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(R===`modal`||R===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&V(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var H=e(n(),1),U=`wizards.runner.translate`,W=new Set;function me(){try{return localStorage.getItem(U)===`on`}catch{return!1}}function he(e){try{localStorage.setItem(U,e?`on`:`off`)}catch{}for(let e of W)e()}function ge(){return(0,L.useSyncExternalStore)(e=>(W.add(e),()=>W.delete(e)),me)}function _e(e){let t=ge(),[n]=(0,L.useState)(()=>M()),r=e?.lang??`en`,a=e?.translatable&&n&&n!==r?n:null,o=a&&t?a:r,s=e?.token,c=l({queryKey:[`public-translation`,s,o],enabled:!!(s&&o!==r),queryFn:()=>i.post(`/api/public/wizards/${s}/translation${B}`,{lang:o}),staleTime:1/0,retry:!1}),u=l({queryKey:[`public-texts`,s,o],enabled:!(!s||N(o)),queryFn:()=>i.get(`/api/public/wizards/${s}/texts/${o}`),staleTime:1/0,retry:!1}),d=!N(o),f=o===r||c.data&&(!d||u.data),p=o!==r&&(c.isError||d&&u.isError),m=f&&!p?o:r,h=(0,L.useMemo)(()=>!N(m)&&u.data?.lang===m?{lang:u.data.lang,runner:u.data.runner,notes:u.data.notes}:null,[m,u.data]);if((0,L.useEffect)(()=>{e&&j(m,h)},[e,m,h]),(0,L.useEffect)(()=>()=>j(null),[]),!e)return null;let g=m!==r&&c.data?c.data:null;return{own:r,other:a,shown:m,wizard:g??e,translating:o!==r&&!f&&!p,failed:!!p,translated:!!g,machine:g?.translation?.machine??!1,pick:e=>he(e!==r)}}function G({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,H.jsx)(F,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function K({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,H.jsx)(`p`,{className:d(`text-ink-3`,n),children:P(`translation.failed`)}):e.translated?(0,H.jsxs)(`p`,{className:d(`text-ink-3`,n),children:[e.machine?(0,H.jsxs)(H.Fragment,{children:[P(`translation.machine`),` · `]}):null,(0,H.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:P(`translation.showOriginal`)})]}):null}function ve(e,t){let n=(0,L.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,L.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,i.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ye(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=h(`/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 q=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,J=q||/Android/.test(navigator.userAgent);function be(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.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||J&&!e&&!q)return null;let i=/Mac/.test(navigator.platform),a=P(J?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,H.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{J&&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:[J?(0,H.jsx)(le,{className:`size-4`}):(0,H.jsx)(ce,{className:`size-4`}),P(J?`install.add`:`install.bookmark`)]}),n?(0,H.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function Y({brand:e,toggle:t=!0,start:n}){return(0,H.jsx)(`header`,{className:`safe-top`,children:(0,H.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,H.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,H.jsx)(`img`,{src:h(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,H.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,H.jsx)(`div`,{className:`absolute right-3`,children:(0,H.jsx)(O,{})}):null]})})}function xe({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.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,H.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function Se({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||p||R?null:(0,H.jsxs)(`a`,{href:v(`${window.location.origin}${o}/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,H.jsx)(S,{className:`size-4`}),` `,P(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=()=>c().state?.elsewhere===!0,Ce=p&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=R===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=m(),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(null),d=(()=>{try{return localStorage.getItem(X(e.token))}catch{return null}})();return{busy:a,error:s,captcha:l,setCaptcha:u,start:async()=>{o(!0),c(null);try{let{runId:a}=await i.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:R!==null,origin:de??void 0,lang:n??void 0});try{localStorage.setItem(X(e.token),a)}catch{}r(`${t}/${a}`,{replace:Ce})}catch(e){c(e.message),o(!1)}},resume:d?()=>r(`${t}/${d}`):null}}function we({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=Z(),d=Ce&&e.available&&!e.turnstileSiteKey,f=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{d&&!f.current&&(f.current=!0,s())},[d]),d&&!r?(0,H.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,H.jsx)(u,{})}):(0,H.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:[l?(0,H.jsx)(`p`,{className:`mb-6 rounded-xl bg-paper-2 px-5 py-3 text-[0.875rem] text-ink-2`,children:P(`run.elsewhere`)}):null,(0,H.jsx)(k,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,H.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,H.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(K,{page:t})}),e.available?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(a,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[P(`run.start`),` `,(0,H.jsx)(_,{className:`size-4`})]}),e.turnstileSiteKey?(0,H.jsx)(xe,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,H.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:P(`run.resume`)}):null,(0,H.jsx)(Te,{wizard:e,current:`steps`}),R||p?null:(0,H.jsx)(be,{}),(0,H.jsx)(Se,{token:e.token})]}):(0,H.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??P(`run.unavailable`)}),r?(0,H.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Te({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,H.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,H.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:P(`run.orAs`,{label:e.label})},e.id))}):null}function Ee({wizard:e,page:t}){let n=D();return(0,H.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,H.jsx)(`span`,{className:d(n?.speaking&&`animate-breathe`),children:(0,H.jsx)(k,{kind:e.avatar,costume:e.costume,size:38})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,H.jsx)(K,{page:t,small:!0})]}),e.brand.logoUrl&&R!==`popout`?(0,H.jsx)(`img`,{src:h(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,H.jsx)(G,{page:t,tone:`surface`}),R?null:(0,H.jsx)(O,{}),R===`popout`?(0,H.jsx)(g,{label:P(`common.close`),onClick:fe,children:(0,H.jsx)(b,{className:`size-5`})}):null]})})}function De({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),d=Z(),f=[];return d&&f.push({key:`elsewhere`,who:`bot`,node:P(`run.elsewhere`)}),f.push({key:`hello`,who:`bot`,node:t.description||t.title}),e!==`chat`&&f.push({key:e,who:`bot`,node:P(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??P(`run.unavailable`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(E(`start`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(C,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[P(`run.start`),` `,(0,H.jsx)(_,{className:`size-4`})]}),u?(0,H.jsx)(C,{onClick:u,children:P(`run.resume`)}):null,t.turnstileSiteKey?(0,H.jsx)(xe,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,H.jsxs)(T,{header:r,footer:i,children:[(0,H.jsx)(x,{avatar:t.avatar,costume:t.costume,lines:f}),(0,H.jsx)(w,{})]})}function Oe({className:e}){return(0,H.jsx)(`footer`,{className:d(`text-center text-ink-4`,e),children:(0,H.jsx)(`a`,{href:`${o}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:P(`run.madeWith`).replace(`engenty wizards`,A.name)})})}function ke({chat:e=!1,steps:t=!1,talk:n=!1,video:c=!1}){let{token:h,runId:g}=f(),_=m(),v=l({queryKey:[`public`,h,B],queryFn:()=>i.get(`/api/public/wizards/${h}${B}`),retry:(e,t)=>r(t)&&e<3}),y=v.data?.runners??[],b=!v.data||y.some(e=>e.id===`talk`),x=!v.data||y.some(e=>e.id===`video`),S=!v.data||y.some(e=>e.id===`chat`)||n&&b||c&&x,C=y[0]?.id,w=e||R===`popout`||!t&&!g&&S&&(C===`chat`||C===`talk`||C===`video`),T=c&&x||!t&&!e&&!n&&C===`video`,E=!T&&(n&&b||!t&&!e&&C===`talk`),D=T?`video`:E?`talk`:`chat`,O=_e(v.data);ve(g,O),ie(v.data?.brand.theme),oe(v.data?.avatar),ye(h,v.data?.title),pe(w);let j=O?.wizard.title??v.data?.title;(0,L.useEffect)(()=>{j&&(document.title=j)},[j]);let M=(0,L.useCallback)(e=>{try{h&&localStorage.getItem(X(h))===g&&localStorage.removeItem(X(h))}catch{}_(e,{replace:!0,state:{elsewhere:!0}})},[_,h,g]);if((0,L.useEffect)(()=>{h&&g&&ee(`run`,{token:h,runId:g})},[h,g]),v.isLoading)return(0,H.jsx)(`div`,{className:d(`flex items-center justify-center text-ink-4`,Q),children:(0,H.jsx)(u,{})});if(e&&v.data&&!S||n&&v.data&&!b||c&&v.data&&!x)return(0,H.jsx)(s,{to:`/w/${h}`,replace:!0});if(!v.data){let e=r(v.error);return(0,H.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,H.jsx)(k,{kind:`pebble`,size:80}),(0,H.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:P(e?`common.offline`:`run.notFound`)}),e?(0,H.jsx)(a,{variant:`secondary`,onClick:()=>void v.refetch(),children:P(`common.retry`)}):null]})}let N=O?.wizard??v.data,F=O?.translating?(0,H.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,H.jsx)(u,{}),(0,H.jsx)(`p`,{className:`text-[0.875rem]`,children:P(`translation.working`)})]}):null;if(w){let e=(0,H.jsx)(Ee,{wizard:N,page:O}),t=p?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(Oe,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,H.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,H.jsx)(ne,{effects:v.data.brand.theme.effects}),R||p?null:(0,H.jsx)(te,{}),F??(g?(0,H.jsx)(ae,{runId:g,talk:E,call:T?`video`:E?`audio`:!1,onRestart:()=>_(`/w/${h}/${D}`),onNotFound:()=>M(`/w/${h}/${D}`),header:T||E?void 0:e,footer:t}):(0,H.jsx)(De,{wizard:N,page:O,header:e,footer:t,door:D}))]})}return(0,H.jsxs)(`div`,{className:d(`wizard-page flex flex-col`,Q),children:[(0,H.jsx)(ne,{effects:v.data.brand.theme.effects}),R||p?null:(0,H.jsx)(te,{}),R===`inline`||p?null:(0,H.jsx)(Y,{brand:v.data.brand,toggle:!R,start:(0,H.jsx)(G,{page:O})}),R===`inline`||p?(0,H.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,H.jsx)(G,{page:O,tone:`surface`})}):null,g&&(O?.translated||O?.failed)?(0,H.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,H.jsx)(K,{page:O})}):null,(0,H.jsx)(`div`,{className:`flex-1`,children:F??(g?(0,H.jsx)(re,{runId:g,onRestart:()=>_(`/w/${h}`),onNotFound:()=>M(`/w/${h}`)}):(0,H.jsx)(we,{wizard:N,page:O}))}),p?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,H.jsx)(`a`,{href:`${o}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:P(`run.madeWith`).replace(`engenty wizards`,A.name)})})]})}export{Y as BrandHeader,ke as PublicRunner};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Kt as r,Q as i,Qt as a,at as o,cr as s,fr as c,hr as l,ln as u,mn as d,mr as f,mt as p,pr as m,pt as h,rn as g,tr as _,vt as v,yt as ee}from"./ui-BCfu5sia.js";import{d as y,n as b}from"./marked.esm-DQ7XA7AC.js";import{c as te}from"./read-aloud-Bfp9_bUY.js";import{_ as x,b as S,d as ne,f as re,g as C,h as w,m as T,n as ie,p as ae,v as E,y as D}from"./theme-D6KUBJnh.js";import{C as O,S as k,k as oe,x as A}from"./session-CMQo8P-G.js";import{a as j,l as M,q as N,s as P}from"./i18n-BBzMbGoo.js";import{n as F}from"./LangSwitch-Dkd0FBIH.js";var se={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`}]]};se.node;var ce=y(se),I={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`]};I.node;var le=y(I),L=e(t(),1);function ue(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var R=ue(),de=R?new URLSearchParams(window.location.search).get(`page`):null,z=new URLSearchParams(window.location.search).get(`theme`),B=z?`?theme=${encodeURIComponent(z)}`:``,V=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),fe=()=>V(`close`);function pe(e){(0,L.useEffect)(()=>{if(R===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>V(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(R===`modal`||R===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&V(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var H=e(n(),1),U=`wizards.runner.translate`,W=new Set;function me(){try{return localStorage.getItem(U)===`on`}catch{return!1}}function he(e){try{localStorage.setItem(U,e?`on`:`off`)}catch{}for(let e of W)e()}function ge(){return(0,L.useSyncExternalStore)(e=>(W.add(e),()=>W.delete(e)),me)}function _e(e){let t=ge(),[n]=(0,L.useState)(()=>M()),r=e?.lang??`en`,a=e?.translatable&&n&&n!==r?n:null,o=a&&t?a:r,s=e?.token,c=l({queryKey:[`public-translation`,s,o],enabled:!!(s&&o!==r),queryFn:()=>i.post(`/api/public/wizards/${s}/translation${B}`,{lang:o}),staleTime:1/0,retry:!1}),u=l({queryKey:[`public-texts`,s,o],enabled:!(!s||N(o)),queryFn:()=>i.get(`/api/public/wizards/${s}/texts/${o}`),staleTime:1/0,retry:!1}),d=!N(o),f=o===r||c.data&&(!d||u.data),p=o!==r&&(c.isError||d&&u.isError),m=f&&!p?o:r,h=(0,L.useMemo)(()=>!N(m)&&u.data?.lang===m?{lang:u.data.lang,runner:u.data.runner,notes:u.data.notes}:null,[m,u.data]);if((0,L.useEffect)(()=>{e&&j(m,h)},[e,m,h]),(0,L.useEffect)(()=>()=>j(null),[]),!e)return null;let g=m!==r&&c.data?c.data:null;return{own:r,other:a,shown:m,wizard:g??e,translating:o!==r&&!f&&!p,failed:!!p,translated:!!g,machine:g?.translation?.machine??!1,pick:e=>he(e!==r)}}function G({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,H.jsx)(F,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function K({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,H.jsx)(`p`,{className:d(`text-ink-3`,n),children:P(`translation.failed`)}):e.translated?(0,H.jsxs)(`p`,{className:d(`text-ink-3`,n),children:[e.machine?(0,H.jsxs)(H.Fragment,{children:[P(`translation.machine`),` · `]}):null,(0,H.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:P(`translation.showOriginal`)})]}):null}function ve(e,t){let n=(0,L.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,L.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,i.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ye(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=h(`/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 q=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,J=q||/Android/.test(navigator.userAgent);function be(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.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||J&&!e&&!q)return null;let i=/Mac/.test(navigator.platform),a=P(J?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,H.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{J&&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:[J?(0,H.jsx)(le,{className:`size-4`}):(0,H.jsx)(ce,{className:`size-4`}),P(J?`install.add`:`install.bookmark`)]}),n?(0,H.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function Y({brand:e,toggle:t=!0,start:n}){return(0,H.jsx)(`header`,{className:`safe-top`,children:(0,H.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,H.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,H.jsx)(`img`,{src:h(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,H.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,H.jsx)(`div`,{className:`absolute right-3`,children:(0,H.jsx)(O,{})}):null]})})}function xe({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.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,H.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function Se({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||p||R?null:(0,H.jsxs)(`a`,{href:v(`${window.location.origin}${o}/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,H.jsx)(S,{className:`size-4`}),` `,P(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=()=>c().state?.elsewhere===!0,Ce=p&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=R===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=m(),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(null),d=(()=>{try{return localStorage.getItem(X(e.token))}catch{return null}})();return{busy:a,error:s,captcha:l,setCaptcha:u,start:async()=>{o(!0),c(null);try{let{runId:a}=await i.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:R!==null,origin:de??void 0,lang:n??void 0});try{localStorage.setItem(X(e.token),a)}catch{}r(`${t}/${a}`,{replace:Ce})}catch(e){c(e.message),o(!1)}},resume:d?()=>r(`${t}/${d}`):null}}function we({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=Z(),d=Ce&&e.available&&!e.turnstileSiteKey,f=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{d&&!f.current&&(f.current=!0,s())},[d]),d&&!r?(0,H.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,H.jsx)(u,{})}):(0,H.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:[l?(0,H.jsx)(`p`,{className:`mb-6 rounded-xl bg-paper-2 px-5 py-3 text-[0.875rem] text-ink-2`,children:P(`run.elsewhere`)}):null,(0,H.jsx)(k,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,H.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,H.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(K,{page:t})}),e.available?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(a,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[P(`run.start`),` `,(0,H.jsx)(_,{className:`size-4`})]}),e.turnstileSiteKey?(0,H.jsx)(xe,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,H.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:P(`run.resume`)}):null,(0,H.jsx)(Te,{wizard:e,current:`steps`}),R||p?null:(0,H.jsx)(be,{}),(0,H.jsx)(Se,{token:e.token})]}):(0,H.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??P(`run.unavailable`)}),r?(0,H.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Te({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,H.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,H.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:P(`run.orAs`,{label:e.label})},e.id))}):null}function Ee({wizard:e,page:t}){let n=D();return(0,H.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,H.jsx)(`span`,{className:d(n?.speaking&&`animate-breathe`),children:(0,H.jsx)(k,{kind:e.avatar,costume:e.costume,size:38})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,H.jsx)(K,{page:t,small:!0})]}),e.brand.logoUrl&&R!==`popout`?(0,H.jsx)(`img`,{src:h(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,H.jsx)(G,{page:t,tone:`surface`}),R?null:(0,H.jsx)(O,{}),R===`popout`?(0,H.jsx)(g,{label:P(`common.close`),onClick:fe,children:(0,H.jsx)(b,{className:`size-5`})}):null]})})}function De({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),d=Z(),f=[];return d&&f.push({key:`elsewhere`,who:`bot`,node:P(`run.elsewhere`)}),f.push({key:`hello`,who:`bot`,node:t.description||t.title}),e!==`chat`&&f.push({key:e,who:`bot`,node:P(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??P(`run.unavailable`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(E(`start`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(C,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[P(`run.start`),` `,(0,H.jsx)(_,{className:`size-4`})]}),u?(0,H.jsx)(C,{onClick:u,children:P(`run.resume`)}):null,t.turnstileSiteKey?(0,H.jsx)(xe,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,H.jsxs)(T,{header:r,footer:i,children:[(0,H.jsx)(x,{avatar:t.avatar,costume:t.costume,lines:f}),(0,H.jsx)(w,{})]})}function Oe({className:e}){return(0,H.jsx)(`footer`,{className:d(`text-center text-ink-4`,e),children:(0,H.jsx)(`a`,{href:`${o}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:P(`run.madeWith`).replace(`engenty wizards`,A.name)})})}function ke({chat:e=!1,steps:t=!1,talk:n=!1,video:c=!1}){let{token:h,runId:g}=f(),_=m(),v=l({queryKey:[`public`,h,B],queryFn:()=>i.get(`/api/public/wizards/${h}${B}`),retry:(e,t)=>r(t)&&e<3}),y=v.data?.runners??[],b=!v.data||y.some(e=>e.id===`talk`),x=!v.data||y.some(e=>e.id===`video`),S=!v.data||y.some(e=>e.id===`chat`)||n&&b||c&&x,C=y[0]?.id,w=e||R===`popout`||!t&&!g&&S&&(C===`chat`||C===`talk`||C===`video`),T=c&&x||!t&&!e&&!n&&C===`video`,E=!T&&(n&&b||!t&&!e&&C===`talk`),D=T?`video`:E?`talk`:`chat`,O=_e(v.data);ve(g,O),ie(v.data?.brand.theme),oe(v.data?.avatar),ye(h,v.data?.title),pe(w);let j=O?.wizard.title??v.data?.title;(0,L.useEffect)(()=>{j&&(document.title=j)},[j]);let M=(0,L.useCallback)(e=>{try{h&&localStorage.getItem(X(h))===g&&localStorage.removeItem(X(h))}catch{}_(e,{replace:!0,state:{elsewhere:!0}})},[_,h,g]);if((0,L.useEffect)(()=>{h&&g&&ee(`run`,{token:h,runId:g})},[h,g]),v.isLoading)return(0,H.jsx)(`div`,{className:d(`flex items-center justify-center text-ink-4`,Q),children:(0,H.jsx)(u,{})});if(e&&v.data&&!S||n&&v.data&&!b||c&&v.data&&!x)return(0,H.jsx)(s,{to:`/w/${h}`,replace:!0});if(!v.data){let e=r(v.error);return(0,H.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,H.jsx)(k,{kind:`pebble`,size:80}),(0,H.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:P(e?`common.offline`:`run.notFound`)}),e?(0,H.jsx)(a,{variant:`secondary`,onClick:()=>void v.refetch(),children:P(`common.retry`)}):null]})}let N=O?.wizard??v.data,F=O?.translating?(0,H.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,H.jsx)(u,{}),(0,H.jsx)(`p`,{className:`text-[0.875rem]`,children:P(`translation.working`)})]}):null;if(w){let e=(0,H.jsx)(Ee,{wizard:N,page:O}),t=p?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(Oe,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,H.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,H.jsx)(ne,{effects:v.data.brand.theme.effects}),R||p?null:(0,H.jsx)(te,{}),F??(g?(0,H.jsx)(ae,{runId:g,talk:E,call:T?`video`:E?`audio`:!1,onRestart:()=>_(`/w/${h}/${D}`),onNotFound:()=>M(`/w/${h}/${D}`),header:T||E?void 0:e,footer:t}):(0,H.jsx)(De,{wizard:N,page:O,header:e,footer:t,door:D}))]})}return(0,H.jsxs)(`div`,{className:d(`wizard-page flex flex-col`,Q),children:[(0,H.jsx)(ne,{effects:v.data.brand.theme.effects}),R||p?null:(0,H.jsx)(te,{}),R===`inline`||p?null:(0,H.jsx)(Y,{brand:v.data.brand,toggle:!R,start:(0,H.jsx)(G,{page:O})}),R===`inline`||p?(0,H.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,H.jsx)(G,{page:O,tone:`surface`})}):null,g&&(O?.translated||O?.failed)?(0,H.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,H.jsx)(K,{page:O})}):null,(0,H.jsx)(`div`,{className:`flex-1`,children:F??(g?(0,H.jsx)(re,{runId:g,onRestart:()=>_(`/w/${h}`),onNotFound:()=>M(`/w/${h}`)}):(0,H.jsx)(we,{wizard:N,page:O}))}),p?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,H.jsx)(`a`,{href:`${o}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:P(`run.madeWith`).replace(`engenty wizards`,A.name)})})]})}export{Y as BrandHeader,ke as PublicRunner};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{d as n}from"./marked.esm-DQ7XA7AC.js";import{Rn as r}from"./host-D5hNHbhF.js";import{s as i}from"./i18n-BBzMbGoo.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return i(e.origin===`local`?`readonly.space`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{d as n}from"./marked.esm-DQ7XA7AC.js";import{Rn as r}from"./host-CJdLkzfY.js";import{s as i}from"./i18n-BBzMbGoo.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return i(e.origin===`local`?`readonly.space`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};