@engenty/wizards-runtime 0.11.11 → 0.11.13

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 (58) hide show
  1. package/apps/runtime/dist/app.js +2 -1
  2. package/apps/runtime/dist/auth/impersonation.js +33 -0
  3. package/apps/runtime/dist/auth/index.js +44 -7
  4. package/apps/runtime/dist/db/control-schema.js +3 -0
  5. package/apps/runtime/dist/db/migrations/control/0013_session_impersonated_by.sql +2 -0
  6. package/apps/runtime/dist/db/migrations/control/meta/0013_snapshot.json +621 -0
  7. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  8. package/apps/runtime/dist/db/migrations/tenant/0026_run_impersonated_by.sql +1 -0
  9. package/apps/runtime/dist/db/migrations/tenant/meta/0026_snapshot.json +3966 -0
  10. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  11. package/apps/runtime/dist/db/schema.js +2 -0
  12. package/apps/runtime/dist/engine/runner.js +2 -0
  13. package/apps/runtime/dist/manage.js +14 -0
  14. package/apps/runtime/dist/routes/runs.js +18 -7
  15. package/apps/runtime/dist/routes/studio.js +4 -0
  16. package/apps/runtime/dist/services/runs.js +1 -0
  17. package/apps/runtime/dist/sharing/index.js +1 -0
  18. package/apps/runtime/dist/texts.js +2 -0
  19. package/apps/web/dist/assets/{AboutDialog-BxPhyBQC.js → AboutDialog-pMHleH_y.js} +1 -1
  20. package/apps/web/dist/assets/{ChangelogDialog-BLst4UYt.js → ChangelogDialog-Cxwkcjdy.js} +1 -1
  21. package/apps/web/dist/assets/{CodeEditor-ydfkafOX.js → CodeEditor-BijLsoJX.js} +1 -1
  22. package/apps/web/dist/assets/{EditorPage-tBrPWV2R.js → EditorPage-v7cpENx3.js} +3 -3
  23. package/apps/web/dist/assets/{FlowPreview-CPEK110v.js → FlowPreview-Wjt28MdG.js} +1 -1
  24. package/apps/web/dist/assets/{Harness-Cm1i8s2W.js → Harness-TUpGhGX5.js} +1 -1
  25. package/apps/web/dist/assets/{Marketplace-_IfcAgYO.js → Marketplace-CpjRqTvn.js} +2 -2
  26. package/apps/web/dist/assets/{NewWizardChannels-45GyOXYL.js → NewWizardChannels-CelW1MGq.js} +1 -1
  27. package/apps/web/dist/assets/{NewWizardPage-XFt4YtU3.js → NewWizardPage-Coswm2WX.js} +1 -1
  28. package/apps/web/dist/assets/{OnboardingPage-Mko1anYV.js → OnboardingPage-C9XM_VXs.js} +1 -1
  29. package/apps/web/dist/assets/{PreviewPane-Dw9WG3lP.js → PreviewPane-BUwlltqA.js} +5 -5
  30. package/apps/web/dist/assets/{ProjectPage-DRnVIWQs.js → ProjectPage-Cw7hdXO6.js} +1 -1
  31. package/apps/web/dist/assets/PublicRunner-B5RGNs07.js +1 -0
  32. package/apps/web/dist/assets/{ReadOnly-CBNxkYUt.js → ReadOnly-DZMZPM-W.js} +1 -1
  33. package/apps/web/dist/assets/SettingsPage-CfL1e3Vs.js +2 -0
  34. package/apps/web/dist/assets/SetupPage-BRPenYa-.js +1 -0
  35. package/apps/web/dist/assets/{SharePage-gjQQ0CtP.js → SharePage-DF8LO8-K.js} +1 -1
  36. package/apps/web/dist/assets/changelog-CO6ysfQg.js +1 -0
  37. package/apps/web/dist/assets/{i18n-BX8GnEZT.js → i18n-BYeH2Dmi.js} +1 -1
  38. package/apps/web/dist/assets/index-Bl7qOZv0.js +34 -0
  39. package/apps/web/dist/assets/{phone-Dd7IVbpJ.js → phone-JGS60FQU.js} +1 -1
  40. package/apps/web/dist/assets/{runners-XifDCQG3.js → runners-CwTP03YR.js} +1 -1
  41. package/apps/web/dist/assets/{session-BwtsznZF.js → session-CngLvd02.js} +1 -1
  42. package/apps/web/dist/assets/{settings-menu-CS-fXrFW.js → settings-menu-C0yo5q3t.js} +1 -1
  43. package/apps/web/dist/assets/{theme-DFKNqmEY.js → theme-D6QLPvJL.js} +2 -2
  44. package/apps/web/dist/assets/{ui-D719V_Yj.js → ui-Bhp_a_44.js} +1 -1
  45. package/apps/web/dist/assets/{upload-CYTDCrYd.js → upload-DPLDQsRT.js} +1 -1
  46. package/apps/web/dist/assets/{useMutation-CVVmJvyz.js → useMutation-Cmn8b7tT.js} +1 -1
  47. package/apps/web/dist/assets/{volume-2-Do0dsjv2.js → volume-2-DGqbhyPO.js} +1 -1
  48. package/apps/web/dist/assets/{wrench-C5syJD9J.js → wrench-Dr19y-10.js} +1 -1
  49. package/apps/web/dist/index.html +7 -7
  50. package/apps/web/dist/mcp/flow.html +1 -1
  51. package/package.json +1 -1
  52. package/plugin/.claude-plugin/plugin.json +1 -1
  53. package/plugin/plugin.json +1 -1
  54. package/apps/web/dist/assets/PublicRunner-C3NwpZKh.js +0 -1
  55. package/apps/web/dist/assets/SettingsPage-DBckGRCS.js +0 -2
  56. package/apps/web/dist/assets/SetupPage-BJxbmS68.js +0 -1
  57. package/apps/web/dist/assets/changelog-C67l3TZ1.js +0 -1
  58. package/apps/web/dist/assets/index-BtNnNYyZ.js +0 -34
@@ -1 +1 @@
1
- import{Xn as e}from"./ui-D719V_Yj.js";var t={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};t.node;var n=e(t);export{n as t};
1
+ import{Xn as e}from"./ui-Bhp_a_44.js";var t={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{S as e}from"./i18n-BX8GnEZT.js";var t=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`motion-graphics`,`surface`];[...e],[...t];var n={default:`steps`,enabled:[`steps`,`chat`]};export{n as t};
1
+ import{S as e}from"./i18n-BYeH2Dmi.js";var t=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`motion-graphics`,`surface`];[...e],[...t];var n={default:`steps`,enabled:[`steps`,`chat`]};export{n as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fluffy-engenty-o_lu9icd.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/engenty-CNjaZCVM.js"])))=>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{$ as r,G as i,Lt as a,Mr as o,W as s,Xn as c,Yt as l,ot as u,sr as d,tt as f}from"./ui-D719V_Yj.js";import{t as ee}from"./preload-helper-DpV6A1kQ.js";import{c as te,s as ne,t as p}from"./engenty-CNjaZCVM.js";import"./logo-CGNoptDg.js";import{O as re,i as m,o as ie,s as h}from"./i18n-BX8GnEZT.js";var g={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};g.node;var _=c(g),v={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};v.node;var y=c(v),b=e(t(),1),x=`wizards.theme`,S=new Set,C=window.matchMedia(`(prefers-color-scheme: dark)`),w=`engenty_theme`;function T(){let e=document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`${w}=`))?.slice(14);return e===`light`||e===`dark`||e===`system`?e:null}function E(e){let t=window.location.hostname,n=t.split(`.`),r=n.length>1&&!/^\d+$/.test(n[n.length-1])?n.length>2?n.slice(1).join(`.`):t:``,i=window.location.protocol===`https:`?`; Secure`:``;document.cookie=`${w}=${e}; Path=/; Max-Age=31536000; SameSite=Lax${r?`; Domain=${r}`:``}${i}`}function D(){try{let e=T()??localStorage.getItem(x);return e===`system`?null:e===`light`?`light`:`dark`}catch{return`dark`}}var O=0,k=null,A=null;function j(){try{return T()!==null||localStorage.getItem(x)!==null}catch{return!1}}function M(){return O>0?`dark`:k||(A&&!j()?A:D()??(C.matches?`dark`:`light`))}function N(){requestAnimationFrame(()=>{let e=document.querySelector(`meta[name="theme-color"]`),t=document.createElement(`canvas`).getContext(`2d`);if(!e||!t||!document.body)return;t.fillStyle=getComputedStyle(document.body).backgroundColor,t.fillRect(0,0,1,1);let[n,r,i]=t.getImageData(0,0,1,1).data;e.content=`#${[n,r,i].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`})}function P(){let e=M()===`dark`;document.documentElement.classList.toggle(`dark`,e),N();for(let e of S)e()}C.addEventListener(`change`,P),T()||E(D()??`system`),P();function F(e){E(e??`system`);try{localStorage.setItem(x,e??`system`)}catch{document.documentElement.classList.toggle(`dark`,(e??M())===`dark`);return}P()}function ae(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),D)}function oe(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>D()??(C.matches?`dark`:`light`))}function I(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>document.documentElement.classList.contains(`dark`)?`dark`:`light`)}var L=e=>`oklch(from ${ne[te[e]??`cobalt`]} 0.34 calc(c * 0.6) h)`;function se(e){(0,b.useEffect)(()=>{if(!e)return;let t=document.documentElement;return O+=1,t.style.setProperty(`--stage`,e),P(),()=>{--O,t.style.removeProperty(`--stage`),P()}},[e])}function R(e){(0,b.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--engenty-stage`,L(e)),N(),()=>{t.style.removeProperty(`--engenty-stage`),N()}},[e])}function z(e){(0,b.useEffect)(()=>{if(e)return A=e,P(),()=>{A=null,P()}},[e])}function B(e){(0,b.useEffect)(()=>{if(e)return k=e,P(),()=>{k=null,P()}},[e])}function V(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>k!==null)}var H=e(n(),1),U={name:`engenty wizards`,short:`wizards`},W=(0,b.lazy)(()=>ee(()=>import(`./fluffy-engenty-o_lu9icd.js`).then(e=>({default:e.FluffyEngenty})),__vite__mapDeps([0,1,2,3])));function G({kind:e,size:t=64,fluffy:n,coat:r,costume:i,helmet:a=!1,interactive:o=!0}){let s=e||`round`,c=I(),l=r??(c===`dark`?`jelly`:`fur`);if(n&&t>=120&&(l===`fur`||c===`dark`))return(0,H.jsx)(b.Suspense,{fallback:(0,H.jsx)(p,{costume:i,helmet:a,kind:s,size:Math.round(t*.62)}),children:(0,H.jsx)(W,{costume:i,gooseHelmet:a,coat:l,kind:s,size:t,quality:`medium`,interactive:o})});if(n&&t>=120){let e=Math.round(t*1.08);return(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{background:L(s),borderRadius:t*.28,height:t,width:t},children:[(0,H.jsx)(`span`,{className:`pointer-events-none absolute rounded-full bg-white`,style:{filter:`blur(${t*.18}px)`,height:t*.8,opacity:.16,right:-t*.3,top:-t*.3,width:t*.8}}),(0,H.jsx)(`div`,{className:`relative`,style:{marginTop:t*.04},children:(0,H.jsx)(b.Suspense,{fallback:(0,H.jsx)(p,{costume:i,helmet:a,kind:s,size:Math.round(e*.62)}),children:(0,H.jsx)(W,{costume:i,gooseHelmet:a,coat:`jelly`,kind:s,size:e,quality:`medium`,interactive:o})})})]})}return(0,H.jsx)(p,{costume:i,helmet:a,kind:s,size:t,animated:o})}function K(){let e=I(),t=V(),n=e===`dark`?`light`:`dark`;return t?null:(0,H.jsx)(l,{label:h(n===`dark`?`theme.dark`:`theme.light`),onClick:()=>F(n),children:e===`dark`?(0,H.jsx)(y,{className:`size-4`}):(0,H.jsx)(_,{className:`size-4`})})}function ce(e){return Object.fromEntries(re.filter(t=>e[t]?.startsWith(`apple:`)).map(e=>[e,``]))}function le(e){return e.split(/\s+/).map(e=>e[0]??``).join(``).slice(0,2).toUpperCase()}function ue(){let e=q().data?.limits.projects;return e===null||(e??1)>1}function de(){return q().data?.limits.build??!0}function fe(){return q().data?.limits.create??!0}function pe(){let e=q().data;return!e||e.mode===`local`||e.tenant.role!==`member`}function me(e){return e.mode===`managed`?e.credits:e.models?.source===`account`?e.account?.credits??null:null}function he(){let e=o();return t=>{m(t),e.setQueryData([`me`],e=>e&&{...e,lang:t}),i.put(`/api/studio/lang`,{lang:t}).catch(()=>void 0)}}function ge(e){let t=o();(0,b.useEffect)(()=>{if(!e)return;if(e.lang){m(e.lang);return}let n=ie();n&&(t.setQueryData([`me`],e=>e&&{...e,lang:n}),i.put(`/api/studio/lang`,{lang:n}).catch(()=>void 0))},[e,t])}function q(){return d({queryKey:[`me`],queryFn:async()=>{try{return await i.get(`/api/studio/me`)}catch(e){if(e instanceof a&&e.status===401)return null;throw e}},staleTime:3e4})}function J(e=!0){return d({queryKey:s.spaces(),queryFn:()=>i.get(`/api/studio/projects`),enabled:e})}var Y=`wz.project`;function _e(){try{return localStorage.getItem(Y)}catch{return null}}var X=_e(),Z=new Set;function ve(e){X=e;try{localStorage.setItem(Y,e)}catch{}for(let e of Z)e()}function Q(){let e=J(),t=(0,b.useSyncExternalStore)(e=>(Z.add(e),()=>Z.delete(e)),()=>X),n=e.data??[];return{project:n.find(e=>e.id===t)??n[0]??null,projects:n,select:ve,loading:e.isLoading}}function ye(e,t){return d({queryKey:[`cloud`,e],queryFn:()=>i.get(`/api/studio/wizards/${e}/cloud`),enabled:t})}function be(e){return e instanceof a&&e.body?.code===`read_only`?e.message:null}async function xe(){let{account:e}=await(await fetch(u(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.href=`${r}/`;return}let t=document.createElement(`form`);t.method=`POST`,t.action=e;let n=document.createElement(`input`);n.type=`hidden`,n.name=`return`,n.value=`${window.location.origin}${r}/`,t.append(n),document.body.append(t),t.submit()}function Se(e=Ce(),t){let n=new URLSearchParams({return:e});f!==r&&n.set(`organization`,f.slice(r.length+1)),t?.trim()&&n.set(`wish`,t.trim()),window.location.href=u(`/api/auth/login?${n}`)}function Ce(){let e=new URLSearchParams(window.location.search);e.delete(`signin`);let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}`}var $=`wizards.wish`,we=1;function Te(e){try{localStorage.setItem($,JSON.stringify({text:e,at:Date.now()}))}catch{}}function Ee(){try{let e=JSON.parse(localStorage.getItem($)??`null`);if(typeof e?.text==`string`&&typeof e.at==`number`&&Date.now()-e.at<we*864e5)return e.text}catch{}return null}function De(){try{localStorage.removeItem($)}catch{}}export{ae as A,F as C,oe as D,z as E,_ as M,R as O,K as S,B as T,he as _,be as a,U as b,me as c,Q as d,pe as f,q as g,fe as h,Ee as i,y as j,I as k,ge as l,de as m,le as n,Se as o,ue as p,Te as r,xe as s,De as t,ye as u,J as v,se as w,G as x,ce as y};
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,G as i,Lt as a,Mr as o,W as s,Xn as c,Yt as l,ot as u,sr as d,tt as f}from"./ui-Bhp_a_44.js";import{t as ee}from"./preload-helper-DpV6A1kQ.js";import{c as te,s as ne,t as p}from"./engenty-CNjaZCVM.js";import"./logo-CGNoptDg.js";import{O as re,i as m,o as ie,s as h}from"./i18n-BYeH2Dmi.js";var g={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};g.node;var _=c(g),v={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};v.node;var y=c(v),b=e(t(),1),x=`wizards.theme`,S=new Set,C=window.matchMedia(`(prefers-color-scheme: dark)`),w=`engenty_theme`;function T(){let e=document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`${w}=`))?.slice(14);return e===`light`||e===`dark`||e===`system`?e:null}function E(e){let t=window.location.hostname,n=t.split(`.`),r=n.length>1&&!/^\d+$/.test(n[n.length-1])?n.length>2?n.slice(1).join(`.`):t:``,i=window.location.protocol===`https:`?`; Secure`:``;document.cookie=`${w}=${e}; Path=/; Max-Age=31536000; SameSite=Lax${r?`; Domain=${r}`:``}${i}`}function D(){try{let e=T()??localStorage.getItem(x);return e===`system`?null:e===`light`?`light`:`dark`}catch{return`dark`}}var O=0,k=null,A=null;function j(){try{return T()!==null||localStorage.getItem(x)!==null}catch{return!1}}function M(){return O>0?`dark`:k||(A&&!j()?A:D()??(C.matches?`dark`:`light`))}function N(){requestAnimationFrame(()=>{let e=document.querySelector(`meta[name="theme-color"]`),t=document.createElement(`canvas`).getContext(`2d`);if(!e||!t||!document.body)return;t.fillStyle=getComputedStyle(document.body).backgroundColor,t.fillRect(0,0,1,1);let[n,r,i]=t.getImageData(0,0,1,1).data;e.content=`#${[n,r,i].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`})}function P(){let e=M()===`dark`;document.documentElement.classList.toggle(`dark`,e),N();for(let e of S)e()}C.addEventListener(`change`,P),T()||E(D()??`system`),P();function F(e){E(e??`system`);try{localStorage.setItem(x,e??`system`)}catch{document.documentElement.classList.toggle(`dark`,(e??M())===`dark`);return}P()}function ae(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),D)}function oe(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>D()??(C.matches?`dark`:`light`))}function I(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>document.documentElement.classList.contains(`dark`)?`dark`:`light`)}var L=e=>`oklch(from ${ne[te[e]??`cobalt`]} 0.34 calc(c * 0.6) h)`;function se(e){(0,b.useEffect)(()=>{if(!e)return;let t=document.documentElement;return O+=1,t.style.setProperty(`--stage`,e),P(),()=>{--O,t.style.removeProperty(`--stage`),P()}},[e])}function R(e){(0,b.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--engenty-stage`,L(e)),N(),()=>{t.style.removeProperty(`--engenty-stage`),N()}},[e])}function z(e){(0,b.useEffect)(()=>{if(e)return A=e,P(),()=>{A=null,P()}},[e])}function B(e){(0,b.useEffect)(()=>{if(e)return k=e,P(),()=>{k=null,P()}},[e])}function V(){return(0,b.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>k!==null)}var H=e(n(),1),U={name:`engenty wizards`,short:`wizards`},W=(0,b.lazy)(()=>ee(()=>import(`./fluffy-engenty-o_lu9icd.js`).then(e=>({default:e.FluffyEngenty})),__vite__mapDeps([0,1,2,3])));function G({kind:e,size:t=64,fluffy:n,coat:r,costume:i,helmet:a=!1,interactive:o=!0}){let s=e||`round`,c=I(),l=r??(c===`dark`?`jelly`:`fur`);if(n&&t>=120&&(l===`fur`||c===`dark`))return(0,H.jsx)(b.Suspense,{fallback:(0,H.jsx)(p,{costume:i,helmet:a,kind:s,size:Math.round(t*.62)}),children:(0,H.jsx)(W,{costume:i,gooseHelmet:a,coat:l,kind:s,size:t,quality:`medium`,interactive:o})});if(n&&t>=120){let e=Math.round(t*1.08);return(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{background:L(s),borderRadius:t*.28,height:t,width:t},children:[(0,H.jsx)(`span`,{className:`pointer-events-none absolute rounded-full bg-white`,style:{filter:`blur(${t*.18}px)`,height:t*.8,opacity:.16,right:-t*.3,top:-t*.3,width:t*.8}}),(0,H.jsx)(`div`,{className:`relative`,style:{marginTop:t*.04},children:(0,H.jsx)(b.Suspense,{fallback:(0,H.jsx)(p,{costume:i,helmet:a,kind:s,size:Math.round(e*.62)}),children:(0,H.jsx)(W,{costume:i,gooseHelmet:a,coat:`jelly`,kind:s,size:e,quality:`medium`,interactive:o})})})]})}return(0,H.jsx)(p,{costume:i,helmet:a,kind:s,size:t,animated:o})}function K(){let e=I(),t=V(),n=e===`dark`?`light`:`dark`;return t?null:(0,H.jsx)(l,{label:h(n===`dark`?`theme.dark`:`theme.light`),onClick:()=>F(n),children:e===`dark`?(0,H.jsx)(y,{className:`size-4`}):(0,H.jsx)(_,{className:`size-4`})})}function ce(e){return Object.fromEntries(re.filter(t=>e[t]?.startsWith(`apple:`)).map(e=>[e,``]))}function le(e){return e.split(/\s+/).map(e=>e[0]??``).join(``).slice(0,2).toUpperCase()}function ue(){let e=q().data?.limits.projects;return e===null||(e??1)>1}function de(){return q().data?.limits.build??!0}function fe(){return q().data?.limits.create??!0}function pe(){let e=q().data;return!e||e.mode===`local`||e.tenant.role!==`member`}function me(e){return e.mode===`managed`?e.credits:e.models?.source===`account`?e.account?.credits??null:null}function he(){let e=o();return t=>{m(t),e.setQueryData([`me`],e=>e&&{...e,lang:t}),i.put(`/api/studio/lang`,{lang:t}).catch(()=>void 0)}}function ge(e){let t=o();(0,b.useEffect)(()=>{if(!e)return;if(e.lang){m(e.lang);return}let n=ie();n&&(t.setQueryData([`me`],e=>e&&{...e,lang:n}),i.put(`/api/studio/lang`,{lang:n}).catch(()=>void 0))},[e,t])}function q(){return d({queryKey:[`me`],queryFn:async()=>{try{return await i.get(`/api/studio/me`)}catch(e){if(e instanceof a&&e.status===401)return null;throw e}},staleTime:3e4})}function J(e=!0){return d({queryKey:s.spaces(),queryFn:()=>i.get(`/api/studio/projects`),enabled:e})}var Y=`wz.project`;function _e(){try{return localStorage.getItem(Y)}catch{return null}}var X=_e(),Z=new Set;function ve(e){X=e;try{localStorage.setItem(Y,e)}catch{}for(let e of Z)e()}function Q(){let e=J(),t=(0,b.useSyncExternalStore)(e=>(Z.add(e),()=>Z.delete(e)),()=>X),n=e.data??[];return{project:n.find(e=>e.id===t)??n[0]??null,projects:n,select:ve,loading:e.isLoading}}function ye(e,t){return d({queryKey:[`cloud`,e],queryFn:()=>i.get(`/api/studio/wizards/${e}/cloud`),enabled:t})}function be(e){return e instanceof a&&e.body?.code===`read_only`?e.message:null}async function xe(){let{account:e}=await(await fetch(u(`/api/auth/sign-out`),{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:`{}`})).json().catch(()=>({}));if(!e){window.location.href=`${r}/`;return}let t=document.createElement(`form`);t.method=`POST`,t.action=e;let n=document.createElement(`input`);n.type=`hidden`,n.name=`return`,n.value=`${window.location.origin}${r}/`,t.append(n),document.body.append(t),t.submit()}function Se(e=Ce(),t){let n=new URLSearchParams({return:e});f!==r&&n.set(`organization`,f.slice(r.length+1)),t?.trim()&&n.set(`wish`,t.trim()),window.location.href=u(`/api/auth/login?${n}`)}function Ce(){let e=new URLSearchParams(window.location.search);e.delete(`signin`);let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}`}var $=`wizards.wish`,we=1;function Te(e){try{localStorage.setItem($,JSON.stringify({text:e,at:Date.now()}))}catch{}}function Ee(){try{let e=JSON.parse(localStorage.getItem($)??`null`);if(typeof e?.text==`string`&&typeof e.at==`number`&&Date.now()-e.at<we*864e5)return e.text}catch{}return null}function De(){try{localStorage.removeItem($)}catch{}}export{ae as A,F as C,oe as D,z as E,_ as M,R as O,K as S,B as T,he as _,be as a,U as b,me as c,Q as d,pe as f,q as g,fe as h,Ee as i,y as j,I as k,ge as l,de as m,le as n,Se as o,ue as p,Te as r,xe as s,De as t,ye as u,J as v,se as w,G as x,ce as y};
@@ -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{Bn as r,Hn as i,Jn as a,Qn as o,Vn as s,on as c}from"./ui-D719V_Yj.js";import{t as l}from"./react-dom-hf6EcyAr.js";import{t as u}from"./media-Cej-H610.js";var d=e(t(),1),f=l(),p=e(n(),1),m=(0,d.createContext)({slot:null,narrow:!1,setDetail:()=>void 0});function h(){return(0,d.useContext)(m)}function g({children:e}){let{slot:t}=h();return t?(0,f.createPortal)(e,t):null}function _(e){let{setDetail:t}=h();(0,d.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function v(){return u(`(max-width: 767px)`)}function y(e){return e===`deeper`?`animate-step-deeper`:e===`back`&&`animate-step-back`}function b({title:e,open:t,onBack:n,root:r}){let i=t??r??null,o=t?n:r?.onBack;return(0,p.jsxs)(`div`,{className:`mb-2 flex h-9 min-w-0 items-center px-1`,children:[(0,p.jsx)(`div`,{className:c(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,i&&o?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,p.jsx)(`button`,{type:`button`,onClick:o,"aria-hidden":!(i&&o),tabIndex:i&&o?void 0:-1,"aria-label":t?e:r?.backLabel,className:`grid size-8 place-items-center rounded-lg text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,p.jsx)(a,{className:`size-4`})})}),i?(0,p.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,p.jsx)(i.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,p.jsx)(`span`,{className:`truncate`,children:i.label})]}):(0,p.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e})]})}function x({entries:e,current:t,onPick:n}){return(0,p.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map((i,a)=>(0,p.jsxs)(`li`,{children:[i.group===e[a-1]?.group?null:i.group?(0,p.jsx)(`div`,{className:`px-2 pt-4 pb-1 font-medium text-[0.75rem] text-ink-3 first:pt-1`,children:i.group}):(0,p.jsx)(`div`,{className:`h-3`,"aria-hidden":!0}),(0,p.jsxs)(o,{to:i.to,onClick:e=>{i.id===t?.id&&(e.preventDefault(),n(i))},"aria-current":i.id===t?.id?`page`:void 0,className:c(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,i.id===t?.id?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,p.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,p.jsx)(i.icon,{className:`size-4 transition-transform duration-200 ease-out group-hover:scale-110`})}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.label}),(0,p.jsx)(r,{className:`size-4 text-ink-4 md:hidden`})]})]},i.id))})}function S({label:e,onBack:t}){return(0,p.jsxs)(`button`,{type:`button`,onClick:t,className:`-ml-1 flex items-center gap-1 rounded-lg py-1.5 pr-3 pl-1 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[(0,p.jsx)(s,{className:`size-4`}),e]})}function C(e){let t=(0,d.useRef)({level:e,direction:null});return e!==t.current.level&&(t.current={level:e,direction:e>t.current.level?`deeper`:`back`}),t.current.direction}function w({label:e,collapsible:t,open:n=!0,count:r,children:a}){let[o,s]=(0,d.useState)(n),l=`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`;return(0,p.jsxs)(`div`,{className:`mt-5 first:mt-0`,children:[t?(0,p.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),"aria-expanded":o,className:c(`mb-1 flex w-full items-center gap-1 px-2 text-left hover:text-ink-2`,l),children:[(0,p.jsx)(`span`,{className:`flex-1`,children:e}),o?null:(0,p.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:r}),(0,p.jsx)(i,{className:c(`size-3.5 transition-transform`,o?null:`-rotate-90`)})]}):(0,p.jsx)(`p`,{className:c(`mb-1 px-2`,l),children:e}),o?(0,p.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:a}):null]})}function T({icon:e,label:t,badge:n,tone:i,toneLabel:a,selected:o,disabled:s,onPick:l}){return(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onClick:l,disabled:s,"aria-current":o?`page`:void 0,className:c(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,o?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,s&&`cursor-default opacity-50 hover:bg-transparent hover:text-ink-2`),children:[(0,p.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,p.jsx)(e,{className:c(`size-4 transition-transform duration-200 ease-out`,!s&&`group-hover:scale-110`,o?`text-ember-strong`:`text-ink-3`)})}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n,i?(0,p.jsx)(`span`,{role:`img`,title:a,"aria-label":a,className:c(`size-2 shrink-0 rounded-full`,i===`done`&&`bg-moss`,i===`credits`&&`bg-amber`,i===`on`&&`bg-ember`,i===`off`&&`ring-1 ring-ink-4 ring-inset`)}):null,s?null:(0,p.jsx)(r,{className:`size-4 shrink-0 text-ink-4 md:hidden`})]})})}export{T as a,y as c,h as d,C as f,w as i,_ as l,b as n,m as o,x as r,g as s,S as t,v as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Bn as r,Hn as i,Jn as a,Qn as o,Vn as s,on as c}from"./ui-Bhp_a_44.js";import{t as l}from"./react-dom-hf6EcyAr.js";import{t as u}from"./media-Cej-H610.js";var d=e(t(),1),f=l(),p=e(n(),1),m=(0,d.createContext)({slot:null,narrow:!1,setDetail:()=>void 0});function h(){return(0,d.useContext)(m)}function g({children:e}){let{slot:t}=h();return t?(0,f.createPortal)(e,t):null}function _(e){let{setDetail:t}=h();(0,d.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function v(){return u(`(max-width: 767px)`)}function y(e){return e===`deeper`?`animate-step-deeper`:e===`back`&&`animate-step-back`}function b({title:e,open:t,onBack:n,root:r}){let i=t??r??null,o=t?n:r?.onBack;return(0,p.jsxs)(`div`,{className:`mb-2 flex h-9 min-w-0 items-center px-1`,children:[(0,p.jsx)(`div`,{className:c(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,i&&o?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,p.jsx)(`button`,{type:`button`,onClick:o,"aria-hidden":!(i&&o),tabIndex:i&&o?void 0:-1,"aria-label":t?e:r?.backLabel,className:`grid size-8 place-items-center rounded-lg text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,p.jsx)(a,{className:`size-4`})})}),i?(0,p.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,p.jsx)(i.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,p.jsx)(`span`,{className:`truncate`,children:i.label})]}):(0,p.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e})]})}function x({entries:e,current:t,onPick:n}){return(0,p.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map((i,a)=>(0,p.jsxs)(`li`,{children:[i.group===e[a-1]?.group?null:i.group?(0,p.jsx)(`div`,{className:`px-2 pt-4 pb-1 font-medium text-[0.75rem] text-ink-3 first:pt-1`,children:i.group}):(0,p.jsx)(`div`,{className:`h-3`,"aria-hidden":!0}),(0,p.jsxs)(o,{to:i.to,onClick:e=>{i.id===t?.id&&(e.preventDefault(),n(i))},"aria-current":i.id===t?.id?`page`:void 0,className:c(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,i.id===t?.id?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,p.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,p.jsx)(i.icon,{className:`size-4 transition-transform duration-200 ease-out group-hover:scale-110`})}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.label}),(0,p.jsx)(r,{className:`size-4 text-ink-4 md:hidden`})]})]},i.id))})}function S({label:e,onBack:t}){return(0,p.jsxs)(`button`,{type:`button`,onClick:t,className:`-ml-1 flex items-center gap-1 rounded-lg py-1.5 pr-3 pl-1 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[(0,p.jsx)(s,{className:`size-4`}),e]})}function C(e){let t=(0,d.useRef)({level:e,direction:null});return e!==t.current.level&&(t.current={level:e,direction:e>t.current.level?`deeper`:`back`}),t.current.direction}function w({label:e,collapsible:t,open:n=!0,count:r,children:a}){let[o,s]=(0,d.useState)(n),l=`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`;return(0,p.jsxs)(`div`,{className:`mt-5 first:mt-0`,children:[t?(0,p.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),"aria-expanded":o,className:c(`mb-1 flex w-full items-center gap-1 px-2 text-left hover:text-ink-2`,l),children:[(0,p.jsx)(`span`,{className:`flex-1`,children:e}),o?null:(0,p.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:r}),(0,p.jsx)(i,{className:c(`size-3.5 transition-transform`,o?null:`-rotate-90`)})]}):(0,p.jsx)(`p`,{className:c(`mb-1 px-2`,l),children:e}),o?(0,p.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:a}):null]})}function T({icon:e,label:t,badge:n,tone:i,toneLabel:a,selected:o,disabled:s,onPick:l}){return(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onClick:l,disabled:s,"aria-current":o?`page`:void 0,className:c(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,o?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,s&&`cursor-default opacity-50 hover:bg-transparent hover:text-ink-2`),children:[(0,p.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,p.jsx)(e,{className:c(`size-4 transition-transform duration-200 ease-out`,!s&&`group-hover:scale-110`,o?`text-ember-strong`:`text-ink-3`)})}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n,i?(0,p.jsx)(`span`,{role:`img`,title:a,"aria-label":a,className:c(`size-2 shrink-0 rounded-full`,i===`done`&&`bg-moss`,i===`credits`&&`bg-amber`,i===`on`&&`bg-ember`,i===`off`&&`ring-1 ring-ink-4 ring-inset`)}):null,s?null:(0,p.jsx)(r,{className:`size-4 shrink-0 text-ink-4 md:hidden`})]})})}export{T as a,y as c,h as d,C as f,w as i,_ as l,b as n,m as o,x as r,g as s,S as t,v as u};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/400-CyB00QFz.css","assets/500-DqciRChS.css","assets/600-B9Zp6bBy.css","assets/700-5l7ov3HZ.css","assets/400-n8m3eWIv.css","assets/500-BrSlhPjT.css","assets/600-CfY_-NCo.css","assets/700-CGFQ5xCB.css","assets/400-C1aMvkWZ.css","assets/500-XHIL5p_x.css","assets/600-BpnjcFCp.css","assets/700-BwKwxaTT.css","assets/400-CvPzio2w.css","assets/500-vjb4iIph.css","assets/600-BMp88EpG.css","assets/700-CReDayoA.css","assets/400-C-EAXind.css","assets/500-BacxruX7.css","assets/600-Bv31zJWL.css","assets/700-D1QH7Wga.css","assets/400-an-Q8PSH.css","assets/500-Dk7ZdhaB.css","assets/600-Bu09rnu5.css","assets/700-CEuaYRw2.css","assets/400-BpGVy8f9.css","assets/500-DjLsfQf4.css","assets/600-BvFs-CRM.css","assets/700-BXdZ1Wt4.css","assets/400-Bx8aXxdn.css","assets/500-ueODFTvD.css","assets/600-CX1ZBIY5.css","assets/700-B057BQ0n.css","assets/400-W7eSYfM-.css","assets/500--5BQEKwF.css","assets/600-B1b7x6MC.css","assets/700-pQg9ODXE.css","assets/400-NJi9pVr7.css","assets/400-fDO2E_2J.css","assets/500-Bp7rE3sO.css","assets/600-D7AGNg1U.css","assets/700-CBDkNWxO.css","assets/400-DiVWFxeN.css","assets/400-CWy8yahC.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{Cn as r,Ct as i,Dt as a,Et as o,Ft as s,G as c,Kn as l,Lt as u,Mt as d,Nt as f,Ot as p,Pt as m,Qt as h,St as g,Tn as _,Tt as v,Un as y,Xn as b,Yt as x,an as S,bn as C,bt as w,cn as T,ct as E,dn as D,fn as O,gn as k,gt as A,ht as ee,l as j,lt as M,mt as N,on as P,ot as F,pn as te,pt as ne,tn as I}from"./ui-D719V_Yj.js";import{t as re}from"./react-dom-hf6EcyAr.js";import{t as L}from"./preload-helper-DpV6A1kQ.js";import{t as ie}from"./volume-2-Do0dsjv2.js";import{E as ae,T as oe,k as se,x as ce}from"./session-BwtsznZF.js";import{t as le}from"./phone-Dd7IVbpJ.js";import{t as ue}from"./engenty-CNjaZCVM.js";import{C as de,Z as R,dt as fe,ft as z,gt as B,ht as pe,k as me,mt as he,n as ge,p as _e,pt as ve,s as V,t as ye,u as H,vt as U,yt as be,z as xe}from"./i18n-BX8GnEZT.js";import{Ot as Se,ft as Ce,jt as we,mt as Te,pt as Ee,t as De,wt as Oe}from"./index-BtNnNYyZ.js";var ke={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};ke.node;var Ae=b(ke),je={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};je.node;var Me=b(je),Ne={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ne.node;var Pe=b(Ne),Fe={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};Fe.node;var Ie=b(Fe),Le=3e3,Re=new Set;function ze(e,t,n){let r=`${e.family}\n${e.url}`;if(Re.has(r))return;Re.add(r);let i=!1,a=setTimeout(()=>i||n(),Le),o=()=>{i=!0,clearTimeout(a)},s=()=>{o(),n()};if(e.stylesheet){let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=t,n.onerror=s,n.onload=()=>{document.fonts.load(`1em "${e.family.replace(/"/g,``)}"`).then(e=>e.length?o():s(),s)},document.head.append(n);return}new FontFace(e.family,`url("${t.replace(/["\\\n]/g,encodeURIComponent)}")`,{display:`swap`,weight:`100 900`}).load().then(e=>{document.fonts.add(e),o()},s)}var Be=re(),W=e(t(),1),G=e(n(),1),Ve=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function He({since:e}){let[t,n]=(0,W.useState)(Date.now());if((0,W.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,G.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function K({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,G.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:P(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,G.jsx)(I,{className:`size-5`}):a})}function Ue({voice:e}){let t=(0,W.useRef)(null),{captions:n}=e;return(0,W.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,G.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,G.jsx)(`li`,{className:P(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,G.jsx)(`div`,{ref:t})]})}):null}function We({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1);(0,W.useEffect)(()=>{s(i?Date.now():null)},[i]);let u=async()=>{l(!1),await e.start(),n&&await e.startCamera()},d=()=>{e.stop(),l(!0)},f=n||e.camera,p=[...e.captions].reverse().find(e=>e.who===`bot`),m=[...e.captions].reverse().find(e=>e.who===`me`),h=e.speaking?V(`talk.speaking`):e.listening?V(`talk.listening`):i?V(`talk.live`):a?V(`talk.connecting`):c?V(`video.ended`):``;return(0,G.jsxs)(`section`,{className:P(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,G.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),h?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,G.jsx)(`span`,{className:P(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,h]}):null,(0,G.jsx)(He,{since:o})]}),(0,G.jsxs)(`div`,{className:P(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,f?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!f&&i&&e.captions.length?`h-[38%]`:f?``:`flex-1`),children:[(0,G.jsxs)(`div`,{className:P(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!f&&`hidden`),children:[(0,G.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:P(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,G.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,G.jsx)(Pe,{className:`size-8`}),(0,G.jsx)(`span`,{className:`text-[0.8125rem]`,children:V(`video.cameraOff`)})]}),(0,G.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[V(`video.you`),e.muted?(0,G.jsx)(we,{className:`ml-1.5 inline size-3`}):null]})]}),(0,G.jsxs)(`div`,{className:P(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,f?`bg-neutral-900`:`bg-transparent`,f&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,G.jsx)(`div`,{className:P(`rounded-full transition-shadow duration-500`,!f&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!f&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,G.jsx)(ce,{kind:t?.wizard.avatar??`round`,costume:t?.wizard.costume,size:f?140:200,fluffy:!0,interactive:!1})}),f?(0,G.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),i&&!f?(0,G.jsx)(Ue,{voice:e}):i&&(p||m)?(0,G.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[m?(0,G.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:m.text}):null,p?(0,G.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:p.text}):null]})}):null,e.error?(0,G.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{label:V(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,G.jsx)(we,{className:`size-5`}):(0,G.jsx)(_,{className:`size-5`})}),(0,G.jsx)(K,{label:V(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,G.jsx)(T,{className:`size-5`}):(0,G.jsx)(Pe,{className:`size-5`})}),e.camera&&Ve?(0,G.jsx)(K,{label:V(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,G.jsx)(D,{className:`size-5`})}):null,(0,G.jsx)(K,{label:V(`video.leave`),danger:!0,onClick:d,children:(0,G.jsx)(Se,{className:`size-5`})})]}):(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,disabled:a||!t?.talk,onClick:()=>void u(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[a?(0,G.jsx)(I,{className:`size-4`}):n?(0,G.jsx)(T,{className:`size-5`}):(0,G.jsx)(_,{className:`size-5`}),V(c?`video.rejoin`:n?`video.join`:`talk.start`)]}),!c&&!e.error?(0,G.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:V(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ge=e=>de[e.kind]!==`device`,Ke=1024,qe=4e3;function Je(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Ye(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),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{Cn as r,Ct as i,Dt as a,Et as o,Ft as s,G as c,Kn as l,Lt as u,Mt as d,Nt as f,Ot as p,Pt as m,Qt as h,St as g,Tn as _,Tt as v,Un as y,Xn as b,Yt as x,an as S,bn as C,bt as w,cn as T,ct as E,dn as D,fn as O,gn as k,gt as A,ht as ee,l as j,lt as M,mt as N,on as P,ot as F,pn as te,pt as ne,tn as I}from"./ui-Bhp_a_44.js";import{t as re}from"./react-dom-hf6EcyAr.js";import{t as L}from"./preload-helper-DpV6A1kQ.js";import{t as ie}from"./volume-2-DGqbhyPO.js";import{E as ae,T as oe,k as se,x as ce}from"./session-CngLvd02.js";import{t as le}from"./phone-JGS60FQU.js";import{t as ue}from"./engenty-CNjaZCVM.js";import{C as de,Z as R,dt as fe,ft as z,gt as B,ht as pe,k as me,mt as he,n as ge,p as _e,pt as ve,s as V,t as ye,u as H,vt as U,yt as be,z as xe}from"./i18n-BYeH2Dmi.js";import{Mt as Se,Tt as Ce,ft as we,kt as Te,mt as Ee,pt as De,t as Oe}from"./index-Bl7qOZv0.js";var ke={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};ke.node;var Ae=b(ke),je={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};je.node;var Me=b(je),Ne={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ne.node;var Pe=b(Ne),Fe={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};Fe.node;var Ie=b(Fe),Le=3e3,Re=new Set;function ze(e,t,n){let r=`${e.family}\n${e.url}`;if(Re.has(r))return;Re.add(r);let i=!1,a=setTimeout(()=>i||n(),Le),o=()=>{i=!0,clearTimeout(a)},s=()=>{o(),n()};if(e.stylesheet){let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=t,n.onerror=s,n.onload=()=>{document.fonts.load(`1em "${e.family.replace(/"/g,``)}"`).then(e=>e.length?o():s(),s)},document.head.append(n);return}new FontFace(e.family,`url("${t.replace(/["\\\n]/g,encodeURIComponent)}")`,{display:`swap`,weight:`100 900`}).load().then(e=>{document.fonts.add(e),o()},s)}var Be=re(),W=e(t(),1),G=e(n(),1),Ve=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function He({since:e}){let[t,n]=(0,W.useState)(Date.now());if((0,W.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,G.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function K({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,G.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:P(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,G.jsx)(I,{className:`size-5`}):a})}function Ue({voice:e}){let t=(0,W.useRef)(null),{captions:n}=e;return(0,W.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,G.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,G.jsx)(`li`,{className:P(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,G.jsx)(`div`,{ref:t})]})}):null}function We({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1);(0,W.useEffect)(()=>{s(i?Date.now():null)},[i]);let u=async()=>{l(!1),await e.start(),n&&await e.startCamera()},d=()=>{e.stop(),l(!0)},f=n||e.camera,p=[...e.captions].reverse().find(e=>e.who===`bot`),m=[...e.captions].reverse().find(e=>e.who===`me`),h=e.speaking?V(`talk.speaking`):e.listening?V(`talk.listening`):i?V(`talk.live`):a?V(`talk.connecting`):c?V(`video.ended`):``;return(0,G.jsxs)(`section`,{className:P(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,G.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),h?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,G.jsx)(`span`,{className:P(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,h]}):null,(0,G.jsx)(He,{since:o})]}),(0,G.jsxs)(`div`,{className:P(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,f?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!f&&i&&e.captions.length?`h-[38%]`:f?``:`flex-1`),children:[(0,G.jsxs)(`div`,{className:P(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!f&&`hidden`),children:[(0,G.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:P(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,G.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,G.jsx)(Pe,{className:`size-8`}),(0,G.jsx)(`span`,{className:`text-[0.8125rem]`,children:V(`video.cameraOff`)})]}),(0,G.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[V(`video.you`),e.muted?(0,G.jsx)(Se,{className:`ml-1.5 inline size-3`}):null]})]}),(0,G.jsxs)(`div`,{className:P(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,f?`bg-neutral-900`:`bg-transparent`,f&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,G.jsx)(`div`,{className:P(`rounded-full transition-shadow duration-500`,!f&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!f&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,G.jsx)(ce,{kind:t?.wizard.avatar??`round`,costume:t?.wizard.costume,size:f?140:200,fluffy:!0,interactive:!1})}),f?(0,G.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),i&&!f?(0,G.jsx)(Ue,{voice:e}):i&&(p||m)?(0,G.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[m?(0,G.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:m.text}):null,p?(0,G.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:p.text}):null]})}):null,e.error?(0,G.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{label:V(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,G.jsx)(Se,{className:`size-5`}):(0,G.jsx)(_,{className:`size-5`})}),(0,G.jsx)(K,{label:V(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,G.jsx)(T,{className:`size-5`}):(0,G.jsx)(Pe,{className:`size-5`})}),e.camera&&Ve?(0,G.jsx)(K,{label:V(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,G.jsx)(D,{className:`size-5`})}):null,(0,G.jsx)(K,{label:V(`video.leave`),danger:!0,onClick:d,children:(0,G.jsx)(Te,{className:`size-5`})})]}):(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,disabled:a||!t?.talk,onClick:()=>void u(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[a?(0,G.jsx)(I,{className:`size-4`}):n?(0,G.jsx)(T,{className:`size-5`}):(0,G.jsx)(_,{className:`size-5`}),V(c?`video.rejoin`:n?`video.join`:`talk.start`)]}),!c&&!e.error?(0,G.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:V(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ge=e=>de[e.kind]!==`device`,Ke=1024,qe=4e3;function Je(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Ye(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),r.join(`
3
3
  `);if(e.status===`running`){let t=[...e.events].reverse().find(e=>e.type===`tool`||e.type===`info`||e.type===`step_started`);return r.push(`working on: ${e.step?.title??``}`),t&&r.push(`doing: ${ye(t)}`),r.join(`
4
4
  `)}if(e.status===`done`){r.push(`done. made:`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.title}: ${Je(n?.text,400)||`(a file, on the screen)`}`);return r.join(`
5
5
  `)}if(e.status===`failed`)return r.push(`failed: ${e.error??``}; go_back or the person retries on the screen`),r.join(`
@@ -8,4 +8,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./j
8
8
  `)}return r.push(`step: ${e.step?.title??``}`),r.join(`
9
9
  `)}function Xe(e,t,n,r){let[i,a]=(0,W.useState)(`off`),[o,s]=(0,W.useState)(null),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(`environment`),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)([]),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(0),w=(0,W.useRef)(!1);w.current=p;let T=(0,W.useRef)(null),E=(0,W.useRef)(null),D=(0,W.useRef)(null),O=(0,W.useRef)(null),k=(0,W.useRef)(t);k.current=t;let A=(0,W.useRef)(r);A.current=r;let ee=(0,W.useRef)(n);ee.current=n;let j=(0,W.useRef)(``),M=(0,W.useCallback)(e=>{let t=E.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),N=(0,W.useCallback)(()=>{let e=x.current;if(!w.current||!e||e.videoWidth===0)return null;let t=Math.min(1,Ke/e.videoWidth),n=document.createElement(`canvas`);return n.width=Math.round(e.videoWidth*t),n.height=Math.round(e.videoHeight*t),n.getContext(`2d`)?.drawImage(e,0,0,n.width,n.height),n.toDataURL(`image/jpeg`,.75)},[]),P=(0,W.useCallback)(()=>{for(let e of S.current?.getTracks()??[])e.stop();S.current=null,x.current&&(x.current.srcObject=null),m(!1)},[]),F=(0,W.useCallback)(async e=>{if(S.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});S.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;g(n===`user`||n===`environment`?n:t),x.current&&(x.current.srcObject=e,await x.current.play().catch(()=>void 0)),m(!0)}catch(e){s(e.name===`NotAllowedError`?V(`talk.cameraDenied`):e.message)}},[]),te=(0,W.useCallback)(async()=>{let e=h===`user`?`environment`:`user`;P(),await F(e)},[h,P,F]),ne=(0,W.useCallback)(()=>{v(e=>{for(let t of O.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),I=(0,W.useCallback)(()=>{P(),E.current?.close(),E.current=null,T.current?.close(),T.current=null;for(let e of O.current?.getTracks()??[])e.stop();O.current=null,D.current&&=(D.current.srcObject=null,D.current.remove(),null),j.current=``,u(!1),f(!1),v(!1),a(`off`)},[P]);(0,W.useEffect)(()=>()=>I(),[I]);let re=(0,W.useCallback)(async(t,n)=>{let r=k.current,i=A.current,a=ee.current;switch(t){case`get_state`:return r?Ye(r,i,w.current):`no run`;case`look`:{let e=N();return e?(M({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows right now`},{type:`input_image`,image_url:e}]}}),`a picture arrived as the next message`):`the camera is off; ask the person to switch it on`}case`take_photo`:{if(!i)return`no page is open`;let t=i.fields.find(e=>e.id===String(n.field??``));if(t?.kind!==`image`)return`no such photo field on this page`;let r=N();if(!r)return`the camera is off; ask the person to switch it on`;try{let n=await(await fetch(r)).blob(),a=new File([n],`photo-${Date.now()}.jpg`,{type:`image/jpeg`}),o=await c.upload(`/api/runs/${e}/uploads`,a),s=i.values[t.id],l=t.multiple?[...Array.isArray(s)?s:s?[s]:[],o.id]:o.id,u=i.setField(t.id,l);return u?`refused: ${u}`:`the photo is in the field`}catch(e){return`failed: ${e.message}`}}case`set_field`:{if(!i)return`no page is open`;let e=i.setField(String(n.field??``),n.value);return e?`refused: ${e}`:`kept`}case`submit_page`:{if(!i)return`no page is open`;let e=i.fields.filter(e=>e.required&&Ge(e)&&e.kind!==`toggle`&&(i.values[e.id]===void 0||i.values[e.id]===null||i.values[e.id]===``));return e.length?`still open: ${e.map(e=>e.id).join(`, `)}`:(i.submit(),`sent; wait for the next state`)}case`accept_review`:return r?.step?.type===`review`?await a.accept(r.step.id)?`accepted`:a.error??`refused`:`no review is open`;case`regenerate`:return r?.step?.type===`review`?await a.regenerate(r.step.id,String(n.target??``),String(n.note??``))?`the wizard makes it again; wait`:a.error??`refused`:`no review is open`;case`answer_ask`:if(!r?.ask)return`no question is open`;try{return await c.post(`/api/runs/${e}/ask/${r.ask.id}`,{type:n.allow?`done`:`skip`}),n.allow?`allowed`:`skipped`}catch(e){return`refused: ${e.message}`}case`go_back`:return await a.back()?`went back; wait for the state`:a.error??`refused`;default:return`unknown tool ${t}`}},[e,N,M]),L=(0,W.useCallback)(async()=>{if(!T.current){s(null),b([]),a(`connecting`);try{let t=await c.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});O.current=n;let r=new RTCPeerConnection;T.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),D.current=i,r.ontrack=e=>{i.srcObject=e.streams[0]};for(let e of n.getTracks())r.addTrack(e,n);let o=r.createDataChannel(`oai-events`);E.current=o,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:u(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:u(!1);break;case`input_audio_buffer.speech_started`:{f(!0);let e=Date.now()-C.current>qe?N():null;e&&(C.current=Date.now(),M({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows while speaking`},{type:`input_image`,image_url:e}]}}));break}case`input_audio_buffer.speech_stopped`:f(!1);break;case`response.output_audio_transcript.done`:case`conversation.item.input_audio_transcription.completed`:{let e=String(t.transcript??``).trim();if(e){let n=t.type===`response.output_audio_transcript.done`?`bot`:`me`;b(t=>[...t.slice(-199),{id:`${Date.now()}:${n}`,who:n,text:e}])}break}case`response.function_call_arguments.done`:{let e=String(t.name??``),n=String(t.call_id??``),r={};try{r=JSON.parse(String(t.arguments??`{}`))}catch{}re(e,r).then(e=>{M({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:n,output:e}}),M({type:`response.create`})});break}case`error`:s(String(t.error?.message??`error`))}},o.onopen=()=>{a(`live`);let e=k.current;e&&(j.current=Ye(e,A.current,w.current),M({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${j.current}\n\nGreet the person in one sentence and ask the first open field.`}]}}),M({type:`response.create`}))},o.onclose=()=>{T.current===r&&I()};let l=await r.createOffer();await r.setLocalDescription(l);let d=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:l.sdp});if(!d.ok)throw Error(`${V(`talk.failed`)} (${d.status})`);await r.setRemoteDescription({type:`answer`,sdp:await d.text()})}catch(e){I(),s(e.name===`NotAllowedError`?V(`chat.micDenied`):e.message),a(`error`)}}},[e,re,N,M,I]);return(0,W.useEffect)(()=>{if(i!==`live`||!t)return;let e=Ye(t,r,p);if(e===j.current)return;let n=j.current;j.current=e,M({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${e}`}]}}),(t.status===`running`&&n.startsWith(`status: running`)&&!n.includes(`working on: `)||t.status!==`running`||n.split(`
10
10
  `)[1]!==e.split(`
11
- `)[1])&&M({type:`response.create`})},[i,t,r,p,M]),{state:i,error:o,speaking:l,listening:d,start:L,stop:I,camera:p,facing:h,startCamera:F,stopCamera:P,flipCamera:te,muted:_,toggleMute:ne,captions:y,video:x}}var Ze=[`classifier`,`low`],Qe=12e3;function $e(e){M(`think`)&&c.post(`/api/runs/${e}/device`,{think:{classes:Ze,maxChars:Qe}}).catch(()=>void 0)}async function et(e,t){if(t.kind!==`think`)return;let n;try{let e=await E(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await c.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var tt=45e3;function nt(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1),[s,l]=(0,W.useState)(!1),[d,f]=(0,W.useState)({});(0,W.useEffect)(()=>{if(n(null),o(!1),!e)return;let t=!1,r=0,i,a=null,s=Date.now(),l=()=>{t=!0,a?.close(),o(!0)},d=async()=>{try{let r=await c.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof u&&e.status===404&&l()}},f=()=>{if(clearTimeout(i),a?.close(),t)return;let o=new EventSource(F(`/api/runs/${e}/stream`),{withCredentials:!0});a=o,s=Date.now(),$e(e),o.addEventListener(`device`,t=>{s=Date.now(),et(e,JSON.parse(t.data))}),o.addEventListener(`view`,e=>{r=0,s=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{s=Date.now()}),o.onerror=()=>{o.close(),!(t||a!==o)&&(a=null,d(),r=Math.min(r+1,6),i=setTimeout(f,500*2**r))}},p=()=>{t||document.visibilityState!==`visible`||(!a||a.readyState===EventSource.CLOSED||Date.now()-s>tt?(r=0,f()):d())},m=setInterval(()=>{!t&&a&&Date.now()-s>tt&&(r=0,f())},15e3);return f(),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pageshow`,p),window.addEventListener(`online`,p),()=>{t=!0,clearTimeout(i),clearInterval(m),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pageshow`,p),window.removeEventListener(`online`,p),a?.close()}},[e]);let p=(0,W.useCallback)(async(t,n)=>{if(!e)return!1;l(!0),i(null),f({});try{return await c.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof u&&e.status===422&&Array.isArray(e.body?.fields)&&f(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{l(!1)}},[e]);return _e(t?.translation?.labels),{view:t,notFound:a,error:r,busy:s,fieldErrors:d,submitPage:(e,t)=>p(`pages/${e}`,{values:t}),accept:(e,t)=>p(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>p(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>p(`back`),retry:()=>p(`retry`),translateResult:e=>p(`translate-result`,{stepId:e}),setLang:e=>p(`lang`,{lang:e})}}var q=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),rt=(e,t,n)=>({key:e,who:`me`,node:t,...n}),it=(0,W.createContext)(null),J=(0,W.createContext)(null);function at(){return(0,W.useContext)(J)?.voice??null}function ot({children:e}){let t=(0,W.useContext)(it);return t?(0,Be.createPortal)(e,t):null}function st({header:e,footer:t,children:n}){let[r,i]=(0,W.useState)(null),a=(0,W.useRef)(null),o=(0,W.useRef)(null),s=(0,W.useRef)(!0);return(0,W.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,G.jsx)(it.Provider,{value:r,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,G.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,G.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,G.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,G.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function Y({avatar:e,costume:t,lines:n}){let r=(0,W.useContext)(J),i=(0,W.useMemo)(()=>n.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[n]),a=(0,W.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);Te(!!r?.readAloud,r?.lang??ge,i,a);let o=[];for(let e of n){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.map((n,r)=>n.who===`bot`?(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,G.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,G.jsx)(ce,{kind:e,costume:t,size:30,interactive:r>=o.length-2})}),(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:n.lines.map(e=>(0,G.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:P(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?P(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},n.lines[0].key):n.lines.map(e=>(0,G.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,G.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,G.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,G.jsx)(C,{className:`size-3`}),` `,V(`chat.change`)]}):null]},e.key)))}function ct(){return(0,G.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":V(`run.working`),children:[0,1,2].map(e=>(0,G.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function lt({children:e}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>q(e,(0,G.jsx)(lt,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:P(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[a?(0,G.jsx)(I,{className:`size-4`}):null,t]})}function ut({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:o,onSend:s}){let[c,u]=(0,W.useState)(e),f=(0,W.useRef)(null),p=o??f,m=(0,W.useContext)(J),h=j(c,u,{endpoint:m?`/api/runs/${m.runId}/transcribe`:void 0}),g=!!m&&h.supported&&!a;(0,W.useEffect)(()=>{if(!g)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),h.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,h.toggle]),(0,W.useEffect)(()=>{!d&&!a&&p.current?.focus()},[a,p]);let v=()=>{i||a||(h.listening&&h.toggle(),s(c)!==!1&&u(``))},y=h.listening?V(`chat.listening`):h.processing?V(`chat.transcribing`):t,b=m?.voice??null,C=!!m?.call,w=m&&!C&&(Ce||g||b)?(0,G.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[b?(0,G.jsx)(x,{label:V(b.state===`live`?`talk.stop`:b.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":b.state===`live`,disabled:b.state===`connecting`,onClick:()=>b.state===`live`?b.stop():void b.start(),className:P(`size-9`,b.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,b.state===`off`&&m.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:b.state===`connecting`?(0,G.jsx)(I,{className:`size-4`}):b.state===`live`?(0,G.jsx)(Se,{className:`size-4`}):(0,G.jsx)(le,{className:`size-4`})}):null,b?.state===`live`?(0,G.jsx)(x,{label:V(b.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":b.camera,onClick:()=>b.camera?b.stopCamera():void b.startCamera(),className:P(`size-9`,b.camera&&`text-ink`),children:b.camera?(0,G.jsx)(T,{className:`size-4`}):(0,G.jsx)(Pe,{className:`size-4`})}):null,Ce?(0,G.jsx)(x,{label:V(m.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":m.readAloud,onClick:()=>m.setReadAloud(!m.readAloud),className:P(`size-9`,m.readAloud&&`text-ink`),children:m.readAloud?(0,G.jsx)(ie,{className:`size-4`}):(0,G.jsx)(Ie,{className:`size-4`})}):null,g?(0,G.jsx)(x,{label:V(h.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":h.listening,disabled:h.processing,onClick:h.toggle,className:P(`size-9`,h.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:h.processing?(0,G.jsx)(I,{className:`size-4`}):h.listening?(0,G.jsx)(O,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,G.jsx)(_,{className:`size-4`})}):null]}):null;return(0,G.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),v()},children:[b&&!C?(0,G.jsx)(`video`,{ref:b.video,muted:!0,playsInline:!0,autoPlay:!0,className:P(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,b.camera?`block`:`hidden`)}):null,(0,G.jsxs)(`div`,{className:P(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,a&&`opacity-60`),children:[w,n?(0,G.jsx)(S,{ref:p,minRows:1,maxRows:6,value:c,disabled:a,placeholder:y,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!d&&!e.nativeEvent.isComposing&&(e.preventDefault(),v())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,G.jsx)(`input`,{ref:p,...r,value:c,disabled:a,placeholder:y,enterKeyHint:`send`,onChange:e=>u(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,G.jsx)(`button`,{type:`submit`,"aria-label":V(`chat.send`),title:V(`chat.send`),disabled:i||a,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:i?(0,G.jsx)(I,{className:`size-4`}):(0,G.jsx)(l,{className:`size-4`})})]}),h.error?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:h.error===`denied`?V(`chat.micDenied`):h.error}):C?null:b?.error?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:b.error}):b?.state===`live`?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:b.speaking?V(`talk.speaking`):b.listening?V(`talk.listening`):V(`talk.live`)}):m?.talk&&b?.state===`off`?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:V(`talk.hint`)}):null]})}function Q({placeholder:e=V(`chat.above`)}){return(0,G.jsx)(ot,{children:(0,G.jsx)(ut,{disabled:!0,placeholder:e,onSend:()=>!1})})}function dt(e){let t=de[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var ft=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function pt(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(ft(t))return e.required&&!n?V(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return V(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return V(`chat.badUrl`)}return e.kind===`number`&&fe(r)===null?V(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?V(`run.filesMin`,{n:t.length,min:e.min}):null}function mt(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function ht({field:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,G.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function gt({step:e,only:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,G.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,G.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function _t({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,G.jsx)(G.Fragment,{children:typeof t==`string`&&t?t:V(`chat.connected`)});if(e.kind===`list`)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(y,{className:`size-4`}),` `,V(`chat.checked`)]});if(e.kind===`toggle`)return(0,G.jsx)(G.Fragment,{children:V(t===!0?`run.yes`:`run.no`)});if(ft(t))return(0,G.jsx)(`span`,{className:`italic opacity-80`,children:V(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,G.jsx)(G.Fragment,{children:t.map(H).join(`, `)});case`select`:return(0,G.jsx)(G.Fragment,{children:H(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,G.jsx)(G.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(ge,{dateStyle:`long`}).format(e)})}case`color`:return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,G.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,G.jsx)(`img`,{src:F(`/api/runs/${n}/assets/${t}`),alt:``,className:P(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(r,{className:`size-4`}),` `,V(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(_,{className:`size-4`}),` `,V(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,G.jsx)(G.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,G.jsx)(G.Fragment,{children:V(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,G.jsx)(G.Fragment,{children:String(t)})}}function vt(e,t,n,r,i,a){let o=[q(t,(0,G.jsx)(gt,{step:e,only:a}))];for(let e of i)a||o.push(q(`${t}:${e.id}`,(0,G.jsx)(ht,{field:e}))),o.push(rt(`${t}:${e.id}:a`,(0,G.jsx)(_t,{field:e,value:n[e.id],runId:r})));return o}var yt=(e,t)=>e.fields.filter(e=>!e.when&&!xe(e)||t[e.id]!==void 0&&t[e.id]!==null);function bt(e,t){let n=[];e.wizard.description&&n.push(q(`hello`,e.wizard.description)),e.wizard.intro&&n.push(q(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...vt(r,i,e.values,e.id,yt(r,e.values),t))}else r.type===`review`&&(n.push(q(i,(0,G.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(rt(`${i}:a`,V(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function xt(e,t){return e.fields.filter(e=>!xe(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function St({view:e,run:t,step:n,before:r}){let i=(0,W.useMemo)(()=>xt(n,e),[n,e]),a=e.known??{},[o,s]=(0,W.useState)(()=>N(n,e)),[c,l]=(0,W.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?R(xt(n,e),e.known??{},N(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,W.useState)({}),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(!1),_=R(i,a,o),v=_.filter(e=>c.includes(e.id)),y=_.find(e=>!c.includes(e.id)),b=i.length===1?i[0]:void 0,x=v.at(-1),S=x?()=>l(e=>e.filter(e=>e!==x.id)):void 0;(0,W.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=R(i,a,o),r=n.findIndex(t=>e.includes(t.id));r>=0&&(l(n.slice(0,r).map(e=>e.id)),d(t.fieldErrors))},[t.fieldErrors]);let C=e=>{t.submitPage(n.id,e).then(h)},w=(0,W.useContext)(J),T=(0,W.useRef)(o);T.current=o;let E=w?.bindPage,D=(0,W.useRef)(C);D.current=C,(0,W.useEffect)(()=>{if(!E)return;let e=R(i,a,o);return E({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?pt(r,n)||(s(e=>({...e,[t]:n})),l(e=>e.includes(t)?e:[...e,t]),d({}),null):`no such field on this page`},submit:()=>D.current(T.current)}),()=>E(null)},[E,n,i,a,o]);let O=e=>{if(!y)return!1;let t=pt(y,e);if(t)return d({[y.id]:t}),!1;let n={...o,[y.id]:e},r=[...c,y.id];return s(n),l(r),d({}),R(i,a,n).some(e=>!r.includes(e.id))||C(n),!0},k=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...vt(n,`now:${n.id}`,o,e.id,v,b).map((e,t,n)=>t===n.length-1&&e.who===`me`&&y?{...e,onEdit:S}:e)];y?(dt(y)===`control`?k.push(q(`now:${n.id}:${y.id}:control`,(0,G.jsx)(g,{field:y,value:o[y.id],values:o,runId:e.id,view:e,closed:e.closed?.[y.id],onChange:e=>s(t=>({...t,[y.id]:e})),onBusy:p}),{wide:!0})):b||k.push(q(`now:${n.id}:${y.id}`,(0,G.jsx)(ht,{field:y}))),u[y.id]&&k.push(q(`now:${n.id}:${y.id}:error`,u[y.id],{tone:`error`}))):t.busy||m?k.push(q(`sending`,(0,G.jsx)(ct,{}))):t.error&&k.push(q(`send-error`,t.error,{tone:`error`}));let A=(0,G.jsx)(Q,{});if(m||!y&&c.length>0&&t.busy)A=(0,G.jsx)(Q,{placeholder:V(`run.working`)});else if(!y)k.push(X(`now:${n.id}:go`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>C(o),children:n.cta||V(`run.next`)}),S?(0,G.jsx)(Z,{onClick:S,disabled:t.busy,children:V(`run.back`)}):null]})));else{let r=dt(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,G.jsx)(Z,{onClick:()=>O(void 0),children:V(`chat.skip`)}):null;if(r===`typed`){i&&k.push(X(`now:${n.id}:${y.id}:replies`,i));let e=o[y.id];A=(0,G.jsx)(ot,{children:(0,G.jsx)(ut,{initial:ft(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:V(`chat.placeholder`)),inputProps:Ct(y),busy:t.busy,onSend:e=>O(mt(y,e))},y.id)})}else if(r===`tapped`)k.push(q(`now:${n.id}:${y.id}:replies`,(0,G.jsx)(wt,{field:y,view:e,value:o[y.id],onAnswer:O}),{bare:!0}));else{let e=_.filter(e=>!c.includes(e.id)).length===1;k.push(X(`now:${n.id}:${y.id}:replies`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{primary:!0,disabled:f,onClick:()=>O(o[y.id]),children:e&&n.cta?n.cta:V(`chat.send`)}),i]})))}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:k}),A]})}function Ct(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return i(e)}}function wt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,W.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,G.jsxs)(lt,{children:[(0,G.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:V(`run.no`)}),(0,G.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:V(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,G.jsxs)(lt,{children:[s.map(e=>(0,G.jsx)(Z,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:H(e)},e)),(0,G.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?V(`chat.send`):V(`chat.skip`)})]}):(0,G.jsxs)(lt,{children:[s.map(e=>(0,G.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:H(e)},e)),e.required?null:(0,G.jsx)(Z,{onClick:()=>r(void 0),children:V(`chat.skip`)})]})}function Tt({view:e}){let t=(0,W.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,W.useState)(Date.now());(0,W.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),o=a.at(-1),s=[...a].reverse().find(Dt),c=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,G.jsxs)(`div`,{className:P(`flex max-w-full flex-col gap-1`,s?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??V(`run.working`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(ct,{}),(0,G.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??V(`run.working`)}),(0,G.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:V(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),o&&o!==s?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,G.jsx)(te,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,G.jsx)(`span`,{className:`truncate`,children:ye(o)})]}):null,s&&e.status===`running`?(0,G.jsx)(kt,{runId:e.id,event:s}):null,c.length?(0,G.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:c.slice(-6).map(t=>(0,G.jsx)(`img`,{src:F(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var Et=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Dt(e){return!!e.note&&Et.has(e.note.code)}var Ot=1e4;function kt({runId:e,event:t}){let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(`agent`),[o,l]=(0,W.useState)(!1),u=t.note?.code;if((0,W.useEffect)(()=>{u===`personDrives`?a(`person`):u===`agentDrives`&&a(`agent`)},[u]),(0,W.useEffect)(()=>{let t=()=>c.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,Ot);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let d=i===`person`,f=async()=>{l(!0);try{let t=await c.post(`/api/runs/${e}/browser/seat`,{to:d?`agent`:`person`});a(t.seat)}catch{}finally{l(!1)}};return(0,G.jsx)(s,{runId:e,driving:d,caption:ye(t),hint:V(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,G.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void f(),className:P(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,d?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[d?(0,G.jsx)(Oe,{className:`size-3.5`}):(0,G.jsx)(Ae,{className:`size-3.5`}),V(d?`browser.handBack`:`browser.takeOver`)]})},n??0)}function At({children:e,end:t}){return(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function jt({view:e,run:t,step:n,before:r,asked:i,onNote:o}){let s=e.shown.filter(e=>e.output),[c,l]=(0,W.useState)(s.length===1?s[0].step.id:null),u=(0,W.useRef)(null),d=[...r,...i.map((e,t)=>rt(`review:${n.id}:asked:${t}`,e)),q(`review:${n.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,G.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...s.map(({step:t,output:r})=>q(`review:${n.id}:${t.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{children:t.title}),(0,G.jsx)(w,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{l(t.id),u.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>q(`review:${n.id}:list:${t.def.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{children:t.def.title}),t.def.check?(0,G.jsx)(v,{runId:e.id,list:t}):(0,G.jsx)(a,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&d.push(q(`review-error`,t.error,{tone:`error`}));let f=n.regenerate&&s.length>0;return d.push(X(`review:${n.id}:replies`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,G.jsx)(y,{className:`size-4`}),` `,V(`run.accept`)]}),f&&s.length>1?s.map(({step:e})=>(0,G.jsx)(Z,{on:c===e.id,onClick:()=>l(e.id),children:e.title},e.id)):null]}))),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:d}),f?(0,G.jsx)(ot,{children:(0,G.jsx)(ut,{multiline:!0,inputRef:u,busy:t.busy,placeholder:s.length>1&&!c?V(`run.feedbackPick`):V(`run.feedbackPlaceholder`),disabled:!c,onSend:e=>{let r=e.trim();return!r||!c?!1:(o(r),t.regenerate(n.id,c,r),!0)}})}):(0,G.jsx)(Q,{})]})}function Mt({view:e,run:t,step:n,before:r,onRestart:i}){let s=e.shown.filter(e=>e.output),c=`/api/runs/${e.id}`,l=[...r,q(`result:${n.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,G.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...s.map(({step:e,output:t,formats:n,label:r})=>q(`result:${e.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{end:(0,G.jsx)(A,{base:c,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,G.jsx)(w,{base:c,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,G.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:V(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>q(`result:list:${t.def.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{end:(0,G.jsx)(o,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,G.jsx)(a,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return l.push(X(`result:replies`,(0,G.jsxs)(G.Fragment,{children:[s.length?(0,G.jsx)(De,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,G.jsxs)(Z,{onClick:i,children:[(0,G.jsx)(k,{className:`size-4`}),` `,V(`run.again`)]}):null,e.canBack?(0,G.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:V(`run.back`)}):null,e.keeps?(0,G.jsx)(`span`,{className:`ml-1`,children:(0,G.jsx)(p,{runId:e.id})}):null]}))),(0,G.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:l})}function Nt({runId:e,onRestart:t,onNotFound:n,onView:r,header:i,footer:a,talk:o=!1,call:s=!1}){let c=nt(e),{view:l}=c,[u,d]=(0,W.useState)(null),p=Xe(e,l,c,u);(0,W.useEffect)(()=>{r?.(l)},[l,r]),(0,W.useEffect)(()=>{c.notFound&&n?.()},[c.notFound,n]);let[g,_]=Ee(),v=(0,W.useMemo)(()=>({runId:e,lang:l?.lang??ge,readAloud:g,setReadAloud:_,voice:l?.talk?p:null,talk:o,call:!!s,bindPage:d}),[e,l?.lang,l?.talk,g,_,p,o,s]);f(l?.status===`running`&&!l.ask),ee(l);let[y,b]=(0,W.useState)({}),[x,S]=(0,W.useState)(null);(0,W.useEffect)(()=>{l&&l.status!==`running`&&S(null)},[l]);let C;if(c.notFound)C=n?null:(0,G.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:V(`run.notFound`)});else if(!l)C=(0,G.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,G.jsx)(I,{})});else{let e=l.step,n=l.status===`waiting_input`,r=bt(l,l.canBack&&n&&!c.busy?()=>void c.back():void 0);if(l.status===`running`&&l.ask)C=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,q(`ask:${l.ask.id}`,(0,G.jsx)(m,{runId:l.id,ask:l.ask}),{wide:!0})]}),(0,G.jsx)(Q,{})]});else if(l.status===`running`)C=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,...x?[rt(`note`,x)]:[],q(`working:${e?.id}`,(0,G.jsx)(Tt,{view:l}),{wide:l.events.some(t=>t.stepId===e?.id&&Dt(t))?`most`:void 0})]}),(0,G.jsx)(Q,{placeholder:V(`run.working`)})]});else if(l.status===`failed`)C=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,q(`failed`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:V(`run.failed`)}),l.error?(0,G.jsx)(`span`,{className:`mt-0.5 block`,children:(0,G.jsx)(h,{text:l.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Z,{primary:!0,busy:c.busy,onClick:()=>void c.retry(),children:[(0,G.jsx)(k,{className:`size-4`}),` `,V(`run.retry`)]}),l.canBack?(0,G.jsx)(Z,{onClick:()=>void c.back(),disabled:c.busy,children:V(`run.back`)}):null]}))]}),(0,G.jsx)(Q,{})]});else if(l.status===`cancelled`)C=(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,q(`cancelled`,V(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,G.jsxs)(Z,{primary:!0,onClick:t,children:[(0,G.jsx)(k,{className:`size-4`}),` `,V(`run.again`)]}))]:[]]});else if(e?.type===`page`)C=(0,G.jsx)(St,{view:l,run:c,step:e,before:r},e.id);else if(e?.type===`review`){let t=l.shown.map(e=>e.output?.at??``).join(`|`);C=(0,G.jsx)(jt,{view:l,run:c,step:e,before:r,asked:y[e.id]??[],onNote:t=>{S(t),b(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else C=e?.type===`result`?(0,G.jsx)(Mt,{view:l,run:c,step:e,before:r,onRestart:t}):(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:r})}return s?(0,G.jsx)(J.Provider,{value:v,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,G.jsx)(We,{voice:p,view:l,video:s===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,G.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,G.jsx)(st,{footer:a,children:C})})]})}):(0,G.jsx)(J.Provider,{value:v,children:(0,G.jsx)(st,{header:i,footer:a,children:C})})}function Pt({runId:e,onNotFound:t,...n}){let r=nt(e);return(0,W.useEffect)(()=>{r.notFound&&t?.()},[r.notFound,t]),r.notFound&&t?null:(0,G.jsx)(ne,{run:r,...n})}function $(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function Ft(e){let t=Array.from({length:7},(t,n)=>({a:(n+.2+$(e+n)*.5)/7.2*(Math.PI/2),len:200*(.84+.16*$(e+n+20))})),n=t.map(e=>`M0 0L${(Math.cos(e.a)*e.len).toFixed(1)} ${(Math.sin(e.a)*e.len).toFixed(1)}`);for(let e=1;e<=9;e++){let r=200*(e/9.6)**1.08;t.slice(1).forEach((e,i)=>{let a=t[i],o=Math.min(r,a.len),s=Math.min(r,e.len),c=(a.a+e.a)/2,l=r*.86;i===0&&n.push(`M${(Math.cos(a.a)*o).toFixed(1)} ${(Math.sin(a.a)*o).toFixed(1)}`),n.push(`Q${(Math.cos(c)*l).toFixed(1)} ${(Math.sin(c)*l).toFixed(1)} ${(Math.cos(e.a)*s).toFixed(1)} ${(Math.sin(e.a)*s).toFixed(1)}`)})}return n.join(``)}var It={left:Ft(1),right:Ft(9)};function Lt({side:e,className:t}){return(0,G.jsx)(`svg`,{className:t??`wizard-web wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:It[e],fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Rt(){return(0,G.jsxs)(`div`,{className:`wizard-spider`,children:[(0,G.jsx)(`div`,{className:`wizard-spider-thread`}),(0,G.jsxs)(`svg`,{viewBox:`-30 -10 60 60`,"aria-hidden":`true`,children:[(0,G.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,fill:`none`,children:[0,1,2,3].map(e=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`path`,{d:`M0 ${8+e*5} Q-16 ${-2+e*6} -24 ${14+e*6}`}),(0,G.jsx)(`path`,{d:`M0 ${8+e*5} Q16 ${-2+e*6} 24 ${14+e*6}`})]},e))}),(0,G.jsx)(`ellipse`,{cx:`0`,cy:`22`,rx:`11`,ry:`14`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`0`,cy:`6`,r:`7`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`-2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`}),(0,G.jsx)(`circle`,{cx:`2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`})]})]})}function zt({side:e}){let t=Array.from({length:9},(e,t)=>{let n=(t+.5)/9*(Math.PI/2),r=70+$(t+40)*110,i=Math.cos(n)*r,a=Math.sin(n)*r,o=Math.cos(n)*r*.55,s=Math.sin(n)*r*.55,c=14+$(t+50)*16;return`M0 0L${i.toFixed(1)} ${a.toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n+.6)*c).toFixed(1)} ${(Math.sin(n+.6)*c).toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n-.6)*c).toFixed(1)} ${(Math.sin(n-.6)*c).toFixed(1)}`}).join(``);return(0,G.jsx)(`svg`,{className:`wizard-frost wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:t,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Bt({kind:e}){let t=e===`stars`?28:22;return(0,G.jsx)(`div`,{className:`wizard-particles wizard-particles-${e}`,children:Array.from({length:t},(t,n)=>(0,G.jsx)(`span`,{style:{left:`${($(n+1)*100).toFixed(2)}%`,top:e===`stars`?`${($(n+2)*100).toFixed(2)}%`:void 0,animationDuration:`${(e===`stars`?2.5:9)+$(n+3)*8}s`,animationDelay:`${(-$(n+4)*16).toFixed(2)}s`,scale:(.6+$(n+5)*.9).toFixed(2),"--hue":`${Math.round($(n+6)*360)}`}},n))})}var Vt=[{kind:`round`,top:16,size:64,seconds:17,delay:1},{kind:`drop`,top:42,size:48,seconds:21,delay:7},{kind:`tower`,top:26,size:56,seconds:19,delay:12.5}],Ht=[{kind:`flame`,side:`right`,seconds:14,delay:2},{kind:`sprout`,side:`left`,seconds:16,delay:9}];function Ut({costume:e,motion:t}){return t===`peek`?(0,G.jsx)(G.Fragment,{children:Ht.map(t=>(0,G.jsx)(`div`,{className:`wizard-peek wizard-peek-${t.side}`,style:{animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,G.jsx)(ue,{kind:t.kind,costume:e,size:96})},t.kind))}):(0,G.jsx)(G.Fragment,{children:Vt.map(t=>(0,G.jsx)(`div`,{className:`wizard-bat`,style:{top:`${t.top}%`,animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,G.jsx)(`div`,{className:`wizard-bat-bob`,children:(0,G.jsx)(ue,{kind:t.kind,costume:e,size:t.size})})},t.kind))})}var Wt=[`witch`,`devil`,`bat`,`pumpkin`];function Gt({effects:e,contained:t}){let n=(e??[]).filter(e=>[`corners`,`particles`,`figures`,`fog`].includes(e.id));if(!n.length)return null;let r=(e,t)=>typeof e[t]==`string`?String(e[t]):``;return(0,G.jsxs)(G.Fragment,{children:[n.some(e=>e.id===`fog`)?(0,G.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fog wizard-fx-contained`:`wizard-fog`}):null,(0,G.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fx wizard-fx-contained`:`wizard-fx`,children:n.map((e,t)=>{let n=`${e.id}-${t}`;if(e.id===`corners`){let t=r(e,`kind`)||`webs`;return t===`frost`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(zt,{side:`left`}),(0,G.jsx)(zt,{side:`right`})]},n):t===`webs`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Lt,{side:`left`}),(0,G.jsx)(Lt,{side:`right`}),(0,G.jsx)(Rt,{})]},n):null}if(e.id===`particles`){let t=r(e,`kind`)||`embers`;return[`embers`,`snow`,`confetti`,`stars`].includes(t)?(0,G.jsx)(Bt,{kind:t},n):null}if(e.id===`figures`){let t=r(e,`costume`);return(0,G.jsx)(Ut,{costume:Wt.includes(t)?t:void 0,motion:r(e,`motion`)||`fly`},n)}return null})})]})}var Kt=[`brand`,`host`,`default`],qt=[...Kt,`engenty`,`wizard`,`wizards`],Jt=[`Inter`,`Figtree`,`DM Sans`,`Nunito`,`Fredoka`,`Bricolage Grotesque`,`Fraunces`,`Playfair Display`,`Lora`,`Young Serif`,`Caveat`,`Creepster`,`Nosifer`],Yt=U().regex(/^#[0-9a-fA-F]{6}$/,`a colour as #rrggbb`),Xt=B({accent:Yt.optional(),background:Yt.optional(),text:Yt.optional()}).extend({scheme:z([`light`,`dark`])}),Zt=B({radius:z([`sharp`,`soft`,`round`]).optional(),cards:z([`solid`,`outline`,`glass`]).optional(),headings:z([`normal`,`uppercase`]).optional()}),Qt=B({id:U().min(1).max(40)}).catchall(be([U().max(40),pe(),he()])),$t=U().min(1).max(60).regex(/^[A-Za-z0-9 -]+$/,`a font by its family name, or brand`);B({id:U().regex(me,`a theme id: lowercase letters, digits and dashes`),name:U().min(1).max(80),version:U().regex(/^\d+\.\d+\.\d+$/).default(`1.0.0`),base:z(Kt).default(`brand`),colors:ve(Xt).min(1).max(2).refine(e=>new Set(e.map(e=>e.scheme)).size===e.length,{message:`Each scheme once: light, dark.`}).optional(),fonts:B({heading:$t.optional(),text:$t.optional()}).optional(),shape:Zt.optional(),effects:ve(Qt).max(8).optional()});function en(e,t){if(!t.has(e))return e;for(let n=2;;n++){let r=`${e.slice(0,44)}-${n}`;if(!t.has(r))return r}}function tn(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48);return t&&!qt.includes(t)?t:`look`}function nn(e,t){let n=e?.colors?.find(e=>e.scheme===t);if(!n)return;let{scheme:r,...i}=n;return i}var rn=`ui-sans-serif, system-ui, sans-serif`,an=`ui-serif, Georgia, serif`,on=/serif|fraunces|playfair|lora|garamond|antiqua|baskerville|caslon|bodoni|didot|times|georgia|merriweather|tiempos/i,sn=e=>on.test(e)&&!/sans/i.test(e),cn=e=>sn(e)?`Lora`:`Inter`;function ln(e,t=[]){let n=t.some(t=>t.family===e)?`"${cn(e)}", `:``;return`"${e.replace(/"/g,``)}", ${n}${sn(e)?an:rn}`}function un(e,t){let n=e.modes?.[t];return{accent:n?.accent??e.accent,background:n?.background??e.background,text:n?.text??null}}var dn={Inter:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([0])),L(()=>Promise.resolve({}),__vite__mapDeps([1])),L(()=>Promise.resolve({}),__vite__mapDeps([2])),L(()=>Promise.resolve({}),__vite__mapDeps([3]))],Figtree:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([4])),L(()=>Promise.resolve({}),__vite__mapDeps([5])),L(()=>Promise.resolve({}),__vite__mapDeps([6])),L(()=>Promise.resolve({}),__vite__mapDeps([7]))],"DM Sans":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([8])),L(()=>Promise.resolve({}),__vite__mapDeps([9])),L(()=>Promise.resolve({}),__vite__mapDeps([10])),L(()=>Promise.resolve({}),__vite__mapDeps([11]))],Nunito:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([12])),L(()=>Promise.resolve({}),__vite__mapDeps([13])),L(()=>Promise.resolve({}),__vite__mapDeps([14])),L(()=>Promise.resolve({}),__vite__mapDeps([15]))],Fredoka:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([16])),L(()=>Promise.resolve({}),__vite__mapDeps([17])),L(()=>Promise.resolve({}),__vite__mapDeps([18])),L(()=>Promise.resolve({}),__vite__mapDeps([19]))],"Bricolage Grotesque":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([20])),L(()=>Promise.resolve({}),__vite__mapDeps([21])),L(()=>Promise.resolve({}),__vite__mapDeps([22])),L(()=>Promise.resolve({}),__vite__mapDeps([23]))],Fraunces:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([24])),L(()=>Promise.resolve({}),__vite__mapDeps([25])),L(()=>Promise.resolve({}),__vite__mapDeps([26])),L(()=>Promise.resolve({}),__vite__mapDeps([27]))],"Playfair Display":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([28])),L(()=>Promise.resolve({}),__vite__mapDeps([29])),L(()=>Promise.resolve({}),__vite__mapDeps([30])),L(()=>Promise.resolve({}),__vite__mapDeps([31]))],Lora:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([32])),L(()=>Promise.resolve({}),__vite__mapDeps([33])),L(()=>Promise.resolve({}),__vite__mapDeps([34])),L(()=>Promise.resolve({}),__vite__mapDeps([35]))],"Young Serif":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([36]))],Caveat:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([37])),L(()=>Promise.resolve({}),__vite__mapDeps([38])),L(()=>Promise.resolve({}),__vite__mapDeps([39])),L(()=>Promise.resolve({}),__vite__mapDeps([40]))],Creepster:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([41]))],Nosifer:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([42]))]},fn=new Set;function pn(e){e&&!fn.has(e)&&e in dn&&(fn.add(e),Promise.all(dn[e]()).catch(()=>fn.delete(e)))}function mn(e){ze(e,e.url.startsWith(`/`)?F(e.url):e.url,()=>pn(cn(e.family)))}function hn(e,t){let n=e.faces??[],r=!!e.modes,i=un({accent:e.accent??null,background:e.background??null,modes:e.modes??null},r?t:e.dark?`dark`:`light`),a=r?t===`dark`:!!e.dark,o=[[`--raw-primary`,i.accent],[`--raw-second`,e.second],[`--raw-background`,i.background],[`--brand-stage`,i.background?a?i.background:`oklch(from ${i.background} 0.3 clamp(0.02, calc(c * 3), 0.1) h)`:null],[`--ink`,i.text],[`--f-display`,e.display?ln(e.display,n):null],[`--f-ui`,e.body?ln(e.body,n):null],[`font-synthesis-weight`,e.display||e.body?`none`:null]],s=[...Object.entries(e.shape??{}).filter(([,e])=>e).map(([e,t])=>`shape-${e}-${t}`),...(e.effects??[]).flatMap(e=>e.id===`glow`?[`fx-glow`]:e.id===`pattern`?[`fx-pattern-${e.kind??`dots`}`]:[])];return{props:o.filter(e=>!!e[1]),marks:s,dark:a,themed:r}}function gn(e){return!!(e&&!e.pinned&&e.modes?.light&&e.modes.dark)}function _n(e){for(let t of e.faces??[])mn(t);pn(e.display),pn(e.body)}function vn(e){oe(e?.pinned?e.dark?`dark`:`light`:null),ae(e?.prefer??null);let t=se(),n=JSON.stringify(e??{});(0,W.useEffect)(()=>{let e=JSON.parse(n),r=document.documentElement;_n(e);let{props:i,marks:a,themed:o}=hn(e,t);for(let[e,t]of i)r.style.setProperty(e,t);r.classList.add(...a);let s=r.classList.contains(`dark`);return!o&&e.dark&&!e.pinned&&r.classList.add(`dark`),()=>{for(let[e]of i)r.style.removeProperty(e);r.classList.remove(...a),!o&&e.dark&&!e.pinned&&!s&&r.classList.remove(`dark`)}},[n,t])}function yn(e,t){let n=JSON.stringify(e??{});if((0,W.useEffect)(()=>{_n(JSON.parse(n))},[n]),!e)return null;let r=e.pinned||!e.prefer?e.dark?`dark`:`light`:e.prefer,{props:i,marks:a,dark:o}=hn(e,t&&gn(e)?t:r);return{className:[`wizard-themed`,...a,o?`dark`:``].filter(Boolean).join(` `),style:Object.fromEntries(i)}}export{Y as _,pn as a,Me as b,nn as c,Gt as d,Pt as f,Z as g,Q as h,mn as i,tn as l,st as m,vn as n,Jt as o,Nt as p,yn as r,en as s,gn as t,Lt as u,X as v,at as y};
11
+ `)[1])&&M({type:`response.create`})},[i,t,r,p,M]),{state:i,error:o,speaking:l,listening:d,start:L,stop:I,camera:p,facing:h,startCamera:F,stopCamera:P,flipCamera:te,muted:_,toggleMute:ne,captions:y,video:x}}var Ze=[`classifier`,`low`],Qe=12e3;function $e(e){M(`think`)&&c.post(`/api/runs/${e}/device`,{think:{classes:Ze,maxChars:Qe}}).catch(()=>void 0)}async function et(e,t){if(t.kind!==`think`)return;let n;try{let e=await E(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await c.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var tt=45e3;function nt(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1),[s,l]=(0,W.useState)(!1),[d,f]=(0,W.useState)({});(0,W.useEffect)(()=>{if(n(null),o(!1),!e)return;let t=!1,r=0,i,a=null,s=Date.now(),l=()=>{t=!0,a?.close(),o(!0)},d=async()=>{try{let r=await c.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof u&&e.status===404&&l()}},f=()=>{if(clearTimeout(i),a?.close(),t)return;let o=new EventSource(F(`/api/runs/${e}/stream`),{withCredentials:!0});a=o,s=Date.now(),$e(e),o.addEventListener(`device`,t=>{s=Date.now(),et(e,JSON.parse(t.data))}),o.addEventListener(`view`,e=>{r=0,s=Date.now(),n(JSON.parse(e.data))}),o.addEventListener(`ping`,()=>{s=Date.now()}),o.onerror=()=>{o.close(),!(t||a!==o)&&(a=null,d(),r=Math.min(r+1,6),i=setTimeout(f,500*2**r))}},p=()=>{t||document.visibilityState!==`visible`||(!a||a.readyState===EventSource.CLOSED||Date.now()-s>tt?(r=0,f()):d())},m=setInterval(()=>{!t&&a&&Date.now()-s>tt&&(r=0,f())},15e3);return f(),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pageshow`,p),window.addEventListener(`online`,p),()=>{t=!0,clearTimeout(i),clearInterval(m),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pageshow`,p),window.removeEventListener(`online`,p),a?.close()}},[e]);let p=(0,W.useCallback)(async(t,n)=>{if(!e)return!1;l(!0),i(null),f({});try{return await c.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof u&&e.status===422&&Array.isArray(e.body?.fields)&&f(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{l(!1)}},[e]);return _e(t?.translation?.labels),{view:t,notFound:a,error:r,busy:s,fieldErrors:d,submitPage:(e,t)=>p(`pages/${e}`,{values:t}),accept:(e,t)=>p(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>p(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>p(`back`),retry:()=>p(`retry`),translateResult:e=>p(`translate-result`,{stepId:e}),setLang:e=>p(`lang`,{lang:e})}}var q=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),rt=(e,t,n)=>({key:e,who:`me`,node:t,...n}),it=(0,W.createContext)(null),J=(0,W.createContext)(null);function at(){return(0,W.useContext)(J)?.voice??null}function ot({children:e}){let t=(0,W.useContext)(it);return t?(0,Be.createPortal)(e,t):null}function st({header:e,footer:t,children:n}){let[r,i]=(0,W.useState)(null),a=(0,W.useRef)(null),o=(0,W.useRef)(null),s=(0,W.useRef)(!0);return(0,W.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,G.jsx)(it.Provider,{value:r,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,G.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,G.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,G.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,G.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function Y({avatar:e,costume:t,lines:n}){let r=(0,W.useContext)(J),i=(0,W.useMemo)(()=>n.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[n]),a=(0,W.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);Ee(!!r?.readAloud,r?.lang??ge,i,a);let o=[];for(let e of n){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.map((n,r)=>n.who===`bot`?(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,G.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,G.jsx)(ce,{kind:e,costume:t,size:30,interactive:r>=o.length-2})}),(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:n.lines.map(e=>(0,G.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:P(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?P(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},n.lines[0].key):n.lines.map(e=>(0,G.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,G.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,G.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,G.jsx)(C,{className:`size-3`}),` `,V(`chat.change`)]}):null]},e.key)))}function ct(){return(0,G.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":V(`run.working`),children:[0,1,2].map(e=>(0,G.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function lt({children:e}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>q(e,(0,G.jsx)(lt,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:P(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[a?(0,G.jsx)(I,{className:`size-4`}):null,t]})}function ut({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:o,onSend:s}){let[c,u]=(0,W.useState)(e),f=(0,W.useRef)(null),p=o??f,m=(0,W.useContext)(J),h=j(c,u,{endpoint:m?`/api/runs/${m.runId}/transcribe`:void 0}),g=!!m&&h.supported&&!a;(0,W.useEffect)(()=>{if(!g)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),h.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,h.toggle]),(0,W.useEffect)(()=>{!d&&!a&&p.current?.focus()},[a,p]);let v=()=>{i||a||(h.listening&&h.toggle(),s(c)!==!1&&u(``))},y=h.listening?V(`chat.listening`):h.processing?V(`chat.transcribing`):t,b=m?.voice??null,C=!!m?.call,w=m&&!C&&(we||g||b)?(0,G.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[b?(0,G.jsx)(x,{label:V(b.state===`live`?`talk.stop`:b.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":b.state===`live`,disabled:b.state===`connecting`,onClick:()=>b.state===`live`?b.stop():void b.start(),className:P(`size-9`,b.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,b.state===`off`&&m.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:b.state===`connecting`?(0,G.jsx)(I,{className:`size-4`}):b.state===`live`?(0,G.jsx)(Te,{className:`size-4`}):(0,G.jsx)(le,{className:`size-4`})}):null,b?.state===`live`?(0,G.jsx)(x,{label:V(b.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":b.camera,onClick:()=>b.camera?b.stopCamera():void b.startCamera(),className:P(`size-9`,b.camera&&`text-ink`),children:b.camera?(0,G.jsx)(T,{className:`size-4`}):(0,G.jsx)(Pe,{className:`size-4`})}):null,we?(0,G.jsx)(x,{label:V(m.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":m.readAloud,onClick:()=>m.setReadAloud(!m.readAloud),className:P(`size-9`,m.readAloud&&`text-ink`),children:m.readAloud?(0,G.jsx)(ie,{className:`size-4`}):(0,G.jsx)(Ie,{className:`size-4`})}):null,g?(0,G.jsx)(x,{label:V(h.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":h.listening,disabled:h.processing,onClick:h.toggle,className:P(`size-9`,h.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:h.processing?(0,G.jsx)(I,{className:`size-4`}):h.listening?(0,G.jsx)(O,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,G.jsx)(_,{className:`size-4`})}):null]}):null;return(0,G.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),v()},children:[b&&!C?(0,G.jsx)(`video`,{ref:b.video,muted:!0,playsInline:!0,autoPlay:!0,className:P(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,b.camera?`block`:`hidden`)}):null,(0,G.jsxs)(`div`,{className:P(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,a&&`opacity-60`),children:[w,n?(0,G.jsx)(S,{ref:p,minRows:1,maxRows:6,value:c,disabled:a,placeholder:y,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!d&&!e.nativeEvent.isComposing&&(e.preventDefault(),v())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,G.jsx)(`input`,{ref:p,...r,value:c,disabled:a,placeholder:y,enterKeyHint:`send`,onChange:e=>u(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,G.jsx)(`button`,{type:`submit`,"aria-label":V(`chat.send`),title:V(`chat.send`),disabled:i||a,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:i?(0,G.jsx)(I,{className:`size-4`}):(0,G.jsx)(l,{className:`size-4`})})]}),h.error?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:h.error===`denied`?V(`chat.micDenied`):h.error}):C?null:b?.error?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:b.error}):b?.state===`live`?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:b.speaking?V(`talk.speaking`):b.listening?V(`talk.listening`):V(`talk.live`)}):m?.talk&&b?.state===`off`?(0,G.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:V(`talk.hint`)}):null]})}function Q({placeholder:e=V(`chat.above`)}){return(0,G.jsx)(ot,{children:(0,G.jsx)(ut,{disabled:!0,placeholder:e,onSend:()=>!1})})}function dt(e){let t=de[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var ft=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function pt(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(ft(t))return e.required&&!n?V(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return V(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return V(`chat.badUrl`)}return e.kind===`number`&&fe(r)===null?V(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?V(`run.filesMin`,{n:t.length,min:e.min}):null}function mt(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function ht({field:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,G.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function gt({step:e,only:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,G.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,G.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function _t({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,G.jsx)(G.Fragment,{children:typeof t==`string`&&t?t:V(`chat.connected`)});if(e.kind===`list`)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(y,{className:`size-4`}),` `,V(`chat.checked`)]});if(e.kind===`toggle`)return(0,G.jsx)(G.Fragment,{children:V(t===!0?`run.yes`:`run.no`)});if(ft(t))return(0,G.jsx)(`span`,{className:`italic opacity-80`,children:V(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,G.jsx)(G.Fragment,{children:t.map(H).join(`, `)});case`select`:return(0,G.jsx)(G.Fragment,{children:H(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,G.jsx)(G.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(ge,{dateStyle:`long`}).format(e)})}case`color`:return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,G.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,G.jsx)(`img`,{src:F(`/api/runs/${n}/assets/${t}`),alt:``,className:P(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(r,{className:`size-4`}),` `,V(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(_,{className:`size-4`}),` `,V(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,G.jsx)(G.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,G.jsx)(G.Fragment,{children:V(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,G.jsx)(G.Fragment,{children:String(t)})}}function vt(e,t,n,r,i,a){let o=[q(t,(0,G.jsx)(gt,{step:e,only:a}))];for(let e of i)a||o.push(q(`${t}:${e.id}`,(0,G.jsx)(ht,{field:e}))),o.push(rt(`${t}:${e.id}:a`,(0,G.jsx)(_t,{field:e,value:n[e.id],runId:r})));return o}var yt=(e,t)=>e.fields.filter(e=>!e.when&&!xe(e)||t[e.id]!==void 0&&t[e.id]!==null);function bt(e,t){let n=[];e.wizard.description&&n.push(q(`hello`,e.wizard.description)),e.wizard.intro&&n.push(q(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...vt(r,i,e.values,e.id,yt(r,e.values),t))}else r.type===`review`&&(n.push(q(i,(0,G.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(rt(`${i}:a`,V(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function xt(e,t){return e.fields.filter(e=>!xe(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function St({view:e,run:t,step:n,before:r}){let i=(0,W.useMemo)(()=>xt(n,e),[n,e]),a=e.known??{},[o,s]=(0,W.useState)(()=>N(n,e)),[c,l]=(0,W.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?R(xt(n,e),e.known??{},N(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,W.useState)({}),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(!1),_=R(i,a,o),v=_.filter(e=>c.includes(e.id)),y=_.find(e=>!c.includes(e.id)),b=i.length===1?i[0]:void 0,x=v.at(-1),S=x?()=>l(e=>e.filter(e=>e!==x.id)):void 0;(0,W.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=R(i,a,o),r=n.findIndex(t=>e.includes(t.id));r>=0&&(l(n.slice(0,r).map(e=>e.id)),d(t.fieldErrors))},[t.fieldErrors]);let C=e=>{t.submitPage(n.id,e).then(h)},w=(0,W.useContext)(J),T=(0,W.useRef)(o);T.current=o;let E=w?.bindPage,D=(0,W.useRef)(C);D.current=C,(0,W.useEffect)(()=>{if(!E)return;let e=R(i,a,o);return E({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?pt(r,n)||(s(e=>({...e,[t]:n})),l(e=>e.includes(t)?e:[...e,t]),d({}),null):`no such field on this page`},submit:()=>D.current(T.current)}),()=>E(null)},[E,n,i,a,o]);let O=e=>{if(!y)return!1;let t=pt(y,e);if(t)return d({[y.id]:t}),!1;let n={...o,[y.id]:e},r=[...c,y.id];return s(n),l(r),d({}),R(i,a,n).some(e=>!r.includes(e.id))||C(n),!0},k=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...vt(n,`now:${n.id}`,o,e.id,v,b).map((e,t,n)=>t===n.length-1&&e.who===`me`&&y?{...e,onEdit:S}:e)];y?(dt(y)===`control`?k.push(q(`now:${n.id}:${y.id}:control`,(0,G.jsx)(g,{field:y,value:o[y.id],values:o,runId:e.id,view:e,closed:e.closed?.[y.id],onChange:e=>s(t=>({...t,[y.id]:e})),onBusy:p}),{wide:!0})):b||k.push(q(`now:${n.id}:${y.id}`,(0,G.jsx)(ht,{field:y}))),u[y.id]&&k.push(q(`now:${n.id}:${y.id}:error`,u[y.id],{tone:`error`}))):t.busy||m?k.push(q(`sending`,(0,G.jsx)(ct,{}))):t.error&&k.push(q(`send-error`,t.error,{tone:`error`}));let A=(0,G.jsx)(Q,{});if(m||!y&&c.length>0&&t.busy)A=(0,G.jsx)(Q,{placeholder:V(`run.working`)});else if(!y)k.push(X(`now:${n.id}:go`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>C(o),children:n.cta||V(`run.next`)}),S?(0,G.jsx)(Z,{onClick:S,disabled:t.busy,children:V(`run.back`)}):null]})));else{let r=dt(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,G.jsx)(Z,{onClick:()=>O(void 0),children:V(`chat.skip`)}):null;if(r===`typed`){i&&k.push(X(`now:${n.id}:${y.id}:replies`,i));let e=o[y.id];A=(0,G.jsx)(ot,{children:(0,G.jsx)(ut,{initial:ft(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:V(`chat.placeholder`)),inputProps:Ct(y),busy:t.busy,onSend:e=>O(mt(y,e))},y.id)})}else if(r===`tapped`)k.push(q(`now:${n.id}:${y.id}:replies`,(0,G.jsx)(wt,{field:y,view:e,value:o[y.id],onAnswer:O}),{bare:!0}));else{let e=_.filter(e=>!c.includes(e.id)).length===1;k.push(X(`now:${n.id}:${y.id}:replies`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{primary:!0,disabled:f,onClick:()=>O(o[y.id]),children:e&&n.cta?n.cta:V(`chat.send`)}),i]})))}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:k}),A]})}function Ct(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return i(e)}}function wt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,W.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,G.jsxs)(lt,{children:[(0,G.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:V(`run.no`)}),(0,G.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:V(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,G.jsxs)(lt,{children:[s.map(e=>(0,G.jsx)(Z,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:H(e)},e)),(0,G.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?V(`chat.send`):V(`chat.skip`)})]}):(0,G.jsxs)(lt,{children:[s.map(e=>(0,G.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:H(e)},e)),e.required?null:(0,G.jsx)(Z,{onClick:()=>r(void 0),children:V(`chat.skip`)})]})}function Tt({view:e}){let t=(0,W.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,W.useState)(Date.now());(0,W.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),o=a.at(-1),s=[...a].reverse().find(Dt),c=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,G.jsxs)(`div`,{className:P(`flex max-w-full flex-col gap-1`,s?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??V(`run.working`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(ct,{}),(0,G.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??V(`run.working`)}),(0,G.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:V(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),o&&o!==s?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,G.jsx)(te,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,G.jsx)(`span`,{className:`truncate`,children:ye(o)})]}):null,s&&e.status===`running`?(0,G.jsx)(kt,{runId:e.id,event:s}):null,c.length?(0,G.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:c.slice(-6).map(t=>(0,G.jsx)(`img`,{src:F(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var Et=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Dt(e){return!!e.note&&Et.has(e.note.code)}var Ot=1e4;function kt({runId:e,event:t}){let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(`agent`),[o,l]=(0,W.useState)(!1),u=t.note?.code;if((0,W.useEffect)(()=>{u===`personDrives`?a(`person`):u===`agentDrives`&&a(`agent`)},[u]),(0,W.useEffect)(()=>{let t=()=>c.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,Ot);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let d=i===`person`,f=async()=>{l(!0);try{let t=await c.post(`/api/runs/${e}/browser/seat`,{to:d?`agent`:`person`});a(t.seat)}catch{}finally{l(!1)}};return(0,G.jsx)(s,{runId:e,driving:d,caption:ye(t),hint:V(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,G.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void f(),className:P(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,d?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[d?(0,G.jsx)(Ce,{className:`size-3.5`}):(0,G.jsx)(Ae,{className:`size-3.5`}),V(d?`browser.handBack`:`browser.takeOver`)]})},n??0)}function At({children:e,end:t}){return(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function jt({view:e,run:t,step:n,before:r,asked:i,onNote:o}){let s=e.shown.filter(e=>e.output),[c,l]=(0,W.useState)(s.length===1?s[0].step.id:null),u=(0,W.useRef)(null),d=[...r,...i.map((e,t)=>rt(`review:${n.id}:asked:${t}`,e)),q(`review:${n.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,G.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...s.map(({step:t,output:r})=>q(`review:${n.id}:${t.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{children:t.title}),(0,G.jsx)(w,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{l(t.id),u.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>q(`review:${n.id}:list:${t.def.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{children:t.def.title}),t.def.check?(0,G.jsx)(v,{runId:e.id,list:t}):(0,G.jsx)(a,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&d.push(q(`review-error`,t.error,{tone:`error`}));let f=n.regenerate&&s.length>0;return d.push(X(`review:${n.id}:replies`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,G.jsx)(y,{className:`size-4`}),` `,V(`run.accept`)]}),f&&s.length>1?s.map(({step:e})=>(0,G.jsx)(Z,{on:c===e.id,onClick:()=>l(e.id),children:e.title},e.id)):null]}))),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:d}),f?(0,G.jsx)(ot,{children:(0,G.jsx)(ut,{multiline:!0,inputRef:u,busy:t.busy,placeholder:s.length>1&&!c?V(`run.feedbackPick`):V(`run.feedbackPlaceholder`),disabled:!c,onSend:e=>{let r=e.trim();return!r||!c?!1:(o(r),t.regenerate(n.id,c,r),!0)}})}):(0,G.jsx)(Q,{})]})}function Mt({view:e,run:t,step:n,before:r,onRestart:i}){let s=e.shown.filter(e=>e.output),c=`/api/runs/${e.id}`,l=[...r,q(`result:${n.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,G.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...s.map(({step:e,output:t,formats:n,label:r})=>q(`result:${e.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{end:(0,G.jsx)(A,{base:c,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,G.jsx)(w,{base:c,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,G.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:V(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>q(`result:list:${t.def.id}`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(At,{end:(0,G.jsx)(o,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,G.jsx)(a,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return l.push(X(`result:replies`,(0,G.jsxs)(G.Fragment,{children:[s.length?(0,G.jsx)(Oe,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,G.jsxs)(Z,{onClick:i,children:[(0,G.jsx)(k,{className:`size-4`}),` `,V(`run.again`)]}):null,e.canBack?(0,G.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:V(`run.back`)}):null,e.keeps?(0,G.jsx)(`span`,{className:`ml-1`,children:(0,G.jsx)(p,{runId:e.id})}):null]}))),(0,G.jsx)(Y,{avatar:e.wizard.avatar,costume:e.wizard.costume,lines:l})}function Nt({runId:e,onRestart:t,onNotFound:n,onView:r,header:i,footer:a,talk:o=!1,call:s=!1}){let c=nt(e),{view:l}=c,[u,d]=(0,W.useState)(null),p=Xe(e,l,c,u);(0,W.useEffect)(()=>{r?.(l)},[l,r]),(0,W.useEffect)(()=>{c.notFound&&n?.()},[c.notFound,n]);let[g,_]=De(),v=(0,W.useMemo)(()=>({runId:e,lang:l?.lang??ge,readAloud:g,setReadAloud:_,voice:l?.talk?p:null,talk:o,call:!!s,bindPage:d}),[e,l?.lang,l?.talk,g,_,p,o,s]);f(l?.status===`running`&&!l.ask),ee(l);let[y,b]=(0,W.useState)({}),[x,S]=(0,W.useState)(null);(0,W.useEffect)(()=>{l&&l.status!==`running`&&S(null)},[l]);let C;if(c.notFound)C=n?null:(0,G.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:V(`run.notFound`)});else if(!l)C=(0,G.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,G.jsx)(I,{})});else{let e=l.step,n=l.status===`waiting_input`,r=bt(l,l.canBack&&n&&!c.busy?()=>void c.back():void 0);if(l.status===`running`&&l.ask)C=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,q(`ask:${l.ask.id}`,(0,G.jsx)(m,{runId:l.id,ask:l.ask}),{wide:!0})]}),(0,G.jsx)(Q,{})]});else if(l.status===`running`)C=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,...x?[rt(`note`,x)]:[],q(`working:${e?.id}`,(0,G.jsx)(Tt,{view:l}),{wide:l.events.some(t=>t.stepId===e?.id&&Dt(t))?`most`:void 0})]}),(0,G.jsx)(Q,{placeholder:V(`run.working`)})]});else if(l.status===`failed`)C=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,q(`failed`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:V(`run.failed`)}),l.error?(0,G.jsx)(`span`,{className:`mt-0.5 block`,children:(0,G.jsx)(h,{text:l.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Z,{primary:!0,busy:c.busy,onClick:()=>void c.retry(),children:[(0,G.jsx)(k,{className:`size-4`}),` `,V(`run.retry`)]}),l.canBack?(0,G.jsx)(Z,{onClick:()=>void c.back(),disabled:c.busy,children:V(`run.back`)}):null]}))]}),(0,G.jsx)(Q,{})]});else if(l.status===`cancelled`)C=(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:[...r,q(`cancelled`,V(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,G.jsxs)(Z,{primary:!0,onClick:t,children:[(0,G.jsx)(k,{className:`size-4`}),` `,V(`run.again`)]}))]:[]]});else if(e?.type===`page`)C=(0,G.jsx)(St,{view:l,run:c,step:e,before:r},e.id);else if(e?.type===`review`){let t=l.shown.map(e=>e.output?.at??``).join(`|`);C=(0,G.jsx)(jt,{view:l,run:c,step:e,before:r,asked:y[e.id]??[],onNote:t=>{S(t),b(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else C=e?.type===`result`?(0,G.jsx)(Mt,{view:l,run:c,step:e,before:r,onRestart:t}):(0,G.jsx)(Y,{avatar:l.wizard.avatar,costume:l.wizard.costume,lines:r})}return s?(0,G.jsx)(J.Provider,{value:v,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,G.jsx)(We,{voice:p,view:l,video:s===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,G.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,G.jsx)(st,{footer:a,children:C})})]})}):(0,G.jsx)(J.Provider,{value:v,children:(0,G.jsx)(st,{header:i,footer:a,children:C})})}function Pt({runId:e,onNotFound:t,...n}){let r=nt(e);return(0,W.useEffect)(()=>{r.notFound&&t?.()},[r.notFound,t]),r.notFound&&t?null:(0,G.jsx)(ne,{run:r,...n})}function $(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function Ft(e){let t=Array.from({length:7},(t,n)=>({a:(n+.2+$(e+n)*.5)/7.2*(Math.PI/2),len:200*(.84+.16*$(e+n+20))})),n=t.map(e=>`M0 0L${(Math.cos(e.a)*e.len).toFixed(1)} ${(Math.sin(e.a)*e.len).toFixed(1)}`);for(let e=1;e<=9;e++){let r=200*(e/9.6)**1.08;t.slice(1).forEach((e,i)=>{let a=t[i],o=Math.min(r,a.len),s=Math.min(r,e.len),c=(a.a+e.a)/2,l=r*.86;i===0&&n.push(`M${(Math.cos(a.a)*o).toFixed(1)} ${(Math.sin(a.a)*o).toFixed(1)}`),n.push(`Q${(Math.cos(c)*l).toFixed(1)} ${(Math.sin(c)*l).toFixed(1)} ${(Math.cos(e.a)*s).toFixed(1)} ${(Math.sin(e.a)*s).toFixed(1)}`)})}return n.join(``)}var It={left:Ft(1),right:Ft(9)};function Lt({side:e,className:t}){return(0,G.jsx)(`svg`,{className:t??`wizard-web wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:It[e],fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Rt(){return(0,G.jsxs)(`div`,{className:`wizard-spider`,children:[(0,G.jsx)(`div`,{className:`wizard-spider-thread`}),(0,G.jsxs)(`svg`,{viewBox:`-30 -10 60 60`,"aria-hidden":`true`,children:[(0,G.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,fill:`none`,children:[0,1,2,3].map(e=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`path`,{d:`M0 ${8+e*5} Q-16 ${-2+e*6} -24 ${14+e*6}`}),(0,G.jsx)(`path`,{d:`M0 ${8+e*5} Q16 ${-2+e*6} 24 ${14+e*6}`})]},e))}),(0,G.jsx)(`ellipse`,{cx:`0`,cy:`22`,rx:`11`,ry:`14`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`0`,cy:`6`,r:`7`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`-2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`}),(0,G.jsx)(`circle`,{cx:`2.6`,cy:`7`,r:`1.6`,className:`wizard-spider-eye`})]})]})}function zt({side:e}){let t=Array.from({length:9},(e,t)=>{let n=(t+.5)/9*(Math.PI/2),r=70+$(t+40)*110,i=Math.cos(n)*r,a=Math.sin(n)*r,o=Math.cos(n)*r*.55,s=Math.sin(n)*r*.55,c=14+$(t+50)*16;return`M0 0L${i.toFixed(1)} ${a.toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n+.6)*c).toFixed(1)} ${(Math.sin(n+.6)*c).toFixed(1)}M${o.toFixed(1)} ${s.toFixed(1)}l${(Math.cos(n-.6)*c).toFixed(1)} ${(Math.sin(n-.6)*c).toFixed(1)}`}).join(``);return(0,G.jsx)(`svg`,{className:`wizard-frost wizard-web-${e}`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:t,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`})})}function Bt({kind:e}){let t=e===`stars`?28:22;return(0,G.jsx)(`div`,{className:`wizard-particles wizard-particles-${e}`,children:Array.from({length:t},(t,n)=>(0,G.jsx)(`span`,{style:{left:`${($(n+1)*100).toFixed(2)}%`,top:e===`stars`?`${($(n+2)*100).toFixed(2)}%`:void 0,animationDuration:`${(e===`stars`?2.5:9)+$(n+3)*8}s`,animationDelay:`${(-$(n+4)*16).toFixed(2)}s`,scale:(.6+$(n+5)*.9).toFixed(2),"--hue":`${Math.round($(n+6)*360)}`}},n))})}var Vt=[{kind:`round`,top:16,size:64,seconds:17,delay:1},{kind:`drop`,top:42,size:48,seconds:21,delay:7},{kind:`tower`,top:26,size:56,seconds:19,delay:12.5}],Ht=[{kind:`flame`,side:`right`,seconds:14,delay:2},{kind:`sprout`,side:`left`,seconds:16,delay:9}];function Ut({costume:e,motion:t}){return t===`peek`?(0,G.jsx)(G.Fragment,{children:Ht.map(t=>(0,G.jsx)(`div`,{className:`wizard-peek wizard-peek-${t.side}`,style:{animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,G.jsx)(ue,{kind:t.kind,costume:e,size:96})},t.kind))}):(0,G.jsx)(G.Fragment,{children:Vt.map(t=>(0,G.jsx)(`div`,{className:`wizard-bat`,style:{top:`${t.top}%`,animationDuration:`${t.seconds}s`,animationDelay:`${t.delay}s`},children:(0,G.jsx)(`div`,{className:`wizard-bat-bob`,children:(0,G.jsx)(ue,{kind:t.kind,costume:e,size:t.size})})},t.kind))})}var Wt=[`witch`,`devil`,`bat`,`pumpkin`];function Gt({effects:e,contained:t}){let n=(e??[]).filter(e=>[`corners`,`particles`,`figures`,`fog`].includes(e.id));if(!n.length)return null;let r=(e,t)=>typeof e[t]==`string`?String(e[t]):``;return(0,G.jsxs)(G.Fragment,{children:[n.some(e=>e.id===`fog`)?(0,G.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fog wizard-fx-contained`:`wizard-fog`}):null,(0,G.jsx)(`div`,{"aria-hidden":`true`,className:t?`wizard-fx wizard-fx-contained`:`wizard-fx`,children:n.map((e,t)=>{let n=`${e.id}-${t}`;if(e.id===`corners`){let t=r(e,`kind`)||`webs`;return t===`frost`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(zt,{side:`left`}),(0,G.jsx)(zt,{side:`right`})]},n):t===`webs`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Lt,{side:`left`}),(0,G.jsx)(Lt,{side:`right`}),(0,G.jsx)(Rt,{})]},n):null}if(e.id===`particles`){let t=r(e,`kind`)||`embers`;return[`embers`,`snow`,`confetti`,`stars`].includes(t)?(0,G.jsx)(Bt,{kind:t},n):null}if(e.id===`figures`){let t=r(e,`costume`);return(0,G.jsx)(Ut,{costume:Wt.includes(t)?t:void 0,motion:r(e,`motion`)||`fly`},n)}return null})})]})}var Kt=[`brand`,`host`,`default`],qt=[...Kt,`engenty`,`wizard`,`wizards`],Jt=[`Inter`,`Figtree`,`DM Sans`,`Nunito`,`Fredoka`,`Bricolage Grotesque`,`Fraunces`,`Playfair Display`,`Lora`,`Young Serif`,`Caveat`,`Creepster`,`Nosifer`],Yt=U().regex(/^#[0-9a-fA-F]{6}$/,`a colour as #rrggbb`),Xt=B({accent:Yt.optional(),background:Yt.optional(),text:Yt.optional()}).extend({scheme:z([`light`,`dark`])}),Zt=B({radius:z([`sharp`,`soft`,`round`]).optional(),cards:z([`solid`,`outline`,`glass`]).optional(),headings:z([`normal`,`uppercase`]).optional()}),Qt=B({id:U().min(1).max(40)}).catchall(be([U().max(40),pe(),he()])),$t=U().min(1).max(60).regex(/^[A-Za-z0-9 -]+$/,`a font by its family name, or brand`);B({id:U().regex(me,`a theme id: lowercase letters, digits and dashes`),name:U().min(1).max(80),version:U().regex(/^\d+\.\d+\.\d+$/).default(`1.0.0`),base:z(Kt).default(`brand`),colors:ve(Xt).min(1).max(2).refine(e=>new Set(e.map(e=>e.scheme)).size===e.length,{message:`Each scheme once: light, dark.`}).optional(),fonts:B({heading:$t.optional(),text:$t.optional()}).optional(),shape:Zt.optional(),effects:ve(Qt).max(8).optional()});function en(e,t){if(!t.has(e))return e;for(let n=2;;n++){let r=`${e.slice(0,44)}-${n}`;if(!t.has(r))return r}}function tn(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48);return t&&!qt.includes(t)?t:`look`}function nn(e,t){let n=e?.colors?.find(e=>e.scheme===t);if(!n)return;let{scheme:r,...i}=n;return i}var rn=`ui-sans-serif, system-ui, sans-serif`,an=`ui-serif, Georgia, serif`,on=/serif|fraunces|playfair|lora|garamond|antiqua|baskerville|caslon|bodoni|didot|times|georgia|merriweather|tiempos/i,sn=e=>on.test(e)&&!/sans/i.test(e),cn=e=>sn(e)?`Lora`:`Inter`;function ln(e,t=[]){let n=t.some(t=>t.family===e)?`"${cn(e)}", `:``;return`"${e.replace(/"/g,``)}", ${n}${sn(e)?an:rn}`}function un(e,t){let n=e.modes?.[t];return{accent:n?.accent??e.accent,background:n?.background??e.background,text:n?.text??null}}var dn={Inter:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([0])),L(()=>Promise.resolve({}),__vite__mapDeps([1])),L(()=>Promise.resolve({}),__vite__mapDeps([2])),L(()=>Promise.resolve({}),__vite__mapDeps([3]))],Figtree:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([4])),L(()=>Promise.resolve({}),__vite__mapDeps([5])),L(()=>Promise.resolve({}),__vite__mapDeps([6])),L(()=>Promise.resolve({}),__vite__mapDeps([7]))],"DM Sans":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([8])),L(()=>Promise.resolve({}),__vite__mapDeps([9])),L(()=>Promise.resolve({}),__vite__mapDeps([10])),L(()=>Promise.resolve({}),__vite__mapDeps([11]))],Nunito:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([12])),L(()=>Promise.resolve({}),__vite__mapDeps([13])),L(()=>Promise.resolve({}),__vite__mapDeps([14])),L(()=>Promise.resolve({}),__vite__mapDeps([15]))],Fredoka:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([16])),L(()=>Promise.resolve({}),__vite__mapDeps([17])),L(()=>Promise.resolve({}),__vite__mapDeps([18])),L(()=>Promise.resolve({}),__vite__mapDeps([19]))],"Bricolage Grotesque":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([20])),L(()=>Promise.resolve({}),__vite__mapDeps([21])),L(()=>Promise.resolve({}),__vite__mapDeps([22])),L(()=>Promise.resolve({}),__vite__mapDeps([23]))],Fraunces:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([24])),L(()=>Promise.resolve({}),__vite__mapDeps([25])),L(()=>Promise.resolve({}),__vite__mapDeps([26])),L(()=>Promise.resolve({}),__vite__mapDeps([27]))],"Playfair Display":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([28])),L(()=>Promise.resolve({}),__vite__mapDeps([29])),L(()=>Promise.resolve({}),__vite__mapDeps([30])),L(()=>Promise.resolve({}),__vite__mapDeps([31]))],Lora:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([32])),L(()=>Promise.resolve({}),__vite__mapDeps([33])),L(()=>Promise.resolve({}),__vite__mapDeps([34])),L(()=>Promise.resolve({}),__vite__mapDeps([35]))],"Young Serif":()=>[L(()=>Promise.resolve({}),__vite__mapDeps([36]))],Caveat:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([37])),L(()=>Promise.resolve({}),__vite__mapDeps([38])),L(()=>Promise.resolve({}),__vite__mapDeps([39])),L(()=>Promise.resolve({}),__vite__mapDeps([40]))],Creepster:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([41]))],Nosifer:()=>[L(()=>Promise.resolve({}),__vite__mapDeps([42]))]},fn=new Set;function pn(e){e&&!fn.has(e)&&e in dn&&(fn.add(e),Promise.all(dn[e]()).catch(()=>fn.delete(e)))}function mn(e){ze(e,e.url.startsWith(`/`)?F(e.url):e.url,()=>pn(cn(e.family)))}function hn(e,t){let n=e.faces??[],r=!!e.modes,i=un({accent:e.accent??null,background:e.background??null,modes:e.modes??null},r?t:e.dark?`dark`:`light`),a=r?t===`dark`:!!e.dark,o=[[`--raw-primary`,i.accent],[`--raw-second`,e.second],[`--raw-background`,i.background],[`--brand-stage`,i.background?a?i.background:`oklch(from ${i.background} 0.3 clamp(0.02, calc(c * 3), 0.1) h)`:null],[`--ink`,i.text],[`--f-display`,e.display?ln(e.display,n):null],[`--f-ui`,e.body?ln(e.body,n):null],[`font-synthesis-weight`,e.display||e.body?`none`:null]],s=[...Object.entries(e.shape??{}).filter(([,e])=>e).map(([e,t])=>`shape-${e}-${t}`),...(e.effects??[]).flatMap(e=>e.id===`glow`?[`fx-glow`]:e.id===`pattern`?[`fx-pattern-${e.kind??`dots`}`]:[])];return{props:o.filter(e=>!!e[1]),marks:s,dark:a,themed:r}}function gn(e){return!!(e&&!e.pinned&&e.modes?.light&&e.modes.dark)}function _n(e){for(let t of e.faces??[])mn(t);pn(e.display),pn(e.body)}function vn(e){oe(e?.pinned?e.dark?`dark`:`light`:null),ae(e?.prefer??null);let t=se(),n=JSON.stringify(e??{});(0,W.useEffect)(()=>{let e=JSON.parse(n),r=document.documentElement;_n(e);let{props:i,marks:a,themed:o}=hn(e,t);for(let[e,t]of i)r.style.setProperty(e,t);r.classList.add(...a);let s=r.classList.contains(`dark`);return!o&&e.dark&&!e.pinned&&r.classList.add(`dark`),()=>{for(let[e]of i)r.style.removeProperty(e);r.classList.remove(...a),!o&&e.dark&&!e.pinned&&!s&&r.classList.remove(`dark`)}},[n,t])}function yn(e,t){let n=JSON.stringify(e??{});if((0,W.useEffect)(()=>{_n(JSON.parse(n))},[n]),!e)return null;let r=e.pinned||!e.prefer?e.dark?`dark`:`light`:e.prefer,{props:i,marks:a,dark:o}=hn(e,t&&gn(e)?t:r);return{className:[`wizard-themed`,...a,o?`dark`:``].filter(Boolean).join(` `),style:Object.fromEntries(i)}}export{Y as _,pn as a,Me as b,nn as c,Gt as d,Pt as f,Z as g,Q as h,mn as i,tn as l,st as m,vn as n,Jt as o,Nt as p,yn as r,en as s,gn as t,Lt as u,X as v,at as y};